@cratis/screenplay-language 4.120.0 → 4.121.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-HI5WTI3G.js → chunk-OPU6YCT3.js} +24 -24
- package/dist/bundles/chunk-OPU6YCT3.js.map +7 -0
- package/dist/bundles/index.js +24 -24
- package/dist/bundles/index.js.map +2 -2
- package/dist/bundles/sub-languages/capture/index.js +2 -2
- package/dist/bundles/sub-languages/capture/index.js.map +2 -2
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/sub-languages/capture/HoverProvider.d.ts.map +1 -1
- package/dist/sub-languages/capture/language.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-HI5WTI3G.js.map +0 -7
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import{a as l}from"./chunk-AYDF3IFZ.js";var kl="screenplay",Ey={id:kl,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Py=["domain","import","concept","type","policy","purpose","persona","authentication","module","layout","theme","ui","feature","slice","event","public","system","eventsource","operation","command","query","projection","capture","reaction","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","case","parameter","example","seed","behavior","exposure","instance"];var No=["depends","direction","inbound","outbound","description","documentation","template","profile","require","authenticated","role","claim","subject","authorize","validate","produces","reads","as","handler","performer","observable","identifier","reason","from","when","given","then","arguments","result","clock","exactly","error","message","not","empty","rule","matches","all","max","min","length","today","true","false","and","or","by","filter","data","via","component","context","property","literal","icons","packages","outlet","display","scopes","reexposes","operations","items","toolbar","item","presentation","exposes","mode","oneWay","twoWay","null","propagate","clear","preserve","expected","action","navigate","to","label","section","table","summary","title","column","field","on","unique","file","concurrency","eventSource","sourceType","streamType","streamId","tag","for","readmodel","no","when","every","at","where","invokes","contains","starts","with","provider","uses","parameter","order","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],Ay=["csharp","typescript","react","html","sql"],er=["command","arguments","tenant","causedBy","causation","occurred","identity"],tr=["subject","name","userName"],nr=["id","name","userName","isAuthenticated","roles","claims"],ir=["StateChange","StateView","Automation","Translate"],qn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],wy=["pii","personal","secret"],Cl=/^\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[^=]*$/,Oy={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Cl,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 nn(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}l(nn,"typeReferenceSymbol");function Ty(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}l(Ty,"typeReferenceText");function Ee(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}l(Ee,"withoutComment");function te(t){return t.length-t.trimStart().length}l(te,"indentOf");function rr(t){return t.trim().split(/\s+/)[0]??""}l(rr,"firstWord");function we(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}l(we,"fenceMap");function qo(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ee(t[s]);if(a.trim().length===0)continue;let d=te(a);d<o&&(r.push(rr(a)),o=d)}return r}l(qo,"enclosingChain");function My(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Ee(t[r]);if(o.trim().length!==0&&te(o)<i)return o.trim()}}l(My,"nearestEnclosingLine");function jy(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ee(t[s]);if(a.trim().length===0)continue;let d=te(a);d<o&&(r.push(a.trim()),o=d)}return r}l(jy,"enclosingHeaders");var Bo="EventContext",rn={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."}]},or=[{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 ar(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}l(ar,"namesEventContextMember");var sr=rn[Bo];function El(t){let e=sr;for(let n of t){let i=e.find(r=>ar(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=rn[i.type]??[]}return e}l(El,"eventContextMembersAfter");function Yy(t){return t.length===0?void 0:El(t.slice(0,-1))?.find(n=>ar(n,t[t.length-1]))}l(Yy,"eventContextMemberAt");function lr(t){let e,n=sr;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=>ar(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:rn[r.type]??[]}return{status:"known",member:e,expected:[]}}l(lr,"resolveEventContextPath");function Fy(){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:**",...sr.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
-
`)}l(
|
|
3
|
-
`)}l(Uy,"describeEventContextMember");var ut={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 on={label:"purpose",insertText:"purpose ${1:Name}",documentation:"Adds a declared processing purpose to the union covering this slice and its enclosing containers."},Qy=[{label:"description",insertText:'description "${1:processing intent}"',documentation:"Describes the processing, not a legal verdict."},{label:"basis",insertText:"basis ${1|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}",documentation:"One Art. 6(1) lawful basis, with an optional quoted reference."},{label:"interest",insertText:'interest "${1:legitimate interests pursued}"',documentation:"Statement accompanying basis legitimateInterests."},{label:"condition",insertText:"condition ${1|explicitConsent,employmentLaw,vitalInterests,notForProfit,madePublic,legalClaims,substantialPublicInterest,healthCare,publicHealth,research|}",documentation:"Art. 9(2) condition for special-category data."},{label:"authorization",insertText:'authorization "${1:authorization in law}"',documentation:"Art. 10 authorization for criminal-offence data."},{label:"subjects",insertText:"subjects ${1:customer}",documentation:"Comma-separated open identifiers for categories of data subjects."},{label:"retention",insertText:'retention "${1:period or criteria}"',documentation:"Declared retention, not enforced."},{label:"recipient",insertText:'recipient "${1:recipient category}"',documentation:"Repeatable recipient category."},{label:"transfer",insertText:'transfer "${1:destination}" safeguard "${2:safeguard}"',documentation:"Repeatable destination and safeguards."},{label:"erasure exception",insertText:"erasure exception ${1|expression,legalObligation,publicTask,publicHealth,archiving,legalClaims|}",documentation:"Declared Art. 17(3) exception; does not change Chronicle per-subject erasure."}];var kt=[{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 cr=[{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."}],Pl=[on,ut,...kt,{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."},...cr],Al=[on,ut,...kt,{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."},...cr],Hy=[ut,{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."}],Xy=[{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."}],eh=[{label:"description",insertText:'description "${1:input surface intent}"',documentation:"Report-only description of the form."},{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...cr],th=[{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."}],nh=[{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."}],Ue=l((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),wl=[Ue("execute","execute ${1:command}","Runs a command."),Ue("navigate to","navigate to ${1:Screen}","Opens a screen."),Ue("open","open ${1:Dialog}","Opens a dialog."),Ue("close","close","Closes the dialog."),Ue("refresh","refresh ${1:query}","Reloads a query."),Ue("set","set ${1:name} ${2:value}","Sets a value."),Ue("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),Ue("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),Ue("raise","raise ${1:Trigger}","Raises a trigger.")],ih=[Ue("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),Ue("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...wl],rh=[{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."}],oh=[{label:"provider",insertText:"provider ${1:Name}",documentation:"An identity provider."},{label:"provider (named)",insertText:"provider ${1:Kind} name ${2:Name}",documentation:"An identity provider of a kind, under its own name."}],ah=[{label:"for",insertText:'for ${1:"event-source-id"}\n ${2:EventType}\n ${3:property} = ${4:value}',documentation:"Events to seed for one event source id."}],sh=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],lh=[{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."}],Ol=[{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
|
|
1
|
+
import{a as l}from"./chunk-AYDF3IFZ.js";var El="screenplay",Py={id:El,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Ay=["domain","import","concept","type","policy","purpose","persona","authentication","module","layout","theme","ui","feature","slice","event","public","system","eventsource","operation","command","query","projection","capture","reaction","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","case","parameter","example","seed","behavior","exposure","instance"];var No=["depends","direction","inbound","outbound","description","documentation","template","profile","require","authenticated","role","claim","subject","authorize","validate","produces","reads","as","handler","performer","observable","identifier","reason","from","when","given","then","arguments","result","clock","exactly","error","message","not","empty","rule","matches","all","max","min","length","today","true","false","and","or","by","filter","data","via","component","context","property","literal","icons","packages","outlet","display","scopes","reexposes","operations","items","toolbar","item","presentation","exposes","mode","oneWay","twoWay","null","propagate","clear","preserve","expected","action","navigate","to","label","section","table","summary","title","column","field","on","unique","file","concurrency","eventSource","sourceType","streamType","streamId","tag","for","readmodel","no","when","every","at","where","invokes","contains","starts","with","provider","uses","parameter","order","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],wy=["csharp","typescript","react","html","sql"],tr=["command","arguments","tenant","causedBy","causation","occurred","identity"],nr=["subject","name","userName"],kt=["id","name","userName","isAuthenticated","roles","claims"],ir=["StateChange","StateView","Automation","Translate"],Bn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Oy=["pii","personal","secret"],Cl=/^\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[^=]*$/,Iy={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Cl,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 rn(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}l(rn,"typeReferenceSymbol");function Ry(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}l(Ry,"typeReferenceText");function Ce(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}l(Ce,"withoutComment");function te(t){return t.length-t.trimStart().length}l(te,"indentOf");function rr(t){return t.trim().split(/\s+/)[0]??""}l(rr,"firstWord");function we(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}l(we,"fenceMap");function qo(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ce(t[s]);if(a.trim().length===0)continue;let d=te(a);d<o&&(r.push(rr(a)),o=d)}return r}l(qo,"enclosingChain");function jy(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Ce(t[r]);if(o.trim().length!==0&&te(o)<i)return o.trim()}}l(jy,"nearestEnclosingLine");function Ly(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ce(t[s]);if(a.trim().length===0)continue;let d=te(a);d<o&&(r.push(a.trim()),o=d)}return r}l(Ly,"enclosingHeaders");var Bo="EventContext",on={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."}]},or=[{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 ar(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}l(ar,"namesEventContextMember");var sr=on[Bo];function Pl(t){let e=sr;for(let n of t){let i=e.find(r=>ar(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=on[i.type]??[]}return e}l(Pl,"eventContextMembersAfter");function Fy(t){return t.length===0?void 0:Pl(t.slice(0,-1))?.find(n=>ar(n,t[t.length-1]))}l(Fy,"eventContextMemberAt");function lr(t){let e,n=sr;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=>ar(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:on[r.type]??[]}return{status:"known",member:e,expected:[]}}l(lr,"resolveEventContextPath");function Uy(){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:**",...sr.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
+
`)}l(Uy,"describeEventContext");function Wy(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:on[e.type]??[],i=[`**$eventContext.${t}**: \`${e.type}\``,"",e.description];return n.length>0&&i.push("",`**Members:** ${n.map(r=>`\`${r.name}\``).join(", ")}`),i.join(`
|
|
3
|
+
`)}l(Wy,"describeEventContextMember");var ut={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 an={label:"purpose",insertText:"purpose ${1:Name}",documentation:"Adds a declared processing purpose to the union covering this slice and its enclosing containers."},Gy=[{label:"description",insertText:'description "${1:processing intent}"',documentation:"Describes the processing, not a legal verdict."},{label:"basis",insertText:"basis ${1|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}",documentation:"One Art. 6(1) lawful basis, with an optional quoted reference."},{label:"interest",insertText:'interest "${1:legitimate interests pursued}"',documentation:"Statement accompanying basis legitimateInterests."},{label:"condition",insertText:"condition ${1|explicitConsent,employmentLaw,vitalInterests,notForProfit,madePublic,legalClaims,substantialPublicInterest,healthCare,publicHealth,research|}",documentation:"Art. 9(2) condition for special-category data."},{label:"authorization",insertText:'authorization "${1:authorization in law}"',documentation:"Art. 10 authorization for criminal-offence data."},{label:"subjects",insertText:"subjects ${1:customer}",documentation:"Comma-separated open identifiers for categories of data subjects."},{label:"retention",insertText:'retention "${1:period or criteria}"',documentation:"Declared retention, not enforced."},{label:"recipient",insertText:'recipient "${1:recipient category}"',documentation:"Repeatable recipient category."},{label:"transfer",insertText:'transfer "${1:destination}" safeguard "${2:safeguard}"',documentation:"Repeatable destination and safeguards."},{label:"erasure exception",insertText:"erasure exception ${1|expression,legalObligation,publicTask,publicHealth,archiving,legalClaims|}",documentation:"Declared Art. 17(3) exception; does not change Chronicle per-subject erasure."}];var Et=[{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 cr=[{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."}],Al=[an,ut,...Et,{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."},...cr],wl=[an,ut,...Et,{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."},...cr],Xy=[ut,{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."}],eh=[{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."}],th=[{label:"description",insertText:'description "${1:input surface intent}"',documentation:"Report-only description of the form."},{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...cr],nh=[{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."}],ih=[{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."}],We=l((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Ol=[We("execute","execute ${1:command}","Runs a command."),We("navigate to","navigate to ${1:Screen}","Opens a screen."),We("open","open ${1:Dialog}","Opens a dialog."),We("close","close","Closes the dialog."),We("refresh","refresh ${1:query}","Reloads a query."),We("set","set ${1:name} ${2:value}","Sets a value."),We("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),We("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),We("raise","raise ${1:Trigger}","Raises a trigger.")],rh=[We("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),We("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Ol],oh=[{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."}],ah=[{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."}],sh=[{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."}],lh=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],ch=[{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."}],Il=[{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
4
|
column
|
|
5
|
-
\${1:slot}`,documentation:"How the slots are placed."}],
|
|
5
|
+
\${1:slot}`,documentation:"How the slots are placed."}],dh=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Il,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var gh=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],Oe=l(t=>`\`\`\`${t}
|
|
6
6
|
\${1}
|
|
7
|
-
\`\`\``,"fenced"),Sh=[{label:"purpose",insertText:'purpose ${1:Name}\n description "${2:processing intent}"\n basis ${3|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}',documentation:"Report-only processing metadata. Not legal advice; referenced by module, feature and slice."},...kt,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams, admitted by ESM v8. Pin the stored name before renaming a source with stored events; Default is reserved."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:"import from",insertText:'import ${1:Module}.${2:Event} from "${3:origin}"',documentation:"Imports a public event contract with a nonblank opaque origin, not a file path. An import has no local shape, so executable binding still refuses it with PLAY0268."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} pii\n pii reason "${3:why this value is personal data}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],gh=[{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."}],Il=[{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:Oe(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],xh=[{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."},...Il.filter(t=>t.label!=="hint")],vh=[{label:"description",insertText:'description "${1:what this value represents}"',documentation:"Report-only authoring description; not a validation or compliance note."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this value is personal data}"',documentation:"A free-text concept note, not a lawful basis."},{label:"secret reason",insertText:'secret reason "${1:why this value is an operational secret}"',documentation:"Records why the secret marker applies."},{label:"secret scope",insertText:"secret scope ${1|subject,namespace,global|}",documentation:"Explicit encryption scope; omitted scope keeps Chronicle\u2019s Subject default."},{label:"pii special",insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:"GDPR Art. 9(1) special category of personal data."},{label:"pii criminal",insertText:"pii criminal",documentation:"Personal data relating to criminal convictions and offenses (GDPR Art. 10)."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],$h=[{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."}],Yo=[on,ut,...kt,{label:"operation",insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:"Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"public event",insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it."},{label:"event from",insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:"An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events."},{label:"direction",insertText:"direction ${1|inbound,outbound|}",documentation:"Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied."},{label:"event",insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an event type \u2014 an immutable, past-tense fact."},{label:"event generation",insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:"Declares a complete numbered event generation; start at 1 and do not skip a number."},{label:"command",insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a command \u2014 an imperative intent that produces events."},{label:"query",insertText:"query ${1:Name} => ${2:ReadModel}",documentation:"Declares a read-side entry point mapping to a return type."},{label:"query observable",insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:"Declares a live read \u2014 the query keeps pushing as the read model changes, instead of answering once."},{label:"readmodel",insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares the shape of a read model \u2014 its properties \u2014 that a projection, reducer or query fills and returns."},{label:"reducer",insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:"Declares a reducer building a read model from events with imperative code, for what a projection cannot express."},{label:"specification",insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:"Given/when/then acceptance criteria for the slice."},{label:"projection",insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:"Declares how events project into a read model (PDL)."},{label:"capture",insertText:"capture ${1:Name}\n source ${2:api}",documentation:"Declares a change data capture converting external data into events (CDL)."},{label:"reaction",insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:"Declares behavior that runs when something happens."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a UI screen."},{label:"constraint",insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:"Declares a server-side rule enforced before events are committed."}],bh=[ut,{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
|
|
7
|
+
\`\`\``,"fenced"),xh=[{label:"purpose",insertText:'purpose ${1:Name}\n description "${2:processing intent}"\n basis ${3|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}',documentation:"Report-only processing metadata. Not legal advice; referenced by module, feature and slice."},...Et,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams, admitted by ESM v8. Pin the stored name before renaming a source with stored events; Default is reserved."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:"import from",insertText:'import ${1:Module}.${2:Event} from "${3:origin}"',documentation:"Imports a public event contract with a nonblank opaque origin, not a file path. An import has no local shape, so executable binding still refuses it with PLAY0268."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} pii\n pii reason "${3:why this value is personal data}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],vh=[{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."}],Tl=[{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:Oe(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],$h=[{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."},...Tl.filter(t=>t.label!=="hint")],bh=[{label:"description",insertText:'description "${1:what this value represents}"',documentation:"Report-only authoring description; not a validation or compliance note."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this value is personal data}"',documentation:"A free-text concept note, not a lawful basis."},{label:"secret reason",insertText:'secret reason "${1:why this value is an operational secret}"',documentation:"Records why the secret marker applies."},{label:"secret scope",insertText:"secret scope ${1|subject,namespace,global|}",documentation:"Explicit encryption scope; omitted scope keeps Chronicle\u2019s Subject default."},{label:"pii special",insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:"GDPR Art. 9(1) special category of personal data."},{label:"pii criminal",insertText:"pii criminal",documentation:"Personal data relating to criminal convictions and offenses (GDPR Art. 10)."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],kh=[{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."}],Yo=[an,ut,...Et,{label:"operation",insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:"Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"public event",insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it."},{label:"event from",insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:"An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events."},{label:"direction",insertText:"direction ${1|inbound,outbound|}",documentation:"Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied."},{label:"event",insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an event type \u2014 an immutable, past-tense fact."},{label:"event generation",insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:"Declares a complete numbered event generation; start at 1 and do not skip a number."},{label:"command",insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a command \u2014 an imperative intent that produces events."},{label:"query",insertText:"query ${1:Name} => ${2:ReadModel}",documentation:"Declares a read-side entry point mapping to a return type."},{label:"query observable",insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:"Declares a live read \u2014 the query keeps pushing as the read model changes, instead of answering once."},{label:"readmodel",insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares the shape of a read model \u2014 its properties \u2014 that a projection, reducer or query fills and returns."},{label:"reducer",insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:"Declares a reducer building a read model from events with imperative code, for what a projection cannot express."},{label:"specification",insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:"Given/when/then acceptance criteria for the slice."},{label:"projection",insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:"Declares how events project into a read model (PDL)."},{label:"capture",insertText:"capture ${1:Name}\n source ${2:api}",documentation:"Declares a change data capture converting external data into events (CDL)."},{label:"reaction",insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:"Declares behavior that runs when something happens."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a UI screen."},{label:"constraint",insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:"Declares a server-side rule enforced before events are committed."}],Eh=[ut,{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
8
|
${Oe("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."}],
|
|
10
|
-
`,documentation:"The code that performs the query \u2014 a file reference or an inline csharp/sql block."}],
|
|
9
|
+
`,documentation:"Fully imperative command implementation \u2014 file reference or inline C#, instead of produces."}],Rl=[{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."}],Ch=[...Rl,{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."}],Ph=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Ah=[{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:Oe(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],wh=[{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:Oe("csharp"),documentation:"Inline C# returning the events to append."}],Oh=[{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."}],Ih=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:Oe("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:Oe("sql"),documentation:"Inline SQL returning the query result."}],Th=[{label:"description",insertText:'description "${1:invariant intent}"',documentation:"Report-only description, distinct from the violation message."},{label:"unique",insertText:"unique ${1:property} on ${2:EventType}",documentation:"Enforces a unique property value across an event type."},{label:"unique event",insertText:"unique event ${1:EventType}",documentation:"Enforces that the event type occurs at most once per event source."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the constraint to a custom C# implementation."}],Rh=[ut,{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."}],Dh=[{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:Oe("csharp"),documentation:"Inline C# returning event side effects."}],ft="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",Mh=[{label:"on refused",insertText:`on refused
|
|
11
11
|
acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${ft}`},{label:"on refused by validation",insertText:`on refused by validation
|
|
12
12
|
acknowledge`,documentation:`Handles validation refusals. ${ft}`},{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. ${ft}`},{label:"on refused by authorization",insertText:`on refused by authorization
|
|
13
|
-
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${ft}`}],Dh=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${ft}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${ft}`}],Mh=[{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."}],jh=[{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. ${ft}`},{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."}],Fo={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. ${ft}`},{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:Oe("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],Lh=[{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")],Nh=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:Oe("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],qh=[{label:"description",insertText:'description "${1:authorization intent}"',documentation:"Report-only description; does not supply an implementation."},{label:"require authenticated",insertText:"require authenticated",documentation:"Requires an authenticated caller."},{label:"require role",insertText:'require role "${1:role}"',documentation:"Requires the caller to have a role."},{label:"require not role",insertText:'require not role "${1:role}"',documentation:"Excludes callers with a role. Add authenticated to require a signed-in caller."},{label:"require not claim",insertText:'require not claim "${1:claim}" matches ${2:subject}',documentation:"Requires that no claim value matches the subject or a value."},{label:"require claim",insertText:'require claim "${1:claim}" matches ${2:subject}',documentation:"Requires a claim to match the subject or a value."},{label:"csharp",insertText:Oe("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],Bh=[{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."}],Yh=[{label:"description",insertText:'description "${1:screen intent}"',documentation:"Report-only description, not a localizable screen title."},{label:"data",insertText:"data ${1:ReadModel} via query ${2:QueryName}",documentation:"Binds a read model to the screen through a query."},{label:"action",insertText:"action ${1:CommandName}",documentation:"Makes a command available as an action on the screen."},{label:'action "\u2026"',insertText:'action "${1:Label}"\n when item.${2:status} == "${3:open}" execute ${4:CommandName}\n otherwise hidden',documentation:"One labeled button selecting the first matching command; hidden without a subject or match."},{label:"layout",insertText:"layout ${1:LayoutName}",documentation:"Uses a layout template and fills its slots."},{label:"section",insertText:"section ${1:name}",documentation:"A named structural section of the screen."},{label:"table",insertText:'table ${1:name}\n column ${2:property} label "${3:text}"',documentation:"A table widget over a read model or collection."},{label:"summary",insertText:'summary ${1:ReadModel}\n field ${2:property} label "${3:text}"',documentation:"A summary widget showing labeled fields."},{label:"title",insertText:'title "${1:text}"',documentation:"The title of the screen or section."},{label:"file",insertText:"file ${1:Path}",documentation:"Full external implementation \u2014 Stage uses the referenced file."},{label:"react",insertText:Oe("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:Oe("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:Oe("html"),documentation:"Inline static HTML."}],Dl=[{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."}],Fh=[{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."},...Dl.filter(t=>t.label!=="label")],Ml=[{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."}],Uh=[{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."},...Ml],Wh=[{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."}],Vh=[{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."}],zh=[{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."},...or.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],jl={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 Qh(t){let e=t?jl[t]:void 0;return e?Yo.filter(n=>n.label==="purpose"||n.label==="example"||n.label==="documentation"||n.label==="public event"||n.label==="event from"||n.label==="direction"&&t==="Translate"||e.includes(n.label)):Yo}l(Qh,"sliceItemsFor");var c={CommandProducesPublicEvent:"PLAY0607",PublicEventRequiresOutboundTranslation:"PLAY0608",OutboundPublicEventCount:"PLAY0609",ForeignPublicEventConsumer:"PLAY0610",OutboundTranslationInput:"PLAY0611",InboundTranslationOutput:"PLAY0612",ForeignPublicEventProduced:"PLAY0613",PublicTranslationRequiresDirection:"PLAY0614",TranslationConstructDirection:"PLAY0615",InboundTranslationInput:"PLAY0616",OutboundTranslationOutput:"PLAY0617",EventTargetOutsideOutboundTranslation:"PLAY0618",EventsSourceOutsideInboundTranslation:"PLAY0619",InvalidCaptureEventsSource:"PLAY0620",InvalidExposureDeclaration:"PLAY0621",UnknownExposureOwner:"PLAY0622",ReExposureCycle:"PLAY0623",ReExposureBroken:"PLAY0624",InvalidInstanceContribution:"PLAY0625",UnknownContributionInstance:"PLAY0626",ContributionNotExposed:"PLAY0627",ContributionTypeMismatch:"PLAY0628",UnknownTemplateContentSlot:"PLAY0629",UnknownNavigationOutlet:"PLAY0630",TemplateScopeMismatch:"PLAY0631",IncompatibleComponentPackage:"PLAY0632",LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",InvalidPurposeDeclaration:"PLAY0596",InvalidPurposeVocabulary:"PLAY0597",DuplicatePurposeField:"PLAY0598",DuplicatePurposeDeclaration:"PLAY0599",UnknownPurpose:"PLAY0600",PurposeInterestMismatch:"PLAY0601",PersonalDataWithoutPurpose:"PLAY0602",SpecialDataWithoutCondition:"PLAY0603",CriminalDataWithoutAuthorization:"PLAY0604",PurposeWithoutBasis:"PLAY0605",UnusedPurpose:"PLAY0606",ConflictingScreenDataBinding:"PLAY0530",ScreenDataQueryMismatch:"PLAY0531",ActionWithoutInputSurface:"PLAY0532",CommandWithoutInputSurface:"PLAY0533",ReadModelFieldWithoutOrigin:"PLAY0534",QueryParameterNotHeldByView:"PLAY0535",UnconsumedEvent:"PLAY0536",UnreachableScreen:"PLAY0537",UnknownActionSubjectField:"PLAY0345",UnresolvedActionSubject:"PLAY0346",UnreachableActionAlternative:"PLAY0347",UnknownActionArgumentProperty:"PLAY0348",UnreachableRefusalBranch:"PLAY0540",InvalidRefusalValue:"PLAY0541",UnknownRefusalConstraint:"PLAY0542",UnknownRedeliveryReaction:"PLAY0544",IndeterminateNegatedClaimTarget:"PLAY0546",InvalidRefusalBranch:"PLAY0538",InvalidRefusalBranchBody:"PLAY0539",UnmatchedRedeliveredOccurrence:"PLAY0543",InvalidNoEventsExpectation:"PLAY0545",InvalidProducesDeclaration:"PLAY0042",ProducesWhenWithoutEvent:"PLAY0043",InvalidPropertyMapping:"PLAY0044",DuplicateProducesTarget:"PLAY0193",EventSourceIdInPayload:"PLAY0469",ExplicitProducesTargetsRequired:"PLAY0470",RedundantEventId:"PLAY0471",InvalidEventId:"PLAY0472",InlineEventCollision:"PLAY0473",InlineEventOutsideCommand:"PLAY0474",InlineEventGeneration:"PLAY0475",ReservedProductionMetadata:"PLAY0476",InvalidEventDocumentation:"PLAY0477",OmittedProductionDestination:"PLAY0478",UnknownConstraintProperty:"PLAY0391",UnknownTopLevelConstruct:"PLAY0001",InvalidDomainDeclaration:"PLAY0002",DuplicateDomain:"PLAY0003",DomainNotFirst:"PLAY0004",InvalidImportDeclaration:"PLAY0005",TabIndentation:"PLAY0006",InvalidConceptDeclaration:"PLAY0007",UnknownPrimitiveType:"PLAY0008",InvalidEnumerationValue:"PLAY0009",UnknownConceptDirective:"PLAY0010",ValidateReadAsEnumerationBlock:"PLAY0011",AttributeReasonWithoutAttribute:"PLAY0012",DuplicateAttributeReason:"PLAY0013",InvalidTypeDeclaration:"PLAY0014",TypeWithoutProperties:"PLAY0015",InvalidPropertyDeclaration:"PLAY0016",IdentifierOutsideCommand:"PLAY0017",InvalidEventDeclaration:"PLAY0018",IdentifierOnEventProperty:"PLAY0019",TagPropertyReadAsTag:"PLAY0020",InvalidModuleDeclaration:"PLAY0021",UnknownModuleDirective:"PLAY0022",InvalidFeatureDeclaration:"PLAY0023",UnknownFeatureDirective:"PLAY0024",InvalidSliceDeclaration:"PLAY0027",UnknownSliceType:"PLAY0028",UnknownSliceDirective:"PLAY0029",InvalidPersonaDeclaration:"PLAY0030",InvalidPersonaPolicyReference:"PLAY0031",UnknownPersonaDirective:"PLAY0032",InvalidCommandDeclaration:"PLAY0033",UnknownCommandDirective:"PLAY0034",DuplicateCommandIdentifier:"PLAY0036",InvalidQueryDeclaration:"PLAY0047",UnknownQueryDirective:"PLAY0048",InvalidQueryParameter:"PLAY0049",InvalidProjectionDeclaration:"PLAY0056",EmptyProjection:"PLAY0057",UnknownProjectionDirective:"PLAY0058",FromWithoutEvent:"PLAY0061",InvalidEventReference:"PLAY0062",InvalidJoinDeclaration:"PLAY0063",JoinWithoutEvent:"PLAY0064",InvalidChildrenDeclaration:"PLAY0065",InvalidNestedDeclaration:"PLAY0066",NestedBlockWithoutFrom:"PLAY0067",InvalidRemoveDeclaration:"PLAY0068",UnknownRemoveDirective:"PLAY0069",InvalidClearDeclaration:"PLAY0070",ClearWithOutsideNestedBlock:"PLAY0071",InvalidSpecificationDeclaration:"PLAY0094",UnknownSpecificationDirective:"PLAY0095",InvalidSpecificationWhen:"PLAY0096",DuplicateSpecificationWhen:"PLAY0097",InvalidThenError:"PLAY0098",InvalidReadModelStep:"PLAY0099",InvalidEventStep:"PLAY0100",InvalidSpecificationValue:"PLAY0101",InvalidScreenDeclaration:"PLAY0102",UnknownScreenDirective:"PLAY0103",InvalidDataDirective:"PLAY0104",InvalidActionDirective:"PLAY0105",UnknownActionDirective:"PLAY0106",InvalidNavigation:"PLAY0107",InvalidScreenLayoutSlot:"PLAY0108",InvalidTitleDirective:"PLAY0109",UnknownTableDirective:"PLAY0110",UnknownSummaryDirective:"PLAY0111",AuthorizeWithoutPolicy:"PLAY0122",InvalidPolicyReference:"PLAY0123",InvalidConstraintDeclaration:"PLAY0132",ConstraintWithoutRule:"PLAY0133",InvalidConstraintBody:"PLAY0134",DuplicateConstraintBody:"PLAY0135",InvalidReactionDeclaration:"PLAY0136",InvalidReactionTrigger:"PLAY0137",ReactionWithoutTrigger:"PLAY0138",InvalidValidateDeclaration:"PLAY0140",InvalidValidationRule:"PLAY0141",InvalidRuleName:"PLAY0143",UnknownRuleImplementationDirective:"PLAY0144",InvalidDescription:"PLAY0145",EmptyDescription:"PLAY0146",DuplicateDescription:"PLAY0147",TagWithoutValue:"PLAY0148",InvalidTagValue:"PLAY0149",UnknownContextPath:"PLAY0153",UnknownContextCausedByProperty:"PLAY0154",UnknownContextIdentityProperty:"PLAY0155",ExpectedCodeFence:"PLAY0163",UnclosedCodeBlock:"PLAY0164",DuplicateDeclaration:"PLAY0168",RepeatedSingularDeclarationAcrossFiles:"PLAY0172",RepeatedDeclarationAcrossFiles:"PLAY0173",ConflictingDescriptionAcrossFiles:"PLAY0174",UnexpectedTokenInAuthorize:"PLAY0184",UnclosedAuthorizeGroup:"PLAY0185",InvalidReadModelDeclaration:"PLAY0186",InvalidInvokesDeclaration:"PLAY0194",InvalidScopeDeclaration:"PLAY0199",DuplicateScope:"PLAY0200",InvalidIntervalTrigger:"PLAY0249",InvalidScheduleTrigger:"PLAY0250",DuplicateReactionTrigger:"PLAY0253",InvalidSpecificationEventSource:"PLAY0275",DuplicateSpecificationEventSource:"PLAY0276",InvalidProjectionVariantDeclaration:"PLAY0277",InvalidEntersOnDeclaration:"PLAY0279",NestedProjectionVariantNotAllowed:"PLAY0280",InvalidStructuredValue:"PLAY0291",DuplicateStructuredValueMember:"PLAY0294",ConflictingSpecificationActions:"PLAY0358",InvalidSpecificationEventOrder:"PLAY0359",InvalidValidationSeverity:"PLAY0368",VariantRequiresEnteringEvent:"PLAY0382",DuplicateProjectionVariant:"PLAY0384",DuplicateVariantEnteringEvent:"PLAY0385",InvalidSpecificationDenied:"PLAY0388",DuplicateAuthorizationAcrossFiles:"PLAY0394",FileConstraintOnlySupportsUniqueness:"PLAY0396",LegacyInlineCodeFence:"PLAY0397",InvalidEventGeneration:"PLAY0446",InvalidFileImport:"PLAY0454",FileImportMatchesNothing:"PLAY0455",ImportedFileNotFound:"PLAY0456",ConflictingImportPlacement:"PLAY0457",ImportCycle:"PLAY0458",ModuleInPlacedFile:"PLAY0459",UnexpectedInPlacedFile:"PLAY0460",InvalidSpecificationClock:"PLAY0461",InvalidSpecificationTrigger:"PLAY0462",InvalidSpecificationCapture:"PLAY0463",InvalidSpecificationQueryAction:"PLAY0464",InvalidSpecificationQuery:"PLAY0265",UnknownSpecificationQueryDirective:"PLAY0266",DuplicateSpecificationQueryArguments:"PLAY0267",InvalidAbsentReadModelStep:"PLAY0453",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",InvalidSpecificationCaller:"PLAY0386",DuplicateSpecificationCallerOrDenied:"PLAY0387",GeneratedPropertyOutsideCommand:"PLAY0482",InvalidGeneratedType:"PLAY0483",InvalidGeneratedModifierOrder:"PLAY0484",DuplicateEventSubject:"PLAY0590",InvalidSubjectType:"PLAY0591",ProtectedSubjectType:"PLAY0592",InvalidSubjectOwner:"PLAY0593",ReadModelSubjectNotSupported:"PLAY0594",InvalidSubjectModifierOrder:"PLAY0595",GeneratedPropertySuppliedAsInput:"PLAY0485",InvalidCommandResponse:"PLAY0486",InvalidResponseSource:"PLAY0487",DuplicateResponseField:"PLAY0488",InvalidResponseShape:"PLAY0489",InvalidGeneratedFixture:"PLAY0490",InvalidReturnExpectation:"PLAY0491",InvalidImplementationBlock:"PLAY0492",InvalidImplementationHint:"PLAY0493",ConflictingImplementationSources:"PLAY0494",UnknownType:"PLAY0165",InvalidSystemDeclaration:"PLAY0495",InvalidOperationDeclaration:"PLAY0496",InvalidProductionReference:"PLAY0497",ProductionDeclarationCollision:"PLAY0498",OperationOutsideCommand:"PLAY0499",InvalidSystemReference:"PLAY0500",InvalidOperationMapping:"PLAY0501",InvalidOperationSpecification:"PLAY0502",InvalidCaptureDeclaration:"PLAY0078",UnknownCaptureDirective:"PLAY0079",InvalidMapEntry:"PLAY0080",InvalidTranslation:"PLAY0081",InvalidSplitDeclaration:"PLAY0082",InvalidSplitTarget:"PLAY0083",InvalidAppendDeclaration:"PLAY0084",UnknownAppendDirective:"PLAY0085",WhenWithoutTrigger:"PLAY0086",InvalidWhenClause:"PLAY0087",InvalidWhenTransitionClause:"PLAY0088",MixedWhenCombinators:"PLAY0089",WhenCombinatorWithoutProperty:"PLAY0090",UnknownCaptureBlockDirective:"PLAY0091",InvalidCompositeKeyPart:"PLAY0072",TemplateInCompositeKey:"PLAY0073",EmptyCompositeKey:"PLAY0074",InvalidProjectionMapping:"PLAY0075",ExpectedLiteralValue:"PLAY0150",InvalidExpression:"PLAY0152",UnterminatedInterpolation:"PLAY0157",UnterminatedTemplateExpression:"PLAY0156",ProjectionDocumentWithoutProjection:"PLAY0055",CaptureDocumentWithoutCapture:"PLAY0077",SpecificationDocumentWithoutSpecification:"PLAY0093",InvalidSeedDeclaration:"PLAY0128",InvalidSeedGroup:"PLAY0129",InvalidSeedEvent:"PLAY0130",InvalidSeedPropertyAssignment:"PLAY0131",InvalidPolicyDeclaration:"PLAY0112",UnknownPolicyDirective:"PLAY0113",PolicyWithoutRequirement:"PLAY0114",ExpectedRoleName:"PLAY0118",ExpectedClaimName:"PLAY0119",ExpectedClaimMatches:"PLAY0120",ExpectedClaimMatchTarget:"PLAY0121",MixedPolicyImplementation:"PLAY0440",RepeatedPolicyRequirement:"PLAY0441",UnexpectedTokenInPolicyCondition:"PLAY0115",ExpectedPolicyCondition:"PLAY0116",UnclosedPolicyConditionGroup:"PLAY0117",UnexpectedTokenInCondition:"PLAY0158",ExpectedCondition:"PLAY0159",ExpectedComparisonOperator:"PLAY0161",ExpectedComparisonValue:"PLAY0162",InvalidActionAlternative:"PLAY0341",GuardedActionWithoutAlternatives:"PLAY0342",MisplacedActionOtherwise:"PLAY0343",UnsupportedActionConditionOperand:"PLAY0344",InvalidInteractionArgument:"PLAY0319",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",InvalidSpecificationExample:"PLAY0518",DuplicateSpecificationAssignment:"PLAY0519",UnresolvedSpecificationExampleType:"PLAY0520",SpecificationExampleNameCollision:"PLAY0521",SpecificationExampleKindMismatch:"PLAY0522",InvalidSpecificationExampleValue:"PLAY0523",MissingSpecificationProperty:"PLAY0524",UnadmittedSpecificationExampleValue:"PLAY0525",InvalidSpecificationExampleBody:"PLAY0526",AmbiguousReference:"PLAY0198",InvalidSpecificationStream:"PLAY0547",SpecificationStreamOnCommand:"PLAY0548",InvalidSpecificationStreamRoute:"PLAY0549",InvalidSpecificationStreamEventSource:"PLAY0550",SpecificationStreamContradictsCommand:"PLAY0551",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",UndeclaredDependency:"PLAY0552",UnusedDependencyDeclaration:"PLAY0553",MutualDependencyDeclarations:"PLAY0556",AuthorizationRefusalWithoutIdentity:"PLAY0557",InvalidDocumentation:"PLAY0558",ConflictingDocumentationAcrossFiles:"PLAY0559",InvalidSpecificationCallerPersona:"PLAY0572",UnsynthesizablePersonaCaller:"PLAY0573",PersonaWithoutGate:"PLAY0574",GateWithoutPersona:"PLAY0575",AmbiguousPersonaCaller:"PLAY0576",InvalidSpecificationParameter:"PLAY0577",InvalidSpecificationCase:"PLAY0578",DuplicateSpecificationParameter:"PLAY0579",DuplicateSpecificationCase:"PLAY0580",IncompleteSpecificationTable:"PLAY0581",InvalidSpecificationCaseAssignment:"PLAY0582",InvalidSpecificationCaseValue:"PLAY0583",InvalidSpecificationCaseReference:"PLAY0584",OptionalSpecificationParameterTarget:"PLAY0585",SpecificationCaseNameCollision:"PLAY0586",IncompatibleSpecificationParameterType:"PLAY0587",UnusedSpecificationParameter:"PLAY0588",SingularSpecificationTableExpansion:"PLAY0589",UnsupportedInteractionAlternatives:"PLAY0560",MixedInteractionAlternatives:"PLAY0561",InteractionAlternativeWithoutActions:"PLAY0562",InlineInteractionAlternative:"PLAY0563",LegacyInteractionWhere:"PLAY0564",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",UnknownEvent:"PLAY0166",UnknownReadModelProperty:"PLAY0514",PiiNotSupportedOnIdentifier:"PLAY0515",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};var dr="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",W="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Z(t){let e=`(?=[\\u0000-\\uFFFF])[${dr}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}l(Z,"nativePattern");function O(t){let e="",n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&i+1<t.length){let o=t[i+1];i++,o==="w"?e+=n?dr:`[${dr}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}l(O,"pattern");var Ll=new RegExp(`^depends${W}+on(?:${W}|$)`,"u"),Nl=new RegExp(`${W}+$`,"u");function It(t,e=!1,n){let i=[],r=0,o=0;for(let s of t.split(`
|
|
14
|
-
`)){r++;let a=s.endsWith("\r")?s.replace(/\r+$/,""):s,d=a.length-a.trimStart().length,p=ql(a.substring(d),e),m=Ll.test(p)?p.replace(Nl,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:d,content:m,startOffset:o}:{number:r,raw:a,indent:d,content:m,path:n,startOffset:o}),o+=s.length+1}return i}l(It,"splitLines");function an(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}l(an,"commentStart");function ql(t,e){let n=an(t,e);return n<0?t:t.substring(0,n)}l(ql,"stripComment");function le(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}l(le,"eventDeclarations");function Bn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}l(Bn,"operationDeclarations");var H;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(H||(H={}));var re=class{static{l(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e,n){let i=l((r,o)=>{for(let s of r){let a=[...o,s.name];for(let d of s.slices)this.slices.push({slice:d,scope:[...a,d.name]});i(s.features,a)}},"collect");e.modules.forEach(r=>i(r.features,[r.name]));for(let{slice:r,scope:o}of this.slices){this.scopes.set(r,o);let s=new Map;for(let d of le(r)){let p=s.get(d.name)??[];p.push(d),s.set(d.name,p)}let a=[...s.values()].flatMap(d=>new Set(d.map(p=>p.generation)).size!==d.length?d:[d.reduce((p,m)=>p.generation>=m.generation?p:m)]);this.declarations.push(...a.map(d=>({kind:H.Event,name:d.name,node:d,scope:o})),...Bn(r).map(d=>({kind:H.Operation,name:d.name,node:d,scope:o})))}n!==void 0&&this.declarations.splice(0,this.declarations.length,...n);for(let r of this.declarations){let o=this.byName.get(r.name)??[];o.push(r),this.byName.set(r.name,o)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:H.Unresolved,declaration:null,candidates:[]};let r=this.resolutions.get(n)??new Map,o=r.get(e);if(o!==void 0)return o;let s=this.resolveFromScope(e,i);return r.set(e,s),this.resolutions.set(n,r),s}resolveFromScope(e,n){let i=this.candidates(e,n);return i.length===1?{kind:i[0].kind,declaration:i[0],candidates:[]}:{kind:i.length===0?H.Unresolved:H.Ambiguous,declaration:null,candidates:i}}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===H.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==H.Operation&&!(i.kind===H.Ambiguous&&i.candidates.some(r=>r.kind===H.Operation))}candidates(e,n){let i=e.split(".").filter(s=>s.length>0);if(i.length===0)return[];let r=this.byName.get(i.at(-1))??[],o=i.slice(0,-1);if(o.length>0)return r.filter(s=>o.length<=s.scope.length&&o.every((a,d)=>s.scope[s.scope.length-o.length+d]===a));for(let s=n.length;s>=0;s--){let a=r.filter(d=>s<=d.scope.length&&n.slice(0,s).every((p,m)=>d.scope[m]===p));if(a.length>0)return a}return[]}};var pe;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(pe||(pe={}));var Re=class{static{l(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?pe.WrongKind:pe.NotFound:i.length>1||r.length>1?o=pe.Ambiguous:o=r.length===1?pe.Unique:pe.NotFound,{kind:o,sources:i,streams:r}}};function Uo(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}l(Uo,"eventProductions");function pr(t,e){let n=Uo(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}l(pr,"requiresExplicitDestinations");function Wo(t,e,n){let i=Uo(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||pr(t,n))return;if(e.inlineEvent===null)return i.some(o=>o.for!==null||o.inlineEvent!==null)?void 0:"new event source";let r=t.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length===1?r[0].name:void 0}l(Wo,"implicitDestination");var ur="79228162514264337593543950335";function nt(t){let e=Vo(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>ur.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===ur.length&&a>ur)return;let d=Math.max(0,o),p=d===0?a:a.length>d?`${a.substring(0,a.length-d)}.${a.substring(a.length-d)}`:`0.${"0".repeat(d-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}l(nt,"parseExactNumber");function sn(t){return Vo(t)!==void 0}l(sn,"isExactNumberToken");function Vo(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&fr(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&fr(t[i]);)i++;if(i===a)return;o=t.substring(a,i)}let s=0;if(t[i]==="e"||t[i]==="E"){i++;let a=t[i]==="-";(t[i]==="+"||t[i]==="-")&&i++;let d=i,p=t.length+29;for(;i<t.length&&fr(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===d)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}l(Vo,"scan");function fr(t){return t>="0"&&t<="9"}l(fr,"isDigit");var mr=class extends Error{static{l(this,"InvalidExactNumber")}};function yr(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||nt(t.value)?.value!==t.value)throw new mr("Expected a canonical, bounded ExactNumber value.");return t.value}l(yr,"canonicalExactText");function zo(t){return!yr(t).includes(".")}l(zo,"exactIsIntegral");var Bl=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,Yl=/^([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 hr(t,e){let n=(e?Yl:Bl).exec(t);if(n===null||n[0].length!==t.length)return!1;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),a=[31,i%4===0&&(i%100!==0||i%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(i<1||r<1||r>12||o<1||o>a[r-1])return!1;if(!e)return!0;if(Number(n[4])>23||Number(n[5])>59||Number(n[6])>59)return!1;if(n[7]===void 0)return!0;let d=Number(n[7]),p=Number(n[8]);return d<=14&&p<=59&&(d!==14||p===0)}l(hr,"responseDateValue");var Fl="http://schemas.microsoft.com/ws/2008/06/identity/claims/role",Sr=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),mt=l(t=>Array.from(t,e=>{let n=e.toUpperCase();return n.length===e.length&&e!=="\u0131"&&e!=="\u017F"?n:e}).join(""),"claimTypeKey");function cn(t,e){let n=[],i=[],r=l(a=>({caller:null,contributions:n,refusal:a}),"refused");if(t.policies.length===0)return r({policy:null,reason:"noPolicies",location:t.location});for(let a of t.policies){let d=(e.policies??[]).find(m=>m.name===a);if(!d)return r({policy:a,reason:"unresolvedPolicy",location:t.location});if(d.condition===null||d.code!==null||d.file!==null)return r({policy:a,reason:"opaqueImplementation",location:d.location});let p=gr(d.condition);if(p)return r({policy:a,reason:"negation",location:p.location});i.push(d)}for(let a of i){let d=xr(a.condition,a.name,n);if(d)return r(d)}for(let a of i){let d=ln(a.condition,a.name,n);if(d)return r(d)}let o=[...new Set(n.filter(a=>a.kind==="role").map(a=>a.value))].sort(Sr),s=[];for(let a of n.filter(d=>d.kind==="claim"))s.some(d=>mt(d.type)===mt(a.type)&&d.value===a.value)||s.push({kind:"SpecificationCallerClaimSyntax",type:a.type,value:a.value,location:a.location});return s.sort((a,d)=>Sr(mt(a.type),mt(d.type))||Sr(a.value,d.value)),{caller:{kind:"SpecificationCallerSyntax",authenticated:!0,roles:o,claims:s,location:t.location},contributions:n,refusal:null}}l(cn,"synthesizePersonaCaller");function gr(t){return t.kind==="NotPolicyConditionSyntax"?t:t.kind==="LogicalPolicyConditionSyntax"?gr(t.left)??gr(t.right):null}l(gr,"negation");function Qo(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(mt(t.claim)===mt(Fl))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}}l(Qo,"atom");function xr(t,e,n){return t.kind!=="LogicalPolicyConditionSyntax"?Qo(t,e,n):t.operator==="Or"?null:xr(t.left,e,n)??xr(t.right,e,n)}l(xr,"required");function Tt(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"&&mt(i.type)===mt(t.claim)&&i.value===n.value)}case"LogicalPolicyConditionSyntax":return t.operator==="And"?Tt(t.left,e)&&Tt(t.right,e):Tt(t.left,e)||Tt(t.right,e);default:return!1}}l(Tt,"satisfied");function ln(t,e,n){if(t.kind!=="LogicalPolicyConditionSyntax")return Tt(t,n)?null:Qo(t,e,n);if(t.operator==="And")return ln(t.left,e,n)??ln(t.right,e,n);if(Tt(t,n))return null;let i=[...n],r=ln(t.left,e,i);if(r===null)return n.push(...i.slice(n.length)),null;let o=[...n];return ln(t.right,e,o)!==null?r:(n.push(...o.slice(n.length)),null)}l(ln,"complete");var vr=new WeakMap;var z='(?:[^"\\\\]|\\\\.)*',Ul={"\\":"\\",'"':'"',n:`
|
|
15
|
-
`,r:"\r",t:" "};function Q(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.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 De(`Expected '${e}' at position ${this.#e}.`)}};var Wl=O("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Vl=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),zl=O("^-?\\d+(\\.\\d+)?$"),_o=["command","arguments","tenant","causedBy","causation","occurred","identity"],Zo=["subject","name","userName"],Ko=["id","name","userName","isAuthenticated","roles","claims"];function Me(t,e,n){return ae(t,e,n,!0)}l(Me,"parseModeledMappingSource");function ae(t,e,n,i=!1){if(t=t.trim(),t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),location:e};if(t.startsWith("$context.")){let o=t.substring(9);return Ql(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 Yn(t,e,n).parse()}catch(o){if(!(o instanceof De))throw o;return n?.error(c.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?dn(t,e):dn(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?Vl:Wl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}l(ae,"parseMappingSource");function Ql(t,e,n){let[i,r]=t.split(".");_o.includes(i)?r!==void 0&&i==="causedBy"&&!Zo.includes(r)?n?.warning(c.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Zo.join(", ")}`,e):r!==void 0&&i==="identity"&&!Ko.includes(r)&&n?.warning(c.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${Ko.join(", ")}`,e):n?.warning(c.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${_o.join(", ")}`,e)}l(Ql,"warnOnUnknownContextPath");function dn(t,e,n){let i=l(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(Q(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!sn(t))return;let o=nt(t);return o!==void 0?i(o):(n.error(c.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(zl.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}l(dn,"parseLiteral");var D=l(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),oe=l(t=>t.replaceAll("@",""),"unescapeIdentifier");function Jo(t,e){let n=[],i=0,r=!1,o=!1;for(let s=0;s<t.length;s++){let a=t[s];a==="\\"&&r&&s+1<t.length?s++:a==='"'&&!o?r=!r:a==="`"&&!r?o=!o:a===e&&!r&&!o&&(n.push(t.substring(i,s)),i=s+1)}return n.push(t.substring(i)),n}l(Jo,"splitTopLevel");var Rt=l((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var $r=l(t=>t.content.length===0,"isBlank"),f=l(t=>Rt(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),Ho=l(t=>Rt(t.number,1,t.path),"startOf");var Gl=O("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),Xo=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),_l=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Ze(t){let e=Gl.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:oe(e[1]),type:je(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}}l(Ze,"tryParseProperty");function je(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}l(je,"parseTypeRef");function Le(t,e){let n=Ze(e);return n!==void 0?We(t,n.type,e):Fn(t,e),n}l(Le,"parseProperty");function We(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(c.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}l(We,"reportLegacyOptionalSuffix");function Fn(t,e){let n=Xo.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(c.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",f(e)),!0;if(_l.test(e.content))return t.error(c.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let i=Xo.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(c.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}l(Fn,"reportInvalidModifierOrder");var br=O("^then\\s+returns\\b"),Un=O("^generated\\s+(?=\\S)(?![=])"),Wn=O("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Zl=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Kl=O(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`);function Dt(t,e,n,i){if(e.startsWith("case."))return Ie(e,n,t);if(jt(e)&&t.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",n),(e.startsWith('"')||e.startsWith("'"))&&!Kl.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ae(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}l(Dt,"parseConcrete");function Mt(t,e,n,i){let r=n.exec(e.content);if(r===null)return t.error(i,"Expected a named fixture or assertion with exactly one concrete value.",f(e)),t.skipBlock(e.indent),null;let o=f(e),s=Dt(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),a=t.peekChild(e.indent);return a!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}l(Mt,"parseConcreteMapping");function ea(t,e){let n=br.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=Dt(t,i,{...r,column:r.column+e.content.indexOf(i,n)},c.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(c.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:r}}let o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=Mt(t,s,Zl,c.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}l(ea,"parseReturn");var Jl=new RegExp(O("^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$").source,"du"),Hl=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Xl=O("^case\\.([a-z_]\\w*)$");function jt(t){return/\bcase\.[a-z_]\w*/.test(t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,""))}l(jt,"containsCaseReference");function Ie(t,e,n,i=!1){if(!t.startsWith("case."))return jt(t)&&n.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",e),ae(t,e,n,i);let r=Xl.exec(t);return r===null&&n.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position: 'case.<parameter>'.",e),{kind:"CaseValueExpressionSyntax",parameter:r?.[1]??t.substring(5),location:e}}l(Ie,"parseSpecificationValue");function ta(t,e){let n=e.content.indexOf(" ")+1,i=n>0?Le(t,{...e,content:e.content.substring(n),indent:e.indent+n}):void 0;if(i===void 0||i.isGenerated||i.isIdentifier)return t.error(c.InvalidSpecificationParameter,"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.",f(e)),t.skipOpaqueBlock(e.indent),null;let r=t.peekChild(e.indent);return r!==void 0&&(t.error(c.InvalidSpecificationParameter,"A parameter has no body or default.",f(r)),t.skipOpaqueBlock(e.indent)),{kind:"SpecificationParameterSyntax",name:i.name,type:i.type,location:f(e)}}l(ta,"parseParameter");function na(t,e){let n=Jl.exec(e.content);if(n===null)return t.error(c.InvalidSpecificationCase,"Expected 'case <Name>' with at most one inline parameter assignment.",f(e)),t.skipOpaqueBlock(e.indent),null;let i=[],r=l((o,s,a)=>{let d=f(a),p={...d,column:d.column+a.content.indexOf(s,a.content.indexOf("=")+1)};if(s.startsWith("case.")){t.error(c.InvalidSpecificationCaseValue,"A case assigns concrete values, not case references.",p);return}let m=Dt(t,s,p,c.InvalidSpecificationCaseValue);m!==null&&i.push({kind:"PropertyMappingSyntax",property:o,source:m,location:a===e?{...d,column:d.column+n.indices.groups.property[0]}:d})},"add");n.groups?.property!==void 0&&r(n.groups.property,n.groups.value,e);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Hl.exec(o.content);if(s===null){t.error(c.InvalidSpecificationCaseAssignment,"Expected '<parameter> = <concrete value>' in a case.",f(o)),t.skipOpaqueBlock(o.indent);continue}r(s[1],s[2],o);let a=t.peekChild(o.indent);a!==void 0&&(t.error(c.InvalidSpecificationCaseValue,"A case value must fit on one line.",f(a)),t.skipOpaqueBlock(o.indent))}return{kind:"SpecificationCaseSyntax",name:n[1],values:i,location:f(e)}}l(na,"parseCase");function Lt(t){return Array.isArray(t)?t.flatMap(Lt):t===null||typeof t!="object"?[]:"kind"in t&&t.kind==="CaseValueExpressionSyntax"?[t]:Object.values(t).flatMap(Lt)}l(Lt,"caseReferences");function ia(t,e){let n=t.parameters??[],i=t.cases??[];n.length===0!=(i.length===0)&&e.error(c.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(c.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(c.DuplicateSpecificationCase,`Case '${o.name}' is declared more than once.`,o.location);for(let a of o.values.filter(d=>!n.some(p=>p.name===d.property)))e.error(c.InvalidSpecificationCaseAssignment,`Case '${o.name}' assigns undeclared parameter '${a.property}'.`,a.location);for(let a of n.filter(d=>o.values.filter(p=>p.property===d.name).length!==1))e.error(c.InvalidSpecificationCaseAssignment,`Case '${o.name}' must assign parameter '${a.name}' exactly once.`,o.location)});let r=Lt(t);for(let o of r)(i.length===0||!n.some(s=>s.name===o.parameter))&&e.error(c.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(c.UnusedSpecificationParameter,`Parameter '${o.name}' is never referenced.`,o.location);for(let o of Lt(t.whenRedelivered))e.error(c.InvalidSpecificationCaseReference,"Case references are not permitted in redelivery locators.",o.location)}l(ia,"validateTable");function Ct(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=>Ct(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,Ct(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}l(Ct,"substituteCase");var it=new WeakMap,ve=l(t=>it.get(t)??{},"dependencySourcesOf");function Nt(t){let e=[],n=l((a,d)=>{for(let p of a??[])e.push({name:p.name,scope:d,example:p})},"examples"),i=l((a,d)=>{for(let p of a){let m=[...d,p.name];n(p.examples,m);for(let u of p.slices){let y=[...d,p.name,u.name];n(u.examples,y);for(let h of new Set(le(u).map(x=>x.name)))e.push({name:h,scope:y,kind:"event"});for(let h of u.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of u.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(p.features,m)}},"features");n(t.examples,[]);for(let a of[...t.concepts,...t.types])e.push({name:a.name,scope:[],kind:"type"});for(let a of t.modules)n(a.examples,[a.name]),i(a.features,[a.name]);let r=l((a,d)=>{let p=l(y=>{let h=y.split("."),x=e.filter(S=>S.name===h.at(-1)),g=h.slice(0,-1);if(g.length)return x.filter(S=>g.length<=S.scope.length&&g.every((E,$)=>S.scope[S.scope.length-g.length+$]===E));for(let S=d.length;S>=0;S--){let E=x.filter($=>S<=$.scope.length&&d.slice(0,S).every((P,A)=>$.scope[A]===P));if(E.length)return E}return[]},"candidates"),m=p(a),u=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&u.length===1&&(m=p(u[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=l((a,d,p)=>{let m=r(a,p),u=m?.example;if(!u)return null;let y=r(u.type,m.scope);return y?.kind===d?{example:u,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=l((a,d)=>[...a.filter(p=>!d.some(m=>m.property===p.property)),...d],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let d=r(a.example.type,a.scope);return d?.kind===void 0?[]:[{example:a.example,kind:d.kind,name:[...d.scope,d.name].join("."),scope:d.scope}]}),eventStep:l((a,d,p)=>{let m=o(a.eventType,"event",p),u=m?.example??null,y=u?.stream??u?.noStream??null,h=a.stream??a.noStream??null,x=h??y,g=m===null?a:{...a,eventType:m.name,values:s(u.values,a.values),for:a.for??u.for,stream:x?.kind==="SpecificationStreamSyntax"?x:null,noStream:x?.kind==="SpecificationNoStreamSyntax"?x:null},S=g.values.map(E=>{let $=u?.values.find(A=>A.property===E.property),P=a.values.includes(E);return{property:E.property,value:E.source,origin:P?$===void 0?"authored":"override":"example",overriddenValue:P?$?.source??null:null}});return g.for!==null&&S.push({property:"for",value:g.for,origin:a.for===null?"example":u?.for==null?"authored":"override",overriddenValue:a.for===null?null:u?.for??null}),{role:d,authored:a,effective:g,example:u,values:S,route:x===null?null:{value:x,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:l((a,d)=>{if(!a)return a;let p=o(a.commandType,"command",d);if(!p)return a;let{example:m,name:u}=p;return{...a,commandType:u,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:l((a,d)=>{let p=o(a.name,"readmodel",d);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}l(Nt,"specificationExamples");function Vn(t){return Nt(t).command}l(Vn,"specificationCommandExamples");function Ve(t){return zn(t).application}l(Ve,"expandSpecificationExamples");function zn(t){let e=Nt(t),n=[],i=l((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(d=>{let p=[...o,s.name,d.name],m={...d,specifications:d.specifications.flatMap(u=>{let y=[],h=l(($,P)=>{let A=e.eventStep($,P,p);return y.push(A),A.effective},"event"),x=t.personas.find($=>$.name===u.givenCallerPersona?.name),g=x===void 0?null:cn(x,t),S=g?.caller==null?null:{...g.caller,location:u.givenCallerPersona.location};S!==null&&y.push({role:"given caller",authored:u.givenCallerPersona,effective:S,example:null,route:null,values:g.contributions.map($=>({property:$.type??$.kind,value:{kind:"LiteralExpressionSyntax",value:$.kind==="authenticated"?!0:$.value,location:$.location},origin:"persona",overriddenValue:null,persona:x.name,policy:$.policy}))});let E={...u,...S===null?{}:{givenCaller:S,givenCallerPersona:void 0},given:u.given.map($=>h($,"given")),givenReadModels:u.givenReadModels.map($=>e.readModel($,p)),when:e.command(u.when,p),whenAppended:u.whenAppended===null?null:h(u.whenAppended,"when append"),thenEvents:u.thenEvents.map($=>h($,"then")),thenReadModels:u.thenReadModels.map($=>e.readModel($,p))};return(u.cases?.length??0)===0?(n.push({authored:u,effective:E,steps:y}),[E]):u.cases.map($=>{let P=new WeakMap,A={...Ct(E,$,P),name:`${u.name}_${$.name}`,parameters:[],cases:[]};return vr.set(A,{table:u.name,case:$.name}),n.push({authored:u,effective:A,table:u.name,case:$.name,steps:y.map(v=>({...v,effective:Ct(v.effective,$,P),values:v.values.map(k=>k.value.kind==="CaseValueExpressionSyntax"?{...k,value:Ct(k.value,$,P),origin:"case",caseParameter:k.value.parameter}:k),route:v.route===null?null:{...v.route,value:Ct(v.route.value,$,P)}}))}),A})})};return it.set(m,ve(d)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}l(zn,"expandEffectiveSpecificationExamples");var Qn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Gn(t,e,n=e.inputUses){let i=Vn(t),r=[],o=l((v,k)=>{let C=[...k,v.name];v.slices.forEach(b=>r.push({slice:b,scope:[...C,b.name]})),v.features.forEach(b=>o(b,C))},"collect");t.modules.forEach(v=>v.features.forEach(k=>o(k,[v.name])));let s=new Map,a=new Map,d=new Map;for(let{slice:v,scope:k}of r)for(let C of v.commands){let b=s.get(C.name)??[];b.push({command:C,scope:k}),s.set(C.name,b),a.set(C,ne(C.properties)),C.response?.kind==="RecordCommandResponseSyntax"&&d.set(C,ne(C.response.fields))}let p=new Map;for(let v of t.imports){let k=v.qualifiedName.split(".").at(-1);p.set(k,[...p.get(k)??[],v.qualifiedName])}let m=new Map,u=l((v,k)=>{let C=`${k.join(".")}|${v}`;if(m.has(C))return m.get(C);let b=p.get(v)??[],I=((s.get(v.split(".").at(-1))??[]).length===0&&b.length===1?b[0]:v).split("."),j=s.get(I.at(-1))??[];if(I.length>1){let L=I.slice(0,-1);j=j.filter(q=>L.length<=q.scope.length&&L.every((V,K)=>q.scope[q.scope.length-L.length+K]===V))}else for(let L=k.length;L>=0;L--){let q=j.filter(V=>L<=V.scope.length&&k.slice(0,L).every((K,J)=>V.scope[J]===K));if(q.length>0){j=q;break}}let N=j.length===1?j[0].command:null;return m.set(C,N),N},"resolve"),y=ne(t.concepts),h=new Set(t.concepts.map(v=>v.name)),x=new Map([...ne(t.types)].map(([v,k])=>[v,ne(k.properties)])),g=new Set(r.flatMap(v=>v.slice.readModels.map(k=>k.name))),S=new Set([...a.keys()].flatMap(v=>[...v.properties])),E=l(v=>{for(let k of v)k.isGenerated&&!S.has(k)&&e.error(c.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",k.location)},"checkDeclarations"),$=l(v=>{v.features.forEach($);for(let k of v.slices){for(let C of k.commands)for(let b of C.produces)b.inlineEvent!==null&&E(b.inlineEvent.properties);k.events.forEach(C=>E(C.properties)),k.readModels.forEach(C=>E(C.properties));for(let C of k.reactions)for(let b of C.triggers)for(let w of b.produces)w.inlineEvent!==null&&E(w.inlineEvent.properties)}},"checkFeature");t.types.forEach(v=>E(v.properties)),t.modules.forEach(v=>v.features.forEach($));let P=l((v,k,C)=>{let b=a.get(C).get(v.property);if(b===void 0){e.error(c.InvalidResponseSource,`Response source '${v.property}' must reference one direct command property.`,v.location);return}let w=b.type;(w.isCollection||g.has(w.name))&&e.error(c.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",v.location),k!==null&&(k.name!==w.name||k.isCollection!==w.isCollection||k.isOptional!==w.isOptional)&&e.error(c.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",k.location)},"validateSource");for(let v of a.keys()){for(let C of v.properties){if(!C.isGenerated)continue;let b=y.get(C.type.name);(C.type.isOptional||C.type.isCollection||(b===void 0?Qn.has(C.type.name)||x.has(C.type.name)||h.has(C.type.name)||g.has(C.type.name):b.type!=="Uuid"))&&e.error(c.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",C.location)}let k=v.response;if(k?.kind==="ScalarCommandResponseSyntax")P(k.source,null,v);else if(k?.kind==="RecordCommandResponseSyntax"){k.fields.length===0&&e.error(c.InvalidCommandResponse,"A response block requires at least one field.",k.location);let C=new Set;for(let b of k.fields)C.has(b.name)&&e.error(c.DuplicateResponseField,`Duplicate response field '${b.name}'.`,b.location),C.add(b.name),P(b.source,b.type,v)}}let A=l((v,k)=>{let C=i(v.when,k),b=C===null?null:u(C.commandType,k);if(C!==null&&b!==null){let j=a.get(b);for(let q of C.values)j.get(q.property.split(".")[0])?.isGenerated&&e.error(c.GeneratedPropertySuppliedAsInput,`Generated property '${q.property}' cannot be supplied as request or form input.`,q.location);let N=[...j.values()].filter(q=>q.isIdentifier);if(C.for!==null&&N.length===1&&N[0].isGenerated){let q=N[0].type;(Qn.has(q.name)||y.has(q.name)||x.has(q.name))&&(q.isOptional||q.isCollection||y.get(q.name)?.type!=="Uuid"||C.for.kind!=="LiteralExpressionSyntax"||typeof C.for.value!="string"||!ra(C.for.value))&&e.error(c.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",C.for.location)}let L=new Set;for(let q of C.generatedValues??[]){let V=j.get(q.property);(L.has(q.property)||V===void 0||!V.isGenerated||V.isIdentifier||!ke(q.source,V.type,y,x))&&e.error(c.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",q.location),L.add(q.property)}}let w=v.thenReturns;if(w==null||((C===null||v.thenErrors.length>0||v.thenDenied!=null)&&e.error(c.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",w.location),b===null))return;let T=b.response,I=a.get(b);if(w.kind==="ScalarSpecificationReturnSyntax"&&T?.kind==="ScalarCommandResponseSyntax"&&I.has(T.source.property))ke(w.value,I.get(T.source.property).type,y,x)||e.error(c.InvalidReturnExpectation,"The expected return value must match the response source's type.",w.location);else if(w.kind==="RecordSpecificationReturnSyntax"&&T?.kind==="RecordCommandResponseSyntax"){w.fields.length===0&&e.error(c.InvalidReturnExpectation,"A record return expectation requires at least one field.",w.location);let j=d.get(b),N=new Set;for(let L of w.fields){let q=j.get(L.property),V=q===void 0?void 0:I.get(q.source.property);(N.has(L.property)||V===void 0||!ke(L.source,V.type,y,x))&&e.error(c.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",L.location),N.add(L.property)}}else e.error(c.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",w.location)},"validateSpecification");for(let{slice:v,scope:k}of r)v.specifications.forEach(C=>A(C,k));for(let v of n){if(v.isParameter===!0)continue;let k=u(v.command,v.scope);k!==null&&a.get(k).get(v.property.split(".")[0])?.isGenerated&&e.error(c.GeneratedPropertySuppliedAsInput,`Generated property '${v.property}' cannot be supplied as request or form input.`,v.location)}}l(Gn,"validateResponses");function ne(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}l(ne,"uniqueByName");function ke(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=>ke(a,{...e,isCollection:!1,isOptional:!1},n,i));let r=i.get(e.name);if(r!==void 0)return t.kind==="ObjectExpressionSyntax"&&t.members.every(a=>{let d=r.get(a.name);return d!==void 0&&ke(a.value,d.type,n,i)});let o=n.get(e.name),s=o?.type??e.name;if(o?.type==="Enum")return t.kind==="LiteralExpressionSyntax"&&typeof t.value=="string"&&o.values.includes(t.value);if(t.kind==="LiteralExpressionSyntax")switch(s){case"Uuid":return typeof t.value=="string"&&ra(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&&zo(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"&&hr(t.value,!1);case"DateTime":return typeof t.value=="string"&&hr(t.value,!0);default:return!Qn.has(s)}return!Qn.has(s)&&o===void 0}l(ke,"compatibleValue");var ec=/^(?:[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 ra(t){return ec.test(t)}l(ra,"uuidValue");function tc(t,e,n){let i=ne(n.types),r=t.properties,o=null,s=!1,a=!1;for(let d of e.split(".")){let p=r.filter(u=>u.name===d);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}l(tc,"commandPathType");function qt(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:Wo(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:tc(t,r,n)}l(qt,"commandDestinationType");var oa=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),Ke=class{static{l(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new re(e).slices,this.types=ne(e.types),this.concepts=ne(e.concepts),this.knownTypes=new Set([...oa,...e.types.map(n=>n.name),...e.concepts.map(n=>n.name)]),this.events=new Map(this.slices.map(({slice:n})=>{let i=new Map;for(let r of le(n))(!i.has(r.name)||i.get(r.name).generation<r.generation)&&i.set(r.name,r);return[n,[...i.values()]]}))}resolve(e,n,i){let r=this.slices.flatMap(({slice:d,scope:p})=>i(d).map(m=>({node:m,slice:d,scope:p}))),o=this.slices.find(d=>d.slice===n)?.scope??[],s=l(d=>{let p=d.split("."),m=r.filter(y=>y.node.name===p.at(-1)),u=p.slice(0,-1);if(u.length>0)return m.filter(y=>u.length<=y.scope.length&&u.every((h,x)=>y.scope[y.scope.length-u.length+x]===h));for(let y=o.length;y>=0;y--){let h=m.filter(x=>y<=x.scope.length&&o.slice(0,y).every((g,S)=>x.scope[S]===g));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let d=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);d.length===1&&(a=s(d[0].qualifiedName))}return a.length===1?a[0]:null}event(e,n){return this.resolve(e,n,i=>this.events.get(i)??[])?.node??null}property(e,n){let i=n.split(".");for(let[r,o]of i.entries()){let s=e?.filter(d=>d.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(oa.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(d=>d.name===a.type.name))return null;e=this.types.get(a.type.name)?.properties??null}return null}compatible(e,n){return this.knownTypes.has(e.name)&&this.knownTypes.has(n.name)?e.name===n.name&&e.isCollection===n.isCollection&&(!e.isOptional||n.isOptional):null}};var nc=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Zn(t,e,n){let i=new Ke(t),r=Nt(t),o=l(d=>nc.has(d)||i.concepts.has(d)||i.types.has(d),"knownType"),s=new Map([...i.types].map(([d,p])=>[d,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:d,scope:p}of a){let m=new Map;for(let u of d.specifications){let y=(u.cases?.length??0)===0?[u.name]:u.cases.map(h=>`${u.name}_${h.name}`);for(let h of y)m.set(h,(m.get(h)??0)+1);(u.cases?.length??0)>0&&m.set(u.name,(m.get(u.name)??0)+1)}for(let u of d.specifications){for(let g of u.cases??[])(m.get(`${u.name}_${g.name}`)??0)>1&&e.error(c.SpecificationCaseNameCollision,`Case '${g.name}' derives specification '${u.name}_${g.name}', which collides in this ${n===void 0?"slice":"document"}.`,g.location);for(let g of u.parameters??[]){n===void 0&&!o(g.type.name)&&e.error(c.IncompatibleSpecificationParameterType,`Parameter '${g.name}' has unknown type '${g.type.name}'.`,g.type.location);for(let S of u.cases??[])for(let E of S.values.filter($=>$.property===g.name))ke(E.source,g.type,i.concepts,s)||e.error(c.InvalidSpecificationCaseValue,`Case '${S.name}' parameter '${g.name}' requires a concrete value of type '${g.type.name}'.`,E.source.location)}let y=l((g,S,E)=>{if(g?.kind!=="CaseValueExpressionSyntax"||S===void 0)return;let $=u.parameters?.find(k=>k.name===g.parameter);if($===void 0||($.type.isOptional&&!S.isOptional&&e.error(c.OptionalSpecificationParameterTarget,`Optional parameter '${$.name}' cannot supply required target '${E}'.`,g.location),n!==void 0&&(!o($.type.name)||!o(S.name))))return;let P=i.concepts.get($.type.name),A=i.concepts.get(S.name);(!($.type.name===S.name||P?.type!=="Enum"&&P?.type===S.name||A?.type!=="Enum"&&A?.type===$.type.name)||$.type.isCollection!==S.isCollection)&&e.error(c.IncompatibleSpecificationParameterType,`Parameter '${$.name}' type '${$.type.name}' is incompatible with target '${E}' type '${S.name}'.`,g.location)},"check"),h=l((g,S)=>{for(let E of g)y(E.source,i.property(S,E.property)?.type,E.property)},"assignments"),x=r.command(u.when,p);if(x!==null){let g=i.resolve(x.commandType,d,S=>S.commands)?.node.properties??null;h(x.values,g),h(x.generatedValues??[],g),y(x.for,g?.find(S=>S.isIdentifier)?.type,"for")}if(x!==null&&u.thenReturns!=null){let g=i.resolve(x.commandType,d,E=>E.commands)?.node,S=g?.response;if(u.thenReturns.kind==="ScalarSpecificationReturnSyntax"&&S?.kind==="ScalarCommandResponseSyntax"&&y(u.thenReturns.value,g?.properties.find(E=>E.name===S.source.property)?.type,"value"),u.thenReturns.kind==="RecordSpecificationReturnSyntax"&&S?.kind==="RecordCommandResponseSyntax")for(let E of u.thenReturns.fields){let $=S.fields.find(P=>P.name===E.property);y(E.source,$?.type??g?.properties.find(P=>P.name===$?.source.property)?.type,E.property)}}for(let g of[...u.given,...u.thenEvents,...u.whenAppended===null?[]:[u.whenAppended]]){let S=r.eventStep(g,"given",p).effective;h(S.values,i.event(S.eventType,d)?.properties??null);let E=S.stream==null?null:new Re(t).resolve(S.stream.eventSource,S.stream.stream),$=E?.kind===pe.Unique?E.sources[0]:void 0,P=E?.kind===pe.Unique?E.streams[0]:void 0;y(S.for,S.stream!=null&&$===void 0?void 0:$?.identifier??ic(S.eventType,d,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(v=>v.name===A.property)?.type,A.property)}for(let g of[...u.givenReadModels,...u.thenReadModels]){let S=r.readModel(g,p);h(S.properties,i.resolve(S.name,d,E=>E.readModels)?.node.properties??null)}if(u.whenTrigger!=null){let g=(t.declaredTriggers??[]).find(S=>S.name===u.whenTrigger.trigger);for(let S of u.whenTrigger.values)y(S.source,g?.data.find(E=>E.name===S.property)?.type,S.property)}for(let g of u.thenErrors)y(g.caseValue??null,{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:g.location},"message");for(let g of u.thenAbsentReadModels??[]){let S=i.resolve(g.name,d,$=>$.readModels)?.node,E=i.slices.flatMap(({slice:$})=>$.queries.filter(P=>P.by!==null&&i.resolve(P.returnType.name,$,A=>A.readModels)?.node===S));y(g.key,S!==void 0&&E.length===1?E[0].by.type:void 0,"for")}for(let g of[...u.thenQueries??[],...u.whenQuery===null?[]:[u.whenQuery]]){let S=i.resolve(g.query,d,A=>A.queries),E=S===null?[]:[...S.node.by===null?[]:[S.node.by],...S.node.filters].map(A=>({...A,kind:"PropertySyntax",isIdentifier:!1}));h(g.arguments,E);let $=S===null?null:i.resolve(S.node.returnType.name,S.slice,A=>A.readModels)?.node.properties??null,P=g.kind==="SpecificationQuerySyntax"?g.results:u.thenResults;for(let A of P)h(A.properties,$)}}}}l(Zn,"validateSpecificationCases");function _n(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}l(_n,"uniqueDestinationType");function ic(t,e,n,i){let r=new re(n),o=i.event(t,e);if(o===null)return;let s=l((d,p=i.slices)=>p.flatMap(({slice:m})=>m.commands.flatMap(u=>u.produces.filter(y=>r.isEventProduction(y,m)&&i.event(y.event,m)===d).map(y=>qt(u,y,n,{resolver:r,slice:m})).filter(y=>y!==null))),"commandTypes"),a=l((d,p)=>{if(p.has(d))return[];p.add(d);let m=s(d);for(let{slice:u}of i.slices){for(let y of u.reactions.flatMap(h=>h.triggers)){let h=y.source.kind==="NamedTriggerSourceSyntax"?y.source.name:void 0,x=h===void 0?null:i.event(h,u);for(let g of y.produces.filter(S=>i.event(S.event,u)===d))if(g.for?.kind==="PathExpressionSyntax"){let S=g.for.path,E=i.property(x?.properties??null,S)?.type??(h===void 0?void 0:(n.declaredTriggers??[]).find($=>$.name===h)?.data.find($=>$.name===S)?.type);E!==void 0&&m.push(E)}else g.for?.kind==="LiteralExpressionSyntax"?m.push({kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:g.location}):g.for===null&&x!==null&&m.push(...a(x,p))}u.captures.flatMap(y=>[...y.appends,...y.children.flatMap(h=>h.appends),...y.nested.flatMap(h=>h.appends)]).some(y=>i.event(y.event,u)===d)&&m.push(_n(s(d))??{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:d.location})}return m},"producerTypes");return _n(s(o,i.slices.filter(d=>d.slice===e)))??_n(s(o))??_n(a(o,new Set))}l(ic,"eventDestinationType");function Kn(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:c.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}l(Kn,"productionDestinationDiagnostics");function Jn(t,e){let n=new re(t).slices.map(r=>r.slice),i=n.flatMap(le);for(let r of n)for(let o of r.constraints.flatMap(s=>[s,...s.additionalRules])){if(o.kind!=="UniquePropertyConstraintSyntax")continue;let s=i.filter(a=>a.name===o.event);if(s.length!==0)for(let a of[o.property,...o.additionalProperties])a.includes(".")||s.some(d=>d.properties.some(p=>p.name===a))||e.error(c.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}l(Jn,"validateConstraintProperties");var aa=l((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),Hn=l(t=>[...t.scope,t.name].join("."),"addressOf"),Te=class{static{l(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=l((r,o)=>{n.push({name:r.name,scope:o}),r.features.forEach(s=>i(s,[...o,r.name]))},"inventory");for(let r of e.modules)n.push({name:r.name,scope:[]}),r.features.forEach(o=>i(o,[r.name]));return[...new Map(n.map(r=>[Hn(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=Hn(r);if(o===i||o.startsWith(i+".")||i.startsWith(o+"."))return[];let s=[...r.scope,r.name];for(let a=1;a<=s.length;a++){let d=s.slice(-a).join(".");if(this.resolve(d,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:d,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=>aa([...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&&aa(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function Xn(t,e){let n=l(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=Te.containersOf(t),r=new Map,o=l((a,d)=>{let p=[],m=d.join(".");r.has(m)||r.set(m,new Set);let u=r.get(m);for(let y of a){let h=Te.resolve(y.target,d,i),x=h.resolved===void 0?void 0:Hn(h.resolved),g=x===void 0?`text:${y.target}`:`resolved:${x}`;if(u.has(g)){e.warning(c.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}u.add(g),p.push(y),h.ambiguous.length>0?e.warning(c.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(Hn).join(", ")}`,y.location):(x===void 0||x===m||x.startsWith(m+".")||m.startsWith(x+"."))&&e.warning(c.InvalidDependencyTarget,`Invalid dependency target '${y.target}' on '${m}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,y.location)}return p},"keep"),s=l((a,d)=>{let p=[...d,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(d=>s(d,[a.name]))}))}}l(Xn,"validateDependencyDeclarations");var Et=[],pn=l(t=>t.length===0,"isDocumentPlacement");function ei(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}l(ei,"describePlacement");var rc=O("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),oc=new RegExp(O("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),ac=O("^[A-Z]\\w*$");function yt(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&rc.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=sc(n),r=f(e);if(i.length===0)return t.error(c.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new kr(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}l(yt,"parseAuthorize");function Je(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}l(Je,"combineAuthorize");function sc(t){let e=[];for(let n of t.match(oc)??[])e.length>0&&lc(e[e.length-1])&&cc(n)&&e.push("and"),e.push(n);return e}l(sc,"tokenize");var sa=l(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),lc=l(t=>t===")"||sa(t),"isOperandEnd"),cc=l(t=>t==="("||sa(t),"isOperandStart"),kr=class{static{l(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(c.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#i("or","Or",()=>this.#s())}#s(){return this.#i("and","And",()=>this.#r())}#i(e,n,i){let r=i();for(;r!==null&&this.tokens[this.#e]===e;){this.#e++;let o=i();if(o===null)return null;r={kind:"LogicalPolicyRequirementSyntax",left:r,operator:n,right:o,location:this.location}}return r}#r(){if(this.tokens[this.#e]!=="(")return this.#o();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(c.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#o(){if(this.#e>=this.tokens.length)return this.context.error(c.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return ac.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(c.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};function Bt(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(c.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,f(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(c.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let d=t.reader.takeRaw();if(d===void 0){t.error(c.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(d.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<d.raw.length&&d.raw[p]===" ";)p++;a.push(d.raw.substring(p))}return a.join(`
|
|
17
|
-
`)}l(Bt,"parseFencedText");var dc=O(`^description\\s+"(${z})"$`);function G(t,e,n,i,r=!1){if(e.content==="description"){let s=Bt(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(c.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):la(t,e,n,i,s)}let o=dc.exec(e.content);return o===null?(t.error(c.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):la(t,e,n,i,Q(o[1]))}l(G,"parseDescription");function la(t,e,n,i,r){return n!==null?(t.error(c.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}l(la,"keep");var pc=O("^purpose\\s+([A-Za-z_]\\w*)$"),uc=O(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${z})")?$`),fc=O(`^(interest|authorization|retention|recipient)\\s+"(${z})"$`),mc=O(`^transfer\\s+"(${z})"\\s+safeguard\\s+"(${z})"$`),yc=O("^[A-Za-z_]\\w*$"),hc=O("^erasure\\s+exception\\s+(\\w+)$"),Sc=["consent","contract","legalObligation","vitalInterests","publicTask","legitimateInterests"],gc=["explicitConsent","employmentLaw","vitalInterests","notForProfit","madePublic","legalClaims","substantialPublicInterest","healthCare","publicHealth","research"],ca=["expression","legalObligation","publicTask","publicHealth","archiving","legalClaims"];function da(t,e){let n=pa(t,e),i={kind:"PurposeSyntax",name:n,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:f(e)},r=new Set,o=[],s=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let d=D(a.content);if(d!=="recipient"&&d!=="transfer"&&r.has(d)){t.error(c.DuplicatePurposeField,`Purpose '${n}' already declares '${d}' - at most one is allowed`,f(a)),t.skipBlock(a.indent);continue}if(r.add(d),d==="description")i={...i,description:G(t,a,i.description,`Purpose '${n}'`)};else if(d==="basis"||d==="condition"){let p=uc.exec(a.content),m=d==="basis"?Sc:gc;if(p===null||!m.includes(p[2]))t.error(c.InvalidPurposeVocabulary,`Invalid ${d} in purpose '${n}' - expected ${m.join(", ")} with an optional quoted reference`,f(a));else{let u=p[3]===void 0?null:Q(p[3]);i=d==="basis"?{...i,basis:p[2],basisReference:u}:{...i,condition:p[2],conditionReference:u}}}else if(d==="interest"||d==="authorization"||d==="retention"||d==="recipient"){let p=fc.exec(a.content);p===null?t.error(c.InvalidPurposeDeclaration,`Invalid purpose field '${a.content}' - expected '${d} "<text>"'`,f(a)):d==="recipient"?o.push(Q(p[2])):i={...i,[d]:Q(p[2])}}else if(d==="subjects"){let p=a.content.slice(8).split(",").map(m=>m.trim());p.every(m=>yc.test(m))?i={...i,subjects:[...new Set(p)]}:t.error(c.InvalidPurposeDeclaration,`Invalid purpose subjects '${a.content}' - expected comma-separated identifiers`,f(a))}else if(d==="erasure"){let p=hc.exec(a.content);p!==null&&ca.includes(p[1])?i={...i,erasureException:p[1]}:t.error(c.InvalidPurposeVocabulary,`Invalid erasure exception '${a.content}' - expected 'erasure exception ${ca.join("|")}'`,f(a))}else if(d==="transfer"){let p=mc.exec(a.content);p===null?t.error(c.InvalidPurposeDeclaration,`Invalid transfer '${a.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,f(a)):s.push({kind:"PurposeTransferSyntax",destination:Q(p[1]),safeguard:Q(p[2]),location:f(a)})}else t.error(c.InvalidPurposeDeclaration,`Unexpected '${a.content}' in purpose '${n}'`,f(a)),t.skipBlock(a.indent)}return{...i,recipients:o,transfers:s}}l(da,"parsePurpose");function Yt(t,e,n){let i=pa(t,e);i.length>0&&!n.some(r=>r.name===i)&&n.push({kind:"PurposeReferenceSyntax",name:i,location:f(e)})}l(Yt,"parsePurposeReference");function pa(t,e){let n=pc.exec(e.content);return n!==null?n[1]:(t.error(c.InvalidPurposeDeclaration,`Invalid purpose declaration '${e.content}' - expected 'purpose <Name>'`,f(e)),"")}l(pa,"purposeName");function Pe(t,e,n,i,r=c.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,f(e)),t.skipOpaqueBlock(e.indent),n;let o=Bt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,f(e)),n):o}l(Pe,"parseDocumentation");var xc=Z(`^depends${W}+on${W}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function ti(t,e,n,i){let r=xc.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,f(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(c.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,f(e));return}n.push({kind:"DependsOnSyntax",target:r,location:f(e)})}l(ti,"parseDependsOn");var vc=O('^import\\s+"([^"\\\\]+)"$'),$c=O('^import\\s+"'),ua=l(t=>$c.test(t),"isFileImport");function fa(t){let e=vc.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}l(fa,"tryParseFileImport");function Ft(t,e,n){let i=fa(e);if(i!==void 0){n.push(i);return}t.error(c.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}l(Ft,"parseFileImport");var Cr={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function ze(t,e,n,i=!1){i||(t=t.valueContext);let r=i?W:"\\s",o=t.sourceOptions.numericMode==="exact"?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${r}|[()])|`:"",s=t.sourceOptions.numericMode==="exact"&&!i?"[\\w.$-]+|[^\\s]":"[\\w.$-]+",a=new RegExp(Z(`"${z}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let x=e.replace(a,"").replace(new RegExp(W,"gu"),"");if(x.length>0)return t.error(c.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${x[0]}'`,n),null}let d=e.match(a)??[],p=0,m=l(()=>{if(d[p]==="("){p++;let E=y();return d[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(c.UnclosedConditionGroup,"Expected ')' in condition",n),E}let x=d[p++];if(i&&x===void 0)return t.error(c.ExpectedCondition,"Expected a condition",n),null;let g=d[p++];if(g==="starts"&&d[p]==="with"&&(g+=" with",p++),i&&!Object.hasOwn(Cr,g))return t.error(c.ExpectedComparisonOperator,`Expected a comparison operator after '${x}'`,n),null;let S=d[p++];return i&&S===void 0?(t.error(c.ExpectedComparisonValue,"Expected a value to compare against",n),null):x===void 0||S===void 0||Cr[g]===void 0?null:{kind:"ComparisonConditionSyntax",left:x,operator:Cr[g],right:Me(S,n,t),location:n}},"group"),u=l(()=>{let x=m();for(;x!==null&&d[p]==="and";){p++;let g=m();if(g===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"And",right:g,location:n}}return x},"and"),y=l(()=>{let x=u();for(;x!==null&&d[p]==="or";){p++;let g=u();if(g===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"Or",right:g,location:n}}return x},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(c.ExpectedCondition,"Expected a condition",n):h!==null&&p<d.length&&t.error(c.UnexpectedTokenInCondition,`Unexpected '${d[p]}' in condition`,n)),h}l(ze,"parseCondition");var bc=O(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),kc=O(`^otherwise${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Cc=O(`^with${W}+([A-Za-z_]\\w*)${W}+from${W}+([^\\n]+)$`),Ec=O("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Pc=new RegExp(`^${W}+|${W}+$`,"gu");function ya(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=bc.exec(d.content),m=kc.exec(d.content);if(p!==null){a&&t.error(c.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(d));let u=ze(t,p[1],f(d),!0),y=ma(t,d);u!==null&&(Ut(t,u),r.push({kind:"ScreenActionAlternativeSyntax",condition:u,command:p[2],arguments:y,location:f(d)}))}else if(d.content==="otherwise hidden"||m!==null)if(a&&t.error(c.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(d)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:ma(t,d),location:f(d)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(d)};for(let u=t.peekChild(d.indent);u!==void 0;u=t.peekChild(d.indent))t.reader.takeSignificant(),t.error(c.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(u)),t.skipBlock(u.indent)}else if(D(d.content)==="navigate")s!==null&&t.error(c.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(d)),s=i(t,d.content,d)??null;else{let u=D(d.content)==="label";t.error(u?c.UnknownActionDirective:c.InvalidActionAlternative,u?"A guarded action's header already supplies its label":`Unexpected '${d.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(d)),t.skipBlock(d.indent)}}return r.length===0&&t.error(c.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",f(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:f(e)}}l(ya,"parseGuardedAction");function ma(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Cc.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(Pc,""),location:f(i)}):(t.error(c.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}l(ma,"parseArguments");function Ut(t,e){if(e.kind==="LogicalConditionSyntax"){Ut(t,e.left),Ut(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=Ec.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(c.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}l(Ut,"validateCondition");var Qe=class t{static{l(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every($r)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&$r(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw new Error("There is no significant line left to take");return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};var ue=class extends Error{static{l(this,"InvalidSyntaxJson")}};var Ne=Object.freeze({numericMode:"legacy"}),ni=Object.freeze({numericMode:"exact"}),ha=Object.freeze({numericMode:"invalid"});function Wt(t){if(typeof t!="object"||t===null||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null||Reflect.ownKeys(t).length!==1||!Object.hasOwn(t,"numericMode"))throw new ue("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new ue("Malformed source numeric options.");return e==="exact"?ni:Ne}l(Wt,"validatedSourceOptions");var Sa=new WeakSet;function ga(t){Sa.add(t)}l(ga,"recordAuthoredDocument");function xa(t){return Sa.has(t)}l(xa,"isAuthoredDocument");var he=class t{static{l(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=Ne;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 Rt(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 Ac=O(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),wc=O(`^on${W}+([^\\n]+)$`),$a=O(`^where${W}+([^\\n]+)$`),va=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function ba(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=wc.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let u=n+1;u<e.length&&e[u].indent>i.indent;u++)o.push(e[u]);let s=o.filter(u=>u.indent===o[0]?.indent),a=s.filter(u=>["when","otherwise"].includes(D(u.content))),d=["click","double click","select"].includes(r[1].trim()),p=s.filter(u=>$a.test(u.content)),m=!1;for(let u of a){let y=D(u.content)==="when",h=y?Ac.exec(u.content):null;if(y){m&&t.error(c.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(u));let S=ze(t,h?.[1]??u.content.slice(4).trim(),f(u),!0);S!==null&&Ut(t,S),h!==null&&t.error(c.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",f(u))}else(m||u.content!=="otherwise")&&t.error(c.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",f(u)),m=!0;let x=o.indexOf(u),g=o[x+1];h===null&&(g===void 0||g.indent<=u.indent||!va.has(D(g.content)))&&t.error(c.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",f(u))}if(a.length>0&&(d||t.error(c.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",f(i)),(p.length>0||s.some(u=>va.has(D(u.content))))&&t.error(c.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",f(i)),a.some(u=>D(u.content)==="when")||t.error(c.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",f(i))),d)for(let u of p)Oc(t,u)}}l(ba,"validateInteractionBodies");function Oc(t,e){let n=new he(new Qe([]));n.sourceOptions=t.sourceOptions;let i=ze(n,$a.exec(e.content)[1].trim(),f(e),!0);i!==null&&Ut(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(c.LegacyInteractionWhere,r,f(e)):t.information(c.LegacyInteractionWhere,r,f(e))}l(Oc,"deprecateWhere");var ka=O("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Ic=O("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Tc=O("^field\\s+([\\w.]+)(?:\\s|$)"),Rc=O("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Dc=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),Mc=O("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),jc=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function qe(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=null,a=l(p=>{for(;n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();let m=o&&n.length===0?Mc.exec(p.content):null;m!==null&&i.add(m[1]);let u=ka.exec(p.content),y=Ic.exec(p.content);if(u!==null)n.push({command:u[1],kind:"form",indent:p.indent});else if(y!==null)n.push({command:y[2],kind:y[1],indent:p.indent});else if(jc.has(D(p.content)))n.push({command:"",kind:"other",indent:p.indent});else{let h=n.at(-1);if(h===void 0||h.kind==="other")return;let x=(h.kind==="form"?Tc:h.kind==="execute"?Rc:Dc).exec(p.content);x!==null&&r.push({command:h.command,property:oe(x[1]),scope:t.scope,location:f(p)})}},"recognize");a(e);let d=[e];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){for(t.reader.takeSignificant();n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();ka.test(e.content)&&D(p.content)==="description"&&n.at(-1)?.kind==="form"?s=G(t,p,s,`Form '${e.content.split(O("\\s+"))[1]}'`):p.content.startsWith("```")?t.skipFencedBody():(d.push(p),a(p))}ba(t,d);for(let p of r)t.inputUses.push(i.has(p.command)?{...p,isParameter:!0}:p)}l(qe,"collectInputUses");function $e(t){return O(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}l($e,"sourceStreamPattern");var Lc=$e("^[A-Za-z_]\\w*(?![\\s\\S])"),Nc=$e("^[\\w.]+(?![\\s\\S])");function Er(t){return typeof t=="string"&&Lc.test(t)}l(Er,"isSourceStreamName");function ii(t){return typeof t=="string"&&Nc.test(t)}l(ii,"isSourceStreamTypeName");var qc=O(`^id\\s+"(${z})"$`),Bc=$e("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Yc=$e("^eventsource\\s+([A-Za-z_]\\w*)$"),Fc=$e("^stream\\s+([A-Za-z_]\\w*)$");function Ca(t,e){let n=Yc.exec(e.content)?.[1]??"";n===""&&rt(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(Uc(t,a));break;case"identifier":r=Ea(t,a,"identifier",r);break;case"description":o=G(t,a,o,`Event source '${n}'`,!0);break;case"id":s=Pa(t,a,n,s);break;default:rt(t,a,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(a.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:s,location:f(e)}}l(Ca,"parseEventSource");function Uc(t,e){let n=Fc.exec(e.content)?.[1]??"";n===""&&rt(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,d=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?(rt(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=f(p),r=Wc(t,p)):(i=Ea(t,p,"streamId",i),o=i!==null);break;case"description":a=G(t,p,a,`Stream '${n}'`,!0);break;case"id":d=Pa(t,p,n,d);break;default:rt(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:d,directiveLocations:s,location:f(e)}}l(Uc,"parseEventStream");function Ea(t,e,n,i){let r=Bc.exec(e.content);return r===null||i!==null?rt(t,e,`Declare at most one '${n} <Type>'.`):(i=je(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),We(t,i,e)),un(t,e,c.InvalidEventSourceDeclaration),i}l(Ea,"parseType");function Pa(t,e,n,i){let r=qc.exec(e.content),o=r===null?null:Q(r[1]);return o===null||o.trim()===""||i!==null?rt(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(c.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),un(t,e,c.InvalidEventSourceDeclaration),i}l(Pa,"parsePin");function Aa(t,e,n,i){let[r,o]=n.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:f(e)};if(i)return t.error(c.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,d=[],p=!1,m={};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),u.content==="streamId"){a!==null||p?(t.error(c.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent)):(p=!0,m.streamId=f(u),d=Pr(t,u,c.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(u.content);if(y===null||a!==null||p)t.error(c.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent);else{let h={...f(u),column:u.indent+1+u.content.indexOf(y[1],u.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ae(y[1],h,t),location:f(u)},un(t,u,c.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:d,directiveLocations:m}}l(Aa,"parseCommandStream");function Wc(t,e){let n=[],i=$e("^([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){rt(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=je(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});We(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),un(t,r,c.InvalidEventSourceDeclaration)}return n.length===0&&rt(t,e,"A streamId part block cannot be empty."),n}l(Wc,"parseStreamIdParts");function Pr(t,e,n){let i=[],r=$e("^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$");for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=r.exec(o.content);if(s===null){t.error(n,"Expected '<part> = <source>' in a streamId part block.",f(o)),t.skipBlock(o.indent);continue}let a={...f(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ae(s[2],a,t),location:f(o)}),un(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}l(Pr,"parseRouteParts");function un(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",f(i)),t.skipBlock(e.indent))}l(un,"rejectChildren");function rt(t,e,n){t.error(c.InvalidEventSourceDeclaration,n,f(e))}l(rt,"invalid");var Vc=O("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),wa=l(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),ye=l(t=>wa(t).length>0,"isFileDirective"),ri=l(t=>ye(t)&&!Vc.test(wa(t)),"isFileDirectiveAmongProperties");var zc=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function oi(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||zc.has(n)))return!1}return!0}l(oi,"isBlankImplementationHint");var Oa=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),Vt=l(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),fn=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function ht(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(c.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,f(e)),{kind:"FileReferenceSyntax",path:n,location:f(e)}}l(ht,"parseFile");var Ar=l(t=>t.raw.trim()==="```","isClosingCodeFence");function Be(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(c.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(c.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(c.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,f(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(c.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Ar(o))break;let s=0;for(;s<i.indent&&o.raw[s]===" ";)s++;r.push(o.raw.substring(s))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
|
|
18
|
-
`),location:f(e)}}l(Be,"parseCode");function Ia(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(c.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return Qc(t,e,n);let i=Vt(n)?ht(t,n):null,r=i===null&&fn(t,n)?Be(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(c.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",f(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:f(e)}}return t.error(c.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}l(Ia,"parseHandler");function Qc(t,e,n){let i=mn(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"?c.InvalidImplementationBlock:c.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),fn(t,r)?Be(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}l(Qc,"parseImplementation");function mn(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(c.InvalidImplementationBlock,"Expected 'implementation' with no operand.",f(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||Oa.test(s.content)){let a=Oa.exec(s.content),d=a===null?null:Q(a[1]);oi(d)?t.error(c.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:d,location:f(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(c.InvalidImplementationHint,"A hint cannot have children.",f(p)),t.skipBlock(s.indent))}else if(Vt(s)||s.content.startsWith("```")){o&&t.error(c.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=Vt(s)?ht(t,s):null,d=a===null?Be(t,s):null;o||(i=a,r=d),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(c.InvalidImplementationBlock,"A file directive cannot have children.",f(p)),t.skipBlock(s.indent))}else t.error(c.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,f(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:f(e)}}}l(mn,"parseImplementationWrapper");var Gc=O("^system\\s+([A-Za-z_]\\w*)$"),_c=O("^operation\\s+([A-Za-z_]\\w*)$"),Zc=O("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),wr=O("^uses\\s+([A-Za-z_]\\w*)$"),Kc=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Jc=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function yn(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}l(yn,"rejectOperationChildren");function Ta(t,e){let n=Gc.exec(e.content);n===null&&t.error(c.InvalidSystemDeclaration,"Expected 'system <Name>'.",f(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=G(t,r,i,`System '${n?.[1]??""}'`):(t.error(c.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",f(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:f(e)}}l(Ta,"parseSystem");function ai(t,e,n=!1){let i=(n?Zc:_c).exec(e.content),r=i?.[1]??"";i===null&&t.error(c.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),d=null,p=null,m=[],u=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let x=Kc.exec(h.content),g=n&&x!==null?{...h,content:x[1].trimEnd()}:h;if(x===null&&Jc.has(D(h.content))){t.error(c.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!wr.test(h.content)&&Ze(g)!==void 0){let S=Le(t,g);n&&x===null&&t.error(c.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),S.isSubject&&t.error(c.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",f(h)),(S.isIdentifier||S.isGenerated)&&t.error(c.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(S.name)&&t.error(c.DuplicateDeclaration,`Operation '${r}' already declares input '${S.name}'.`,f(h)),y.add(S.name),m.push(S),n&&x!==null&&u.push({kind:"PropertyMappingSyntax",property:S.name,source:ae(x[2],{...f(h),column:h.indent+h.content.length-x[2].length+1},t),location:f(h)}),yn(t,h,c.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=G(t,h,o,`Operation '${r}'`);else if(wr.test(h.content))s!==null?t.error(c.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=wr.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),yn(t,h,c.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let S=Hc(t,h);h.content==="execute"?d!==null?t.error(c.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):d=S:p!==null?t.error(c.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):p=S}else t.error(c.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,f(h)),t.skipBlock(h.indent)}return s===null&&t.error(c.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:d,compensate:p,location:f(e)},mappings:u}}l(ai,"parseOperation");function Hc(t,e){let n=null,i=null,r=null,o=null,s=!1;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(a.content)==="description"){n=G(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(c.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let d=mn(t,a);s||(i=d.file,r=d.code,o=d.implementation),s=!0}else if(ye(a)||a.content.startsWith("```")){s&&t.error(c.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let d=ye(a)?ht(t,a):null,p=d===null?Be(t,a):null;s||(i=d,r=p),s=!0,d!==null&&yn(t,a,c.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(c.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",f(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:f(e)}}l(Hc,"parseOperationPhase");var Xc=O("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),ed=O("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),td=O("^specification\\s+([A-Za-z_]\\w*)$"),nd=O("^given caller as ([A-Za-z_]\\w*)$"),id="([A-Z]\\w*(?:\\.\\w+)*)",rd="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",zt=l((t,e="")=>Z(`^${t}\\s+${id}${e}${rd}$`.replaceAll("\\s",W)),"stepPattern"),od=zt("given"),ad=zt("when\\s+append"),sd=zt("when"),ld=zt("then"),cd=O("^then\\s+query\\b"),Ra=O("^(?:given|then)\\s+readmodel\\b"),dd=zt("given\\s+readmodel"),pd=zt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Da=O("^then\\s+no\\b"),ud=O(`^then\\s+error\\s+"(${z})"$`),Tr=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),fd=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),md=O("^given\\s+clock\\b"),yd=O("^given\\s+capture\\b"),hd=O("^when\\s+clock\\b"),Sd=O("^when\\s+trigger\\b"),gd=O("^when\\s+capture\\b"),xd=O("^when\\s+query\\b"),vd=O("^then\\s+result\\b"),$d=O("^then\\s+no\\s+result\\b"),bd=Z("^when\\s+redelivered\\b"),kd=Z("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Cd=O("^then\\s+no\\s+events\\b"),Ed=O('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Pd=O("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),Ad=O("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),wd=O("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Od=O("^then\\s+result(\\s+exactly)?$"),Ma=Z("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Id=Z(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`),Td=Z("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function Rr(t,e){let n=td.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i=null,r=[],o=[],s={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(u)||Rd(t,u,s))continue;let y=Da.test(u.content)?"then":D(u.content);if(y==="parameter"){let h=ta(t,u);h!==null&&r.push(h)}else if(y==="case"){let h=na(t,u);h!==null&&o.push(h)}else y==="description"?i=G(t,u,i,`Specification '${n}'`):y==="given"?Dd(t,u,s):y==="when"?Nd(t,u,s,n):y==="then"?qd(t,u,s):(t.error(c.UnknownSpecificationDirective,`Unexpected '${D(u.content)}' in specification body`,f(u)),t.skipBlock(u.indent))}s.noEventsLine!==void 0&&(s.whenAppended!==null||s.thenEvents.length>0||s.thenEventsInAnyOrder||s.thenErrors.length>0||s.thenDenied!==null)&&t.error(c.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(s.noEventsLine));let{whenDeclared:a,noEventsLine:d,...p}=s,m={kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...p,...r.length===0?{}:{parameters:r},...o.length===0?{}:{cases:o},location:f(e)};return ia(m,t),m}l(Rr,"parseSpecification");function Rd(t,e,n){if(!Xc.test(e.content))return!1;let i=ed.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(c.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),Se(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=Mt(t,o,Tr,c.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else yn(t,e,c.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:f(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:f(e)});return!0}l(Rd,"parseOperationStep");function Dd(t,e,n){if(md.test(e.content))n.givenClock!==null?(t.error(c.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),Se(t,e.indent)):n.givenClock=ja(t,e,"given");else if(yd.test(e.content)){let i=La(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(c.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent);else if(e.content.startsWith("given caller as")){let i=nd.exec(e.content);i===null&&t.error(c.InvalidSpecificationCallerPersona,"Expected 'given caller as <Persona>'.",f(e));let r=t.peekChild(e.indent);r!==void 0&&t.error(c.InvalidSpecificationCallerPersona,"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.",f(r)),Se(t,e.indent),i!==null&&(n.givenCallerPersona={kind:"SpecificationCallerPersonaSyntax",name:i[1],location:f(e)})}else n.givenCaller=Ld(t,e);else if(Ra.test(e.content)){let i=Na(t,e,dd,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Dr(t,e,od,"given");i!==void 0&&n.given.push(i)}}l(Dd,"parseGiven");var Md=O(`^role${W}+"(${z})"$`),jd=O(`^claim${W}+"(${z})"${W}*=${W}*"(${z})"$`);function Ld(t,e){if(e.content!=="given caller")return t.error(c.InvalidSpecificationCaller,"Expected exactly 'given caller'.",f(e)),t.skipBlock(e.indent),null;let n=!1,i=[],r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Md.exec(o.content),a=jd.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(Q(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:Q(a[1]),value:Q(a[2]),location:f(o)}):t.error(jt(o.content)?c.InvalidSpecificationCaseReference:c.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,f(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:f(e)}}l(Ld,"parseCaller");function Nd(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let d=n.whenAppended!==null||r?c.ConflictingSpecificationActions:c.DuplicateSpecificationWhen;t.error(d,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),Se(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Dr(t,e,ad,"when append")??null;return}if(bd.test(e.content)){let d=kd.exec(e.content);d===null?(t.error(c.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),Se(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:d[1],reaction:d[2],...Ir(t,e,void 0,void 0,"when redelivered"),location:f(e)};return}if(hd.test(e.content)){n.whenClock=ja(t,e,"when");return}if(Sd.test(e.content)){n.whenTrigger=Or(t,e,Pd,c.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(d,p)=>({kind:"SpecificationTriggerSyntax",trigger:d,values:p,location:f(e)}));return}if(gd.test(e.content)){n.whenCapture=La(t,e,"when");return}if(xd.test(e.content)){n.whenQuery=Or(t,e,wd,c.InvalidSpecificationQueryAction,"when query","when query <Query>",(d,p)=>({kind:"SpecificationWhenQuerySyntax",query:d,arguments:p,location:f(e)}));return}let o=sd.exec(e.content);if(o===null){t.error(c.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),Se(t,e.indent);return}let s=[],a=Ir(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}l(Nd,"parseWhen");function qd(t,e,n){if(Cd.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(c.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",f(e)):(n.thenNoEvents=!0,n.noEventsLine=e);let o=t.peekChild(e.indent);o!==void 0&&t.error(c.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),Se(t,e.indent);return}if(br.test(e.content)){let o=ea(t,e);n.thenReturns!==null?t.error(c.InvalidReturnExpectation,"A specification declares at most one return expectation.",f(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(c.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,Se(t,e.indent);return}if(vd.test(e.content)){Yd(t,e,n);return}if($d.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(c.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},Se(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(c.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),Se(t,e.indent)):n.thenDenied!==null?t.error(c.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",f(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:f(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:f(e)});return}if(e.content.startsWith("then error case.")){let o=Ie(e.content.substring(11),{...f(e),column:f(e).column+11},t);o.kind==="CaseValueExpressionSyntax"&&n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,caseValue:o,location:f(e)});return}let i=ud.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:Q(i[1]),location:f(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(c.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),Se(t,e.indent);return}if(Da.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=Bd(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=Ma.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=Ie(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax"||s.kind==="CaseValueExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:f(e)})}t.skipOpaqueBlock(e.indent);return}if(cd.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=l((u,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(u,y,f(h)),t.skipBlock(h.indent)},"reject"),a=Td.exec(e.content);if(a===null)return s(c.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let d=[],p=[],m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!m?d.push(...hn(t.valueContext,u,!0)):u.content==="arguments"?s(c.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,u):u.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:hn(t.valueContext,u,!0),exactly:!1,location:f(u)}):s(c.UnknownSpecificationQueryDirective,`Unexpected '${D(u.content)}' in 'then query' body - expected arguments or result`,u),m||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:d,results:p,exactly:a[2]!==void 0,location:f(e)});return}if(Ra.test(e.content)){let o=Na(t,e,pd,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Dr(t,e,ld,"then");r!==void 0&&n.thenEvents.push(r)}l(qd,"parseThen");function Bd(t,e){let n=Ma.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(c.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),Se(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Id.test(i)?Ie(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax"||o.kind==="CaseValueExpressionSyntax");s||t.error(c.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(c.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(d)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}l(Bd,"parseAbsentReadModel");function Se(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}l(Se,"skipBody");function ja(t,e,n){let i=Ed.exec(e.content);return Se(t,e.indent),i===null||i[1]!==n?(t.error(jt(e.content)?c.InvalidSpecificationCaseReference:c.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,f(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:f(e)}}l(ja,"parseClock");function La(t,e,n){return Or(t,e,Ad,c.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}l(La,"parseCapture");function Or(t,e,n,i,r,o,s){let a=n.exec(e.content);return a===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,f(e)),Se(t,e.indent),null):s(a[1],hn(t,e))}l(Or,"parseNamedStep");function Yd(t,e,n){let i=Od.exec(e.content);if(i===null){t.error(c.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),Se(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:hn(t,e),exactly:i[1]!==void 0,location:f(e)})}l(Yd,"parseResult");function Na(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(c.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),Se(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:hn(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}l(Na,"parseReadModelStep");function Dr(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(c.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),Se(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...Ir(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}l(Dr,"parseEventStep");var Mr=$e("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),Fd=O("^streamId\\s*=(?!=|>)\\s*(.+)$");function Ir(t,e,n,i,r){let o=[];li(t,e,i,o);let s=null,a,d,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Un.test(m.content)){let y=Mt(t,m,Wn,c.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let u=Tr.exec(m.content);if(u!==null)Sn(t,o,qa(t,m,u));else if(D(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(c.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(p){t.error(c.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=Mr.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(d={kind:"SpecificationNoStreamSyntax",location:f(m)},p=!0,si(t,m)):y!==null?(a=jr(t,m,y),p=!0):(t.error(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(D(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(c.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(c.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=Ie(y,f(m),t)}else t.error(c.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...d===void 0?{}:{noStream:d}}}l(Ir,"parseValuesWithEventSource");function jr(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(c.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=f(a),r=Pr(t,a,c.InvalidSpecificationStream).map(m=>m.source.kind==="PathExpressionSyntax"&&m.source.path.startsWith("case.")?{...m,source:Ie(m.source.path,m.source.location,t)}:m));continue}let d=Fd.exec(a.content);if(d===null||i!==null||o){t.error(c.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let p={...f(a),column:a.indent+1+a.content.indexOf(d[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:Ie(d[1],p,t),location:f(a)},si(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...f(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:f(e)}}l(jr,"parseSpecificationStream");function si(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(c.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}l(si,"rejectSpecificationRouteChildren");function hn(t,e,n=!1,i){let r=[];li(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"?fd:Tr).exec(o.content);if(s===null){t.error(c.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}Sn(t,r,qa(t,o,s,n))}return r}l(hn,"parseValues");function qa(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:Ie(n[2],f(e),t,i),location:f(e)}}l(qa,"mappingOf");var Ud=Z("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",W)),Wd=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",W));function ot(t,e){let n=Ud.exec(e.content);if(n===null)return t.error(c.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:f(e)};let i=Vd(t,e,void 0,!0,n[1]);for(let r of Lt(i))t.error(c.InvalidSpecificationCaseReference,"Case references are not permitted in example bodies.",r.location);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}l(ot,"parseExample");function li(t,e,n,i){if(n?.groups?.property===void 0)return;let r=n.groups.property,o=n.groups.value,s=e.content.length-o.length,a=f(e),d=Dt(t,o,{...a,column:a.column+s},c.InvalidSpecificationValue);d!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:d,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}l(li,"addInlineValue");function Sn(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(c.DuplicateSpecificationAssignment,`Property '${n.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,n.location);return}e.push(n)}l(Sn,"addFixtureValue");function Vd(t,e,n,i=!1,r){let o=[],s=[],a=null,d=null,p,m;li(t,e,n,o);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(u.content)==="description"){d=G(t,u,d,`Example '${r}'`);continue}if(i&&Un.test(u.content)){let h=Mt(t,u,Wn,c.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):Sn(t,s,h,o));continue}let y=Wd.exec(u.content);if(r!==void 0&&y===null&&(D(u.content)==="stream"||u.content.startsWith("no stream"))){let h=Mr.exec(u.content);p!==void 0||m!==void 0?(t.error(c.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(u)),t.skipOpaqueBlock(u.indent)):u.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:f(u)},si(t,u)):h!==null?p=jr(t,u,h):(t.error(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",f(u)),t.skipOpaqueBlock(u.indent));continue}if(y!==null)Sn(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:Ie(y[2],f(u),t),location:f(u)},s);else if(D(u.content)==="for"){let h=u.content.substring(3).trim();h.length===0?t.error(c.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(u)):a!==null?t.error(c.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(u)):a=Ie(h,f(u),t)}else t.error(c.InvalidSpecificationValue,`Invalid property mapping '${u.content}' - expected '<property> = <value>'`,f(u))}return{values:o,for:a,generatedValues:s,description:d,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}l(Vd,"parseFixtureBody");var Ba=["StateChange","StateView","Automation","Translate"];var de;(function(t){t.Inbound="Inbound",t.Outbound="Outbound"})(de||(de={}));var Lr="events",Nr="from";function gn(t){return t.syntaxKind===Lr}l(gn,"isEventsSource");function Ya(t){return gn(t)?t.settings.filter(e=>e.name===Nr):[]}l(Ya,"consumedEvents");var se;(function(t){t.Private="Private",t.Public="Public"})(se||(se={}));var zd=new RegExp(`^${W}*$`),xn=l(t=>zd.test(t),"isBlankPublicEventOrigin");function ci(t){if(t.kind==="EventSyntax"||t.kind==="ImportSyntax"){let e=t,n=e.visibility===void 0?se.Private:e.visibility;if(n!==se.Private&&n!==se.Public)return"Event visibility must be Private or Public.";if(e.origin!=null&&(typeof e.origin!="string"||xn(e.origin)))return"An event or import origin must be a nonblank quoted string.";if(e.origin!=null&&n!==se.Public)return"An event or import with an origin is a public contract.";if(t.kind==="ImportSyntax"&&n===se.Public&&e.origin==null)return"A public contract import requires an origin."}if(t.kind==="SliceSyntax"){let e=t;if(e.direction!=null&&e.type!=="Translate")return"Only a Translate slice may declare a direction.";if(e.direction!=null&&e.direction!==de.Inbound&&e.direction!==de.Outbound)return"A translation direction must be Inbound or Outbound."}}l(ci,"publicEventMetadataError");var vn=["tag"];var Qd=O(`^id\\s+"(${z})"$`),Qt=class{static{l(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(D(n.content)){case"id":{let r=Qd.exec(n.content),o=r===null?"":Q(r[1]);return o.trim().length===0||this.value.id!==null?e.error(c.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(c.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=G(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=Pe(e,n,this.value.documentation,`Event '${this.name}'`,c.InvalidEventDocumentation),!0;default:return!1}}};var Gd=O("^type\\s+([A-Za-z_]\\w*)$"),_d=O(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${z})")?$`),Zd=O("^readmodel\\s+([A-Za-z_]\\w*)$"),Fa=4294967295,Kd=O("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Jd=O("^[A-Za-z_]\\w*$"),Ua=l(t=>D(t.content)==="description"&&Ze(t)===void 0,"isDescription");function qr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}l(qr,"withoutIdentifier");function Wa(t,e){let n=Gd.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,f(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Ua(o)){r=G(t,o,r,`Type '${n}'`);continue}if(ri(o))continue;let s=Le(t,o);if(s===void 0){t.error(c.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(qr(t,s,o,c.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(c.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}l(Wa,"parseType");function Va(t,e){let n=_d.exec(e.content),i=n?.groups?.name??"";n===null&&t.error(c.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,f(e));let r=n?.groups?.origin===void 0?null:Q(n.groups.origin),o=n?.groups?.public!==void 0||r!==null?se.Public:se.Private;r!==null&&xn(r)&&t.error(c.InvalidEventDeclaration,"An event origin must be a nonblank quoted string",f(e));let s=n?.groups?.generation!==void 0,a=1;if(s){let u=Number(n.groups.generation);!Number.isSafeInteger(u)||u===0||u>=Fa?t.error(c.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Fa-1}`,f(e)):a=u}let d=[],p=[],m=new Qt(i);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ri(u))continue;if(vn.includes(D(u.content))){let h=$n(t,u);h!==void 0&&p.push(h);continue}let y=Le(t,u);if(y===void 0){m.tryParse(t,u)||t.error(c.InvalidPropertyDeclaration,`Invalid property '${u.content}' - expected '<name> <Type>'`,f(u));continue}d.push(qr(t,y,u,c.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:d,tags:p,visibility:o,origin:r,generation:a,hasGenerationMarker:s,...m.value,location:f(e)}}l(Va,"parseEvent");function $n(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&Kd.test(i)&&t.warning(c.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,f(e)),i.length===0){t.error(c.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(Jd.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=ae(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(c.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,f(e));return}return{kind:"TagSyntax",value:r,location:f(e)}}l($n,"parseTag");function za(t,e){let n=Zd.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,f(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Ua(s))r=G(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&Ze(s)===void 0)o=Pe(t,s,o,`Read model '${n}'`);else{if(ri(s))continue;{let a=Le(t,s);if(a===void 0){t.error(c.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,f(s));continue}i.push(qr(t,a,s,c.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,documentation:o,location:f(e)}}l(za,"parseReadModel");var Hd=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function be(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(c.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let s=t.substring(1,t.length-1),a=0;for(let d=0;d<s.length;d++){if(s[d]!=="$"||s[d+1]!=="{")continue;d>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,d),location:e});let p=s.indexOf("}",d);if(p<0)return n.error(c.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:be(s.substring(d+2,p),e,n),location:e}),d=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 Me(i,e,n);if(t.startsWith("literal ")){let o=dn(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(c.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=dn(t,e,n);return r!==void 0?r:Hd.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(c.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}l(be,"parseProjectionExpression");var pi=l(t=>({legacy:O(t),native:Z(t)}),"grammar"),Xd=pi("^capture\\s+([A-Za-z_]\\w*)$"),ep=/^[A-Za-z_][\w.]*$/,tp=pi("^append\\s+([A-Z]\\w*)$"),np=pi("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),ip=pi("^nested\\s+([\\w.]+)$"),di=l((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),rp=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),op=Z("^([a-z_]\\w*)\\s*=\\s*(.+)$"),ap=Z(`^"(${z})"\\s*=>\\s*(\\w+)$`),sp=Z(`^split\\s+(\\S+)\\s+by\\s+"(${z})"$`),lp=new RegExp(Z(`"${z}"|[\\w.]+`).source,"gu"),cp=Z("^[\\w.]+$");function Br(t,e){let n=t;t=t.valueContext;let i=di(t,Xd).exec(e.content)?.[1]??"";i===""&&t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"source":r=dp(t,m,n);break;case"key":o=m.content.substring(3).trim();break;case"map":s.push(...Ga(t,m));break;case"append":_a(t,m,a);break;case"children":{let u=di(t,np).exec(m.content);if(u===null){t.error(c.InvalidChildrenDeclaration,`Invalid children declaration '${m.content}' - expected 'children <collection> identified by <key>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Qa(t,m);u!==null&&d.push({kind:"CaptureChildrenSyntax",property:u[1],identifiedBy:u[2],...y,location:f(m)});break}case"nested":{let u=di(t,ip).exec(m.content);if(u===null){t.error(c.InvalidNestedDeclaration,`Invalid nested declaration '${m.content}' - expected 'nested <Property>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Qa(t,m);u!==null&&p.push({kind:"CaptureNestedSyntax",property:u[1],...y,location:f(m)});break}default:t.error(c.UnknownCaptureDirective,`Unexpected '${m.content}' in capture body`,f(m)),t.skipOpaqueBlock(m.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:i,source:r,key:o,map:s,appends:a,children:d,nested:p,location:f(e)}}l(Br,"parseCapture");function dp(t,e,n){let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);i.push({kind:"CaptureSourceSettingSyntax",name:s,value:o.content.substring(s.length).trim(),location:f(o)})}let r=e.content.substring(6).trim();return r===Lr&&pp(n,e,i),{kind:"CaptureSourceSyntax",syntaxKind:r,settings:i,location:f(e)}}l(dp,"parseSource");function pp(t,e,n){n.length===0&&t.error(c.InvalidCaptureEventsSource,"'source events' needs at least one 'from <Event>' line naming a public event to consume",f(e));let i=new Set;for(let r of n)r.name!==Nr?t.error(c.InvalidCaptureEventsSource,`'source events' accepts only 'from <Event>' lines, got '${r.name}'`,r.location):ep.test(r.value)?i.has(r.value)?t.error(c.InvalidCaptureEventsSource,`Event '${r.value}' is already consumed by this 'source events'`,r.location):i.add(r.value):t.error(c.InvalidCaptureEventsSource,`Invalid event '${r.value}' - expected 'from <Event>', optionally qualified with dots`,r.location)}l(pp,"validateEventsSource");function Ga(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=f(i);if(D(i.content)==="split"){let u=sp.exec(i.content);if(u===null){t.error(c.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(),cp.test(h.content)?y.push(h.content):t.error(c.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));u!==null&&n.push({kind:"CaptureSplitSyntax",source:be(u[1],r,t),separator:Q(u[2]),targets:y,location:r});continue}let o=op.exec(i.content);if(o===null){t.error(c.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let s=o[2].trim(),a=s.startsWith("`")?s.indexOf("`",1):-1,d=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||d||s.substring(a+1).trim()==="")?s.substring(0,a+1):d?s.substring(0,s.length-10).trimEnd():s,m=[];if(d)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let y=ap.exec(u.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:Q(y[1]),to:y[2],location:f(u)}):t.error(c.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,f(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:be(p,r,t),translations:m,location:r})}return n}l(Ga,"parseMap");function Qa(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=Ga(t,r):D(r.content)==="append"?_a(t,r,i):(t.error(c.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}l(Qa,"mapAndAppends");function _a(t,e,n){let i=di(t,tp).exec(e.content);if(i===null){t.error(c.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=l((d,p=!1)=>{let m=f(d);if(D(d.content)==="tag"){let y=$n(t.valueContext,d,!1);y!==void 0&&o.push(y);return}let u=rp.exec(d.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:oe(u[1]),source:Me(u[2],m,t.valueContext),location:m}):t.error(p?c.InvalidPropertyMapping:c.UnknownAppendDirective,`Unexpected '${d.content}' in append body`,m)},"mapping");for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(d.content)==="when"){s=up(t,d);for(let p=t.peekChild(d.indent);p!==void 0;p=t.peekChild(d.indent))t.reader.takeSignificant(),a(p,!0)}else a(d);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}l(_a,"pushAppend");function up(t,e){let n=e.content.substring(4).trim(),i=f(e),r=l((d,p=[],m=null,u=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:d,properties:p,fromValue:m,toValue:u,expression:y,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(c.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(c.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${z}"|[^\\s]+`,"gu"):lp)??[]],s=l(d=>d.startsWith('"')&&d.endsWith('"')?Q(d.substring(1,d.length-1)):d,"unquote");if(o.length===0)return t.error(c.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(c.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(c.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(c.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let d=1;d<o.length-1;d+=2){if(o[d]!==o[1])return t.error(c.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[d+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}l(up,"parseWhen");var Yr=O("^returns\\s+(@?[A-Za-z_]\\w*)$"),fp=O("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Fr(t,e){let n=f(e);if(e.content!=="returns"){let r=Yr.exec(e.content);if(r===null)return t.error(c.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(c.InvalidCommandResponse,"A scalar response cannot have child directives.",f(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:oe(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=fp.exec(r.content);if(o===null){Ze({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(c.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",f(r)):t.error(c.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",f(r)),t.skipBlock(r.indent);continue}let s=f(r),a=o[2]===void 0?null:je(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&We(t,a,r),i.push({kind:"ResponseFieldSyntax",name:oe(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:oe(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let d=t.peekChild(r.indent);d!==void 0&&(t.error(c.InvalidCommandResponse,"A response field cannot have child directives.",f(d)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}l(Fr,"parseCommandResponse");var ui=new WeakMap;function fi(t){let e=Z(`^reads${W}+([A-Z]\\w*)(?:${W}+as${W}+([a-z_]\\w*))?(?:${W}+by${W}+([a-z_]\\w*))?$`).exec(t.content);if(!(e===null||["as","by","reads"].includes(e[2])))return{kind:"ReadsSyntax",readModel:e[1],alias:e[2]??null,by:e[3]??null,location:f(t)}}l(fi,"captureReads");function Za(t){return new he(t.reader.fork(),t.path,t.languages)}l(Za,"fork");function Ka(t,e){if(e.content!=="concurrency")return;let n=Za(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),D(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=Z(`^(sourceType|streamType|streamId)${W}+([A-Za-z_]\\w*)$`).exec(s.content);a!==null&&(r[a[1]]??=a[2]);break}case"events":{if(o!==void 0)break;let a=s.content.slice(6).split(",").map(d=>d.replace(new RegExp(`^${W}+|${W}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(d=>Z("^[A-Z]\\w*$").test(d))&&(o=a);break}default:n.skipBlock(s.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:f(e)}}l(Ka,"captureConcurrency");function Ja(t,e){let n=Z(`^reducer${W}+([A-Za-z_]\\w*)${W}*=>${W}*([A-Za-z_]\\w*)$`).exec(e.content),i=Za(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),D(o.content)==="description"){G(i,o,null,"Reducer");continue}let s=Z(`^on${W}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:f(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:f(e)}}l(Ja,"captureReducer");var mp=O("^produces\\s+operation(?:\\s|$)"),yp=O("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),hp=O("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Ha=O("^produces\\s+when\\s+(.+)$"),Sp=O("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),gp=O("^for\\s+(\\S.*)$"),xp=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),vp=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),$p=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function bn(t,e,n=!1){if(mp.test(e.content)){if(!n){t.error(c.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let x=ai(t,e,!0);return{kind:"ProducesSyntax",when:null,event:x.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:x.operation,mappings:x.mappings,for:null,tags:[],location:f(e)}}let i=yp.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(c.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(c.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",f(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(Ha.test(e.content)){o=ze(t,Ha.exec(e.content)[1],f(e));let x=t.peekChild(e.indent);if(x===void 0||!Sp.test(x.content)){t.error(c.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=x,s=x.content,a=x.indent+1}else{let x=hp.exec(e.content);if(x===null){t.error(c.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=x[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let d=[],p=new Set,m=[],u=[],y=new Qt(s),h=null;for(let x=t.peekChild(r.indent);x!==void 0;x=t.peekChild(r.indent)){t.reader.takeSignificant();let g=D(x.content),S=f(x);if($p.has(g)){t.error(c.ReservedProductionMetadata,`'${g}' is system-assigned production metadata and cannot be supplied here`,S),t.skipOpaqueBlock(x.indent);continue}if(i!==null&&(g==="generation"||g==="origin")){t.error(g==="generation"?c.InlineEventGeneration:c.ReservedProductionMetadata,g==="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(x.indent);continue}if(g==="tag"){let A=$n(t,x,!1);A!==void 0&&u.push(A);continue}let E=gp.exec(x.content);if(E!==null){h!==null?t.error(c.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,S):h=ae(E[1],S,t);continue}let $=(i===null?xp:vp).exec(x.content),P=$===null||i===null?void 0:Le(t,{...x,content:$[1].trimEnd()});if($!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(c.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(c.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,S),p.add(A),d.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??oe($[1]),source:ae($[2],{...S,column:x.indent+x.content.length-$[2].length+1},t),location:S})}else(i===null||!y.tryParse(t,x))&&t.error(c.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${x.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,S)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...f(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?u:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:d,tags:u,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}l(bn,"parseProduces");var bp=O("^command\\s+([A-Za-z_]\\w*)$"),kp=$e("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Cp=O("\\bseverity\\s+(\\S+)$"),es=O(`\\bmessage\\s+(?:"(${z})"|(\\$strings\\.\\S*))$`),Ep=O("^([\\w.]+)\\s+(.+)$"),Pp=O("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),Ap=$e("^[A-Za-z_]\\w*$"),wp=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),Op={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},ts={information:"Information",warning:"Warning",error:"Error"},Ip=new Set(["reads","concurrency"]),Tp=new Set(["description","documentation","handler","concurrency"]);function ns(t,e){let n=new Set,i=new he(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,Xa(i,e,void 0,n),Xa(t,e,n)}l(ns,"parseCommand");function Xa(t,e,n,i){let r=bp.exec(e.content)?.[1]??"";r===""&&t.error(c.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,d=[],p=[],m=[],u=[],y,h=null,x=null,g=null,S=null,E=null,$=[];for(let b=t.peekChild(e.indent);b!==void 0;b=t.peekChild(e.indent)){t.reader.takeSignificant();let w=D(b.content),T=Ze(b);if(T!==void 0&&(Tp.has(w)||w==="validate"&&b.content!=="validate csharp"))a=mi(t,o,T,r,b,a);else if(w==="returns"){let I=Yr.exec(b.content);I!==null&&!I[1].startsWith("@")&&T!==void 0?n===void 0?(o.push(T),s.push({line:b,candidate:T,response:null})):n.has(T.type.name)?s.push({line:b,candidate:null,response:Fr(t,b)}):a=mi(t,o,T,r,b,a):T!==void 0?a=mi(t,o,T,r,b,a):Fn(t,b)?t.skipBlock(b.indent):s.push({line:b,candidate:null,response:Fr(t,b)})}else if(w==="stream"&&kp.test(b.content)&&T!==void 0&&t.streamCandidates?.hasSource(T.type.name.split(".")[0])===!0){let[I,j]=T.type.name.split("."),N=t.streamCandidates.hasPropertyType(T.type.name)&&t.streamCandidates.hasUniqueStream(I,j),L=Aa(t,b,T,N);(E!==null||$.length>0)&&t.error(c.InvalidCommandStream,"A command declares at most one stream route.",f(b)),N||E!==null?$.push(L):E=L}else if(w==="description")h=G(t,b,h,`Command '${r}'`);else if(w==="documentation")x=Pe(t,b,x,`Command '${r}'`);else if(w==="authorize")g=Je(g,yt(t,b));else if(w==="validate"){let I=Ur(t,b,"command");I!==void 0&&d.push(I)}else if(w==="produces"){let I=bn(t,b,!0);I!==void 0&&p.push(I)}else if(w==="handler")S=Ia(t,b);else if(Ip.has(w)){let I=fi(b);I!==void 0&&u.push(I),w==="concurrency"&&y===void 0&&(y=Ka(t,b));let j=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(b.content);j!==null&&m.push({readModel:j[1],alias:j[2]??null}),wp.test(b.content)&&t.error(c.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(b)),t.skipOpaqueBlock(b.indent)}else T!==void 0?a=mi(t,o,T,r,b,a):(Fn(t,b),t.error(c.UnknownCommandDirective,`Unexpected '${b.content}' in command body`,f(b)),t.skipBlock(b.indent))}let P=new Set(s.flatMap(b=>b.candidate===null?[]:[b.candidate])),A=new Set(o.filter(b=>!P.has(b)).map(b=>b.name));s.some(b=>b.candidate!==null&&!A.has(b.candidate.type.name)&&b.candidate.type.name!=="returns")&&A.add("returns");for(let b of A)i?.add(b);let v=null,k=new Set;for(let b of s){let w=b.response;if(b.candidate!==null){if(!A.has(b.candidate.type.name))continue;k.add(b.candidate),w={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:b.candidate.type.name,location:b.candidate.type.location},location:f(b.line)}}w!==null&&(v!==null?t.error(c.InvalidCommandResponse,"A command declares at most one unconditional response.",f(b.line)):v=w)}S!==null&&p.length>0&&t.error(c.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let C={kind:"CommandSyntax",name:r,description:h,documentation:x,authorize:g,properties:o.filter(b=>!k.has(b)),validations:d,produces:p,handler:S,response:v,stream:E,streamCandidates:$,location:f(e)};return ui.set(C,m),it.set(C,{reads:u,concurrency:y}),C}l(Xa,"parseCommandBody");function mi(t,e,n,i,r,o){return We(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(c.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,n.location),n={...n,isIdentifier:!1}),e.push(n),o??(n.isIdentifier?n:void 0)}l(mi,"addProperty");function Ur(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=Be(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:f(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(c.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=ze(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,u="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let x=es.exec(h.content);x!==null&&x.index===0?m=x[1]!==void 0?Q(x[1]):x[2]:D(h.content)==="severity"?(y||(u=ts[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:u,location:f(a)});continue}let d=Rp(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);d!==void 0&&r.push(d)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=Be(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(c.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}l(Ur,"parseValidate");function Rp(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=Mp(e.content),s=jp(i,e,r);if(s===void 0)return;let a=Ep.exec(s.content);if(a===null){i.error(c.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let d=Lp(i,a[2],e);if(d===void 0)return;let p=d.kind==="Rule"?Dp(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:d.kind,value:d.value,message:o,severity:s.severity,...p,location:f(e)}}l(Rp,"parseValidationRule");function Dp(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?mn(t,i):{file:Vt(i)?ht(t,i):null,code:!Vt(i)&&fn(t,i)?Be(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(c.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,f(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?c.InvalidImplementationBlock:c.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),fn(t,s)?Be(t,s):t.skipBlock(s.indent);return o}l(Dp,"parseRuleImplementation");function Mp(t){let e=es.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?Q(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}l(Mp,"splitMessage");function jp(t,e,n){let i=Cp.exec(n);if(i===null)return{content:n,severity:"Error"};let r=ts[i[1]];if(r===void 0){t.error(c.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}l(jp,"splitSeverity");function Lp(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Pp.exec(e);if(i===null){t.error(c.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!Ap.test(r)){t.error(c.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,f(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:f(n)}}}return{kind:Op[i[1]],value:ae(i[2],f(n),t)}}l(Lp,"parseRule");var Np=O("^constraint\\s+([A-Za-z_]\\w*)$"),qp=O("^unique\\s+event\\s+([A-Z]\\w*)$"),Bp=O("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Yp=O("^released\\s+by\\s+([A-Z]\\w*)$"),Fp=O(`^message\\s+"(${z})"$`),Up=l(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function is(t,e){let n=Np.exec(e.content);n===null&&t.error(c.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,d=null,p=null,m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(u.content)==="description"){p=G(t,u,p,`Constraint '${i}'`);continue}let y=Yp.exec(u.content),h=Fp.exec(u.content);y!==null?s.has(y[1])?t.error(c.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${y[1]}'`,f(u)):(o.push(y[1]),s.add(y[1])):h!==null?d!==null?t.error(c.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(u)):d=Q(h[1]):u.content==="ignore casing"?(m&&t.error(c.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(u)),m=!0):Wp(t,i,u,r,a)}for(let u of o.filter(y=>a.has(y)))t.error(c.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${u}'`,f(e));return r.length===0&&(t.error(c.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(yi(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||d!==null||m)&&t.error(c.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:d,ignoreCasing:m,description:p}}l(is,"parseConstraint");function Wp(t,e,n,i,r){let o=Vp(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(c.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=Up(o);if(s!==void 0&&r.has(s)){t.error(c.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}l(Wp,"addRule");function Vp(t,e,n){let i=f(n),r=qp.exec(n.content);if(r!==null)return yi(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=Bp.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(c.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return yi(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(ye(n)){t.warning(c.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 yi(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(c.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}l(Vp,"parseRule");function yi(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}l(yi,"rule");var zp=O("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),Qp=O("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Gp=O("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),_p=O("^with\\s+(@?[\\w.]+)$"),Zp=O("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),Kp=O("^nested\\s+(@?[\\w.]+)$"),Jp=O("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Hp=O("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Xp=O("^clear\\s+with\\s+(@?[\\w.]+)$"),eu=O("^variant\\s+(@?[\\w.]+)\\s*$"),tu=O("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),nu=O("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),iu=O("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),ru=O("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),rs=O("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),ou={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Vr(t,e){let n=zp.exec(e.content);if(n===null)return t.error(c.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o=null,s="Inherit",a=null,d=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(p))continue;let m=D(p.content);if(m==="description")o=G(t,p,o,`Projection '${i}'`);else if(m==="sequence")r=p.content.substring(8).trim();else if(m==="automap")s="Enabled";else if(p.content==="no automap")s="Disabled";else if(m==="key")a=as(t,p);else if(m==="variant")d.push(fu(t,p));else{let u=zr(t,p,!1);u!==void 0&&d.push(u)}}return au(t,d,i),d.length===0&&t.error(c.EmptyProjection,`Projection '${i}' must contain at least one directive`,f(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:s,key:a,blocks:d,description:o,location:f(e)}}l(Vr,"parseProjection");function au(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(c.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(c.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}l(au,"reportVariantConflicts");function zr(t,e,n){let i=f(e);switch(D(e.content)){case"from":return su(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Wr(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}=Wr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return lu(t,e);case"children":return cu(t,e);case"nested":return du(t,e);case"remove":return pu(t,e);case"clear":return n||t.error(c.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),uu(t,e);default:t.error(c.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}l(zr,"parseBlock");function su(t,e){let n=[];for(let s of Jo(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(c.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let d=Qp.exec(a);if(d===null){t.error(c.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:oe(d[1]),key:d[2]===void 0?null:be(d[2],f(e),t),location:f(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=as(t,s):a==="parent"?o=be(s.content.substring(6),f(s),t):ss(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}l(su,"parseFrom");function lu(t,e){let n=Gp.exec(e.content);if(n===null)return t.error(c.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,f(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:f(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=_p.exec(r.content);if(o===null){t.error(c.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Wr(t,r);i.push({kind:"JoinEventSyntax",event:oe(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:oe(n[1]),on:oe(n[2]),events:i,location:f(e)}}l(lu,"parseJoin");function cu(t,e){let n=Zp.exec(e.content);if(n===null)return t.error(c.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,f(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let{autoMap:i,blocks:r}=os(t,e);return{kind:"ChildrenSyntax",property:oe(n[1]),identifiedBy:be(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}l(cu,"parseChildren");function du(t,e){let n=Kp.exec(e.content);if(n===null)return t.error(c.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,f(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let i=oe(n[1]),{autoMap:r,blocks:o}=os(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(c.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}l(du,"parseNested");function os(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=zr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}l(os,"parseChildBlocks");function pu(t,e){let n=Hp.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:oe(n[1]),key:n[2]===void 0?null:be(n[2],f(e),t),location:f(e)};let i=Jp.exec(e.content);if(i===null){t.error(c.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,f(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),D(o.content)==="parent"?r=be(o.content.substring(6),f(o),t):t.error(c.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:oe(i[1]),key:i[2]===void 0?null:be(i[2],f(e),t),parentKey:r,location:f(e)}}l(pu,"parseRemove");function uu(t,e){let n=Xp.exec(e.content);return n===null?(t.error(c.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:oe(n[1]),location:f(e)}}l(uu,"parseClearWith");function fu(t,e){let n=eu.exec(e.content);if(n===null)return t.error(c.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:f(e)};let i=oe(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(mu(t,s));else if(a==="variant")t.error(c.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let d=zr(t,s,!1);d!==void 0&&o.push(d)}}return r.length===0&&t.error(c.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}l(fu,"parseVariant");function mu(t,e){let n=tu.exec(e.content);return n===null?(t.error(c.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:f(e)}):{kind:"ProjectionEntersOnSyntax",event:oe(n[1]),key:n[2]===void 0?null:be(n[2],f(e),t),location:f(e)}}l(mu,"parseEntersOn");function as(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:be(n,f(e),t),location:f(e)};let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),o.content==="}")continue;let s=rs.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=be(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(c.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:oe(s[1]),expression:a,location:f(o)})}let r=t.reader.peekSignificant();return r!==void 0&&r.indent===e.indent&&r.content==="}"&&t.reader.takeSignificant(),t.sourceOptions.numericMode==="exact"&&i.length===0&&t.error(c.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}l(as,"parseKey");function Wr(t,e,n=()=>!1){let i="Inherit",r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),o.content==="automap"?i="Enabled":o.content==="no automap"?i="Disabled":n(o)||ss(t,o,r);return{autoMap:i,mappings:r}}l(Wr,"parseMappingBlock");function ss(t,e,n){let i=f(e),r=nu.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:ou[r[1]],property:oe(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(c.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=iu.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:oe(o[2]),value:be(o[3],i,t),location:i});return}let s=ru.exec(e.content)??rs.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:oe(s[1]),source:be(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}l(ss,"pushMapping");var yu=O("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),hu=O("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Su=O("^scoped\\s+to\\s+([a-z_]\\w*)$"),gu=new Set(["performer"]);function cs(t,e){let n=yu.exec(e.content);if(n===null)return t.error(c.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:je("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=je(n[3],{...f(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||We(t,r,e);let o=null,s=[],a=null,d=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=D(m.content);if(u==="description")a=G(t,m,a,`Query '${i}'`);else if(u==="by"){let y=ls(t,m,"by");y!==void 0&&(o!==null&&t.error(c.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(u==="filter"){let y=ls(t,m,"filter");y!==void 0&&s.push(y)}else u==="authorize"?p=Je(p,yt(t,m)):u==="scoped"?d=xu(t,m,d,i)??d:gu.has(u)?t.skipOpaqueBlock(m.indent):(t.error(c.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,f(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:d,authorize:p,location:f(e)}}l(cs,"parseQuery");function ls(t,e,n){let i=hu.exec(e.content.substring(n.length).trim());if(i===null){t.error(c.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,f(e));return}let r=e.content.indexOf(i[1],n.length),o=je(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return We(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ae(i[3],f(e),t.valueContext),location:f(e)}}l(ls,"parseParameter");function xu(t,e,n,i){let r=Su.exec(e.content);if(r===null){t.error(c.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(c.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}l(xu,"parseScope");var vu=O("^@?[a-z_]\\w*\\s+[\\w.]+");function Qr(t,e){let n=Le(t,e);if(n!==void 0){n.isGenerated&&t.error(c.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(c.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}vu.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(c.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}l(Qr,"parseTriggerData");function ds(t,e){let n=t.triggerData.length;for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),D(i.content)==="description"?G(t,i,null,`Trigger '${e.content}'`):ye(i)||Qr(t,i);return t.triggerData.slice(n)}l(ds,"parseTriggerDeclaration");var $u=O("^reaction\\s+([A-Za-z_]\\w*)$"),bu=O("^when\\s+([A-Za-z_]\\w*)$"),ku=O("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Cu=O("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Eu=new Set(["when","every","at"]),Pu=O("^invokes\\s+([A-Z]\\w*)$"),Au=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Gr=Z("^on\\s+refused\\b(?=$|\\s+by\\b)"),wu=Z("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),Ou=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function ps(t,e){let n=$u.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=null,s=[],a=new Set,d=!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=G(t,p,i,`Reaction '${n}'`);continue}if(m==="documentation"){r=Pe(t,p,r,`Reaction '${n}'`);continue}if(m==="where"){o=ze(t,p.content.substring(5).trim(),f(p));continue}if(Gr.test(p.content)){t.error(c.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent),d=!0;continue}if(!Eu.has(m)){t.error(c.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,f(p)),t.skipBlock(p.indent),d=!0;continue}let u=Du(t,p);if(u===void 0){d=!0;continue}let y=Ru(u);if(a.has(y)){t.error(c.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,f(p)),t.skipBlock(p.indent);continue}a.add(y),s.push(Iu(t,p,u))}return s.length===0&&!d&&t.error(c.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:f(e)}}l(ps,"parseReaction");function Iu(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=G(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let u=bn(t,p);u!==void 0&&r.push(u)}else if(m==="invokes"){let u=Pu.exec(p.content);if(u===null)t.error(c.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,f(p)),t.skipBlock(p.indent);else{let y=new he(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,qe(y,p),t.inputUses.push(...y.inputUses);let h=[],x=[];for(let g=t.peekChild(p.indent);g!==void 0;g=t.peekChild(p.indent)){if(t.reader.takeSignificant(),Gr.test(g.content)){let E=Tu(t,g);E!==void 0&&x.push(E);continue}let S=Au.exec(g.content);S!==null?h.push({kind:"PropertyMappingSyntax",property:S[1].replaceAll("@",""),source:Me(S[2],f(g),t.valueContext),location:f(g)}):t.error(c.InvalidPropertyMapping,`Invalid property mapping '${g.content}' - expected '<property> = <source>'`,f(g))}o.push({kind:"InvokesSyntax",command:u[1],mappings:h,onRefused:x,location:f(p)})}}else if(Gr.test(p.content))t.error(c.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let u=fi(p);u!==void 0&&s.push(u),Ou.test(p.content)&&t.error(c.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let u=t.triggerData.length;Qr(t,p);for(let y of t.triggerData.slice(u))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let d={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return it.set(d,{reads:s,data:a}),d}l(Iu,"parseTrigger");function Tu(t,e){let n=wu.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(c.InvalidRefusalBranch,"Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.",f(e)),t.skipBlock(e.indent);return}let i=[],r=!1,o=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(c.InvalidRefusalBranchBody,"A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.",f(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(c.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=bn(t,s);a!==void 0?i.push(a):o=!0}else t.error(c.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",f(s)),t.skipBlock(s.indent),o=!0;return!r&&i.length===0&&!o&&t.error(c.InvalidRefusalBranchBody,"A refusal branch must acknowledge or produce an event.",f(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:f(e)}}l(Tu,"parseRefusal");function Ru(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}l(Ru,"sourceKey");function Du(t,e){let n=f(e);switch(D(e.content)){case"when":{let i=bu.exec(e.content);if(i===null){t.error(c.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=ku.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(c.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:Lu(i[2]),location:n}}default:return Mu(t,e)}}l(Du,"parseTriggerSource");function Mu(t,e){let n=f(e),i=Cu.exec(e.content),r=i===null?void 0:ju(i[1]);if(i===null||r===void 0){t.error(c.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(c.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${e.content}' - a day of the month is between 1 and 31`,n),t.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:null,dayOfMonth:o,location:n}}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:i[2]??null,dayOfMonth:null,location:n}}l(Mu,"parseSchedule");function ju(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}l(ju,"timeOf");function Lu(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}l(Lu,"unitOf");var Nu=O("^(data|query|component)\\s+(\\S+)(.*)$"),qu=O("^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$"),Bu=O("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),Yu=O('^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$'),Fu=O("^mode\\s+(oneWay|twoWay)\\b(.*)$"),Uu=O("^null\\s+(propagate|clear|preserve)\\b(.*)$"),Wu=O("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function Gt(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"||r==="literal"?us(t,`from ${i}`,n):us(t,i,n)}l(Gt,"parseFromClause");function us(t,e,n){let i=e.trim();if(!i.startsWith("from "))return _r(t,at("DataContext",i,n),"",n);let r=i.substring(5).trim();if(r.startsWith("literal ")){let a=qu.exec(r);return a===null?(t.error(c.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from literal <value>'`,n),{...at("Invalid",r,n),rawText:i}):_r(t,{...at("Literal","",n),literal:ae(a[1],n,t)},a[2]??"",n)}let o=Nu.exec(r);if(o===null)return t.error(c.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,n),{...at("Invalid",r,n),rawText:i};let s=Vu(t,o[1],o[2],i,n);return _r(t,s,o[3],n)}l(us,"parseUiBinding");function Vu(t,e,n,i,r){return e==="data"?at("DataContext",n,r):e==="query"?zu(t,n,i,r):Qu(t,n,i,r)}l(Vu,"parseBindingSource");function zu(t,e,n,i){let r=Bu.exec(e);return r===null?(t.error(c.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...at("Invalid",e,i),rawText:n}):{...at("QueryResult",r[2]??"",i),query:r[1]}}l(zu,"queryBinding");function Qu(t,e,n,i){let r=Yu.exec(e);if(r===null)return t.error(c.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...at("Invalid",e,i),rawText:n};let o=r[1]??r[2],s=r[3];return{...at("ComponentProperty",s,i),componentId:o,componentPropertyPath:s}}l(Qu,"componentBinding");function _r(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=Fu.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=Uu.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let d=Wu.exec(o);if(d!==null){r={...r,expectedValueType:d[1]},o=d[2].trim();continue}return t.error(c.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}l(_r,"withModifiers");function at(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}l(at,"create");var Pt=`(?:"(${z})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,Gu=O("^screen\\s+([A-Za-z_]\\w*)$"),_u=O("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Zu=O("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),fs=O(`^label\\s+${Pt}$`),Ku=O(`^action\\s+${Pt}$`),Ju=O("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Hu=O(`^route\\s+${Pt}$`),Xu=O("^outlet\\s+([A-Za-z_]\\w*)$"),ef=O("^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$"),ms=O("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),tf=O("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),nf=O(`^id\\s+(?:"(${z})"|(\\S+))$`),rf=O("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),of=O("^property\\s+([\\w.]+)\\s*=\\s+(.+)$"),af=O("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),sf=O(`^presentation\\s+([A-Za-z_]\\w*)\\s+${Pt}$`),lf=O("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),cf=O("^[a-z_]\\w*$"),df=O(`^title\\s+${Pt}$`),pf=O(`^column\\s+([\\w.]+)(?:\\s+label\\s+${Pt})?$`),uf=O("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),ff=O(`^field\\s+([\\w.]+)\\s+label\\s+${Pt}$`),st=l((t,e)=>t[e]!==void 0?Q(t[e]):t[e+1],"operandText"),mf=l(t=>["on","uses"].includes(D(t.content)),"isInteraction"),yf=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function ys(t,e){let n=Gu.exec(e.content);n===null&&t.error(c.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[],r=[],o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="contribute"){let a=hf(t,s);a!==void 0&&r.push(a)}else D(s.content)==="description"?o=G(t,s,o,`Screen '${n?.[1]??""}'`):ye(s)||hs(t,s,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,description:o,...r.length>0?{contributions:r}:{},location:f(e)}}l(ys,"parseScreen");function hf(t,e){let n=ef.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid screen contribution '${e.content}' - expected 'contribute to <Point> [order <n>]'`,f(e)),t.skipBlock(e.indent);return}return{kind:"ScreenContributionSyntax",contributionPoint:n[1],order:n[2]===void 0?null:Number(n[2]),directives:Si(t,e),location:f(e)}}l(hf,"parseScreenContribution");function hs(t,e,n){let i=Sf(t,e);i!==void 0&&n.push(i)}l(hs,"pushDirective");function Si(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),hs(t,i,n);return n}l(Si,"parseDirectives");function Sf(t,e){switch(D(e.content)){case"data":return gf(t,e);case"action":return xf(t,e);case"template":return vf(t,e);case"section":return $f(t,e);case"title":return bf(t,e);case"table":return kf(t,e);case"summary":return Cf(t,e);case"component":return Ef(t,e);case"toolbar":return If(t,e);case"navigate":return hi(t,e.content,e);case"on":return qe(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(yf(t,e))return Df(t,e);t.error(c.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}l(Sf,"parseDirective");function gf(t,e){let n=_u.exec(e.content);if(n===null){t.error(c.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:je(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}l(gf,"parseData");function xf(t,e){let n=Ku.exec(e.content);if(n!==null)return ya(t,e,st(n,1),hi);let i=Zu.exec(e.content);if(i===null){t.error(c.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,f(e)),t.skipBlock(e.indent);return}let r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=fs.exec(s.content);a!==null?r=st(a,1):D(s.content)==="navigate"?o=hi(t,s.content,s)??null:t.error(c.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,f(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:f(e)}}l(xf,"parseAction");function hi(t,e,n){let i=Ju.exec(e);if(i===null){t.error(c.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}let r=[],o=null,s=null;for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let d=ms.exec(a.content);if(d!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:d[1],binding:Gt(t,d[2],f(a)),location:f(a)});continue}let p=Hu.exec(a.content);if(p!==null){o=st(p,1);continue}let m=Xu.exec(a.content);if(m!==null){s=m[1];continue}t.error(c.InvalidNavigation,`Unexpected '${a.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,f(a))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,...s===null?{}:{outlet:s},parameters:r,location:f(n)}}l(hi,"parseNavigate");function vf(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(),!cf.test(r.content)){t.error(c.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:Si(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}l(vf,"parseTemplateReference");function $f(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:Si(t,e),location:f(e)}}l($f,"parseSection");function bf(t,e){let n=df.exec(e.content);return n===null?(t.error(c.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:st(n,1),location:f(e)}}l(bf,"parseTitle");function kf(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=pf.exec(o.content),a=uf.exec(o.content);if(s!==null){let d=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:d?st(s,2):null,location:f(o)})}else a!==null?r=hi(t,a[1],o)??null:D(o.content)==="on"?qe(t,o):mf(o)?t.skipOpaqueBlock(o.indent):t.error(c.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,f(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:f(e)}}l(kf,"parseTable");function Cf(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.exec(r.content);if(o===null){t.error(c.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:st(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}l(Cf,"parseSummary");function Ef(t,e){let n=tf.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"context":i=Pf(t,m);break;case"id":r=wf(t,m);break;case"property":Af(t,m,s);break;case"icon":o=m.content.substring(4).trim();break;case"presentation":Ss(t,m,d);break;case"exposes":Of(t,m,a);break;case"outlet":p.push({kind:"ComponentOutletSyntax",name:m.content.substring(6).trim(),directives:Si(t,m),location:f(m)});break;case"on":qe(t,m);break;case"uses":t.skipOpaqueBlock(m.indent);break;default:t.error(c.UnknownScreenDirective,`Unexpected '${m.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,f(m)),t.skipBlock(m.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],stableId:r,context:i,properties:s,exposes:a,presentation:d,icon:o,outlets:p,location:f(e)}}l(Ef,"parseComponent");function Pf(t,e){return Rf(t,e.content.substring(7).trim(),e)}l(Pf,"parseUiContext");function Af(t,e,n){let i=rf.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Gt(t,i[2],f(e)),value:null,location:f(e)});return}let r=of.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:ae(r[2],f(e),t),location:f(e)});return}t.error(c.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,f(e))}l(Af,"parseComponentProperty");function wf(t,e){let n=nf.exec(e.content);return n===null?(t.error(c.UnknownScreenDirective,`Invalid component id '${e.content}' - expected 'id "stable-id"'`,f(e)),null):st(n,1)}l(wf,"parseStableId");function Of(t,e,n){let i=af.exec(e.content);if(i===null){t.error(c.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,f(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Gt(t,i[2],f(e)),location:f(e)})}l(Of,"parseExposedValue");function Ss(t,e,n){let i=sf.exec(e.content);if(i===null){t.error(c.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,f(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:st(i,2),location:f(e)})}l(Ss,"parsePresentationValue");function If(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=Tf(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:f(e)}}l(If,"parseToolbar");function Tf(t,e){let n=lf.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=fs.exec(d.content);if(p!==null){i=st(p,1);continue}let m=ms.exec(d.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:Gt(t,m[2],f(d)),location:f(d)});continue}if(D(d.content)==="icon"){r=d.content.substring(4).trim();continue}Ss(t,d,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:f(e)}}l(Tf,"parseToolbarItem");function Rf(t,e,n){return Gt(t,e,f(n))}l(Rf,"parseUiBindingValue");function Df(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(c.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(c.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=Bt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}l(Df,"parseCode");var Mf=O("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),jf=new Set(["reducer"]);function gs(t,e){let n=Mf.exec(e.content),i="StateChange",r="";n===null?t.error(c.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Ba.includes(n[1])?i=n[1]:t.error(c.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,f(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=!1,d=null,p=null,m=[],u=[],y=[],h=[],x=[],g=[],S=[],E=[],$=[],P=[],A=[],v=[],k=[],C=[];for(let w=t.peekChild(e.indent);w!==void 0;w=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(w))continue;let T=w.content.split(/[ \t]/,1)[0],I=T==="public"||T==="direction"?T:D(w.content);if(I==="description")d=G(t,w,d,`Slice '${r}'`);else if(I==="documentation")p=Pe(t,w,p,`Slice '${r}'`);else if(I==="purpose")Yt(t,w,A);else if(I==="operation")u.push(ai(t,w).operation);else if(I==="direction"){let j=/^direction\s+(inbound|outbound)$/.exec(w.content);a||i!=="Translate"||j===null?t.error(c.InvalidSliceDeclaration,"Declare direction inbound or direction outbound once, inside a Translate slice only",f(w)):s=j[1]==="inbound"?de.Inbound:de.Outbound,a=!0}else I==="event"||I==="public"?m.push(Va(t,w)):I==="command"?y.push(ns(t,w)):I==="query"?h.push(cs(t,w)):I==="projection"?x.push(Vr(t,w)):I==="capture"?S.push(Br(t,w)):I==="reaction"?g.push(ps(t,w)):I==="constraint"?E.push(is(t,w)):I==="example"?P.push(ot(t,w)):I==="specification"?$.push(Rr(t,w)):I==="readmodel"?v.push(za(t,w)):I==="screen"?k.push(ys(t,w)):jf.has(I)?(C.push(Ja(t,w)),t.skipOpaqueBlock(w.indent)):(t.warning(c.UnknownSliceDirective,`Unknown construct '${I}' in slice '${r}'`,f(w)),t.skipBlock(w.indent))}t.scope=o;let b={kind:"SliceSyntax",type:i,name:r,direction:s,description:d,documentation:p,examples:P,purposes:A,events:m,operations:u,commands:y,queries:h,projections:x,captures:S,reactions:g,constraints:E,specifications:$,readModels:v,screens:k,location:f(e)};return it.set(b,{reducers:C}),b}l(gs,"parseSlice");var Lf=O("^feature\\s+([A-Za-z_]\\w*)$"),Nf=new Set(["on","uses","contribute"]),Zr="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",kn=class{static{l(this,"FeatureBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=[];#l=null;#a=null;#n=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#l=G(e,n,this.#l,`Feature '${this.name}'`),!0;case"documentation":return this.#a=Pe(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return ti(e,n,this.#r,c.UnknownFeatureDirective),!0;case"purpose":return Yt(e,n,this.#o),!0;case"authorize":return this.#n=Je(this.#n,yt(e,n)),!0;case"import":return Ft(e,n,this.#i),!0;case"feature":return this.#e.push(gi(e,n)),!0;case"example":return this.#s.push(ot(e,n)),!0;case"slice":return this.#t.push(gs(e,n)),!0;default:return Nf.has(i)?(qe(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#l,documentation:this.#a,authorize:this.#n,dependsOn:this.#r,purposes:this.#o,features:this.#e,slices:this.#t,examples:this.#s,fileImports:this.#i,isPlacement:n,location:e}}};function gi(t,e){let n=Lf.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new kn(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(c.UnknownFeatureDirective,`Unexpected '${D(o.content)}' in feature body - expected ${Zr}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}l(gi,"parseFeature");var Kr=O("^module\\s+([A-Za-z_]\\w*)$"),qf=new Set(["on","uses","screen","dialog","form","contribute"]),Jr="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",Cn=class{static{l(this,"ModuleBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=null;#l=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#o=G(e,n,this.#o,`Module '${this.name}'`),!0;case"documentation":return this.#l=Pe(e,n,this.#l,`Module '${this.name}'`),!0;case"depends":return ti(e,n,this.#i,c.UnknownModuleDirective),!0;case"purpose":return Yt(e,n,this.#r),!0;case"authorize":return this.#a=Je(this.#a,yt(e,n)),!0;case"import":return Ft(e,n,this.#s),!0;case"example":return this.#t.push(ot(e,n)),!0;case"feature":return this.#e.push(gi(e,n)),!0;default:return qf.has(i)?(qe(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(c.UnknownModuleDirective,`Unexpected '${D(i.content)}' in module body - expected ${Jr}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#o,documentation:this.#l,authorize:this.#a,dependsOn:this.#i,purposes:this.#r,features:this.#e,examples:this.#t,fileImports:this.#s,isPlacement:n,location:e}}};function Hr(t,e){let n=Kr.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new Cn(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}l(Hr,"parseModule");var Ff=new WeakMap,Ge=l(t=>JSON.stringify(t),"authoredOrderKey");function En(t){return Ff.get(t)??new Map}l(En,"authoredOrderOf");var St=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var lt=class extends Error{static{l(this,"InvalidDependencyQuery")}};var Ye=class{static{l(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.exposures?.forEach(n=>{this.visitNode(n),n.properties.forEach(i=>this.visitNode(i))}),e.instanceContributions?.forEach(n=>{this.visitNode(n),n.contributions.forEach(i=>{this.visitNode(i),i.value!==null&&this.visitExpression(i.value),i.items.forEach(r=>{this.visitNode(r),r.values.forEach(o=>{this.visitNode(o),this.visitExpression(o.value)})})})}),e.purposes?.forEach(n=>this.visitPurpose(n)),e.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n))}visitPurpose(e){this.visitNode(e),e.transfers.forEach(n=>this.visitPurposeTransfer(n))}visitPurposeReference(e){this.visitNode(e)}visitPurposeTransfer(e){this.visitNode(e)}visitPolicy(e){this.visitNode(e),e.condition!==null&&this.visitPolicyCondition(e.condition),e.code!==null&&this.visitCodeBlock(e.code),e.file!==null&&this.visitFileReference(e.file)}visitPolicyCondition(e){this.visitNode(e),e.kind==="ClaimConditionSyntax"&&e.matches!==null&&this.visitExpression(e.matches),e.kind==="NotPolicyConditionSyntax"&&this.visitPolicyCondition(e.operand),e.kind==="LogicalPolicyConditionSyntax"&&(this.visitPolicyCondition(e.left),this.visitPolicyCondition(e.right))}visitSeed(e){this.visitNode(e),e.groups.forEach(n=>{this.visitNode(n),n.events.forEach(i=>{this.visitNode(i),i.properties.forEach(r=>this.visitPropertyMapping(r))})})}visitPersona(e){this.visitNode(e)}visitAuthorize(e){this.visitNode(e),this.visitPolicyRequirement(e.requirement)}visitPolicyRequirement(e){this.visitNode(e),e.kind==="LogicalPolicyRequirementSyntax"&&(this.visitPolicyRequirement(e.left),this.visitPolicyRequirement(e.right))}visitDomain(e){this.visitNode(e)}visitImport(e){this.visitNode(e)}visitFileImport(e){this.visitNode(e)}visitConcept(e){this.visitNode(e),e.attributes.forEach(n=>this.visitNode(n)),e.validations?.forEach(n=>this.visitValidate(n))}visitType(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitDependsOn(e){this.visitNode(e)}visitModule(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n))}visitFeature(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n)),e.slices.forEach(n=>this.visitSlice(n))}visitSlice(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.commands.forEach(n=>this.visitCommand(n)),e.operations?.forEach(n=>this.visitOperation(n)),e.events.forEach(n=>this.visitEvent(n)),e.constraints.forEach(n=>this.visitConstraint(n)),e.queries.forEach(n=>this.visitQuery(n)),e.projections.forEach(n=>this.visitProjection(n)),e.readModels.forEach(n=>this.visitReadModel(n)),e.captures.forEach(n=>this.visitCapture(n)),e.reactions.forEach(n=>this.visitReaction(n)),e.screens.forEach(n=>this.visitScreen(n)),e.specifications.forEach(n=>this.visitSpecification(n))}visitTriggerData(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type)}visitReads(e){this.visitNode(e)}visitConcurrency(e){this.visitNode(e)}visitReducer(e){this.visitNode(e),e.rules.forEach(n=>this.visitReducerRule(n))}visitReducerRule(e){this.visitNode(e),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitForm(e){this.visitNode(e),e.populate!==null&&this.visitNode(e.populate),e.fields.forEach(n=>this.visitNode(n)),e.columns?.forEach(n=>this.visitNode(n)),e.layout!==null&&e.layout!==void 0&&(this.visitNode(e.layout),e.layout.columns.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width),n.minWidth!==null&&this.visitNode(n.minWidth),n.maxWidth!==null&&this.visitNode(n.maxWidth)}),e.layout.columnGap!==null&&this.visitNode(e.layout.columnGap),e.layout.rowGap!==null&&this.visitNode(e.layout.rowGap),e.layout.placements.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width)})),e.onSubmit!==null&&this.visitScreenDirective(e.onSubmit)}visitCommand(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.stream!=null&&this.visitCommandStream(e.stream),e.streamCandidates?.forEach(n=>this.visitCommandStream(n)),e.validations.forEach(n=>this.visitValidate(n)),e.produces.forEach(n=>this.visitProduces(n)),e.handler!=null&&this.visitHandler(e.handler),e.response!=null&&this.visitCommandResponse(e.response)}visitEventSource(e){this.visitNode(e),e.identifier!==null&&this.visitTypeRef(e.identifier),e.streams.forEach(n=>this.visitEventStream(n))}visitEventStream(e){this.visitNode(e),e.streamId!==null&&this.visitTypeRef(e.streamId),e.streamIdParts.forEach(n=>this.visitEventStreamIdPart(n))}visitEventStreamIdPart(e){this.visitNode(e),this.visitTypeRef(e.type)}visitCommandStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n)),e.propertyCandidate!==null&&this.visitProperty(e.propertyCandidate)}visitSystem(e){this.visitNode(e)}visitOperation(e){this.visitNode(e),e.inputs.forEach(n=>this.visitProperty(n)),e.execute!==null&&this.visitOperationPhase(e.execute),e.compensate!==null&&this.visitOperationPhase(e.compensate)}visitOperationPhase(e){this.visitNode(e),e.implementation!==null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitSpecificationOperationFailure(e){this.visitNode(e)}visitSpecificationCompensated(e){this.visitNode(e)}visitSpecificationOperation(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitHandler(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitImplementation(e){this.visitNode(e),e.hints.forEach(n=>this.visitImplementationHint(n))}visitImplementationHint(e){this.visitNode(e)}visitFileReference(e){this.visitNode(e)}visitCodeBlock(e){this.visitNode(e)}visitCommandResponse(e){e.kind==="ScalarCommandResponseSyntax"?this.visitScalarCommandResponse(e):this.visitRecordCommandResponse(e)}visitScalarCommandResponse(e){this.visitNode(e),this.visitPropertyResponseSource(e.source)}visitRecordCommandResponse(e){this.visitNode(e),e.fields.forEach(n=>this.visitResponseField(n))}visitResponseField(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type),this.visitPropertyResponseSource(e.source)}visitPropertyResponseSource(e){this.visitNode(e)}visitSpecificationReturn(e){e.kind==="ScalarSpecificationReturnSyntax"?this.visitScalarSpecificationReturn(e):this.visitRecordSpecificationReturn(e)}visitScalarSpecificationReturn(e){this.visitNode(e),this.visitExpression(e.value)}visitRecordSpecificationReturn(e){this.visitNode(e),e.fields.forEach(n=>this.visitPropertyMapping(n))}visitValidate(e){this.visitNode(e),e.kind==="DeclarativeValidateSyntax"?(e.rules.forEach(n=>this.visitValidationRule(n)),e.requirements?.forEach(n=>{this.visitNode(n),this.visitCondition(n.condition)})):e.code!=null&&this.visitCodeBlock(e.code)}visitValidationRule(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.value!==null&&this.visitExpression(e.value),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitEvent(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.tags.forEach(n=>this.visitTag(n))}visitTag(e){this.visitNode(e),this.visitExpression(e.value)}visitReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitConstraint(e){this.visitNode(e),e.kind==="FileConstraintSyntax"&&this.visitNode(e.file),e.additionalRules.forEach(n=>this.visitConstraint(n))}visitQuery(e){this.visitNode(e),this.visitTypeRef(e.returnType),e.by!==null&&this.visitQueryParameter(e.by),e.filters.forEach(n=>this.visitQueryParameter(n)),e.authorize!==null&&this.visitAuthorize(e.authorize)}visitQueryParameter(e){this.visitNode(e),this.visitTypeRef(e.type),e.source!=null&&this.visitExpression(e.source)}visitKey(e){this.visitNode(e),e.kind==="ExpressionKeySyntax"?this.visitExpression(e.expression):e.parts.forEach(n=>{this.visitNode(n),this.visitExpression(n.expression)})}visitProjection(e){this.visitNode(e),e.key!=null&&this.visitKey(e.key),e.blocks.forEach(n=>this.visitProjectionBlock(n))}visitProjectionBlock(e){switch(this.visitNode(e),e.kind){case"FromSyntax":e.events.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.key!=null&&this.visitKey(e.key),e.parentKey!=null&&this.visitExpression(e.parentKey),e.mappings.forEach(n=>this.visitMapping(n));break;case"EverySyntax":case"AllSyntax":e.mappings.forEach(n=>this.visitMapping(n));break;case"JoinSyntax":e.events.forEach(n=>this.visitJoinEvent(n));break;case"ProjectionVariantSyntax":e.entersOn.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"ChildrenSyntax":e.identifiedBy!==void 0&&this.visitExpression(e.identifiedBy),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"NestedSyntax":e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"RemoveWithSyntax":e.parentKey!=null&&this.visitExpression(e.parentKey),e.key!=null&&this.visitExpression(e.key);break;case"RemoveViaJoinSyntax":e.key!=null&&this.visitExpression(e.key);break}}visitJoinEvent(e){this.visitNode(e),e.mappings.forEach(n=>this.visitMapping(n))}visitMapping(e){this.visitNode(e),e.source!==void 0&&this.visitExpression(e.source),e.value!==void 0&&this.visitExpression(e.value)}visitCondition(e){this.visitNode(e),e.kind==="ComparisonConditionSyntax"?this.visitExpression(e.right):(this.visitCondition(e.left),this.visitCondition(e.right))}visitReaction(e){this.visitNode(e),e.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)),e.contributions?.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))})}visitScreenDirective(e){if(e.kind==="ScreenGuardedActionSyntax"){this.visitScreenGuardedAction(e);return}switch(this.visitNode(e),e.kind){case"ScreenDataSyntax":this.visitTypeRef(e.type);break;case"ScreenActionSyntax":e.navigate!==null&&this.visitScreenDirective(e.navigate);break;case"ScreenNavigateSyntax":e.parameters.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)});break;case"ScreenTemplateReferenceSyntax":e.slots.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(n=>this.visitScreenDirective(n));break;case"ScreenTableSyntax":e.columns.forEach(n=>this.visitNode(n)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(n=>this.visitNode(n));break;case"ScreenComponentSyntax":e.context!==null&&this.visitUiBinding(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitUiBinding(n.binding),n.value!==null&&this.visitExpression(n.value)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)}),e.presentation.forEach(n=>this.visitNode(n)),e.outlets.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenToolbarSyntax":e.items.forEach(n=>{this.visitNode(n),n.parameters.forEach(i=>{this.visitNode(i),this.visitUiBinding(i.binding)}),n.presentation.forEach(i=>this.visitNode(i))});break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitScreenGuardedAction(e){this.visitNode(e),e.alternatives.forEach(n=>this.visitScreenActionAlternative(n)),e.otherwise!==null&&this.visitScreenActionOtherwise(e.otherwise),e.navigate!==null&&this.visitScreenDirective(e.navigate)}visitScreenActionAlternative(e){this.visitNode(e),this.visitCondition(e.condition),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitScreenActionOtherwise(e){this.visitNode(e),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitInteractionArgument(e){this.visitNode(e)}visitSpecification(e){this.visitNode(e),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.parameters?.forEach(n=>{this.visitNode(n),this.visitTypeRef(n.type)}),e.cases?.forEach(n=>{this.visitNode(n),n.values.forEach(i=>this.visitPropertyMapping(i))}),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(n=>this.visitSpecificationOperationFailure(n)),e.thenOperations?.forEach(n=>this.visitSpecificationOperation(n)),e.thenCompensated?.forEach(n=>this.visitSpecificationCompensated(n)),e.givenCallerPersona!=null&&this.visitNode(e.givenCallerPersona),e.givenCaller!=null&&(this.visitNode(e.givenCaller),e.givenCaller.claims.forEach(n=>this.visitNode(n))),e.given.forEach(n=>this.visitSpecificationEvent(n)),e.givenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(n=>this.visitSpecificationCapture(n)),e.whenAppended!==null&&this.visitSpecificationEvent(e.whenAppended),e.whenRedelivered!=null&&this.visitSpecificationRedelivery(e.whenRedelivered),e.whenClock!==null&&this.visitSpecificationClock(e.whenClock),e.whenTrigger!==null&&this.visitSpecificationTrigger(e.whenTrigger),e.whenCapture!==null&&this.visitSpecificationCapture(e.whenCapture),e.whenQuery!==null&&this.visitSpecificationWhenQuery(e.whenQuery),e.thenEvents.forEach(n=>this.visitSpecificationEvent(n)),e.thenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.thenAbsentReadModels?.forEach(n=>{this.visitNode(n),this.visitExpression(n.key)}),e.thenQueries?.forEach(n=>{this.visitNode(n),n.arguments.forEach(i=>this.visitPropertyMapping(i)),n.results.forEach(i=>this.visitSpecificationQueryResult(i))}),e.thenResults.forEach(n=>this.visitSpecificationQueryResult(n)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(n=>{this.visitNode(n),n.caseValue!=null&&this.visitExpression(n.caseValue)})}visitSpecificationRedelivery(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationExample(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.generatedValues.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationNoStream(e){this.visitNode(e)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(n=>this.visitPropertyMapping(n)),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitPropertyMapping(e){this.visitNode(e),this.visitExpression(e.source)}visitProperty(e){this.visitNode(e),this.visitTypeRef(e.type)}visitTypeRef(e){this.visitNode(e)}visitUiBinding(e){this.visitNode(e),e.literal!==null&&this.visitExpression(e.literal)}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 Uf={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 vi(t){let e=new xi;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}l(vi,"sliceReferences");function $s(t,e){let n=new xi(e);return t.projections.forEach(i=>n.visitProjection(i)),ve(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}l($s,"buildingReadModelReferences");function to(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...to(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?to(e.blocks):[])}l(to,"variants");var xi=class extends Ye{static{l(this,"SliceReferenceCollector")}readModel;references=[];shared=[];specification;projection=!1;constructor(e){super(),this.readModel=e}matches(e){return e.toLowerCase()===this.readModel?.toLowerCase()}visitSlice(e){super.visitSlice(e),ve(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=ve(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=ve(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=to(e.blocks);if(n.length===0?!this.matches(e.readModel??e.name):!n.some(i=>this.matches(i.name)))return}this.projection=!0,super.visitProjection(e),this.projection=!1}visitSpecification(e){this.specification=e,super.visitSpecification(e),this.specification=void 0}visitNode(e){let n=l((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:Uf[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 Pn(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=l(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let d=[],p;do p=i.pop(),r.delete(p),d.push(p);while(p!==a);o.push(d.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}l(Pn,"stronglyConnectedGroups");var bs=["usesFactsFrom","reactsTo","decidesFrom"],Xe=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),no=l((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),io=l((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),oo=l((t,e)=>t.rank-e.rank||Xe(t.key,e.key),"compareNodes"),An=l(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(oo),"distinctNodes"),ks=l((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||St.indexOf(t.kind)-St.indexOf(e.kind)||t.producer.rank-e.producer.rank||Xe(t.location.path??"",e.location.path??"")||Xe(t.role,e.role)||Xe(t.name,e.name),"compareEvidence");function ao(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...ao(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?ao(e.blocks):[])}l(ao,"variants");var _t=class t{static{l(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=io("application","",[],-1);static for(e,n=En(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=Ve(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=l(($,P)=>$.map((A,v)=>({syntax:A,index:v,rank:n.get(Ge([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,v)=>A.rank-v.rank||A.index-v.index).map(A=>A.syntax),"ordered"),r=l(($,P)=>{let A=this.add("feature",$.name,P);for(let v of i($.slices,A))this.slices.push({node:this.add("slice",v.name,A),syntax:v});for(let v of i($.features,A))r(v,A)},"feature");for(let $ of i(e.modules,this.root)){let P=this.add("module",$.name,this.root);for(let A of i($.features,P))r(A,P)}let o=new Map,s=new Map,a=l(($,P,A,v)=>{let k=no(P,A);$.has(k)||$.set(k,[]);let C=$.get(k);C.includes(v)||C.push(v);let b=no(P,[...v.scope,A].join("."));$.has(b)||$.set(b,[]);let w=$.get(b);w.includes(v)||w.push(v)},"declare");for(let{node:$,syntax:P}of this.slices){for(let A of le(P))a(o,"Event",A.name,$);for(let A of P.commands)a(o,"Command",A.name,$);for(let A of P.reactions)a(o,"Reaction",A.name,$);for(let A of P.queries)a(o,"Query",A.name,$);for(let A of P.screens)a(o,"Screen",A.name,$);for(let A of P.readModels)a(o,"ReadModel",A.name,$);for(let A of P.projections){let v=ao(A.blocks);v.length===0&&a(s,"ReadModel",A.readModel??A.name,$);for(let k of v)a(s,"ReadModel",k.name,$)}for(let A of ve(P).reducers??[])a(s,"ReadModel",A.readModel,$)}let d=new Set((e.declaredTriggers??[]).map($=>$.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map($=>$.name.toLowerCase())),m=new Set((e.policies??[]).map($=>$.name.toLowerCase())),u=e.imports.filter($=>$.qualifiedName.includes(".")).slice().sort(($,P)=>Xe($.location.path??"",P.location.path??"")||$.location.line-P.location.line||$.location.column-P.location.column||Xe($.qualifiedName,P.qualifiedName)),y=new Map,h=[],x=[],g=new Set,S=0;for(let{node:$,syntax:P}of this.slices){let A=vi(P);S+=A.shared.filter(v=>(v.kind==="type"?p:m).has(v.name.toLowerCase())).length;for(let v of A.references){let k=no(v.targetKind,v.name),b=(v.targetKind==="ReadModel"&&s.has(k)?s:o).get(k);if(b!==void 0&&b.length>0){let T=b[0];T!==$&&h.push({consumer:$,producer:T,kind:v.kind,role:v.role,name:v.name,ambiguous:b.length>1,alternatives:b.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}let w=v.targetKind==="Event"?u.filter(T=>T.qualifiedName.slice(T.qualifiedName.lastIndexOf(".")+1).toLowerCase()===v.name.toLowerCase()):[];if(w.length>0){let T=[];for(let I of w){g.add(I.qualifiedName);let j=I.qualifiedName.slice(0,I.qualifiedName.lastIndexOf(".")),N=`context:${j}`;if(!y.has(N)){let q=io("context",N,[j],this.modelNodes.length);this.modelNodes.push(q),y.set(N,q)}let L=y.get(N);T.includes(L)||T.push(L)}h.push({consumer:$,producer:T[0],kind:"outsideTheModel",role:v.role,name:v.name,ambiguous:T.length>1,alternatives:T.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}if(v.role==="trigger"&&d.has(v.name.toLowerCase())){S++;continue}x.push({consumer:$,kind:v.kind,role:v.role,name:v.name,location:v.location})}}let E=new Map;for(let $ of h.sort(ks)){let P=JSON.stringify([$.consumer.key,$.producer.key,$.kind]);E.has(P)||E.set(P,[]),E.get(P).push($)}this.edges=[...E.values()].map($=>({consumer:$[0].consumer,producer:$[0].producer,kind:$[0].kind,evidence:$})),this.unresolved=x.sort(($,P)=>$.consumer.rank-P.consumer.rank||$.location.line-P.location.line||$.location.column-P.location.column||St.indexOf($.kind)-St.indexOf(P.kind)||Xe($.location.path??"",P.location.path??"")||Xe($.name,P.name)),this.excludedReferences=S,this.unusedImports=[...new Set(u.filter($=>!g.has($.qualifiedName)).map($=>$.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new lt(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new lt(`Unsupported target level '${n}'.`);if(o<0)throw new lt("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let d of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(d,m))){let m=JSON.stringify([d.key,p.key]);s.has(m)||s.set(m,{source:d,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,d)=>a.source.rank-d.source.rank||a.target.rank-d.target.rank||Xe(a.source.key,d.source.key)||Xe(a.target.key,d.target.key)).map(a=>{let d=a.evidence.sort(ks),p={};for(let m of St){let u=d.filter(y=>y.kind===m).length;u>0&&(p[m]=u)}return{source:a.source,target:a.target,sliceEdges:new Set(d.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:d.length,byKind:p,consumers:An(d.map(m=>m.consumer)),producers:An(d.map(m=>m.producer)),evidence:d.slice(0,o),evidenceCount:d.length,evidenceTruncated:d.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new lt(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Cs(n)),r=An(i.flatMap(o=>[o.source,o.target]));return Es(ro(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Es(ro(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let d=this.children.get(a.key),p=n.filter(S=>S.container===a),m=new Map(d.map(S=>[S.key,S])),u=Pn(ro(d,p)).map(S=>S.map(E=>m.get(E)).sort(oo)).sort((S,E)=>S[0].rank-E[0].rank),y=new Map(u.flatMap((S,E)=>S.map($=>[$.key,E]))),h=new Map(d.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 u)for(let E=1;E<S.length;E++)h.get(S[E].key).add(S[E-1].key);let x=new Set(d.map(S=>S.key)),g=[];for(;x.size>0;){let S=[...x].filter(E=>h.get(E).size===0).sort((E,$)=>oo(m.get(E),m.get($)))[0];g.push(m.get(S)),x.delete(S);for(let E of x)h.get(E).delete(S)}i.push({container:a,children:g,changed:d.some((S,E)=>S!==g[E])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=l(a=>{if(a.kind==="slice")o.push(a);else for(let d of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(d)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new lt(`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],d=[];for(let p=0;p<a.length;p++)for(let m of o.filter(u=>u.source.address===a[p]).sort((u,y)=>u.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),d.push(m.target),a.push(m.target.address));return An(d)}add(e,n,i){let r=[...i.scope,n],o=r.join("."),s=`${e}:${o}`,a=this.byKey.get(s);if(a!==void 0)return a;let d=io(e,o,r,this.modelNodes.length);return this.modelNodes.push(d),this.byKey.set(s,d),this.parents.set(s,i),this.children.get(i.key).push(d),e!=="slice"&&this.children.set(s,[]),d}ancestors(e){let n=[];for(let i=this.parents.get(e.key);i!==void 0;i=this.parents.get(i.key))n.push(i);return n}disjoint(e,n){return e.key!==n.key&&!this.ancestors(e).includes(n)&&!this.ancestors(n).includes(e)}at(e,n){return[e,...this.ancestors(e)].filter(i=>i.kind===n)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind==="module"||e.kind==="feature")]}evidence(e,n){let i=Ps(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(Cs(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 Ps(t){let e=new Set(t??St);if([...e].some(n=>!St.includes(n)))throw new lt("Unsupported dependency kind.");return e}l(Ps,"selectedKinds");function Cs(t){return[...Ps(t??bs)].filter(e=>bs.includes(e))}l(Cs,"selectedOrderingKinds");function ro(t,e){let n=new Map(t.map(i=>[i.key,new Set]));for(let i of e)n.get(i.source.key).add(i.target.key);return n}l(ro,"adjacency");function Es(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return Pn(t).filter(r=>r.length>1).map(r=>({container:n,members:An(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}l(Es,"groupsOf");var Wf=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],et=l((t,e)=>e===t||e.startsWith(t+"."),"contains"),Zt=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),Vf=l((t,e)=>Zt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||Zt(t.kind,e.kind)||Zt(t.consumer.address,e.consumer.address)||Zt(t.producer.address,e.producer.address)||Zt(t.role,e.role)||Zt(t.name,e.name),"orderedEvidence"),Kt=class{static{l(this,"DeclaredDependencies")}static for(e){let n=new Map,i=l((u,y)=>{let h=u.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(x=>i([...u,x.name],x))},"inventory");if(e.modules.forEach(u=>i([u.name],u)),![...n.values()].some(u=>u.dependencies.length))return{containers:[],diagnostics:[]};let r=_t.for(e,new Map),o=r.nodes.filter(u=>u.kind==="module"||u.kind==="feature"),s=Te.containersOf(e),a=l((u,y)=>{let h=Te.resolve(u,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),d=[],p=[],m=l((u,y,h,x)=>p.push({code:u,severity:y,message:h,location:x}),"finding");for(let u of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(u.address),h=y.dependencies.map(S=>{let E=a(S.target,u.scope),$=E!==void 0&&!et(u.address,E)&&!et(E,u.address);return{syntax:S,resolved:E,status:$?"unused":"invalid"}}),x=[],g=new Map;for(let S of r.edges.flatMap(E=>E.evidence).filter(E=>Wf.includes(E.kind)&&et(u.address,E.consumer.address)).sort(Vf)){let E=[S.producer,...S.alternatives].filter(A=>!et(u.address,A.address)&&!et(A.scope.slice(0,-1).join("."),u.address));if(!E.length)continue;let $=h.filter(A=>A.status!=="invalid"&&E.some(v=>et(A.resolved,v.address)));for(let A of $)A.status=S.ambiguous&&A.status!=="used"?"provisional":"used";let P=S.ambiguous?"provisional":$.length?"declared":"undeclared";if(x.push({evidence:S,status:P,coveringDeclarations:$.map(A=>A.syntax)}),P==="undeclared"){let A=S.producer.scope[0];g.has(A)||g.set(A,[]),g.get(A).push(S)}}for(let S of g.values()){let E=S[0].producer.scope.slice(0,-1),$=E.findIndex((k,C)=>S.some(b=>C>=b.producer.scope.length-1||b.producer.scope[C]!==k));$>=0&&(E=E.slice(0,$));let P=E.join("."),A=et(u.address,P)||et(P,u.address)?[...new Set(S.map(k=>k.producer.scope.slice(0,-1).map((C,b)=>k.producer.scope.slice(0,b+1).join(".")).find(C=>!et(u.address,C)&&!et(C,u.address))))]:[P],v=S.map(k=>`${k.kind} ${k.role} '${k.name}' at ${k.location.path??""}:${k.location.line}:${k.location.column}`).join("; ");m(c.UndeclaredDependency,"warning",`Container '${u.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${v}`,y.location)}for(let S of h)S.status==="unused"&&m(c.UnusedDependencyDeclaration,"information",`Dependency '${S.syntax.target}' on '${u.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("."))===u.address)&&m(c.MutualDependencyDeclarations,"information",`Containers '${u.address}' and '${S.resolved}' declare each other`,S.syntax.location);d.push({container:u,location:y.location,declarations:h,edges:x})}return{containers:d,diagnostics:p}}static validate(e,n){for(let i of this.for(e).diagnostics)n[i.severity==="warning"?"warning":"information"](i.code,i.message,i.location)}};var $i=class extends Ye{static{l(this,"PublicEventUsageCollector")}command=!1;uses=[];allEvents=[];projectionTargets=[];eventSources=[];visitProjection(e){e.readModel!=null&&this.projectionTargets.push({target:e.readModel,node:e}),super.visitProjection(e)}visitReducer(e){this.projectionTargets.push({target:e.readModel,node:e}),super.visitReducer(e)}visitCaptureSource(e){gn(e)&&(this.eventSources.push(e),Ya(e).forEach(n=>this.uses.push({name:n.value,node:n,output:!1,command:!1}))),super.visitCaptureSource(e)}visitSlice(e){super.visitSlice(e),ve(e).reducers?.forEach(n=>this.visitReducer(n))}visitCommand(e){this.command=!0,super.visitCommand(e),this.command=!1}visitProduces(e){e.inlineOperation==null&&this.uses.push({name:e.event,node:e,output:!0,command:this.command})}visitCaptureAppend(e){this.inputOrOutput(e.event,e,!0)}visitJoinEvent(e){this.inputOrOutput(e.event,e)}visitReducerRule(e){this.inputOrOutput(e.event,e)}visitConstraint(e){e.releasedBy.forEach(n=>this.inputOrOutput(n,e)),e.kind!=="FileConstraintSyntax"&&this.inputOrOutput(e.event,e),super.visitConstraint(e)}visitProjectionBlock(e){switch(e.kind){case"FromSyntax":e.events.forEach(n=>this.inputOrOutput(n.event,n));break;case"ClearWithSyntax":case"RemoveWithSyntax":case"RemoveViaJoinSyntax":this.inputOrOutput(e.event,e);break;case"AllSyntax":this.allEvents.push(e);break}super.visitProjectionBlock(e)}visitReactionTrigger(e){e.source.kind==="NamedTriggerSourceSyntax"&&this.inputOrOutput(e.source.name,e.source),super.visitReactionTrigger(e)}visitSpecification(e){}inputOrOutput(e,n,i=!1){this.uses.push({name:e,node:n,output:i,command:!1})}};var so=class extends Ye{static{l(this,"PublicEventMetadataValidator")}context;constructor(e){super(),this.context=e}visitNode(e){let n=ci(e);if(n===void 0)return;let i=e.kind==="EventSyntax"?c.InvalidEventDeclaration:e.kind==="ImportSyntax"?c.InvalidImportDeclaration:c.InvalidSliceDeclaration;this.context.error(i,n,e.location)}};function As(t,e){new so(e).visitApplication(t)}l(As,"validatePublicEventMetadata");function bi(t,e){As(t,e);let n=new re(t);if(!n.declarations.some(r=>r.node.kind==="EventSyntax"&&(r.node.visibility===se.Public||r.node.origin!=null))&&!t.imports.some(r=>r.visibility===se.Public||r.origin!=null)&&!n.slices.some(({slice:r})=>r.direction!=null||Qf(r)||Gf(r,n)))return;let i=new re(t,n.declarations.filter(r=>r.kind===H.Event));for(let{slice:r,scope:o}of n.slices)zf(t,r,o,n,i,e);for(let r of t.seeds?.flatMap(o=>o.groups.flatMap(s=>s.events))??[]){let o=co(t,i,[],r.event,r,!0,e);if(o?.visibility!==se.Public)continue;let s=o.origin==null?c.PublicEventRequiresOutboundTranslation:c.ForeignPublicEventProduced;e.error(s,`Seed cannot append public event '${r.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,r.location)}}l(bi,"validatePublicEventUsage");function zf(t,e,n,i,r,o){let s=new $i;s.visitSlice(e);let a=[],d=e.type==="Translate"&&e.direction===de.Outbound,p=new Set(e.readModels.map(u=>u.name));for(let{target:u,node:y}of s.projectionTargets){let h=p.has(u)?void 0:co(t,r,n,u,y,!1,o);if(h!==void 0){if(!d){o.error(c.EventTargetOutsideOutboundTranslation,`'${u}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,y.location);continue}a.push({node:h,output:!0}),lo(e,u,y,!0,!1,h,o)}}if(!(e.type==="Translate"&&e.direction===de.Inbound)&&!d)for(let u of s.eventSources)o.error(c.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${e.name}'.`,u.location);for(let u of s.uses){let y=co(t,u.node.kind==="ProducesSyntax"?i:r,n,u.name,u.node,u.output,o);y!==void 0&&(a.push({node:y,output:u.output}),lo(e,u.name,u.node,u.output,u.command,y,o))}for(let u of s.allEvents){let y=i.declarations.filter(h=>h.kind===H.Event).map(h=>h.node);for(let h of[...y,...t.imports.filter(x=>x.visibility===se.Public)])a.push({node:h,output:!1}),lo(e,h.kind==="ImportSyntax"?h.qualifiedName:h.name,u,!1,!1,h,o)}if(e.type!=="Translate"||(e.direction==null&&(le(e).some(u=>u.visibility===se.Public)||a.some(u=>u.node.visibility===se.Public))&&o.error(c.PublicTranslationRequiresDirection,"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.",e.location),e.direction!==de.Outbound))return;let m=new Set(a.filter(u=>u.output&&u.node.visibility===se.Public&&u.node.origin==null).map(u=>u.node)).size;m!==1&&o.error(c.OutboundPublicEventCount,`Outbound Translate slice '${e.name}' must produce exactly one local public event type; found ${m}.`,e.location);for(let u of e.captures)o.error(c.TranslationConstructDirection,"An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.",u.location)}l(zf,"validateSlice");function lo(t,e,n,i,r,o,s){let a=o.origin!=null,d=o.visibility===se.Public,p=l((m,u)=>s.error(m,u,n.location),"error");i?(r&&d&&p(c.CommandProducesPublicEvent,`Command cannot produce public event '${e}'; publish through an outbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&!d&&p(c.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${e}'.`),a&&p(c.ForeignPublicEventProduced,`Foreign public event '${e}' cannot be produced locally; translate it into a private local event.`),d&&!a&&(t.type!=="Translate"||t.direction!==de.Outbound)&&p(c.PublicEventRequiresOutboundTranslation,`Local public event '${e}' may only be produced by an explicitly outbound Translate slice.`),t.type==="Translate"&&(t.direction??de.Inbound)===de.Inbound&&(d||a)&&p(c.InboundTranslationOutput,`Inbound translation must produce private local events, not '${e}'.`)):(a&&(t.type!=="Translate"||t.direction!==de.Inbound)&&p(c.ForeignPublicEventConsumer,`Foreign public event '${e}' may only be consumed by an explicitly inbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&(d||a)&&p(c.OutboundTranslationInput,`Outbound translation must consume private local events, not '${e}'.`),t.type==="Translate"&&t.direction===de.Inbound&&(!d||!a)&&p(c.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${e}'.`))}l(lo,"validateUse");function co(t,e,n,i,r,o,s){let a=e.resolveFromScope(i,n);if(a.declaration?.node.kind==="EventSyntax")return a.declaration.node;if(a.kind===H.Operation)return;if(a.kind===H.Ambiguous){s.warning(c.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,r.location);return}let d=t.imports.filter(p=>p.qualifiedName.split(".").at(-1)===i||p.qualifiedName===i);if(d.length===1){let p=d[0],m=e.resolveFromScope(p.qualifiedName,n);if(m.declaration?.node.kind==="EventSyntax")return m.declaration.node;if(m.kind===H.Ambiguous){s.warning(c.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,r.location);return}return p.visibility===se.Public?p:void 0}d.length>1?s.warning(c.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,r.location):(o&&r.kind!=="CaptureAppendSyntax"||r.kind==="CaptureSourceSettingSyntax")&&!s.diagnostics.some(p=>p.code===c.UnknownEvent&&p.location.path===r.location.path&&p.location.line===r.location.line&&p.location.column===r.location.column)&&s.warning(c.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,r.location)}l(co,"resolve");function Qf(t){return t.captures.some(e=>e.source!=null&&gn(e.source))}l(Qf,"usesEventSource");function Gf(t,e){return[...t.projections.map(i=>i.readModel),...(ve(t).reducers??[]).map(i=>i.readModel)].some(i=>i!=null&&e.declarations.some(r=>r.kind===H.Event&&r.name===i))}l(Gf,"targetsEvent");function ki(t,e,n,i=!1){let r=[],o=[],s=Ne,a=!1,d=!1,p=!1,m=new Map,u=new he(new Qe([]),e,n).languages;for(let h of t){let x=h;if(x.number===1&&x.raw.startsWith("\uFEFF")){let g=x.raw.substring(1),S=g.length-g.trimStart().length,E=an(g.substring(S),i);x={...x,indent:S,contentOffset:1,content:(E<0?g.substring(S):g.substring(S,S+E)).trimEnd()}}if(p){Ar(x)&&(p=!1),r.push(x);continue}if(x.content.startsWith("```")&&(["```","```text","```markdown"].includes(x.content)||u.has(x.content.substring(3)))&&(p=!0),!p&&x.indent===0&&D(x.content)==="numbers"){let g=x.content!=="numbers exact"?c.InvalidNumericDirective:a?c.DuplicateNumericDirective:d?c.LateNumericDirective:void 0;g!==void 0?(o.push({severity:"error",code:g,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f(x)}),s=Object.freeze({numericMode:"invalid"})):s=ni,a=!0,r.push({...x,content:""});continue}!p&&x.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(x.content)&&m.set(x.number,{severity:"error",code:c.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f(x)}),d||=x.content.trim().length>0,r.push(x)}let y=new he(new Qe(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}l(ki,"sourceContext");function Ci(t,e){let n=[],i=l(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(le))r.set(a.name,(r.get(a.name)??0)+1);let o=new Set(t.imports.map(a=>a.qualifiedName.split(".").at(-1))),s=new re(t);for(let{slice:a,command:d}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=d.produces.filter(y=>s.isEventProduction(y,a)),m=d.properties.find(y=>y.isIdentifier)?.name,u=pr(d,{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(c.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),u&&y.for===null&&e.error(c.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${d.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let x=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||x!==m))for(let g 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 '${g.property}' although it already identifies the event source`;h===null?e.information(c.EventSourceIdInPayload,S,g.location):e.warning(c.EventSourceIdInPayload,S,g.location)}}}}l(Ci,"validateInlineEvents");function Ei(t,e){let n=new re(t),i=Vn(t),r=ne(t.concepts),o=new Map([...ne(t.types)].map(([$,P])=>[$,ne(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map($=>$.qualifiedName.split(".").at(-1))),d=new Map;for(let $ of t.imports){let P=$.qualifiedName.split(".").at(-1);d.set(P,[...d.get(P)??[],$.qualifiedName])}let p=l($=>{let P=new Map,A=new Map;for(let v of $){let k=P.get(v.name)??[];k.push(v),P.set(v.name,k)}return(v,k)=>{let C=JSON.stringify([v,k]);if(A.has(C))return A.get(C);let b=l(j=>{let N=j.split("."),L=P.get(N.at(-1))??[],q=N.slice(0,-1);if(q.length>0)return L.filter(V=>q.length<=V.scope.length&&q.every((K,J)=>V.scope[V.scope.length-q.length+J]===K));for(let V=k.length;V>=0;V--){let K=L.filter(J=>V<=J.scope.length&&k.slice(0,V).every((U,_)=>J.scope[_]===U));if(K.length>0)return K}return[]},"candidates"),w=b(v),T=d.get(v)??[];w.length===0&&T.length===1&&(w=b(T[0]));let I=w.length===1?w[0].node:null;return A.set(C,I),I}},"scoped"),m=p(n.slices.flatMap(({slice:$,scope:P})=>$.readModels.map(A=>({name:A.name,scope:P,node:A})))),u=p(n.slices.flatMap(({slice:$,scope:P})=>$.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:$}})))),y=new Map;for(let $ of t.systems??[])y.has($.name)&&e.error(c.InvalidSystemDeclaration,`System '${$.name}' is declared more than once.`,$.location),y.set($.name,(y.get($.name)??0)+1);let h=l(($,P,A=!0)=>{let[v,...k]=P.split("."),C=$.filter(I=>I.name===v);if(C.length!==1)return{type:null,missing:C.length===0};let b=C[0].type;if(k.length===0)return{type:b,missing:!1};let w=o.get(b.name);if(w===void 0)return{type:null,missing:s.has(b.name)};let T=h([...w.values()],k.join("."),A);return T.type===null?T:{type:{...T.type,isOptional:A&&b.isOptional||T.type.isOptional,isCollection:b.isCollection||T.type.isCollection},missing:!1}},"pathType"),x=l(($,P,A,v,k=new Set)=>{if(A.has(P)||$.isOptional&&!v.has(P))return!0;if($.isCollection||k.has($.name))return!1;let C=o.get($.name);return C===void 0?v.has(P)&&!s.has($.name):[...C.values()].every(b=>x(b.type,`${P}.${b.name}`,A,v,new Set([...k,$.name])))},"covered"),g=l(($,P)=>{if($.kind==="ListExpressionSyntax"&&P.isCollection)return $.items.every(v=>g(v,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return $.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(v=>(v.type.isOptional||$.members.some(k=>k.name===v.name))&&$.members.filter(k=>k.name===v.name).every(k=>g(k.value,v.type)))},"completeValue"),S=l($=>$.kind==="LiteralExpressionSyntax"?typeof $.value!="number"||Number.isFinite($.value):$.kind==="ObjectExpressionSyntax"?$.members.every(P=>S(P.value)):$.kind==="ListExpressionSyntax"&&$.items.every(S),"concrete"),E=l(($,P,A,v,k)=>{let C=new Set,b=new Set($.map(T=>T.property)),w=new Set;for(let T of $){let I=T.property.split(".");for(let j=1;j<=I.length;j++)w.add(I.slice(0,j).join("."))}for(let T of $){C.has(T.property)&&e.error(c.InvalidOperationMapping,`Duplicate operation input mapping '${T.property}'.`,T.location),C.add(T.property);let I=h(P.inputs,T.property,!1);if(I.missing&&e.error(c.InvalidOperationMapping,`Operation '${P.name}' declares no input '${T.property}'.`,T.location),I.type===null)continue;let j=T.property.split(".");for(let N=1;N<j.length;N++)b.has(j.slice(0,N).join("."))&&e.error(c.InvalidOperationMapping,`Operation input mapping '${T.property}' overlaps a whole input mapping.`,T.location);if(A!==null&&T.source.kind==="PathExpressionSyntax"){let N=h(A.properties,T.source.path),L=T.source.path.split("."),q=(ui.get(A)??[]).filter(J=>(J.alias??J.readModel)===L[0]);if(N.missing&&q.length>0){N={type:null,missing:!1};let J=q.length===1?m(q[0].readModel,k):null;L.length>1&&J!==null&&(N=h(J.properties,L.slice(1).join(".")))}N.missing&&e.error(c.InvalidOperationMapping,`Command '${A.name}' declares no source '${T.source.path}'.`,T.source.location);let V=N.type,K=I.type;V!==null&&s.has(V.name)&&s.has(K.name)&&(V.name!==K.name||V.isCollection!==K.isCollection||V.isOptional&&!K.isOptional)&&e.error(c.InvalidOperationMapping,`Source '${T.source.path}' is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(T.source.kind)&&(!ke(T.source,I.type,r,o)||v&&!g(T.source,I.type))&&e.error(c.InvalidOperationMapping,`Value is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}if(v)for(let T of P.inputs)x(T.type,T.name,C,w)||e.error(c.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${T.name}'.`,P.location)},"validateMappings");for(let{slice:$,scope:P}of n.slices){let A=Bn($),v=new Set(le($).map(k=>k.name));for(let k of A){v.has(k.name)&&e.error(c.ProductionDeclarationCollision,`Operation '${k.name}' collides with another event or operation in slice '${$.name}'.`,k.location),v.add(k.name),k.uses.length>0&&y.get(k.uses)!==1&&e.error(c.InvalidSystemReference,`Operation '${k.name}' must use one declared system; '${k.uses}' does not resolve uniquely.`,k.usesLocation??k.location);for(let C of k.inputs)!s.has(C.type.name)&&!a.has(C.type.name)&&e.warning(c.UnknownType,`Unknown type '${C.type.name}' on input '${C.name}' of operation '${k.name}'.`,C.type.location)}for(let k of $.commands)for(let C of k.produces){let b=n.resolve(C.event,$);b.kind===H.Ambiguous&&b.candidates.some(w=>w.kind===H.Operation)&&e.error(c.InvalidProductionReference,`Production '${C.event}' is ambiguous.`,C.location),C.event.includes(".")&&b.kind!==H.Operation&&e.error(c.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",C.location),b.declaration?.node.kind==="OperationSyntax"&&((C.for!==null||C.tags.length>0)&&e.error(c.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",C.location),E(C.mappings,b.declaration.node,k,!0,P))}for(let k of $.reactions.flatMap(C=>C.triggers).flatMap(C=>C.produces)){let C=n.resolve(k.event,$);C.kind===H.Ambiguous&&C.candidates.some(b=>b.kind===H.Operation)&&e.error(c.InvalidProductionReference,`Production '${k.event}' is ambiguous.`,k.location),k.event.includes(".")&&n.resolve(k.event,$).kind!==H.Operation&&e.error(c.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",k.location),n.isOperation(k,$)&&e.error(c.OperationOutsideCommand,"Operations can only be produced by commands.",k.location)}for(let k of $.specifications){let C=[...k.givenOperationFailures??[],...k.thenOperations??[],...k.thenCompensated??[]];if(C.length===0)continue;let b=u(i(k.when,P)?.commandType??"",P);(b===null||k.whenAppended!==null||k.whenQuery!==null||k.whenTrigger!==null||k.whenClock!==null||k.whenCapture!==null)&&e.error(c.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",k.location);let w=new Map;for(let T of C){if(T.kind==="SpecificationOperationSyntax")for(let N of T.values)S(N.source)||e.error(c.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let I=n.resolve(T.operation,$).declaration?.node;if(I?.kind!=="OperationSyntax"){e.error(c.InvalidOperationSpecification,`'${T.operation}' does not resolve uniquely to a declared operation.`,T.location);continue}let j=w.get(I)??new Set;if(j.has(T.kind)&&e.error(c.InvalidOperationSpecification,`Duplicate operation step '${T.operation}'.`,T.location),j.add(T.kind),w.set(I,j),T.kind==="SpecificationCompensatedSyntax"&&I.compensate===null&&e.error(c.InvalidOperationSpecification,`Operation '${T.operation}' declares no compensation.`,T.location),b!==null&&b.command.handler==null){let N=b.command.produces.map(L=>n.resolve(L.event,b.slice));N.every(L=>L.kind===H.Event||L.kind===H.Operation)&&!N.some(L=>L.declaration?.node===I)&&e.error(c.InvalidOperationSpecification,`Command '${b.command.name}' does not produce operation '${T.operation}'.`,T.location)}T.kind==="SpecificationOperationSyntax"&&E(T.values,I,null,!1,P)}}}}l(Ei,"validateOperations");var ws=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],_f=O("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),Zf=O(`^"(${z})"$`);function po(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}l(po,"complianceWireName");function Kf(t){let e=po(t);return e==="sensitive"?"secret":e}l(Kf,"canonicalComplianceName");function Os(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return Ts(t,e,i),i.map(r=>{let o=po(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(c.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,f(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:f(e)}})}l(Os,"parseComplianceMarkers");function Is(t,e,n,i){let r=_f.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",d=po(o),p=Kf(o);if(Ts(t,e,[o]),!["pii","sensitive"].includes(d)||o==="@personal"||o==="@secret")return t.error(c.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,f(e)),!0;let m=i.findIndex(y=>y.name===d);if(m<0)return t.error(c.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${p} ${s}' without the marker - write 'concept ${n} : <Type> ${p}'`,f(e)),!0;let u=i[m];switch(s){case"reason":{let y=Zf.exec(a);return y===null?(t.error(c.UnknownConceptDirective,`Invalid '${p} reason' - expected '${p} reason "<text>"'`,f(e)),!0):u.reason!==null?(t.error(c.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${p}' - at most one is allowed`,f(e)),!0):(i[m]={...u,reason:Q(y[1])},!0)}case"scope":return d!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(c.InvalidSecretScope,`Invalid '${p} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,f(e)),!0):u.scope!=null?(t.error(c.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,f(e)),!0):(i[m]={...u,scope:a},i.some(y=>y.name==="pii")&&t.warning(c.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,f(e)),!0);case"special":case"criminal":return d!=="pii"||(s==="special"?!ws.includes(a):a.length>0)?(t.error(c.InvalidPersonalDataQualifier,`Invalid '${p} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${ws.join(", ")}`,f(e)),!0):s==="special"&&u.specialCategory!=null?(t.error(c.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,f(e)),!0):(i[m]=s==="special"?{...u,specialCategory:a}:{...u,criminal:!0},!0);default:return!1}}l(Is,"parseComplianceDirective");function Ts(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(c.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",f(e))}l(Ts,"reportLegacy");var Jf=Z("^policy\\s+([A-Za-z_]\\w*)$");function Rs(t,e){let n=t;t=t.valueContext;let i=Jf.exec(e.content)?.[1]??"";i===""&&t.error(c.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1,d=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(p.content)==="description")d=G(n,p,d,`Policy '${i}'`);else if(D(p.content)==="require"){let m=p.content.substring(7).trim();for(let h=t.peekChild(p.indent);h!==void 0;h=t.peekChild(p.indent))t.reader.takeSignificant(),m+=` ${h.content}`;let u=Hf(t,m);u.includes("not")&&(t=n);let y=Xf(t,u,f(p));a?t.error(c.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(p)):r=y,a=!0}else if(D(p.content)==="file"){let m=ht(t,p);o===null&&s===null?s=m:t.error(c.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else if(p.content.startsWith("```")||t.languages.has(p.content)){let m=Be(t,p);o===null&&s===null?o=m:t.error(c.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else t.error(c.UnknownPolicyDirective,`Unexpected '${p.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(p)),t.skipOpaqueBlock(p.indent);return r!==null&&(o!==null||s!==null)&&t.error(c.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(c.PolicyWithoutRequirement,`Policy '${i}' must declare a 'require' condition, a file reference or an inline code block`,f(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,description:d,location:f(e)}}l(Rs,"parsePolicy");function Hf(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Z(`"${z}"|\\(|\\)|${n}`).source,"gu"))??[]]}l(Hf,"tokenizePolicyCondition");function Xf(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=l(u=>u!==void 0&&u.startsWith('"')&&u.endsWith('"'),"quoted"),s=l(u=>Q(u.substring(1,u.length-1)),"unquote"),a=l(()=>{if(e[r]==="not"){r++;let x=a();return x===null?null:{kind:"NotPolicyConditionSyntax",operand:x,location:n}}if(e[r]==="("){r++;let x=p();return e[r]===")"?r++:i&&t.error(c.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),x}let u=e[r++];if(u==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(u!=="role"&&u!=="claim")return t.error(u===void 0?c.ExpectedPolicyCondition:c.UnexpectedTokenInPolicyCondition,u===void 0?"Expected a policy condition":`Unexpected '${u}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(u==="role"?c.ExpectedRoleName:c.ExpectedClaimName,`Expected a quoted ${u} name after '${u}'`,n),null;if(u==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(c.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(c.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:Me(h,n,t),location:n}},"group"),d=l(()=>{let u=a();for(;u!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"And",right:y,location:n}}return u},"and"),p=l(()=>{let u=d();for(;u!==null&&e[r]==="or";){r++;let y=d();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"Or",right:y,location:n}}return u},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(c.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}l(Xf,"parsePolicyCondition");var em=new RegExp(`^for\\s+"(${z})"$`,"u"),tm=Z("^[A-Z]\\w*$"),nm=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Ds(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(c.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:f(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=em.exec(i.content);if(r===null){t.error(c.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,f(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let s=t.peekChild(i.indent);s!==void 0;s=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!tm.test(s.content)){t.error(c.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let d=t.peekChild(s.indent);d!==void 0;d=t.peekChild(s.indent)){t.reader.takeSignificant();let p=nm.exec(d.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:Me(p[2],f(d),t),location:f(d)}):t.error(c.InvalidSeedPropertyAssignment,`Invalid property assignment '${d.content}' - expected '<property> = <value>'`,f(d))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:Q(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}l(Ds,"parseSeed");var uo=`(?:([A-Za-z_]\\w*)|"(${z})")\\.(\\w+(?:\\.\\w+)*)`,im=O("^exposure\\s+for\\s+([A-Za-z_]\\w*)$"),rm=O("^instance\\s+([A-Za-z_]\\w*)$"),om=O(`^property\\s+${uo}(?:\\s+label\\s+"(${z})")?(?:\\s+operations\\s+([\\w-]+(?:\\s*,\\s*[\\w-]+)*))?(?:\\s+fields\\s+(\\w+(?:\\s*,\\s*\\w+)*))?(?:\\s+reexposes\\s+([A-Za-z_]\\w*))?$`),am=O(`^set\\s+${uo}\\s*=\\s*(.+)$`),sm=O(`^items\\s+${uo}$`),lm=O(`^item\\s+(?:([A-Za-z_][\\w-]*)|"(${z})")$`),cm=O("^([A-Za-z_]\\w*)\\s*=\\s*(.+)$"),dm=["add","remove","reorder","edit-fields"],pm=`'property <component>.<path> [label "<text>"] [operations <add|remove|reorder|edit-fields>, ...] [fields <field>, ...] [reexposes <Owner>]'`,Pi=l((t,e)=>t[e]??Q(t[e+1]),"reference"),Ms=l(t=>t.trim()==="none"?[]:t.split(",").map(e=>e.trim()).filter(e=>e.length>0),"list");function js(t,e){let n=im.exec(e.content);n===null&&t.error(c.InvalidExposureDeclaration,`Invalid exposure declaration '${e.content}' - expected 'exposure for <Owner>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=um(t,r);o!==void 0&&i.push(o)}return{kind:"ExposureSyntax",owner:n?.[1]??e.content,properties:i,location:f(e)}}l(js,"parseExposure");function Ls(t,e){let n=rm.exec(e.content);n===null&&t.error(c.InvalidInstanceContribution,`Invalid instance declaration '${e.content}' - expected 'instance <Screen or Template>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=fm(t,r);o!==void 0&&i.push(o)}return{kind:"InstanceContributionsSyntax",instance:n?.[1]??e.content,contributions:i,location:f(e)}}l(Ls,"parseInstance");function um(t,e){let n=om.exec(e.content);if(n===null){t.error(c.InvalidExposureDeclaration,`Invalid exposed property '${e.content}' - expected ${pm}`,f(e));return}let i=n[5]===void 0?[]:Ms(n[5]),r=i.find(o=>!dm.includes(o));if(r!==void 0){t.error(c.InvalidExposureDeclaration,`Unknown collection operation '${r}' - expected add, remove, reorder, edit-fields or none`,f(e));return}return{kind:"ExposedPropertySyntax",component:Pi(n,1),path:n[3],label:n[4]===void 0?null:Q(n[4]),isCollection:n[5]!==void 0,operations:i,restrictsFields:n[6]!==void 0,editableFields:n[6]===void 0?[]:Ms(n[6]),reExposes:n[7]??null,location:f(e)}}l(um,"parseExposedProperty");function fm(t,e){let n=am.exec(e.content);if(n!==null)return t.skipBlock(e.indent),{kind:"InstanceContributionSyntax",component:Pi(n,1),path:n[3],value:ae(n[4],f(e),t),items:[],location:f(e)};let i=sm.exec(e.content);if(i!==null){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=mm(t,o);s!==void 0&&r.push(s)}return{kind:"InstanceContributionSyntax",component:Pi(i,1),path:i[3],value:null,items:r,location:f(e)}}t.error(c.InvalidInstanceContribution,`Invalid instance contribution '${e.content}' - expected 'set <component>.<path> = <value>' or 'items <component>.<path>'`,f(e)),t.skipBlock(e.indent)}l(fm,"parseContribution");function mm(t,e){let n=lm.exec(e.content);if(n===null){t.error(c.InvalidInstanceContribution,`Invalid contributed item '${e.content}' - expected 'item <id>'`,f(e)),t.skipBlock(e.indent);return}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=cm.exec(r.content);if(o===null){t.error(c.InvalidInstanceContribution,`Invalid item value '${r.content}' - expected '<field> = <value>'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ContributedItemValueSyntax",field:o[1],value:ae(o[2],f(r),t),location:f(r)})}return{kind:"ContributedItemSyntax",id:Pi(n,1),values:i,location:f(e)}}l(mm,"parseItem");var ym=O("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Bs=O(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${z})")?$`),hm=O("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),Sm=O("^@?[a-z_]\\w*$"),gm=O("^persona\\s+([A-Za-z_]\\w*)$"),xm=O("^policy\\s+([A-Za-z_]\\w*)$"),vm=/^[ ]*\t/,Ns=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Ys=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),$m=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function Ai(t,e,n=Et){Pm(t,e);let i=n.length===1?new Cn(n[0]):void 0,r=n.length>1?new kn(n[n.length-1]):void 0,o=i??r,s=null,a=[],d=[],p=[],m=[],u=[],y=[],h=[],x=[],g=[],S=[],E=[],$=[],P=[],A=[],v=[],k=!1;for(let b=t.reader.peekSignificant();b!==void 0;b=t.reader.peekSignificant()){t.reader.takeSignificant();let w=D(b.content);if(w==="domain"){t.authoredDeclarations=!0,s=Em(t,b,s,k);continue}if(k||=qs(w,b,n),t.authoredDeclarations||=w!=="import"&&qs(w,b,n),w==="import"&&ua(b.content))o!==void 0?o.tryParse(t,b):Ft(t,b,d);else if(w==="import"){let T=Bs.exec(b.content);if(T===null)t.error(c.InvalidImportDeclaration,`Invalid import '${b.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,f(b));else{let I=T.groups?.origin===void 0?null:Q(T.groups.origin);I!==null&&xn(I)&&t.error(c.InvalidImportDeclaration,"An import origin must be a nonblank quoted string",f(b)),a.push({kind:"ImportSyntax",qualifiedName:T[1],origin:I,visibility:I===null?se.Private:se.Public,location:f(b)})}}else if(w==="example")o!==void 0?o.tryParse(t,b):$.push(ot(t,b));else if(w==="eventsource")y.push(Ca(t,b));else if(w==="system")u.push(Ta(t,b));else if(w==="concept")p.push(Am(t,b));else if(w==="type")m.push(Wa(t,b));else if(w==="module"&&!pn(n))bm(t,b,n,i);else if(w==="module")h.push(Hr(t,b));else if(w==="persona")x.push(wm(t,b));else if(w==="seed")E.push(Ds(t.valueContext,b));else if(w==="purpose"&&o!==void 0)o.tryParse(t,b);else if(w==="purpose")S.push(da(t,b));else if(w==="policy")g.push(Rs(t,b));else if(w==="exposure")A.push(js(t,b));else if(w==="instance")v.push(Ls(t,b));else if(w==="trigger"){let T=ds(t,b),I=/^trigger\s+([A-Za-z_]\w*)$/.exec(b.content)?.[1];I!==void 0&&P.push({name:I,data:T})}else Ys.has(w)?w==="behavior"||w==="layout"?qe(t,b):t.skipOpaqueBlock(b.indent):o?.tryParse(t,b)!==!0&&km(t,b,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(Cm(n,r.build(t.start,!0),t.start));let C={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:m,systems:u,eventSources:y,examples:$,modules:h,personas:x,policies:g,purposes:S,seeds:E,declaredTriggers:P,fileImports:d,...A.length>0?{exposures:A}:{},...v.length>0?{instanceContributions:v}:{},location:t.start};return t.authoredDeclarations&&ga(C),C}l(Ai,"parseApplication");function qs(t,e,n){return t==="import"?Bs.test(e.content):t==="module"?pn(n):t==="purpose"||t==="example"||t==="exposure"||t==="instance"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||Ys.has(t)}l(qs,"declaresConstruct");function bm(t,e,n,i){let r=Kr.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(c.ModuleInPlacedFile,`This file is imported into ${ei(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}l(bm,"parseModuleInPlacedFile");function km(t,e,n){let i=D(e.content);if(pn(n)){let r=$m.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(c.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?Jr:Zr;t.error(c.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${ei(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}l(km,"reportUnexpectedTopLevel");function Cm(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}l(Cm,"place");function Em(t,e,n,i){let r=ym.exec(e.content);return r===null?(t.error(c.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(c.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(c.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}l(Em,"parseDomain");function Pm(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&vm.test(i.raw)&&t.warning(c.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",Ho(i))}}l(Pm,"warnOnTabIndentation");function Am(t,e){let n=hm.exec(e.content);if(n===null)return t.error(c.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=Os(t,e,o);r!=="Enum"&&!Ns.includes(r)&&t.error(c.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Ns.join(", ")} or Enum`,f(e));let a=[],d=null,p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(m.content)==="description"&&(r!=="Enum"||m.content!=="description"||t.peekChild(m.indent)?.content.startsWith("```")===!0))d=G(t,m,d,`Concept '${i}'`);else{if(ye(m))continue;if(D(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(c.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let u=Ur(t,m,"concept");u!==void 0&&p.push(u)}else Is(t,m,i,s)||(r==="Enum"&&Sm.test(m.content)?a.push(oe(m.content)):r==="Enum"?t.error(c.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(c.UnknownConceptDirective,`Unexpected '${m.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,f(m)),t.skipBlock(m.indent)))}return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:p,description:d,location:f(e)}}l(Am,"parseConcept");function wm(t,e){let n=gm.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,f(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=G(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=xm.exec(o.content);a===null?t.error(c.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(c.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,f(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:f(e)}}l(wm,"parsePersona");var Jt=class t{static{l(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=Et,i){return this.capturePlaced([...e].map(r=>({lines:r,placement:n})),i)}static capturePlaced(e,n){let i=new Map,r=new Set,o=new Set;for(let{lines:a,placement:d}of e){let p=ki(a,a[0]?.path,n);p.scope=d;let m=Ai(p,a,d);for(let u of m.types)r.add(u.name);for(let u of m.concepts)r.add(u.name);for(let u of m.imports)o.add(u.qualifiedName);for(let u of m.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.streams.map(y=>y.name)])}let s=new Set([...o].filter(a=>r.has(a.substring(a.lastIndexOf(".")+1))));return new t(i,s)}};var ge;(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"})(ge||(ge={}));function Fs(t){return t.length===0?{value:null,failure:ge.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:ge.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:ge.NotNfc}:{value:t,failure:null}}l(Fs,"tryFormatText");function Us(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:ge.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}}l(Us,"tryFormatUuidText");function wi(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:ge.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:ge.OutOfRange}:{value:n.toString(),failure:null}}l(wi,"tryFormatInteger");function Oi(t){switch(t){case ge.Empty:return"A stream id text literal cannot be empty.";case ge.NotNfc:return"A stream id text literal must be Unicode NFC.";case ge.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case ge.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case ge.NotIntegral:return"A stream id integer must be a finite integral value.";case ge.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case ge.Arity:return"A composite stream id must match the declared part count of at least two.";case ge.Escape:return"A composite stream id permits only %25 and %7C escapes.";case ge.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}l(Oi,"streamIdFailureMessage");function Ii(t,e,n,i,r,o,s){if(n){o.error(r,"A composite stream requires a streamId part block, not a scalar mapping.",i);return}let a=t.streamIdParts;for(let p of a.filter(m=>!e.some(u=>u.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let d=new Set;for(let p of e){let m=a.find(u=>u.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):d.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(d.add(p.property),s(p,m.type))}}l(Ii,"validateStreamIdParts");function Ti(t,e,n){let i=ne(n.concepts),r=ne(n.types),o=new Map([...r].map(([a,d])=>[a,ne(d.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!ke(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?wn(t,e,n)?.value??null:null}l(Ti,"formatSpecificationStreamId");function Ws(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Re(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==pe.Unique||s.kind!==pe.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],d=l((p,m,u)=>{let y=Ti(p,u,i),h=Ti(m,u,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 u=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return u.length===1&&y.length===1?d(u[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:d(t.streamId?.source,e.streamId?.source,a.streamId)}l(Ws,"matchesSpecificationRoute");function zs(t,e){let n=new re(t).slices.flatMap(({slice:s})=>s.specifications.flatMap(a=>a.cases??[]));if(n.length===0)return Vs(t,e);let i=new he(new Qe([]));Vs(t,i);let r=new Set,o=new Set;for(let s of i.diagnostics){let a=JSON.stringify([s.code,s.location.path,s.location.line,s.location.column,s.message]);if(o.has(a))continue;o.add(a);let d=s.code===c.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(d===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 '${d.name}': ${s.message}`,s.location),r.add(p)}}}l(zs,"validateSpecificationStreams");function Vs(t,e){let n=Nt(t).resolvedExamples,i=zn(t);t=i.application;let r=new re(t),o=new Set,s=n.flatMap($=>{if($.kind!=="event")return($.kind==="command"||$.kind==="readmodel")&&($.example.stream!=null||$.example.noStream!=null)&&e.error(c.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",($.example.stream??$.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:$.name,values:$.example.values,for:$.example.for,stream:$.example.stream,noStream:$.example.noStream,location:$.example.location};return o.add(P),[{scope:$.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Re(t),d=ne(t.concepts),p=ne(t.types),m=new Map([...p].map(([$,P])=>[$,ne(P.properties)])),u=l(($,P)=>ke($,P,d,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...d.keys(),...p.keys()]),h=l(($,P)=>y.has($.name)&&y.has(P.name)?$.name===P.name&&$.isCollection===P.isCollection&&(!$.isOptional||P.isOptional):null,"nominallyCompatible"),x=l(($,P)=>Ti($,P,t),"formatStreamId"),g=l(($,P)=>{let A=r.resolve($,P).declaration;return A?.node.kind==="EventSyntax"?A.node:null},"eventOf"),S=[];for(let{slice:$}of r.slices){for(let P of $.commands)for(let A of P.produces){if(!r.isEventProduction(A,$))continue;let v=g(A.event,$);if(v===null)continue;let k=qt(P,A,t,{resolver:r,slice:$});S.push({event:v,command:P,type:k})}for(let P of $.reactions.flatMap(A=>A.triggers).flatMap(A=>A.produces)){let A=g(P.event,$);A!==null&&S.push({event:A,command:null,type:null})}for(let P of $.captures)for(let A of[...P.appends,...P.children.flatMap(v=>v.appends),...P.nested.flatMap(v=>v.appends)]){let v=g(A.event,$);v!==null&&S.push({event:v,command:null,type:null})}}let E=[...s.flatMap($=>r.slices.filter(P=>P.scope.join(".")===$.scope.join(".")).map(({slice:P,scope:A})=>({slice:P,scope:A,specification:$.specification}))),...r.slices.flatMap(({slice:$,scope:P})=>$.specifications.map(A=>({slice:$,scope:P,specification:A})))];for(let{slice:$,scope:P,specification:A}of E){let v=r.slices.flatMap(I=>I.slice.commands.map(j=>({command:j,scope:I.scope}))),k=A.when?.commandType.split(".")??[],C=k.slice(0,-1),b=v.filter(I=>I.command.name===k.at(-1)&&C.every((j,N)=>I.scope[I.scope.length-C.length+N]===j)),w=C.length>0&&b.length===1?b[0].command:null;for(let I=P.length;C.length===0&&I>=0&&w===null;I--){let j=b.filter(N=>P.slice(0,I).every((L,q)=>N.scope[q]===L));if(j.length>0){w=j.length===1?j[0].command:null;break}}let T=[...A.given.map(I=>({node:I,required:!0,expected:!1})),...A.whenAppended===null?[]:[{node:A.whenAppended,required:!0,expected:!1}],...A.thenEvents.map(I=>({node:I,required:!1,expected:!o.has(I)})),...A.whenRedelivered==null?[]:[{node:{...A.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:I,required:j,expected:N}of T){let L=i.specifications.flatMap(F=>F.steps).find(F=>F.effective===I),q=L?.route?.origin!=="example",V=q||I.for!==L?.example?.for,K=l((F,ce,fe)=>{e.error(F,L?.example==null?ce:`${ce} Example '${L.example.name}' is used here.`,L?.example==null?fe:L.authored.location)},"contextualError");if(I.stream==null&&I.noStream==null)continue;j&&I.noStream!=null&&K(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",I.noStream.location);let J=null,U=g(I.eventType,$),_=S.filter(F=>F.event===U);if(I.stream!=null){let F=I.stream,ce=a.resolve(F.eventSource,F.stream);if(ce.kind!==pe.Unique){let me={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[ce.kind];q&&e.error(c.InvalidSpecificationStreamRoute,`Stream '${F.eventSource}.${F.stream}' is ${me}; routing requires one physical source and stream.`,F.location);continue}let fe=ce.sources[0],Ae=ce.streams[0],$t=l((me,xe)=>{let R=me.source,M=wn(R,xe,t);M?.failure!=null?e.error(c.InvalidSpecificationStreamRoute,Oi(M.failure),R.location):(R.kind!=="LiteralExpressionSyntax"||R.value===null||xe!==null&&!u(R,xe))&&e.error(c.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",R.location)},"validateLiteral");if(q&&(Ae.streamIdParts.length>0?Ii(Ae,F.streamIdParts,F.streamId!==null,F.location,c.InvalidSpecificationStreamRoute,e,$t):F.streamIdParts.length>0?e.error(c.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",F.location):(Ae.streamId===null!=(F.streamId===null)&&e.error(c.InvalidSpecificationStreamRoute,Ae.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",F.location),F.streamId!==null&&$t(F.streamId,Ae.streamId))),J=fe.identifier,J===null){let me=_.map(R=>R.type),xe=new Set(me.filter(R=>R!==null).map(R=>`${R.name}:${R.isOptional}:${R.isCollection}`));me.length===0||me.some(R=>R===null)||xe.size!==1?q&&e.error(c.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${fe.name}'; the event's producers do not supply one unambiguous destination type.`,F.location):J=me[0]}let bt=!1;if(L?.example?.stream!=null&&I.for!==null&&I.for===L.example.for){let me=a.resolve(L.example.stream.eventSource,L.example.stream.stream);if(me.kind===pe.Unique){let xe=_.map(B=>B.type),R=new Set(xe.filter(B=>B!==null).map(B=>`${B.name}:${B.isOptional}:${B.isCollection}`)),M=me.sources[0].identifier??(xe.length>0&&!xe.some(B=>B===null)&&R.size===1?xe[0]:null);M!==null&&(bt=I.for.kind!=="LiteralExpressionSyntax"||I.for.value===null||M.isCollection||M.isOptional||!u(I.for,M))}}j&&I.for===null?K(c.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",F.location):V&&!bt&&I.for!==null&&(I.for.kind!=="LiteralExpressionSyntax"||I.for.value===null||J!==null&&(J.isCollection||J.isOptional||!u(I.for,J)))&&K(c.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",I.for.location)}if(!N||w===null||_.length===0||_.some(F=>F.command!==w))continue;let ie=w.stream?.propertyCandidate===null?w.stream:null,Ce=I.noStream!=null?ie!=null:ie==null||ie.eventSource!==I.stream.eventSource||ie.stream!==I.stream.stream;if(!Ce&&I.stream!=null&&ie!=null){let F=a.resolve(I.stream.eventSource,I.stream.stream),ce=F.kind===pe.Unique?F.streams[0]:null;if(ce!==null&&ce.streamIdParts.length>0){if(ie.streamId===null&&I.stream.streamId===null&&ie.streamIdParts.length>0&&I.stream.streamIdParts.length>0)for(let fe of ce.streamIdParts){let Ae=ie.streamIdParts.filter(xe=>xe.property===fe.name),$t=I.stream.streamIdParts.filter(xe=>xe.property===fe.name);if(Ae.length!==1||$t.length!==1)continue;let bt=x(Ae[0].source,fe.type),me=x($t[0].source,fe.type);bt!==null&&me!==null&&bt!==me&&(Ce=!0)}}else if(ce?.streamId!=null&&ie.streamIdParts.length===0&&I.stream.streamIdParts.length===0){let fe=x(ie.streamId?.source,ce.streamId),Ae=x(I.stream.streamId?.source,ce.streamId);fe!==null&&Ae!==null&&fe!==Ae&&(Ce=!0)}}I.for?.kind==="LiteralExpressionSyntax"&&_.every(F=>F.type!==null&&(J!==null?h(F.type,J)===!1:!u(I.for,F.type)))&&(Ce=!0),Ce&&K(c.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(I.stream??I.noStream).location)}}}l(Vs,"validateRoutes");var On=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function fo(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&On.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}l(fo,"supportsStreamIdentity");function wn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:ne(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?Us(i):Fs(i):typeof i=="number"?wi(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?wi(NaN):wi(BigInt(i.value),!1):null}l(wn,"formatStreamIdLiteral");function Ri(t,e){let n=ne(t.concepts),i=ne(t.types),r=new Set([...On,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,ne(h.properties)])),s=l((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=l((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(S=>S.name===y.name)){e.error(c.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let x=t.concepts.filter(S=>S.name===y.name),g=x.length===1?x[0].type:x.length===0&&On.has(y.name)?y.name:null;h&&g!==null&&!fo(y,t)&&e.error(c.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),g===null&&!t.imports.some(S=>S.qualifiedName===y.name||S.qualifiedName.split(".").at(-1)===y.name)&&e.warning(c.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),d=new Set;for(let y of t.eventSources??[]){d.has(y.name)&&e.error(c.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),d.add(y.name),a(y.identifier,!1);let h=new Set;for(let x of y.streams){h.has(x.name)&&e.error(c.InvalidEventSourceDeclaration,`Stream '${y.name}.${x.name}' has multiple declarations under this source.`,x.location),h.add(x.name),a(x.streamId,!0);let g=x.streamIdParts;if(g.length>0){g.length<2&&e.error(c.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",x.directiveLocations?.streamId??x.location);for(let S of new Set(g.map(E=>E.name)))for(let E of g.filter($=>$.name===S).slice(1))e.error(c.InvalidEventSourceDeclaration,`Stream id part '${E.name}' is declared more than once.`,E.location);for(let S of g)a(S.type,!0)}}}let p=l((y,h)=>{let[x,...g]=h.split(".");if(y===null)return{property:null,missing:!1};let S=y.filter(P=>P.name===x);if(S.length!==1)return{property:null,missing:S.length===0};let E=S[0];if(g.length===0)return{property:E,missing:!1};if(On.has(E.type.name)||n.has(E.type.name)&&!i.has(E.type.name))return{property:null,missing:!0};let $=p(i.get(E.type.name)?.properties??null,g.join("."));return $.property===null?$:{property:{...$.property,type:{...$.property.type,isCollection:E.type.isCollection||$.property.type.isCollection,isOptional:E.type.isOptional||$.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Re(t),u=new re(t);for(let{slice:y}of u.slices)for(let h of y.commands){let x=h.stream;if(x==null||x.propertyCandidate!==null)continue;let g=m.resolve(x.eventSource,x.stream);if(g.kind!==pe.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[g.kind];e.error(c.InvalidCommandStream,`Stream '${x.eventSource}.${x.stream}' is ${A}; routing requires one physical source and stream.`,x.location);continue}let S=g.sources[0],E=g.streams[0],$=h.properties.filter(A=>A.isIdentifier);S.identifier!==null&&$.length===1&&s($[0].type,S.identifier)===!1&&e.error(c.InvalidCommandStream,`Command identifier '${$[0].name}' does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,$[0].location);for(let A of h.produces.filter(v=>u.isEventProduction(v,y))){if(S.identifier===null)continue;let v=qt(h,A,t,{resolver:u,slice:y});if(v===null||A.for===null&&A.inlineEvent!==null&&$.length===1&&s($[0].type,S.identifier)===!1)continue;let k=A.for===null&&A.inlineEvent===null&&!h.properties.some(w=>w.isGenerated&&w.isIdentifier),C=n.get(S.identifier.name)?.type??(On.has(S.identifier.name)?S.identifier.name:null);(k?C===null?null:C==="Uuid":s(v,S.identifier))===!1&&e.error(c.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=l((A,v)=>{let k=A.source;if(k.kind==="PathExpressionSyntax"){let C=p(h.properties,k.path);(C.missing||C.property!==null&&s(C.property.type,v)===!1)&&e.error(c.InvalidCommandStream,`Stream id source '${k.path}' is absent or incompatible with nominal type '${v.name}'.`,k.location)}else if(k.kind==="LiteralExpressionSyntax"&&k.value!==null){let C=wn(k,v,t);C?.failure!=null?e.error(c.InvalidCommandStream,Oi(C.failure),k.location):ke(k,v,n,o)||e.error(c.InvalidCommandStream,`Stream id value is incompatible with nominal type '${v.name}'.`,k.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(k.kind)||k.kind==="LiteralExpressionSyntax"&&k.value===null)&&e.error(c.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",k.location)},"validateMapping");if(E.streamIdParts.length>0){Ii(E,x.streamIdParts,x.streamId!==null,x.location,c.InvalidCommandStream,e,P);continue}if(x.streamIdParts.length>0){e.error(c.InvalidCommandStream,"A streamId part block requires a composite stream.",x.location);continue}(E.streamId===null&&x.streamId!==null||E.streamId!==null&&x.streamId===null)&&e.error(c.InvalidCommandStream,E.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",x.location),!(E.streamId===null||x.streamId===null)&&P(x.streamId,E.streamId)}zs(t,e)}l(Ri,"validateEventSources");function Di(t,e){let n=new re(t),i=n.slices,r=new Set(t.imports.map(g=>g.qualifiedName)),o=new Set([...i.flatMap(({slice:g})=>le(g).map(S=>S.name)),...t.imports.map(g=>g.qualifiedName.split(".").at(-1))]),s=ne(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(g=>g.name)].filter(g=>!s.has(g))),d=l((g,S)=>{let[E,...$]=S.split(".");if(g===null)return{value:null,missing:!1};let P=g.filter(v=>v.name===E);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return $.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:d(s.get(A.type.name)?.properties??null,$.join("."))},"property"),p=i.flatMap(({slice:g,scope:S})=>g.readModels.map(E=>({node:E,scope:S}))),m=l((g,S)=>{let E=l(A=>{let v=A.split("."),k=p.filter(b=>b.node.name===v.at(-1)),C=v.slice(0,-1);if(C.length>0)return k.filter(b=>C.length<=b.scope.length&&C.every((w,T)=>b.scope[b.scope.length-C.length+T]===w));for(let b=S.length;b>=0;b--){let w=k.filter(T=>b<=T.scope.length&&S.slice(0,b).every((I,j)=>T.scope[j]===I));if(w.length>0)return w}return[]},"candidates"),$=E(g),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===g);return $.length===0&&P.length===1&&($=E(P[0].qualifiedName)),$.length===1?$[0].node.properties:null},"viewProperties"),u=l((g,S,E)=>{let $=n.resolve(g,E);o.has(g)||r.has(g)||$.declaration?.kind===H.Event||$.candidates.some(A=>A.kind===H.Event)||e.warning(c.UnknownEvent,`Unknown event '${g}' - declare it with 'event ${g}'`,S)},"unknownEvent"),y=l((g,S)=>{for(let E of g)(E.kind==="RemoveWithSyntax"||E.kind==="RemoveViaJoinSyntax")&&u(E.event,E.location,S),"blocks"in E&&y(E.blocks,S)},"removals"),h=new Set,x=l((g,S,E=!1,$=!1)=>{let P=l((v,k)=>{let C=d(S,v),b=JSON.stringify([k.path,k.line,k.column]);return C.missing&&!h.has(b)&&(h.add(b),e.warning(c.UnknownReadModelProperty,`Projection target '${v}' is not a declared ${E?"element":"read-model"} property`,k)),C.value},"validate"),A=$||g.some(v=>v.kind==="FromSyntax"||v.kind==="JoinSyntax"||v.kind==="AllSyntax");for(let v of g){let k=v.kind==="EverySyntax"&&!A?[]:"mappings"in v?v.mappings:v.kind==="JoinSyntax"?v.events.flatMap(C=>C.mappings):[];for(let C of k)P(C.property,C.location);if(v.kind==="ChildrenSyntax"||v.kind==="NestedSyntax"){let C=P(v.property,v.location);x(v.blocks,C===null?null:s.get(C.type.name)?.properties??null,!0)}}},"walk");for(let{slice:g}of i){for(let S of g.projections)y(S.blocks,g);for(let S of g.captures)for(let E of[...S.appends,...S.children.flatMap($=>$.appends),...S.nested.flatMap($=>$.appends)])u(E.event,E.location,g)}for(let{slice:g,scope:S}of i)for(let E of g.projections){let $=E.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");$.length===0&&x(E.blocks,m(E.readModel??E.name,S));for(let P of $){let A=m(P.name,S);x(E.blocks.filter(k=>k.kind==="ChildrenSyntax"||k.kind==="NestedSyntax"),A);let v=P.entersOn.length>0||E.blocks.some(k=>k.kind==="FromSyntax"||k.kind==="JoinSyntax"||k.kind==="AllSyntax");x(P.blocks,A,!1,v)}}}l(Di,"validateProjectionTargets");function Mi(t,e){let n=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="pii")).map(u=>u.name)),i=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="sensitive")).map(u=>u.name)),r=ne(t.types),o=new re(t),s=new Set(t.imports.map(u=>u.qualifiedName.split(".").at(-1))),a=new Map;for(let u of t.declaredTriggers??[]){let y=a.get(u.name)??[];y.push(u.data),a.set(u.name,y)}let d=l((u,y,h="an event source identifier")=>{if(n.has(u.name)||i.has(u.name)){let x=n.has(u.name)?"pii":"secret";e.error(c.PiiNotSupportedOnIdentifier,`Concept '${u.name}' is ${x} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${x} value as a property`,y)}},"validate"),p=l((u,y)=>{let[h,...x]=y.split("."),g=u.filter(E=>E.name===h);if(g.length!==1)return null;let S=g[0];return x.length===0?S:p(r.get(S.type.name)?.properties??[],x.join("."))},"property");for(let u of t.eventSources??[]){u.identifier!=null&&d(u.identifier,u.identifier.location);for(let y of u.streams){y.streamId!==null&&d(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)d(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Re(t);for(let{slice:u}of o.slices){for(let y of u.commands){for(let h of y.properties.filter(x=>x.isIdentifier))d(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(x=>x.propertyCandidate===null)){let x=m.resolve(h.eventSource,h.stream),g=x.kind===pe.Unique?x.streams[0]:void 0,S=[...h.streamId===null?[]:[{mapping:h.streamId,target:g?.streamId}],...h.streamIdParts.map(E=>({mapping:E,target:g?.streamIdParts.find($=>$.name===E.property)?.type}))];for(let{mapping:E,target:$}of S){if(E.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,E.source.path);P!==null&&(P.type.name===$?.name&&(n.has(P.type.name)||i.has(P.type.name))||d(P.type,E.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(x=>o.isEventProduction(x,u))){if(h.for?.kind!=="PathExpressionSyntax")continue;let x=p(y.properties,h.for.path);x!==null&&!x.isIdentifier&&d(x.type,h.for.location)}}for(let y of u.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let x=o.resolve(y.source.name,u).declaration?.node,g=(ve(y).data??[]).flatMap(E=>E.type===null?[]:[{kind:"PropertySyntax",name:E.name,type:E.type,isIdentifier:!1,location:E.location}]),S=[x?.kind==="EventSyntax"?x.properties:[],g];x?.kind!=="EventSyntax"&&!s.has(y.source.name)&&S.push(...a.get(y.source.name)??[]);for(let E of y.produces.filter($=>o.isEventProduction($,u))){if(E.for?.kind!=="PathExpressionSyntax")continue;let $=E.for.path,P=S.map(A=>p(A,$)).find(A=>A!==null&&(n.has(A.type.name)||i.has(A.type.name)));P!=null&&d(P.type,E.for.location)}}}}l(Mi,"validateIdentifierCompliance");function ji(t,e){let n=l((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(c.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(c.ReadModelSubjectNotSupported,"Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.",o.location);for(let r of le(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(c.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(c.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(c.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let d=t.concepts.filter(m=>m.name===a.name);d.some(m=>m.attributes.some(u=>["pii","sensitive"].includes(u.name)))&&e.error(c.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let p=d.length===1?d[0].type:d.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;d.length===0&&p===null&&t.imports.some(m=>m.qualifiedName===a.name||m.qualifiedName.split(".").at(-1)===a.name)&&e.warning(c.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(d.some(m=>m.type==="Enum")||p!==null&&!fo(a,t))&&e.error(c.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}l(ji,"validateEventSubjects");var Li=class extends Ye{static{l(this,"RefusalValueWalker")}declarations;context;slice=null;branch=null;properties=null;target=null;mapping=!1;constructor(e,n){super(),this.declarations=e,this.context=n}visitSlice(e){this.slice=e,super.visitSlice(e),this.slice=null}visitInvocationRefusal(e){this.branch=e,super.visitInvocationRefusal(e),this.branch=null}visitProduces(e){if(this.branch===null||this.slice===null){super.visitProduces(e);return}this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.when!=null&&this.visitCondition(e.when),e.tags.forEach(n=>this.visitTag(n)),this.properties=this.declarations.event(e.event,this.slice)?.properties??null,e.mappings.forEach(n=>this.visitPropertyMapping(n)),this.properties=null}visitPropertyMapping(e){this.mapping=this.branch!==null,this.target=this.declarations.property(this.properties,e.property)?.type??null,super.visitPropertyMapping(e),this.target=null,this.mapping=!1}visitObjectMember(e){let n=this.target;this.target=this.declarations.property(n===null?null:this.declarations.types.get(n.name)?.properties??null,e.name)?.type??null,super.visitObjectMember(e),this.target=n}visitExpression(e){e.kind==="RefusalExpressionSyntax"&&(!this.mapping||this.branch===null||!["reason","constraint","message"].includes(e.member)||e.member==="constraint"&&this.branch.selector!=="constraint"?this.context.error(c.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(c.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 Om(){return!0}l(Om,"invocationHasNoDeclaredIdentity");function Im(t){let e=new Set,n=l((i,r)=>{let o=r||i.authorize!==null;o&&i.slices.forEach(s=>e.add(s)),i.features.forEach(s=>n(s,o))},"collect");return t.modules.forEach(i=>i.features.forEach(r=>n(r,i.authorize!==null))),e}l(Im,"authorizationGatedSlices");function Ni(t,e){let n=new Ke(Ve(t));new Li(n,e).visitApplication(n.application);let i=Im(n.application);for(let{slice:r}of n.slices){let o=l(d=>n.resolve(d,r,p=>p.constraints),"constraintOf"),s=l((d,p)=>d===p||o(d)!==null&&o(d)?.node===o(p)?.node,"sameConstraint"),a=l((d,p)=>d.selector==="any"&&["any","validation","constraint"].includes(p.selector)||d.selector===p.selector&&(d.selector!=="constraint"||d.constraint===null||p.constraint!==null&&s(d.constraint,p.constraint)),"covers");for(let d of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(d.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),u=[];for(let y of d.onRefused??[]){if(u.some(E=>a(E,y))&&e.warning(c.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",y.location),u.push(y),y.selector==="authorization"&&Om()&&m&&e.warning(c.AuthorizationRefusalWithoutIdentity,`Command '${d.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(c.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${y.constraint}'.`,y.location);continue}if(p===null||p.node.handler!==null)continue;let x=[h.node,...h.node.additionalRules];if(x.some(E=>E.kind==="FileConstraintSyntax"))continue;let g=x.map(E=>E.kind==="FileConstraintSyntax"?null:n.event(E.event,h.slice)),S=p.node.produces.map(E=>n.event(E.event,p.slice));g.every(E=>E!==null)&&S.every(E=>E!==null)&&!g.some(E=>S.includes(E))&&e.warning(c.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${d.command}'.`,y.location)}}}}l(Ni,"validateReactionRefusals");function qi(t,e,n){let i=e===null||e.isCollection?void 0:n.concepts.get(e.name),r=i!==void 0&&i.type==="Enum"?i:null,o=l(a=>r!==null&&a.startsWith(`${r.name}.`)?a.substring(r.name.length+1):a,"member");if(e?.isCollection&&t.kind==="ListExpressionSyntax"&&n.compatible({...e,isCollection:!1},{...e,isCollection:!1})===!0){let a=t.items.map(d=>qi(d,{...e,isCollection:!1,isOptional:!1},n));return a.some(d=>d===void 0)?void 0:{canonical:`[${a.map(Bi).join(",")}]`}}let s=e===null?void 0:n.types.get(e.name)?.properties;if(e!==null&&!e.isCollection&&t.kind==="ObjectExpressionSyntax"&&s!==void 0){let a=t.members.map(d=>{let p=n.property(s,d.name);return{name:d.name,value:p===null?void 0:qi(d.value,p.type,n)}});return a.some(d=>d.value===void 0)?void 0:{canonical:`{${a.sort((d,p)=>d.name<p.name?-1:d.name>p.name?1:0).map(d=>`${JSON.stringify(d.name)}:${Bi(d.value)}`).join(",")}}`}}if(t.kind==="LiteralExpressionSyntax")return r!==null&&typeof t.value=="string"?o(t.value):t.value;if(t.kind==="PathExpressionSyntax"&&r!==null)return o(t.path)}l(qi,"redeliveryValue");function Bi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:yr(t):JSON.stringify(t)}l(Bi,"canonical");function mo(t,e,n,i){let r=qi(t,n,i),o=qi(e,n,i);return r===void 0||o===void 0?null:Bi(r)===Bi(o)}l(mo,"sameRedeliveryValue");function Yi(t,e){t=Ve(t);let n=new Ke(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(c.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let d=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Tm(m,o,s,n,t)),p=d.filter(m=>m===!0).length;d.some(m=>m===null)?e.error(c.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(c.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}l(Yi,"validateSpecificationRedelivery");function Tm(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:mo(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(d=>d.property===s.property);o.push(a.length===1?mo(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(Ws(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}l(Tm,"matches");var Qs=64;function Gs(t,e){let n=[];for(let i of t.alternatives){let r=yo(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(c.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}l(Gs,"validateGuardedActionShadowing");function yo(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=yo(t.left),n=yo(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>Qs?null:[...e,...n]:e.length*n.length>Qs?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}l(yo,"normalize");var Rm=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Fi(t,e){let n=new Ke(t);for(let{slice:i}of n.slices)for(let r of i.screens)ho(r.directives,[],i,n,e)}l(Fi,"validateGuardedActions");function ho(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":Dm(a,s,n,i,r);break;case"ScreenSectionSyntax":ho(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let d of a.slots)ho(d.directives,s,n,i,r);break}}l(ho,"validateContainer");function Zs(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}l(Zs,"viewProperties");function Dm(t,e,n,i,r){let o=e.length===1?Zs(e[0].type.name,n,i):null;e.length!==1&&r.warning(c.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 So(s.condition))Ks(a.left,a.location,o,n,i,r);_s(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&_s(t.otherwise.command,t.otherwise.arguments,o,n,i,r),Gs(t,r)}l(Dm,"validateAction");function _s(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let d=s?.properties.filter(m=>m.name===a.name);d?.length===0&&o.warning(c.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=Ks(a.binding,a.location,n,i,r,o,!0);d?.length===1&&p!==null&&d[0].type.isCollection!==p.type.isCollection&&o.warning(c.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}l(_s,"validateArguments");function Ks(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[d,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||d<a.length-1))return o.warning(c.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(d===a.length-1)return m[0];let u=m[0].type;if(n=r.types.get(u.name)?.properties??Zs(u.name,i,r),n===null)return(Rm.has(u.name)||r.application.concepts.some(y=>y.name===u.name)&&!r.application.types.some(y=>y.name===u.name))&&o.warning(c.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}l(Ks,"validateItemPath");function So(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...So(t.left),...So(t.right)]}l(So,"comparisons");function Ui(t,e){let n=t.personas.map(r=>r.name),i=l(r=>{for(let o of r){i(o.features);for(let s of o.slices)for(let a of s.specifications){let d=a.givenCallerPersona;if(d!=null){let p=n.filter(m=>m===d.name).length;p!==1&&e.error(c.InvalidSpecificationCallerPersona,`${p===0?"Unknown":"Ambiguous"} persona '${d.name}' - declared personas: ${n.join(", ")}.`,d.location)}}}},"visit");for(let r of t.modules)i(r.features)}l(Ui,"validatePersonaCallers");function Wi(t,e){let n=new Set;for(let o of t.purposes??[])n.has(o.name)&&e.error(c.DuplicatePurposeDeclaration,`Duplicate purpose '${o.name}' - a purpose is declared once`,o.location),n.add(o.name);for(let o of t.purposes??[])o.interest!==null&&o.basis!=="legitimateInterests"?e.warning(c.PurposeInterestMismatch,`Purpose '${o.name}' declares an interest without basis legitimateInterests`,o.location):o.basis==="legitimateInterests"&&!o.interest?.trim()&&e.warning(c.PurposeInterestMismatch,`Purpose '${o.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`,o.location);let i=[],r=l(o=>{i.push(...o.purposes??[],...o.slices.flatMap(s=>s.purposes??[])),o.features.forEach(r)},"collect");for(let o of t.modules)i.push(...o.purposes??[]),o.features.forEach(r);for(let o of i)n.has(o.name)||e.warning(c.UnknownPurpose,`Unknown purpose '${o.name}' - declare it with 'purpose ${o.name}'`,o.location)}l(Wi,"validatePurposes");function At(t){return Array.from(t,e=>{if(e==="\u0131"||e==="\u017F")return e;let n=e.codePointAt(0);if(n>=8064&&n<=8071||n>=8080&&n<=8087||n>=8096&&n<=8103)return String.fromCodePoint(n+8);if(n===8115)return"\u1FBC";if(n===8131)return"\u1FCC";if(n===8179)return"\u1FFC";let i=e.toUpperCase();return Array.from(i).length===1?i:e}).join("")}l(At,"ordinalIgnoreCaseKey");function go(t){let e=En(t),n=l((h,x)=>h.map(g=>({syntax:g,rank:e.get(Ge([...x,g.name]))??Number.MAX_SAFE_INTEGER})).sort((g,S)=>g.rank-S.rank).map(g=>g.syntax),"ordered"),i=[],r=l((h,x)=>{let g=[...x,h.name];for(let S of n(h.slices,g))i.push({syntax:S,scope:[...g,S.name],identity:[...g.map(E=>`container:${E}`),`slice:${S.name}`],index:i.length});for(let S of n(h.features,g))r(S,g)},"feature");for(let h of n(t.modules,[]))for(let x of n(h.features,[h.name]))r(x,[h.name]);let o=new Map(i.map(h=>[h,new Set([...le(h.syntax).map(x=>At(x.name)),...h.syntax.commands.flatMap(x=>x.produces.map(g=>At(g.event))),...h.syntax.reactions.flatMap(x=>x.triggers.flatMap(g=>g.produces.map(S=>At(S.event))))])])),s=new Map;for(let h of i)for(let x of le(h.syntax)){let g=At(x.name);s.has(g)||s.set(g,h)}let a=new Map;for(let h of i){let x=Ge(h.scope);a.has(x)||a.set(x,h)}let d=new Map;for(let h of _t.for(t,e).edges.filter(x=>x.kind==="decidesFrom"))for(let x of h.evidence){let g=Ge([...h.consumer.scope,x.name.toLowerCase()]);d.has(g)||d.set(g,a.get(Ge(h.producer.scope)))}let p=[];for(let h of i){let x=new Set,g=vi(h.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location,readModel:S.targetKind==="ReadModel"}));for(let S of g){let E=At(S.event),$=`${S.readModel?"ReadModel":"Event"}:${E}`;if(x.has($))continue;x.add($);let P=S.readModel?d.get(Ge([...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 v=h.identity.slice(0,A+1),k=new Set(i.filter(C=>v.every((b,w)=>C.identity[w]===b)).flatMap(C=>[...o.get(C)]));if($s(P.syntax,S.event).some(C=>C.timeline&&C.kind==="usesFactsFrom"&&C.targetKind==="Event"&&k.has(At(C.name))))continue}p.push({...S,consumer:h,producer:P,container:Ge(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let m=l((h,x)=>h.consumer.index-x.consumer.index||h.location.line-x.location.line||h.location.column-x.location.column,"compare"),u=new Set,y=[];for(let h of new Set(p.map(x=>x.container))){let x=p.filter(S=>S.container===h),g=new Map;for(let S of x)g.has(S.left)||g.set(S.left,new Set),g.has(S.right)||g.set(S.right,new Set),g.get(S.left).add(S.right);for(let S of Pn(g).filter(E=>E.length>1)){let E=new Set(S),$=x.filter(v=>E.has(v.left)&&E.has(v.right));$.forEach(v=>u.add(v));let P=$.filter(v=>v.consumer.index<v.producer.index).sort(m)[0];if(P===void 0)continue;let A=l(v=>Math.min(...$.flatMap(k=>[k.consumer,k.producer]).filter(k=>{let C=JSON.parse(h);return k.identity[C.length]===v}).map(k=>k.index)),"memberIndex");S.sort((v,k)=>A(v)-A(k)),y.push({edge:P,diagnostic:{severity:"information",code:c.TimelineCycleGroup,message:`Timeline group ${S.map(v=>`${v.startsWith("slice:")?"slice":h===Ge([])?"module":"feature"} '${v.slice(v.indexOf(":")+1)}'`).join(", ")} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:P.location}})}}for(let h of p){if(h.consumer.index>=h.producer.index||u.has(h))continue;let x=h.consumer.scope.slice(0,-1),S=h.producer.scope.length>h.consumer.scope.length&&x.every(($,P)=>h.producer.scope[P]===$)?" 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:c.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${E} slice '${h.producer.syntax.name}' drawn after it.${S}`,location:h.location}})}return y.sort((h,x)=>m(h.edge,x.edge)).map(h=>h.diagnostic)}l(go,"timelineOrderDiagnostics");function He(t,e,n=Et,i=!0,r,o){let s=It(t,!1,e),a=ki(s,e,o);a.scope=n,a.streamCandidates=r??Jt.capture([s],n,o);let d=Ai(a,s,n);if(i){Wi(d,a),Ci(d,a),Jn(d,a),Ei(d,a),bi(d,a),Zn(d,a);let p=Ve(d);Gn(p,a),Ri(d,a),Di(d,a),Mi(p,a),ji(d,a),Ni(d,a),Yi(d,a),Fi(d,a),Ui(d,a),d=Xn(d,a),Kt.validate(d,a);for(let m of Kn(d))a.information(m.code,m.message,m.location);for(let m of go(d))a.information(m.code,m.message,m.location)}return{value:d,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}l(He,"parseForAuthoring");function qO(t){return t===c.LegacyOptionalSuffix||t===c.LegacyComplianceMarker||t===c.RedundantEventId||t===c.PublicTranslationRequiresDirection}l(qO,"isQuickFixDiagnostic");function vo(t,e){return e.code!==c.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}l(vo,"legacyOptionalTypeLength");function BO(t,e={}){let n=He(t,void 0,e.placement),i=new Set(Array.from({length:14},(v,k)=>`PLAY0${607+k}`)),r=l(v=>v.success||v.diagnostics.every(k=>k.severity!=="error"||i.has(k.code)),"acceptable"),o=l(v=>new Set(v.diagnostics.filter(k=>k.severity==="error").map(k=>k.code)),"errorCodes");if(!r(n))return()=>[];let s=It(t),a=new Map,d=new Map;new class extends Ye{visitEvent(v){a.set(v.location.line,v)}visitSlice(v){d.set(v.location.line,v),super.visitSlice(v)}}().visitApplication(n.value);let m=new Map,u=new Map,y=new Map,h;for(let v of s)h=a.get(v.number)??h,h!==void 0&&y.set(v.number,h);for(let v of n.diagnostics){m.set(v.code,(m.get(v.code)??0)+1);let k=s[v.location.line-1],C=vo(k.raw,v);if(C>0)u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:k.startOffset+v.location.column+C-2,length:1,text:" optional"}]}});else if(v.code===c.LegacyComplianceMarker){let b=Mm(k.raw,k.startOffset);b!==void 0&&u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[b]}})}else if(v.code===c.PublicTranslationRequiresDirection){let b=d.get(k.number),w=/^\s*/.exec(k.raw)[0],T=t.includes(`\r
|
|
13
|
+
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${ft}`}],jh=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${ft}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${ft}`}],Lh=[{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."}],Nh=[{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. ${ft}`},{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."}],Fo={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. ${ft}`},{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."}]},Dl=[{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:Oe("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],qh=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...Dl.filter(t=>t.label!=="hint")],Bh=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:Oe("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],Yh=[{label:"description",insertText:'description "${1:authorization intent}"',documentation:"Report-only description; does not supply an implementation."},{label:"require authenticated",insertText:"require authenticated",documentation:"Requires an authenticated caller."},{label:"require role",insertText:'require role "${1:role}"',documentation:"Requires the caller to have a role."},{label:"require not role",insertText:'require not role "${1:role}"',documentation:"Excludes callers with a role. Add authenticated to require a signed-in caller."},{label:"require not claim",insertText:'require not claim "${1:claim}" matches ${2:subject}',documentation:"Requires that no claim value matches the subject or a value."},{label:"require claim",insertText:'require claim "${1:claim}" matches ${2:subject}',documentation:"Requires a claim to match the subject or a value."},{label:"csharp",insertText:Oe("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],Fh=[{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."}],Uh=[{label:"description",insertText:'description "${1:screen intent}"',documentation:"Report-only description, not a localizable screen title."},{label:"data",insertText:"data ${1:ReadModel} via query ${2:QueryName}",documentation:"Binds a read model to the screen through a query."},{label:"action",insertText:"action ${1:CommandName}",documentation:"Makes a command available as an action on the screen."},{label:'action "\u2026"',insertText:'action "${1:Label}"\n when item.${2:status} == "${3:open}" execute ${4:CommandName}\n otherwise hidden',documentation:"One labeled button selecting the first matching command; hidden without a subject or match."},{label:"layout",insertText:"layout ${1:LayoutName}",documentation:"Uses a layout template and fills its slots."},{label:"section",insertText:"section ${1:name}",documentation:"A named structural section of the screen."},{label:"table",insertText:'table ${1:name}\n column ${2:property} label "${3:text}"',documentation:"A table widget over a read model or collection."},{label:"summary",insertText:'summary ${1:ReadModel}\n field ${2:property} label "${3:text}"',documentation:"A summary widget showing labeled fields."},{label:"title",insertText:'title "${1:text}"',documentation:"The title of the screen or section."},{label:"file",insertText:"file ${1:Path}",documentation:"Full external implementation \u2014 Stage uses the referenced file."},{label:"react",insertText:Oe("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:Oe("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:Oe("html"),documentation:"Inline static HTML."}],Ml=[{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."}],Wh=[{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."},...Ml.filter(t=>t.label!=="label")],jl=[{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."}],Vh=[{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."},...jl],zh=[{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."}],Qh=[{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."}],Gh=[...kt.map(t=>({label:`$identity.${t}${t==="claims"?".":""}`,insertText:`$identity.${t}${t==="claims"?".${1:name}":""}`,documentation:`The caller's ${t}, equivalent to $context.identity.${t}.`})),{label:"$context.occurred",insertText:"$context.occurred",documentation:"When the command or query was received."},{label:"$context.tenant",insertText:"$context.tenant",documentation:"The tenant the command or query is executing for."},{label:"$context.command.",insertText:"$context.command.${1:property}",documentation:"A property of the command being handled."},{label:"$context.arguments.",insertText:"$context.arguments.${1:name}",documentation:"An argument of the query being performed."},{label:"$context.causedBy.subject",insertText:"$context.causedBy.subject",documentation:"Subject of the identity that caused the command or query."},{label:"$context.causedBy.name",insertText:"$context.causedBy.name",documentation:"Display name of the identity that caused the command or query."},{label:"$context.causedBy.userName",insertText:"$context.causedBy.userName",documentation:"User name of the identity that caused the command or query."},{label:"$context.causation.type",insertText:"$context.causation.type",documentation:"What caused this \u2014 a command, a reactor, a schedule."},{label:"$context.identity.id",insertText:"$context.identity.id",documentation:"The identifier of the caller from the auth token."},{label:"$context.identity.name",insertText:"$context.identity.name",documentation:"The display name of the caller."},{label:"$context.identity.userName",insertText:"$context.identity.userName",documentation:"The user name of the caller."},{label:"$context.identity.isAuthenticated",insertText:"$context.identity.isAuthenticated",documentation:"Whether the caller is authenticated."},{label:"$context.identity.roles",insertText:"$context.identity.roles",documentation:"The roles the caller holds."},{label:"$context.identity.claims.",insertText:"$context.identity.claims.${1:name}",documentation:"The value of a claim the caller carries."},{label:"$env.",insertText:"$env.${1:VAR_NAME}",documentation:"An environment variable."},...or.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],Ll={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 _h(t){let e=t?Ll[t]:void 0;return e?Yo.filter(n=>n.label==="purpose"||n.label==="example"||n.label==="documentation"||n.label==="public event"||n.label==="event from"||n.label==="direction"&&t==="Translate"||e.includes(n.label)):Yo}l(_h,"sliceItemsFor");var c={CommandProducesPublicEvent:"PLAY0607",PublicEventRequiresOutboundTranslation:"PLAY0608",OutboundPublicEventCount:"PLAY0609",ForeignPublicEventConsumer:"PLAY0610",OutboundTranslationInput:"PLAY0611",InboundTranslationOutput:"PLAY0612",ForeignPublicEventProduced:"PLAY0613",PublicTranslationRequiresDirection:"PLAY0614",TranslationConstructDirection:"PLAY0615",InboundTranslationInput:"PLAY0616",OutboundTranslationOutput:"PLAY0617",EventTargetOutsideOutboundTranslation:"PLAY0618",EventsSourceOutsideInboundTranslation:"PLAY0619",InvalidCaptureEventsSource:"PLAY0620",InvalidExposureDeclaration:"PLAY0621",UnknownExposureOwner:"PLAY0622",ReExposureCycle:"PLAY0623",ReExposureBroken:"PLAY0624",InvalidInstanceContribution:"PLAY0625",UnknownContributionInstance:"PLAY0626",ContributionNotExposed:"PLAY0627",ContributionTypeMismatch:"PLAY0628",UnknownTemplateContentSlot:"PLAY0629",UnknownNavigationOutlet:"PLAY0630",TemplateScopeMismatch:"PLAY0631",IncompatibleComponentPackage:"PLAY0632",LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",InvalidPurposeDeclaration:"PLAY0596",InvalidPurposeVocabulary:"PLAY0597",DuplicatePurposeField:"PLAY0598",DuplicatePurposeDeclaration:"PLAY0599",UnknownPurpose:"PLAY0600",PurposeInterestMismatch:"PLAY0601",PersonalDataWithoutPurpose:"PLAY0602",SpecialDataWithoutCondition:"PLAY0603",CriminalDataWithoutAuthorization:"PLAY0604",PurposeWithoutBasis:"PLAY0605",UnusedPurpose:"PLAY0606",ConflictingScreenDataBinding:"PLAY0530",ScreenDataQueryMismatch:"PLAY0531",ActionWithoutInputSurface:"PLAY0532",CommandWithoutInputSurface:"PLAY0533",ReadModelFieldWithoutOrigin:"PLAY0534",QueryParameterNotHeldByView:"PLAY0535",UnconsumedEvent:"PLAY0536",UnreachableScreen:"PLAY0537",UnknownActionSubjectField:"PLAY0345",UnresolvedActionSubject:"PLAY0346",UnreachableActionAlternative:"PLAY0347",UnknownActionArgumentProperty:"PLAY0348",UnreachableRefusalBranch:"PLAY0540",InvalidRefusalValue:"PLAY0541",UnknownRefusalConstraint:"PLAY0542",UnknownRedeliveryReaction:"PLAY0544",IndeterminateNegatedClaimTarget:"PLAY0546",InvalidRefusalBranch:"PLAY0538",InvalidRefusalBranchBody:"PLAY0539",UnmatchedRedeliveredOccurrence:"PLAY0543",InvalidNoEventsExpectation:"PLAY0545",InvalidProducesDeclaration:"PLAY0042",ProducesWhenWithoutEvent:"PLAY0043",InvalidPropertyMapping:"PLAY0044",DuplicateProducesTarget:"PLAY0193",EventSourceIdInPayload:"PLAY0469",ExplicitProducesTargetsRequired:"PLAY0470",RedundantEventId:"PLAY0471",InvalidEventId:"PLAY0472",InlineEventCollision:"PLAY0473",InlineEventOutsideCommand:"PLAY0474",InlineEventGeneration:"PLAY0475",ReservedProductionMetadata:"PLAY0476",InvalidEventDocumentation:"PLAY0477",OmittedProductionDestination:"PLAY0478",UnknownConstraintProperty:"PLAY0391",UnknownTopLevelConstruct:"PLAY0001",InvalidDomainDeclaration:"PLAY0002",DuplicateDomain:"PLAY0003",DomainNotFirst:"PLAY0004",InvalidImportDeclaration:"PLAY0005",TabIndentation:"PLAY0006",InvalidConceptDeclaration:"PLAY0007",UnknownPrimitiveType:"PLAY0008",InvalidEnumerationValue:"PLAY0009",UnknownConceptDirective:"PLAY0010",ValidateReadAsEnumerationBlock:"PLAY0011",AttributeReasonWithoutAttribute:"PLAY0012",DuplicateAttributeReason:"PLAY0013",InvalidTypeDeclaration:"PLAY0014",TypeWithoutProperties:"PLAY0015",InvalidPropertyDeclaration:"PLAY0016",IdentifierOutsideCommand:"PLAY0017",InvalidEventDeclaration:"PLAY0018",IdentifierOnEventProperty:"PLAY0019",TagPropertyReadAsTag:"PLAY0020",InvalidModuleDeclaration:"PLAY0021",UnknownModuleDirective:"PLAY0022",InvalidFeatureDeclaration:"PLAY0023",UnknownFeatureDirective:"PLAY0024",InvalidSliceDeclaration:"PLAY0027",UnknownSliceType:"PLAY0028",UnknownSliceDirective:"PLAY0029",InvalidPersonaDeclaration:"PLAY0030",InvalidPersonaPolicyReference:"PLAY0031",UnknownPersonaDirective:"PLAY0032",InvalidCommandDeclaration:"PLAY0033",UnknownCommandDirective:"PLAY0034",DuplicateCommandIdentifier:"PLAY0036",InvalidQueryDeclaration:"PLAY0047",UnknownQueryDirective:"PLAY0048",InvalidQueryParameter:"PLAY0049",InvalidProjectionDeclaration:"PLAY0056",EmptyProjection:"PLAY0057",UnknownProjectionDirective:"PLAY0058",FromWithoutEvent:"PLAY0061",InvalidEventReference:"PLAY0062",InvalidJoinDeclaration:"PLAY0063",JoinWithoutEvent:"PLAY0064",InvalidChildrenDeclaration:"PLAY0065",InvalidNestedDeclaration:"PLAY0066",NestedBlockWithoutFrom:"PLAY0067",InvalidRemoveDeclaration:"PLAY0068",UnknownRemoveDirective:"PLAY0069",InvalidClearDeclaration:"PLAY0070",ClearWithOutsideNestedBlock:"PLAY0071",InvalidSpecificationDeclaration:"PLAY0094",UnknownSpecificationDirective:"PLAY0095",InvalidSpecificationWhen:"PLAY0096",DuplicateSpecificationWhen:"PLAY0097",InvalidThenError:"PLAY0098",InvalidReadModelStep:"PLAY0099",InvalidEventStep:"PLAY0100",InvalidSpecificationValue:"PLAY0101",InvalidScreenDeclaration:"PLAY0102",UnknownScreenDirective:"PLAY0103",InvalidDataDirective:"PLAY0104",InvalidActionDirective:"PLAY0105",UnknownActionDirective:"PLAY0106",InvalidNavigation:"PLAY0107",InvalidScreenLayoutSlot:"PLAY0108",InvalidTitleDirective:"PLAY0109",UnknownTableDirective:"PLAY0110",UnknownSummaryDirective:"PLAY0111",AuthorizeWithoutPolicy:"PLAY0122",InvalidPolicyReference:"PLAY0123",InvalidConstraintDeclaration:"PLAY0132",ConstraintWithoutRule:"PLAY0133",InvalidConstraintBody:"PLAY0134",DuplicateConstraintBody:"PLAY0135",InvalidReactionDeclaration:"PLAY0136",InvalidReactionTrigger:"PLAY0137",ReactionWithoutTrigger:"PLAY0138",InvalidValidateDeclaration:"PLAY0140",InvalidValidationRule:"PLAY0141",InvalidRuleName:"PLAY0143",UnknownRuleImplementationDirective:"PLAY0144",InvalidDescription:"PLAY0145",EmptyDescription:"PLAY0146",DuplicateDescription:"PLAY0147",TagWithoutValue:"PLAY0148",InvalidTagValue:"PLAY0149",UnknownContextPath:"PLAY0153",UnknownContextCausedByProperty:"PLAY0154",UnknownContextIdentityProperty:"PLAY0155",ExpectedCodeFence:"PLAY0163",UnclosedCodeBlock:"PLAY0164",DuplicateDeclaration:"PLAY0168",RepeatedSingularDeclarationAcrossFiles:"PLAY0172",RepeatedDeclarationAcrossFiles:"PLAY0173",ConflictingDescriptionAcrossFiles:"PLAY0174",UnexpectedTokenInAuthorize:"PLAY0184",UnclosedAuthorizeGroup:"PLAY0185",InvalidReadModelDeclaration:"PLAY0186",InvalidInvokesDeclaration:"PLAY0194",InvalidScopeDeclaration:"PLAY0199",DuplicateScope:"PLAY0200",InvalidIntervalTrigger:"PLAY0249",InvalidScheduleTrigger:"PLAY0250",DuplicateReactionTrigger:"PLAY0253",InvalidSpecificationEventSource:"PLAY0275",DuplicateSpecificationEventSource:"PLAY0276",InvalidProjectionVariantDeclaration:"PLAY0277",InvalidEntersOnDeclaration:"PLAY0279",NestedProjectionVariantNotAllowed:"PLAY0280",InvalidStructuredValue:"PLAY0291",DuplicateStructuredValueMember:"PLAY0294",ConflictingSpecificationActions:"PLAY0358",InvalidSpecificationEventOrder:"PLAY0359",InvalidValidationSeverity:"PLAY0368",VariantRequiresEnteringEvent:"PLAY0382",DuplicateProjectionVariant:"PLAY0384",DuplicateVariantEnteringEvent:"PLAY0385",InvalidSpecificationDenied:"PLAY0388",DuplicateAuthorizationAcrossFiles:"PLAY0394",FileConstraintOnlySupportsUniqueness:"PLAY0396",LegacyInlineCodeFence:"PLAY0397",InvalidEventGeneration:"PLAY0446",InvalidFileImport:"PLAY0454",FileImportMatchesNothing:"PLAY0455",ImportedFileNotFound:"PLAY0456",ConflictingImportPlacement:"PLAY0457",ImportCycle:"PLAY0458",ModuleInPlacedFile:"PLAY0459",UnexpectedInPlacedFile:"PLAY0460",InvalidSpecificationClock:"PLAY0461",InvalidSpecificationTrigger:"PLAY0462",InvalidSpecificationCapture:"PLAY0463",InvalidSpecificationQueryAction:"PLAY0464",InvalidSpecificationQuery:"PLAY0265",UnknownSpecificationQueryDirective:"PLAY0266",DuplicateSpecificationQueryArguments:"PLAY0267",InvalidAbsentReadModelStep:"PLAY0453",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",InvalidSpecificationCaller:"PLAY0386",DuplicateSpecificationCallerOrDenied:"PLAY0387",GeneratedPropertyOutsideCommand:"PLAY0482",InvalidGeneratedType:"PLAY0483",InvalidGeneratedModifierOrder:"PLAY0484",DuplicateEventSubject:"PLAY0590",InvalidSubjectType:"PLAY0591",ProtectedSubjectType:"PLAY0592",InvalidSubjectOwner:"PLAY0593",ReadModelSubjectNotSupported:"PLAY0594",InvalidSubjectModifierOrder:"PLAY0595",GeneratedPropertySuppliedAsInput:"PLAY0485",InvalidCommandResponse:"PLAY0486",InvalidResponseSource:"PLAY0487",DuplicateResponseField:"PLAY0488",InvalidResponseShape:"PLAY0489",InvalidGeneratedFixture:"PLAY0490",InvalidReturnExpectation:"PLAY0491",InvalidImplementationBlock:"PLAY0492",InvalidImplementationHint:"PLAY0493",ConflictingImplementationSources:"PLAY0494",UnknownType:"PLAY0165",InvalidSystemDeclaration:"PLAY0495",InvalidOperationDeclaration:"PLAY0496",InvalidProductionReference:"PLAY0497",ProductionDeclarationCollision:"PLAY0498",OperationOutsideCommand:"PLAY0499",InvalidSystemReference:"PLAY0500",InvalidOperationMapping:"PLAY0501",InvalidOperationSpecification:"PLAY0502",InvalidCaptureDeclaration:"PLAY0078",UnknownCaptureDirective:"PLAY0079",InvalidMapEntry:"PLAY0080",InvalidTranslation:"PLAY0081",InvalidSplitDeclaration:"PLAY0082",InvalidSplitTarget:"PLAY0083",InvalidAppendDeclaration:"PLAY0084",UnknownAppendDirective:"PLAY0085",WhenWithoutTrigger:"PLAY0086",InvalidWhenClause:"PLAY0087",InvalidWhenTransitionClause:"PLAY0088",MixedWhenCombinators:"PLAY0089",WhenCombinatorWithoutProperty:"PLAY0090",UnknownCaptureBlockDirective:"PLAY0091",InvalidCompositeKeyPart:"PLAY0072",TemplateInCompositeKey:"PLAY0073",EmptyCompositeKey:"PLAY0074",InvalidProjectionMapping:"PLAY0075",ExpectedLiteralValue:"PLAY0150",InvalidExpression:"PLAY0152",UnterminatedInterpolation:"PLAY0157",UnterminatedTemplateExpression:"PLAY0156",ProjectionDocumentWithoutProjection:"PLAY0055",CaptureDocumentWithoutCapture:"PLAY0077",SpecificationDocumentWithoutSpecification:"PLAY0093",InvalidSeedDeclaration:"PLAY0128",InvalidSeedGroup:"PLAY0129",InvalidSeedEvent:"PLAY0130",InvalidSeedPropertyAssignment:"PLAY0131",InvalidPolicyDeclaration:"PLAY0112",UnknownPolicyDirective:"PLAY0113",PolicyWithoutRequirement:"PLAY0114",ExpectedRoleName:"PLAY0118",ExpectedClaimName:"PLAY0119",ExpectedClaimMatches:"PLAY0120",ExpectedClaimMatchTarget:"PLAY0121",MixedPolicyImplementation:"PLAY0440",RepeatedPolicyRequirement:"PLAY0441",UnexpectedTokenInPolicyCondition:"PLAY0115",ExpectedPolicyCondition:"PLAY0116",UnclosedPolicyConditionGroup:"PLAY0117",UnexpectedTokenInCondition:"PLAY0158",ExpectedCondition:"PLAY0159",ExpectedComparisonOperator:"PLAY0161",ExpectedComparisonValue:"PLAY0162",InvalidActionAlternative:"PLAY0341",GuardedActionWithoutAlternatives:"PLAY0342",MisplacedActionOtherwise:"PLAY0343",UnsupportedActionConditionOperand:"PLAY0344",InvalidInteractionArgument:"PLAY0319",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",InvalidSpecificationExample:"PLAY0518",DuplicateSpecificationAssignment:"PLAY0519",UnresolvedSpecificationExampleType:"PLAY0520",SpecificationExampleNameCollision:"PLAY0521",SpecificationExampleKindMismatch:"PLAY0522",InvalidSpecificationExampleValue:"PLAY0523",MissingSpecificationProperty:"PLAY0524",UnadmittedSpecificationExampleValue:"PLAY0525",InvalidSpecificationExampleBody:"PLAY0526",AmbiguousReference:"PLAY0198",InvalidSpecificationStream:"PLAY0547",SpecificationStreamOnCommand:"PLAY0548",InvalidSpecificationStreamRoute:"PLAY0549",InvalidSpecificationStreamEventSource:"PLAY0550",SpecificationStreamContradictsCommand:"PLAY0551",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",UndeclaredDependency:"PLAY0552",UnusedDependencyDeclaration:"PLAY0553",MutualDependencyDeclarations:"PLAY0556",AuthorizationRefusalWithoutIdentity:"PLAY0557",InvalidDocumentation:"PLAY0558",ConflictingDocumentationAcrossFiles:"PLAY0559",InvalidSpecificationCallerPersona:"PLAY0572",UnsynthesizablePersonaCaller:"PLAY0573",PersonaWithoutGate:"PLAY0574",GateWithoutPersona:"PLAY0575",AmbiguousPersonaCaller:"PLAY0576",InvalidSpecificationParameter:"PLAY0577",InvalidSpecificationCase:"PLAY0578",DuplicateSpecificationParameter:"PLAY0579",DuplicateSpecificationCase:"PLAY0580",IncompleteSpecificationTable:"PLAY0581",InvalidSpecificationCaseAssignment:"PLAY0582",InvalidSpecificationCaseValue:"PLAY0583",InvalidSpecificationCaseReference:"PLAY0584",OptionalSpecificationParameterTarget:"PLAY0585",SpecificationCaseNameCollision:"PLAY0586",IncompatibleSpecificationParameterType:"PLAY0587",UnusedSpecificationParameter:"PLAY0588",SingularSpecificationTableExpansion:"PLAY0589",UnsupportedInteractionAlternatives:"PLAY0560",MixedInteractionAlternatives:"PLAY0561",InteractionAlternativeWithoutActions:"PLAY0562",InlineInteractionAlternative:"PLAY0563",LegacyInteractionWhere:"PLAY0564",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",UnknownEvent:"PLAY0166",UnknownReadModelProperty:"PLAY0514",PiiNotSupportedOnIdentifier:"PLAY0515",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};var dr="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",W="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Z(t){let e=`(?=[\\u0000-\\uFFFF])[${dr}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}l(Z,"nativePattern");function O(t){let e="",n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&i+1<t.length){let o=t[i+1];i++,o==="w"?e+=n?dr:`[${dr}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}l(O,"pattern");var Nl=new RegExp(`^depends${W}+on(?:${W}|$)`,"u"),ql=new RegExp(`${W}+$`,"u");function Tt(t,e=!1,n){let i=[],r=0,o=0;for(let s of t.split(`
|
|
14
|
+
`)){r++;let a=s.endsWith("\r")?s.replace(/\r+$/,""):s,d=a.length-a.trimStart().length,p=Bl(a.substring(d),e),m=Nl.test(p)?p.replace(ql,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:d,content:m,startOffset:o}:{number:r,raw:a,indent:d,content:m,path:n,startOffset:o}),o+=s.length+1}return i}l(Tt,"splitLines");function sn(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}l(sn,"commentStart");function Bl(t,e){let n=sn(t,e);return n<0?t:t.substring(0,n)}l(Bl,"stripComment");function le(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}l(le,"eventDeclarations");function Yn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}l(Yn,"operationDeclarations");var H;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(H||(H={}));var re=class{static{l(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e,n){let i=l((r,o)=>{for(let s of r){let a=[...o,s.name];for(let d of s.slices)this.slices.push({slice:d,scope:[...a,d.name]});i(s.features,a)}},"collect");e.modules.forEach(r=>i(r.features,[r.name]));for(let{slice:r,scope:o}of this.slices){this.scopes.set(r,o);let s=new Map;for(let d of le(r)){let p=s.get(d.name)??[];p.push(d),s.set(d.name,p)}let a=[...s.values()].flatMap(d=>new Set(d.map(p=>p.generation)).size!==d.length?d:[d.reduce((p,m)=>p.generation>=m.generation?p:m)]);this.declarations.push(...a.map(d=>({kind:H.Event,name:d.name,node:d,scope:o})),...Yn(r).map(d=>({kind:H.Operation,name:d.name,node:d,scope:o})))}n!==void 0&&this.declarations.splice(0,this.declarations.length,...n);for(let r of this.declarations){let o=this.byName.get(r.name)??[];o.push(r),this.byName.set(r.name,o)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:H.Unresolved,declaration:null,candidates:[]};let r=this.resolutions.get(n)??new Map,o=r.get(e);if(o!==void 0)return o;let s=this.resolveFromScope(e,i);return r.set(e,s),this.resolutions.set(n,r),s}resolveFromScope(e,n){let i=this.candidates(e,n);return i.length===1?{kind:i[0].kind,declaration:i[0],candidates:[]}:{kind:i.length===0?H.Unresolved:H.Ambiguous,declaration:null,candidates:i}}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===H.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==H.Operation&&!(i.kind===H.Ambiguous&&i.candidates.some(r=>r.kind===H.Operation))}candidates(e,n){let i=e.split(".").filter(s=>s.length>0);if(i.length===0)return[];let r=this.byName.get(i.at(-1))??[],o=i.slice(0,-1);if(o.length>0)return r.filter(s=>o.length<=s.scope.length&&o.every((a,d)=>s.scope[s.scope.length-o.length+d]===a));for(let s=n.length;s>=0;s--){let a=r.filter(d=>s<=d.scope.length&&n.slice(0,s).every((p,m)=>d.scope[m]===p));if(a.length>0)return a}return[]}};var pe;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(pe||(pe={}));var Re=class{static{l(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?pe.WrongKind:pe.NotFound:i.length>1||r.length>1?o=pe.Ambiguous:o=r.length===1?pe.Unique:pe.NotFound,{kind:o,sources:i,streams:r}}};function Uo(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}l(Uo,"eventProductions");function pr(t,e){let n=Uo(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}l(pr,"requiresExplicitDestinations");function Wo(t,e,n){let i=Uo(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||pr(t,n))return;if(e.inlineEvent===null)return i.some(o=>o.for!==null||o.inlineEvent!==null)?void 0:"new event source";let r=t.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length===1?r[0].name:void 0}l(Wo,"implicitDestination");var ur="79228162514264337593543950335";function nt(t){let e=Vo(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>ur.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===ur.length&&a>ur)return;let d=Math.max(0,o),p=d===0?a:a.length>d?`${a.substring(0,a.length-d)}.${a.substring(a.length-d)}`:`0.${"0".repeat(d-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}l(nt,"parseExactNumber");function ln(t){return Vo(t)!==void 0}l(ln,"isExactNumberToken");function Vo(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&fr(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&fr(t[i]);)i++;if(i===a)return;o=t.substring(a,i)}let s=0;if(t[i]==="e"||t[i]==="E"){i++;let a=t[i]==="-";(t[i]==="+"||t[i]==="-")&&i++;let d=i,p=t.length+29;for(;i<t.length&&fr(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===d)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}l(Vo,"scan");function fr(t){return t>="0"&&t<="9"}l(fr,"isDigit");var mr=class extends Error{static{l(this,"InvalidExactNumber")}};function yr(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||nt(t.value)?.value!==t.value)throw new mr("Expected a canonical, bounded ExactNumber value.");return t.value}l(yr,"canonicalExactText");function zo(t){return!yr(t).includes(".")}l(zo,"exactIsIntegral");var Yl=/^([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 hr(t,e){let n=(e?Fl:Yl).exec(t);if(n===null||n[0].length!==t.length)return!1;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),a=[31,i%4===0&&(i%100!==0||i%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(i<1||r<1||r>12||o<1||o>a[r-1])return!1;if(!e)return!0;if(Number(n[4])>23||Number(n[5])>59||Number(n[6])>59)return!1;if(n[7]===void 0)return!0;let d=Number(n[7]),p=Number(n[8]);return d<=14&&p<=59&&(d!==14||p===0)}l(hr,"responseDateValue");var Ul="http://schemas.microsoft.com/ws/2008/06/identity/claims/role",Sr=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),mt=l(t=>Array.from(t,e=>{let n=e.toUpperCase();return n.length===e.length&&e!=="\u0131"&&e!=="\u017F"?n:e}).join(""),"claimTypeKey");function dn(t,e){let n=[],i=[],r=l(a=>({caller:null,contributions:n,refusal:a}),"refused");if(t.policies.length===0)return r({policy:null,reason:"noPolicies",location:t.location});for(let a of t.policies){let d=(e.policies??[]).find(m=>m.name===a);if(!d)return r({policy:a,reason:"unresolvedPolicy",location:t.location});if(d.condition===null||d.code!==null||d.file!==null)return r({policy:a,reason:"opaqueImplementation",location:d.location});let p=gr(d.condition);if(p)return r({policy:a,reason:"negation",location:p.location});i.push(d)}for(let a of i){let d=xr(a.condition,a.name,n);if(d)return r(d)}for(let a of i){let d=cn(a.condition,a.name,n);if(d)return r(d)}let o=[...new Set(n.filter(a=>a.kind==="role").map(a=>a.value))].sort(Sr),s=[];for(let a of n.filter(d=>d.kind==="claim"))s.some(d=>mt(d.type)===mt(a.type)&&d.value===a.value)||s.push({kind:"SpecificationCallerClaimSyntax",type:a.type,value:a.value,location:a.location});return s.sort((a,d)=>Sr(mt(a.type),mt(d.type))||Sr(a.value,d.value)),{caller:{kind:"SpecificationCallerSyntax",authenticated:!0,roles:o,claims:s,location:t.location},contributions:n,refusal:null}}l(dn,"synthesizePersonaCaller");function gr(t){return t.kind==="NotPolicyConditionSyntax"?t:t.kind==="LogicalPolicyConditionSyntax"?gr(t.left)??gr(t.right):null}l(gr,"negation");function Qo(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(mt(t.claim)===mt(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}}l(Qo,"atom");function xr(t,e,n){return t.kind!=="LogicalPolicyConditionSyntax"?Qo(t,e,n):t.operator==="Or"?null:xr(t.left,e,n)??xr(t.right,e,n)}l(xr,"required");function Rt(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"&&mt(i.type)===mt(t.claim)&&i.value===n.value)}case"LogicalPolicyConditionSyntax":return t.operator==="And"?Rt(t.left,e)&&Rt(t.right,e):Rt(t.left,e)||Rt(t.right,e);default:return!1}}l(Rt,"satisfied");function cn(t,e,n){if(t.kind!=="LogicalPolicyConditionSyntax")return Rt(t,n)?null:Qo(t,e,n);if(t.operator==="And")return cn(t.left,e,n)??cn(t.right,e,n);if(Rt(t,n))return null;let i=[...n],r=cn(t.left,e,i);if(r===null)return n.push(...i.slice(n.length)),null;let o=[...n];return cn(t.right,e,o)!==null?r:(n.push(...o.slice(n.length)),null)}l(cn,"complete");var vr=new WeakMap;var z='(?:[^"\\\\]|\\\\.)*',Wl={"\\":"\\",'"':'"',n:`
|
|
15
|
+
`,r:"\r",t:" "};function Q(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?Wl[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}l(Q,"unescapeString");var Go=64,De=class extends Error{static{l(this,"InvalidStructuredValue")}},Fn=class{static{l(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,n,i){this.text=e,this.start=n,this.context=i}parse(){let e=this.#t(0);if(this.#n(),this.#e<this.text.length)throw new De(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#n();let n=this.#a(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Go)throw new De(`The value nests deeper than ${Go} levels.`);return i==="["?this.#s(e,n):this.#i(e,n)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#r(),location:n};for(let[r,o]of[["true",!0],["false",!1],["null",null]])if(this.text.startsWith(r,this.#e))return this.#e+=r.length,{kind:"LiteralExpressionSyntax",value:o,location:n};return this.#l(n)}#s(e,n){this.#e++;let i=[];if(this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#d(",")}}#i(e,n){this.#e++;let i=[],r=new Set;if(this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#n();let o=this.#a();if(this.text[this.#e]!=='"')throw new De("Expected a property name in double quotes.");let s=this.#r();this.#n(),this.#d(":");let a=this.#t(e+1);if(r.has(s)?this.context?.error(c.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,o):(r.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:a,location:o})),this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#d(",")}}#r(){let e=this.#o(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new De(`${n} is not a valid JSON string.`)}}#o(e){for(let n=e+1;n<this.text.length;n++)if(this.text[n]==="\\")n++;else if(this.text[n]==='"')return n+1;throw new De("A string is not closed.")}#l(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new De(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=nt(n[0]);return r===void 0?(this.context.error(c.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 De("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#a(){return{...this.start,column:this.start.column+this.#e}}#n(){for(;this.#e<this.text.length&&`
|
|
16
|
+
\r`.includes(this.text[this.#e]);)this.#e++}#c(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#d(e){if(!this.#c(e))throw new De(`Expected '${e}' at position ${this.#e}.`)}};var Vl=O("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),zl=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Ql=O("^-?\\d+(\\.\\d+)?$"),_o=["command","arguments","tenant","causedBy","causation","occurred","identity"],Zo=["subject","name","userName"],Ko=["id","name","userName","isAuthenticated","roles","claims"];function Me(t,e,n){return ae(t,e,n,!0)}l(Me,"parseModeledMappingSource");function ae(t,e,n,i=!1){if(t=t.trim(),t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),location:e};if(t==="$identity"||t==="$identity.")return n?.error(c.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e};if(t.startsWith("$identity.")){let o=t.substring(10);return Jo(o.split(".")[0],"$identity",e,n),{kind:"IdentityExpressionSyntax",path:o,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 Fn(t,e,n).parse()}catch(o){if(!(o instanceof De))throw o;return n?.error(c.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?pn(t,e):pn(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?zl:Vl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}l(ae,"parseMappingSource");function Gl(t,e,n){let[i,r]=t.split(".");_o.includes(i)?r!==void 0&&i==="causedBy"&&!Zo.includes(r)?n?.warning(c.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Zo.join(", ")}`,e):r!==void 0&&i==="identity"&&Jo(r,"$context.identity",e,n):n?.warning(c.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${_o.join(", ")}`,e)}l(Gl,"warnOnUnknownContextPath");function Jo(t,e,n,i){Ko.includes(t)||i?.warning(c.UnknownContextIdentityProperty,`Unknown ${e} property '${t}' - expected ${Ko.join(", ")}`,n)}l(Jo,"warnOnUnknownIdentityProperty");function pn(t,e,n){let i=l(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(Q(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!ln(t))return;let o=nt(t);return o!==void 0?i(o):(n.error(c.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(Ql.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}l(pn,"parseLiteral");var D=l(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),oe=l(t=>t.replaceAll("@",""),"unescapeIdentifier");function Ho(t,e){let n=[],i=0,r=!1,o=!1;for(let s=0;s<t.length;s++){let a=t[s];a==="\\"&&r&&s+1<t.length?s++:a==='"'&&!o?r=!r:a==="`"&&!r?o=!o:a===e&&!r&&!o&&(n.push(t.substring(i,s)),i=s+1)}return n.push(t.substring(i)),n}l(Ho,"splitTopLevel");var Dt=l((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var $r=l(t=>t.content.length===0,"isBlank"),f=l(t=>Dt(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),Xo=l(t=>Dt(t.number,1,t.path),"startOf");var _l=O("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),ea=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),Zl=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Ze(t){let e=_l.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:oe(e[1]),type:je(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}}l(Ze,"tryParseProperty");function je(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}l(je,"parseTypeRef");function Le(t,e){let n=Ze(e);return n!==void 0?Ve(t,n.type,e):Un(t,e),n}l(Le,"parseProperty");function Ve(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(c.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}l(Ve,"reportLegacyOptionalSuffix");function Un(t,e){let n=ea.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(c.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",f(e)),!0;if(Zl.test(e.content))return t.error(c.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let i=ea.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(c.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}l(Un,"reportInvalidModifierOrder");var br=O("^then\\s+returns\\b"),Wn=O("^generated\\s+(?=\\S)(?![=])"),Vn=O("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Kl=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Jl=O(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`);function Mt(t,e,n,i){if(e.startsWith("case."))return Ie(e,n,t);if(Lt(e)&&t.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",n),(e.startsWith('"')||e.startsWith("'"))&&!Jl.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ae(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}l(Mt,"parseConcrete");function jt(t,e,n,i){let r=n.exec(e.content);if(r===null)return t.error(i,"Expected a named fixture or assertion with exactly one concrete value.",f(e)),t.skipBlock(e.indent),null;let o=f(e),s=Mt(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),a=t.peekChild(e.indent);return a!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}l(jt,"parseConcreteMapping");function ta(t,e){let n=br.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=Mt(t,i,{...r,column:r.column+e.content.indexOf(i,n)},c.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(c.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:r}}let o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=jt(t,s,Kl,c.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}l(ta,"parseReturn");var Hl=new RegExp(O("^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$").source,"du"),Xl=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ec=O("^case\\.([a-z_]\\w*)$");function Lt(t){return/\bcase\.[a-z_]\w*/.test(t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,""))}l(Lt,"containsCaseReference");function Ie(t,e,n,i=!1){if(!t.startsWith("case."))return Lt(t)&&n.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",e),ae(t,e,n,i);let r=ec.exec(t);return r===null&&n.error(c.InvalidSpecificationCaseReference,"A case reference fills a whole value position: 'case.<parameter>'.",e),{kind:"CaseValueExpressionSyntax",parameter:r?.[1]??t.substring(5),location:e}}l(Ie,"parseSpecificationValue");function na(t,e){let n=e.content.indexOf(" ")+1,i=n>0?Le(t,{...e,content:e.content.substring(n),indent:e.indent+n}):void 0;if(i===void 0||i.isGenerated||i.isIdentifier)return t.error(c.InvalidSpecificationParameter,"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.",f(e)),t.skipOpaqueBlock(e.indent),null;let r=t.peekChild(e.indent);return r!==void 0&&(t.error(c.InvalidSpecificationParameter,"A parameter has no body or default.",f(r)),t.skipOpaqueBlock(e.indent)),{kind:"SpecificationParameterSyntax",name:i.name,type:i.type,location:f(e)}}l(na,"parseParameter");function ia(t,e){let n=Hl.exec(e.content);if(n===null)return t.error(c.InvalidSpecificationCase,"Expected 'case <Name>' with at most one inline parameter assignment.",f(e)),t.skipOpaqueBlock(e.indent),null;let i=[],r=l((o,s,a)=>{let d=f(a),p={...d,column:d.column+a.content.indexOf(s,a.content.indexOf("=")+1)};if(s.startsWith("case.")){t.error(c.InvalidSpecificationCaseValue,"A case assigns concrete values, not case references.",p);return}let m=Mt(t,s,p,c.InvalidSpecificationCaseValue);m!==null&&i.push({kind:"PropertyMappingSyntax",property:o,source:m,location:a===e?{...d,column:d.column+n.indices.groups.property[0]}:d})},"add");n.groups?.property!==void 0&&r(n.groups.property,n.groups.value,e);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Xl.exec(o.content);if(s===null){t.error(c.InvalidSpecificationCaseAssignment,"Expected '<parameter> = <concrete value>' in a case.",f(o)),t.skipOpaqueBlock(o.indent);continue}r(s[1],s[2],o);let a=t.peekChild(o.indent);a!==void 0&&(t.error(c.InvalidSpecificationCaseValue,"A case value must fit on one line.",f(a)),t.skipOpaqueBlock(o.indent))}return{kind:"SpecificationCaseSyntax",name:n[1],values:i,location:f(e)}}l(ia,"parseCase");function Nt(t){return Array.isArray(t)?t.flatMap(Nt):t===null||typeof t!="object"?[]:"kind"in t&&t.kind==="CaseValueExpressionSyntax"?[t]:Object.values(t).flatMap(Nt)}l(Nt,"caseReferences");function ra(t,e){let n=t.parameters??[],i=t.cases??[];n.length===0!=(i.length===0)&&e.error(c.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(c.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(c.DuplicateSpecificationCase,`Case '${o.name}' is declared more than once.`,o.location);for(let a of o.values.filter(d=>!n.some(p=>p.name===d.property)))e.error(c.InvalidSpecificationCaseAssignment,`Case '${o.name}' assigns undeclared parameter '${a.property}'.`,a.location);for(let a of n.filter(d=>o.values.filter(p=>p.property===d.name).length!==1))e.error(c.InvalidSpecificationCaseAssignment,`Case '${o.name}' must assign parameter '${a.name}' exactly once.`,o.location)});let r=Nt(t);for(let o of r)(i.length===0||!n.some(s=>s.name===o.parameter))&&e.error(c.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(c.UnusedSpecificationParameter,`Parameter '${o.name}' is never referenced.`,o.location);for(let o of Nt(t.whenRedelivered))e.error(c.InvalidSpecificationCaseReference,"Case references are not permitted in redelivery locators.",o.location)}l(ra,"validateTable");function Ct(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=>Ct(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,Ct(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}l(Ct,"substituteCase");var it=new WeakMap,ve=l(t=>it.get(t)??{},"dependencySourcesOf");function qt(t){let e=[],n=l((a,d)=>{for(let p of a??[])e.push({name:p.name,scope:d,example:p})},"examples"),i=l((a,d)=>{for(let p of a){let m=[...d,p.name];n(p.examples,m);for(let u of p.slices){let y=[...d,p.name,u.name];n(u.examples,y);for(let h of new Set(le(u).map(x=>x.name)))e.push({name:h,scope:y,kind:"event"});for(let h of u.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of u.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(p.features,m)}},"features");n(t.examples,[]);for(let a of[...t.concepts,...t.types])e.push({name:a.name,scope:[],kind:"type"});for(let a of t.modules)n(a.examples,[a.name]),i(a.features,[a.name]);let r=l((a,d)=>{let p=l(y=>{let h=y.split("."),x=e.filter(S=>S.name===h.at(-1)),g=h.slice(0,-1);if(g.length)return x.filter(S=>g.length<=S.scope.length&&g.every((C,$)=>S.scope[S.scope.length-g.length+$]===C));for(let S=d.length;S>=0;S--){let C=x.filter($=>S<=$.scope.length&&d.slice(0,S).every((P,A)=>$.scope[A]===P));if(C.length)return C}return[]},"candidates"),m=p(a),u=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&u.length===1&&(m=p(u[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=l((a,d,p)=>{let m=r(a,p),u=m?.example;if(!u)return null;let y=r(u.type,m.scope);return y?.kind===d?{example:u,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=l((a,d)=>[...a.filter(p=>!d.some(m=>m.property===p.property)),...d],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let d=r(a.example.type,a.scope);return d?.kind===void 0?[]:[{example:a.example,kind:d.kind,name:[...d.scope,d.name].join("."),scope:d.scope}]}),eventStep:l((a,d,p)=>{let m=o(a.eventType,"event",p),u=m?.example??null,y=u?.stream??u?.noStream??null,h=a.stream??a.noStream??null,x=h??y,g=m===null?a:{...a,eventType:m.name,values:s(u.values,a.values),for:a.for??u.for,stream:x?.kind==="SpecificationStreamSyntax"?x:null,noStream:x?.kind==="SpecificationNoStreamSyntax"?x:null},S=g.values.map(C=>{let $=u?.values.find(A=>A.property===C.property),P=a.values.includes(C);return{property:C.property,value:C.source,origin:P?$===void 0?"authored":"override":"example",overriddenValue:P?$?.source??null:null}});return g.for!==null&&S.push({property:"for",value:g.for,origin:a.for===null?"example":u?.for==null?"authored":"override",overriddenValue:a.for===null?null:u?.for??null}),{role:d,authored:a,effective:g,example:u,values:S,route:x===null?null:{value:x,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:l((a,d)=>{if(!a)return a;let p=o(a.commandType,"command",d);if(!p)return a;let{example:m,name:u}=p;return{...a,commandType:u,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:l((a,d)=>{let p=o(a.name,"readmodel",d);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}l(qt,"specificationExamples");function zn(t){return qt(t).command}l(zn,"specificationCommandExamples");function ze(t){return Qn(t).application}l(ze,"expandSpecificationExamples");function Qn(t){let e=qt(t),n=[],i=l((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(d=>{let p=[...o,s.name,d.name],m={...d,specifications:d.specifications.flatMap(u=>{let y=[],h=l(($,P)=>{let A=e.eventStep($,P,p);return y.push(A),A.effective},"event"),x=t.personas.find($=>$.name===u.givenCallerPersona?.name),g=x===void 0?null:dn(x,t),S=g?.caller==null?null:{...g.caller,location:u.givenCallerPersona.location};S!==null&&y.push({role:"given caller",authored:u.givenCallerPersona,effective:S,example:null,route:null,values:g.contributions.map($=>({property:$.type??$.kind,value:{kind:"LiteralExpressionSyntax",value:$.kind==="authenticated"?!0:$.value,location:$.location},origin:"persona",overriddenValue:null,persona:x.name,policy:$.policy}))});let C={...u,...S===null?{}:{givenCaller:S,givenCallerPersona:void 0},given:u.given.map($=>h($,"given")),givenReadModels:u.givenReadModels.map($=>e.readModel($,p)),when:e.command(u.when,p),whenAppended:u.whenAppended===null?null:h(u.whenAppended,"when append"),thenEvents:u.thenEvents.map($=>h($,"then")),thenReadModels:u.thenReadModels.map($=>e.readModel($,p))};return(u.cases?.length??0)===0?(n.push({authored:u,effective:C,steps:y}),[C]):u.cases.map($=>{let P=new WeakMap,A={...Ct(C,$,P),name:`${u.name}_${$.name}`,parameters:[],cases:[]};return vr.set(A,{table:u.name,case:$.name}),n.push({authored:u,effective:A,table:u.name,case:$.name,steps:y.map(v=>({...v,effective:Ct(v.effective,$,P),values:v.values.map(k=>k.value.kind==="CaseValueExpressionSyntax"?{...k,value:Ct(k.value,$,P),origin:"case",caseParameter:k.value.parameter}:k),route:v.route===null?null:{...v.route,value:Ct(v.route.value,$,P)}}))}),A})})};return it.set(m,ve(d)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}l(Qn,"expandEffectiveSpecificationExamples");var Gn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function _n(t,e,n=e.inputUses){let i=zn(t),r=[],o=l((v,k)=>{let E=[...k,v.name];v.slices.forEach(b=>r.push({slice:b,scope:[...E,b.name]})),v.features.forEach(b=>o(b,E))},"collect");t.modules.forEach(v=>v.features.forEach(k=>o(k,[v.name])));let s=new Map,a=new Map,d=new Map;for(let{slice:v,scope:k}of r)for(let E of v.commands){let b=s.get(E.name)??[];b.push({command:E,scope:k}),s.set(E.name,b),a.set(E,ne(E.properties)),E.response?.kind==="RecordCommandResponseSyntax"&&d.set(E,ne(E.response.fields))}let p=new Map;for(let v of t.imports){let k=v.qualifiedName.split(".").at(-1);p.set(k,[...p.get(k)??[],v.qualifiedName])}let m=new Map,u=l((v,k)=>{let E=`${k.join(".")}|${v}`;if(m.has(E))return m.get(E);let b=p.get(v)??[],I=((s.get(v.split(".").at(-1))??[]).length===0&&b.length===1?b[0]:v).split("."),j=s.get(I.at(-1))??[];if(I.length>1){let L=I.slice(0,-1);j=j.filter(q=>L.length<=q.scope.length&&L.every((V,K)=>q.scope[q.scope.length-L.length+K]===V))}else for(let L=k.length;L>=0;L--){let q=j.filter(V=>L<=V.scope.length&&k.slice(0,L).every((K,J)=>V.scope[J]===K));if(q.length>0){j=q;break}}let N=j.length===1?j[0].command:null;return m.set(E,N),N},"resolve"),y=ne(t.concepts),h=new Set(t.concepts.map(v=>v.name)),x=new Map([...ne(t.types)].map(([v,k])=>[v,ne(k.properties)])),g=new Set(r.flatMap(v=>v.slice.readModels.map(k=>k.name))),S=new Set([...a.keys()].flatMap(v=>[...v.properties])),C=l(v=>{for(let k of v)k.isGenerated&&!S.has(k)&&e.error(c.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",k.location)},"checkDeclarations"),$=l(v=>{v.features.forEach($);for(let k of v.slices){for(let E of k.commands)for(let b of E.produces)b.inlineEvent!==null&&C(b.inlineEvent.properties);k.events.forEach(E=>C(E.properties)),k.readModels.forEach(E=>C(E.properties));for(let E of k.reactions)for(let b of E.triggers)for(let w of b.produces)w.inlineEvent!==null&&C(w.inlineEvent.properties)}},"checkFeature");t.types.forEach(v=>C(v.properties)),t.modules.forEach(v=>v.features.forEach($));let P=l((v,k,E)=>{let b=a.get(E).get(v.property);if(b===void 0){e.error(c.InvalidResponseSource,`Response source '${v.property}' must reference one direct command property.`,v.location);return}let w=b.type;(w.isCollection||g.has(w.name))&&e.error(c.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",v.location),k!==null&&(k.name!==w.name||k.isCollection!==w.isCollection||k.isOptional!==w.isOptional)&&e.error(c.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",k.location)},"validateSource");for(let v of a.keys()){for(let E of v.properties){if(!E.isGenerated)continue;let b=y.get(E.type.name);(E.type.isOptional||E.type.isCollection||(b===void 0?Gn.has(E.type.name)||x.has(E.type.name)||h.has(E.type.name)||g.has(E.type.name):b.type!=="Uuid"))&&e.error(c.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",E.location)}let k=v.response;if(k?.kind==="ScalarCommandResponseSyntax")P(k.source,null,v);else if(k?.kind==="RecordCommandResponseSyntax"){k.fields.length===0&&e.error(c.InvalidCommandResponse,"A response block requires at least one field.",k.location);let E=new Set;for(let b of k.fields)E.has(b.name)&&e.error(c.DuplicateResponseField,`Duplicate response field '${b.name}'.`,b.location),E.add(b.name),P(b.source,b.type,v)}}let A=l((v,k)=>{let E=i(v.when,k),b=E===null?null:u(E.commandType,k);if(E!==null&&b!==null){let j=a.get(b);for(let q of E.values)j.get(q.property.split(".")[0])?.isGenerated&&e.error(c.GeneratedPropertySuppliedAsInput,`Generated property '${q.property}' cannot be supplied as request or form input.`,q.location);let N=[...j.values()].filter(q=>q.isIdentifier);if(E.for!==null&&N.length===1&&N[0].isGenerated){let q=N[0].type;(Gn.has(q.name)||y.has(q.name)||x.has(q.name))&&(q.isOptional||q.isCollection||y.get(q.name)?.type!=="Uuid"||E.for.kind!=="LiteralExpressionSyntax"||typeof E.for.value!="string"||!oa(E.for.value))&&e.error(c.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",E.for.location)}let L=new Set;for(let q of E.generatedValues??[]){let V=j.get(q.property);(L.has(q.property)||V===void 0||!V.isGenerated||V.isIdentifier||!ke(q.source,V.type,y,x))&&e.error(c.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",q.location),L.add(q.property)}}let w=v.thenReturns;if(w==null||((E===null||v.thenErrors.length>0||v.thenDenied!=null)&&e.error(c.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",w.location),b===null))return;let T=b.response,I=a.get(b);if(w.kind==="ScalarSpecificationReturnSyntax"&&T?.kind==="ScalarCommandResponseSyntax"&&I.has(T.source.property))ke(w.value,I.get(T.source.property).type,y,x)||e.error(c.InvalidReturnExpectation,"The expected return value must match the response source's type.",w.location);else if(w.kind==="RecordSpecificationReturnSyntax"&&T?.kind==="RecordCommandResponseSyntax"){w.fields.length===0&&e.error(c.InvalidReturnExpectation,"A record return expectation requires at least one field.",w.location);let j=d.get(b),N=new Set;for(let L of w.fields){let q=j.get(L.property),V=q===void 0?void 0:I.get(q.source.property);(N.has(L.property)||V===void 0||!ke(L.source,V.type,y,x))&&e.error(c.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",L.location),N.add(L.property)}}else e.error(c.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",w.location)},"validateSpecification");for(let{slice:v,scope:k}of r)v.specifications.forEach(E=>A(E,k));for(let v of n){if(v.isParameter===!0)continue;let k=u(v.command,v.scope);k!==null&&a.get(k).get(v.property.split(".")[0])?.isGenerated&&e.error(c.GeneratedPropertySuppliedAsInput,`Generated property '${v.property}' cannot be supplied as request or form input.`,v.location)}}l(_n,"validateResponses");function ne(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}l(ne,"uniqueByName");function ke(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=>ke(a,{...e,isCollection:!1,isOptional:!1},n,i));let r=i.get(e.name);if(r!==void 0)return t.kind==="ObjectExpressionSyntax"&&t.members.every(a=>{let d=r.get(a.name);return d!==void 0&&ke(a.value,d.type,n,i)});let o=n.get(e.name),s=o?.type??e.name;if(o?.type==="Enum")return t.kind==="LiteralExpressionSyntax"&&typeof t.value=="string"&&o.values.includes(t.value);if(t.kind==="LiteralExpressionSyntax")switch(s){case"Uuid":return typeof t.value=="string"&&oa(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&&zo(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"&&hr(t.value,!1);case"DateTime":return typeof t.value=="string"&&hr(t.value,!0);default:return!Gn.has(s)}return!Gn.has(s)&&o===void 0}l(ke,"compatibleValue");var tc=/^(?:[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 oa(t){return tc.test(t)}l(oa,"uuidValue");function nc(t,e,n){let i=ne(n.types),r=t.properties,o=null,s=!1,a=!1;for(let d of e.split(".")){let p=r.filter(u=>u.name===d);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}l(nc,"commandPathType");function Bt(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:Wo(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:nc(t,r,n)}l(Bt,"commandDestinationType");var aa=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),Ke=class{static{l(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new re(e).slices,this.types=ne(e.types),this.concepts=ne(e.concepts),this.knownTypes=new Set([...aa,...e.types.map(n=>n.name),...e.concepts.map(n=>n.name)]),this.events=new Map(this.slices.map(({slice:n})=>{let i=new Map;for(let r of le(n))(!i.has(r.name)||i.get(r.name).generation<r.generation)&&i.set(r.name,r);return[n,[...i.values()]]}))}resolve(e,n,i){let r=this.slices.flatMap(({slice:d,scope:p})=>i(d).map(m=>({node:m,slice:d,scope:p}))),o=this.slices.find(d=>d.slice===n)?.scope??[],s=l(d=>{let p=d.split("."),m=r.filter(y=>y.node.name===p.at(-1)),u=p.slice(0,-1);if(u.length>0)return m.filter(y=>u.length<=y.scope.length&&u.every((h,x)=>y.scope[y.scope.length-u.length+x]===h));for(let y=o.length;y>=0;y--){let h=m.filter(x=>y<=x.scope.length&&o.slice(0,y).every((g,S)=>x.scope[S]===g));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let d=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);d.length===1&&(a=s(d[0].qualifiedName))}return a.length===1?a[0]:null}event(e,n){return this.resolve(e,n,i=>this.events.get(i)??[])?.node??null}property(e,n){let i=n.split(".");for(let[r,o]of i.entries()){let s=e?.filter(d=>d.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(aa.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(d=>d.name===a.type.name))return null;e=this.types.get(a.type.name)?.properties??null}return null}compatible(e,n){return this.knownTypes.has(e.name)&&this.knownTypes.has(n.name)?e.name===n.name&&e.isCollection===n.isCollection&&(!e.isOptional||n.isOptional):null}};var ic=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Kn(t,e,n){let i=new Ke(t),r=qt(t),o=l(d=>ic.has(d)||i.concepts.has(d)||i.types.has(d),"knownType"),s=new Map([...i.types].map(([d,p])=>[d,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:d,scope:p}of a){let m=new Map;for(let u of d.specifications){let y=(u.cases?.length??0)===0?[u.name]:u.cases.map(h=>`${u.name}_${h.name}`);for(let h of y)m.set(h,(m.get(h)??0)+1);(u.cases?.length??0)>0&&m.set(u.name,(m.get(u.name)??0)+1)}for(let u of d.specifications){for(let g of u.cases??[])(m.get(`${u.name}_${g.name}`)??0)>1&&e.error(c.SpecificationCaseNameCollision,`Case '${g.name}' derives specification '${u.name}_${g.name}', which collides in this ${n===void 0?"slice":"document"}.`,g.location);for(let g of u.parameters??[]){n===void 0&&!o(g.type.name)&&e.error(c.IncompatibleSpecificationParameterType,`Parameter '${g.name}' has unknown type '${g.type.name}'.`,g.type.location);for(let S of u.cases??[])for(let C of S.values.filter($=>$.property===g.name))ke(C.source,g.type,i.concepts,s)||e.error(c.InvalidSpecificationCaseValue,`Case '${S.name}' parameter '${g.name}' requires a concrete value of type '${g.type.name}'.`,C.source.location)}let y=l((g,S,C)=>{if(g?.kind!=="CaseValueExpressionSyntax"||S===void 0)return;let $=u.parameters?.find(k=>k.name===g.parameter);if($===void 0||($.type.isOptional&&!S.isOptional&&e.error(c.OptionalSpecificationParameterTarget,`Optional parameter '${$.name}' cannot supply required target '${C}'.`,g.location),n!==void 0&&(!o($.type.name)||!o(S.name))))return;let P=i.concepts.get($.type.name),A=i.concepts.get(S.name);(!($.type.name===S.name||P?.type!=="Enum"&&P?.type===S.name||A?.type!=="Enum"&&A?.type===$.type.name)||$.type.isCollection!==S.isCollection)&&e.error(c.IncompatibleSpecificationParameterType,`Parameter '${$.name}' type '${$.type.name}' is incompatible with target '${C}' type '${S.name}'.`,g.location)},"check"),h=l((g,S)=>{for(let C of g)y(C.source,i.property(S,C.property)?.type,C.property)},"assignments"),x=r.command(u.when,p);if(x!==null){let g=i.resolve(x.commandType,d,S=>S.commands)?.node.properties??null;h(x.values,g),h(x.generatedValues??[],g),y(x.for,g?.find(S=>S.isIdentifier)?.type,"for")}if(x!==null&&u.thenReturns!=null){let g=i.resolve(x.commandType,d,C=>C.commands)?.node,S=g?.response;if(u.thenReturns.kind==="ScalarSpecificationReturnSyntax"&&S?.kind==="ScalarCommandResponseSyntax"&&y(u.thenReturns.value,g?.properties.find(C=>C.name===S.source.property)?.type,"value"),u.thenReturns.kind==="RecordSpecificationReturnSyntax"&&S?.kind==="RecordCommandResponseSyntax")for(let C of u.thenReturns.fields){let $=S.fields.find(P=>P.name===C.property);y(C.source,$?.type??g?.properties.find(P=>P.name===$?.source.property)?.type,C.property)}}for(let g of[...u.given,...u.thenEvents,...u.whenAppended===null?[]:[u.whenAppended]]){let S=r.eventStep(g,"given",p).effective;h(S.values,i.event(S.eventType,d)?.properties??null);let C=S.stream==null?null:new Re(t).resolve(S.stream.eventSource,S.stream.stream),$=C?.kind===pe.Unique?C.sources[0]:void 0,P=C?.kind===pe.Unique?C.streams[0]:void 0;y(S.for,S.stream!=null&&$===void 0?void 0:$?.identifier??rc(S.eventType,d,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(v=>v.name===A.property)?.type,A.property)}for(let g of[...u.givenReadModels,...u.thenReadModels]){let S=r.readModel(g,p);h(S.properties,i.resolve(S.name,d,C=>C.readModels)?.node.properties??null)}if(u.whenTrigger!=null){let g=(t.declaredTriggers??[]).find(S=>S.name===u.whenTrigger.trigger);for(let S of u.whenTrigger.values)y(S.source,g?.data.find(C=>C.name===S.property)?.type,S.property)}for(let g of u.thenErrors)y(g.caseValue??null,{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:g.location},"message");for(let g of u.thenAbsentReadModels??[]){let S=i.resolve(g.name,d,$=>$.readModels)?.node,C=i.slices.flatMap(({slice:$})=>$.queries.filter(P=>P.by!==null&&i.resolve(P.returnType.name,$,A=>A.readModels)?.node===S));y(g.key,S!==void 0&&C.length===1?C[0].by.type:void 0,"for")}for(let g of[...u.thenQueries??[],...u.whenQuery===null?[]:[u.whenQuery]]){let S=i.resolve(g.query,d,A=>A.queries),C=S===null?[]:[...S.node.by===null?[]:[S.node.by],...S.node.filters].map(A=>({...A,kind:"PropertySyntax",isIdentifier:!1}));h(g.arguments,C);let $=S===null?null:i.resolve(S.node.returnType.name,S.slice,A=>A.readModels)?.node.properties??null,P=g.kind==="SpecificationQuerySyntax"?g.results:u.thenResults;for(let A of P)h(A.properties,$)}}}}l(Kn,"validateSpecificationCases");function Zn(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}l(Zn,"uniqueDestinationType");function rc(t,e,n,i){let r=new re(n),o=i.event(t,e);if(o===null)return;let s=l((d,p=i.slices)=>p.flatMap(({slice:m})=>m.commands.flatMap(u=>u.produces.filter(y=>r.isEventProduction(y,m)&&i.event(y.event,m)===d).map(y=>Bt(u,y,n,{resolver:r,slice:m})).filter(y=>y!==null))),"commandTypes"),a=l((d,p)=>{if(p.has(d))return[];p.add(d);let m=s(d);for(let{slice:u}of i.slices){for(let y of u.reactions.flatMap(h=>h.triggers)){let h=y.source.kind==="NamedTriggerSourceSyntax"?y.source.name:void 0,x=h===void 0?null:i.event(h,u);for(let g of y.produces.filter(S=>i.event(S.event,u)===d))if(g.for?.kind==="PathExpressionSyntax"){let S=g.for.path,C=i.property(x?.properties??null,S)?.type??(h===void 0?void 0:(n.declaredTriggers??[]).find($=>$.name===h)?.data.find($=>$.name===S)?.type);C!==void 0&&m.push(C)}else g.for?.kind==="LiteralExpressionSyntax"?m.push({kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:g.location}):g.for===null&&x!==null&&m.push(...a(x,p))}u.captures.flatMap(y=>[...y.appends,...y.children.flatMap(h=>h.appends),...y.nested.flatMap(h=>h.appends)]).some(y=>i.event(y.event,u)===d)&&m.push(Zn(s(d))??{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:d.location})}return m},"producerTypes");return Zn(s(o,i.slices.filter(d=>d.slice===e)))??Zn(s(o))??Zn(a(o,new Set))}l(rc,"eventDestinationType");function Jn(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:c.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}l(Jn,"productionDestinationDiagnostics");function Hn(t,e){let n=new re(t).slices.map(r=>r.slice),i=n.flatMap(le);for(let r of n)for(let o of r.constraints.flatMap(s=>[s,...s.additionalRules])){if(o.kind!=="UniquePropertyConstraintSyntax")continue;let s=i.filter(a=>a.name===o.event);if(s.length!==0)for(let a of[o.property,...o.additionalProperties])a.includes(".")||s.some(d=>d.properties.some(p=>p.name===a))||e.error(c.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}l(Hn,"validateConstraintProperties");var sa=l((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),Xn=l(t=>[...t.scope,t.name].join("."),"addressOf"),Te=class{static{l(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=l((r,o)=>{n.push({name:r.name,scope:o}),r.features.forEach(s=>i(s,[...o,r.name]))},"inventory");for(let r of e.modules)n.push({name:r.name,scope:[]}),r.features.forEach(o=>i(o,[r.name]));return[...new Map(n.map(r=>[Xn(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=Xn(r);if(o===i||o.startsWith(i+".")||i.startsWith(o+"."))return[];let s=[...r.scope,r.name];for(let a=1;a<=s.length;a++){let d=s.slice(-a).join(".");if(this.resolve(d,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:d,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=>sa([...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&&sa(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function ei(t,e){let n=l(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=Te.containersOf(t),r=new Map,o=l((a,d)=>{let p=[],m=d.join(".");r.has(m)||r.set(m,new Set);let u=r.get(m);for(let y of a){let h=Te.resolve(y.target,d,i),x=h.resolved===void 0?void 0:Xn(h.resolved),g=x===void 0?`text:${y.target}`:`resolved:${x}`;if(u.has(g)){e.warning(c.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}u.add(g),p.push(y),h.ambiguous.length>0?e.warning(c.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(Xn).join(", ")}`,y.location):(x===void 0||x===m||x.startsWith(m+".")||m.startsWith(x+"."))&&e.warning(c.InvalidDependencyTarget,`Invalid dependency target '${y.target}' on '${m}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,y.location)}return p},"keep"),s=l((a,d)=>{let p=[...d,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(d=>s(d,[a.name]))}))}}l(ei,"validateDependencyDeclarations");var Pt=[],un=l(t=>t.length===0,"isDocumentPlacement");function ti(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}l(ti,"describePlacement");var oc=O("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),ac=new RegExp(O("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),sc=O("^[A-Z]\\w*$");function yt(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&oc.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=lc(n),r=f(e);if(i.length===0)return t.error(c.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new kr(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}l(yt,"parseAuthorize");function Je(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}l(Je,"combineAuthorize");function lc(t){let e=[];for(let n of t.match(ac)??[])e.length>0&&cc(e[e.length-1])&&dc(n)&&e.push("and"),e.push(n);return e}l(lc,"tokenize");var la=l(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),cc=l(t=>t===")"||la(t),"isOperandEnd"),dc=l(t=>t==="("||la(t),"isOperandStart"),kr=class{static{l(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(c.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#i("or","Or",()=>this.#s())}#s(){return this.#i("and","And",()=>this.#r())}#i(e,n,i){let r=i();for(;r!==null&&this.tokens[this.#e]===e;){this.#e++;let o=i();if(o===null)return null;r={kind:"LogicalPolicyRequirementSyntax",left:r,operator:n,right:o,location:this.location}}return r}#r(){if(this.tokens[this.#e]!=="(")return this.#o();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(c.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#o(){if(this.#e>=this.tokens.length)return this.context.error(c.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return sc.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(c.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};function Yt(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(c.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,f(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(c.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let d=t.reader.takeRaw();if(d===void 0){t.error(c.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(d.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<d.raw.length&&d.raw[p]===" ";)p++;a.push(d.raw.substring(p))}return a.join(`
|
|
17
|
+
`)}l(Yt,"parseFencedText");var pc=O(`^description\\s+"(${z})"$`);function G(t,e,n,i,r=!1){if(e.content==="description"){let s=Yt(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(c.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):ca(t,e,n,i,s)}let o=pc.exec(e.content);return o===null?(t.error(c.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):ca(t,e,n,i,Q(o[1]))}l(G,"parseDescription");function ca(t,e,n,i,r){return n!==null?(t.error(c.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}l(ca,"keep");var uc=O("^purpose\\s+([A-Za-z_]\\w*)$"),fc=O(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${z})")?$`),mc=O(`^(interest|authorization|retention|recipient)\\s+"(${z})"$`),yc=O(`^transfer\\s+"(${z})"\\s+safeguard\\s+"(${z})"$`),hc=O("^[A-Za-z_]\\w*$"),Sc=O("^erasure\\s+exception\\s+(\\w+)$"),gc=["consent","contract","legalObligation","vitalInterests","publicTask","legitimateInterests"],xc=["explicitConsent","employmentLaw","vitalInterests","notForProfit","madePublic","legalClaims","substantialPublicInterest","healthCare","publicHealth","research"],da=["expression","legalObligation","publicTask","publicHealth","archiving","legalClaims"];function pa(t,e){let n=ua(t,e),i={kind:"PurposeSyntax",name:n,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:f(e)},r=new Set,o=[],s=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let d=D(a.content);if(d!=="recipient"&&d!=="transfer"&&r.has(d)){t.error(c.DuplicatePurposeField,`Purpose '${n}' already declares '${d}' - at most one is allowed`,f(a)),t.skipBlock(a.indent);continue}if(r.add(d),d==="description")i={...i,description:G(t,a,i.description,`Purpose '${n}'`)};else if(d==="basis"||d==="condition"){let p=fc.exec(a.content),m=d==="basis"?gc:xc;if(p===null||!m.includes(p[2]))t.error(c.InvalidPurposeVocabulary,`Invalid ${d} in purpose '${n}' - expected ${m.join(", ")} with an optional quoted reference`,f(a));else{let u=p[3]===void 0?null:Q(p[3]);i=d==="basis"?{...i,basis:p[2],basisReference:u}:{...i,condition:p[2],conditionReference:u}}}else if(d==="interest"||d==="authorization"||d==="retention"||d==="recipient"){let p=mc.exec(a.content);p===null?t.error(c.InvalidPurposeDeclaration,`Invalid purpose field '${a.content}' - expected '${d} "<text>"'`,f(a)):d==="recipient"?o.push(Q(p[2])):i={...i,[d]:Q(p[2])}}else if(d==="subjects"){let p=a.content.slice(8).split(",").map(m=>m.trim());p.every(m=>hc.test(m))?i={...i,subjects:[...new Set(p)]}:t.error(c.InvalidPurposeDeclaration,`Invalid purpose subjects '${a.content}' - expected comma-separated identifiers`,f(a))}else if(d==="erasure"){let p=Sc.exec(a.content);p!==null&&da.includes(p[1])?i={...i,erasureException:p[1]}:t.error(c.InvalidPurposeVocabulary,`Invalid erasure exception '${a.content}' - expected 'erasure exception ${da.join("|")}'`,f(a))}else if(d==="transfer"){let p=yc.exec(a.content);p===null?t.error(c.InvalidPurposeDeclaration,`Invalid transfer '${a.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,f(a)):s.push({kind:"PurposeTransferSyntax",destination:Q(p[1]),safeguard:Q(p[2]),location:f(a)})}else t.error(c.InvalidPurposeDeclaration,`Unexpected '${a.content}' in purpose '${n}'`,f(a)),t.skipBlock(a.indent)}return{...i,recipients:o,transfers:s}}l(pa,"parsePurpose");function Ft(t,e,n){let i=ua(t,e);i.length>0&&!n.some(r=>r.name===i)&&n.push({kind:"PurposeReferenceSyntax",name:i,location:f(e)})}l(Ft,"parsePurposeReference");function ua(t,e){let n=uc.exec(e.content);return n!==null?n[1]:(t.error(c.InvalidPurposeDeclaration,`Invalid purpose declaration '${e.content}' - expected 'purpose <Name>'`,f(e)),"")}l(ua,"purposeName");function Pe(t,e,n,i,r=c.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,f(e)),t.skipOpaqueBlock(e.indent),n;let o=Yt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,f(e)),n):o}l(Pe,"parseDocumentation");var vc=Z(`^depends${W}+on${W}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function ni(t,e,n,i){let r=vc.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,f(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(c.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,f(e));return}n.push({kind:"DependsOnSyntax",target:r,location:f(e)})}l(ni,"parseDependsOn");var $c=O('^import\\s+"([^"\\\\]+)"$'),bc=O('^import\\s+"'),fa=l(t=>bc.test(t),"isFileImport");function ma(t){let e=$c.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}l(ma,"tryParseFileImport");function Ut(t,e,n){let i=ma(e);if(i!==void 0){n.push(i);return}t.error(c.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}l(Ut,"parseFileImport");var Er={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function Qe(t,e,n,i=!1){i||(t=t.valueContext);let r=i?W:"\\s",o=t.sourceOptions.numericMode==="exact"?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${r}|[()])|`:"",s=t.sourceOptions.numericMode==="exact"&&!i?"[\\w.$-]+|[^\\s]":"[\\w.$-]+",a=new RegExp(Z(`"${z}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let x=e.replace(a,"").replace(new RegExp(W,"gu"),"");if(x.length>0)return t.error(c.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${x[0]}'`,n),null}let d=e.match(a)??[],p=0,m=l(()=>{if(d[p]==="("){p++;let C=y();return d[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(c.UnclosedConditionGroup,"Expected ')' in condition",n),C}let x=d[p++];if(i&&x===void 0)return t.error(c.ExpectedCondition,"Expected a condition",n),null;let g=d[p++];if(g==="starts"&&d[p]==="with"&&(g+=" with",p++),i&&!Object.hasOwn(Er,g))return t.error(c.ExpectedComparisonOperator,`Expected a comparison operator after '${x}'`,n),null;let S=d[p++];return i&&S===void 0?(t.error(c.ExpectedComparisonValue,"Expected a value to compare against",n),null):x===void 0||S===void 0||Er[g]===void 0?null:{kind:"ComparisonConditionSyntax",left:x,operator:Er[g],right:Me(S,n,t),location:n}},"group"),u=l(()=>{let x=m();for(;x!==null&&d[p]==="and";){p++;let g=m();if(g===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"And",right:g,location:n}}return x},"and"),y=l(()=>{let x=u();for(;x!==null&&d[p]==="or";){p++;let g=u();if(g===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"Or",right:g,location:n}}return x},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(c.ExpectedCondition,"Expected a condition",n):h!==null&&p<d.length&&t.error(c.UnexpectedTokenInCondition,`Unexpected '${d[p]}' in condition`,n)),h}l(Qe,"parseCondition");var kc=O(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Ec=O(`^otherwise${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Cc=O(`^with${W}+([A-Za-z_]\\w*)${W}+from${W}+([^\\n]+)$`),Pc=O("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Ac=new RegExp(`^${W}+|${W}+$`,"gu");function ha(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=kc.exec(d.content),m=Ec.exec(d.content);if(p!==null){a&&t.error(c.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(d));let u=Qe(t,p[1],f(d),!0),y=ya(t,d);u!==null&&(Wt(t,u),r.push({kind:"ScreenActionAlternativeSyntax",condition:u,command:p[2],arguments:y,location:f(d)}))}else if(d.content==="otherwise hidden"||m!==null)if(a&&t.error(c.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(d)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:ya(t,d),location:f(d)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(d)};for(let u=t.peekChild(d.indent);u!==void 0;u=t.peekChild(d.indent))t.reader.takeSignificant(),t.error(c.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(u)),t.skipBlock(u.indent)}else if(D(d.content)==="navigate")s!==null&&t.error(c.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(d)),s=i(t,d.content,d)??null;else{let u=D(d.content)==="label";t.error(u?c.UnknownActionDirective:c.InvalidActionAlternative,u?"A guarded action's header already supplies its label":`Unexpected '${d.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(d)),t.skipBlock(d.indent)}}return r.length===0&&t.error(c.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",f(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:f(e)}}l(ha,"parseGuardedAction");function ya(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Cc.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(Ac,""),location:f(i)}):(t.error(c.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}l(ya,"parseArguments");function Wt(t,e){if(e.kind==="LogicalConditionSyntax"){Wt(t,e.left),Wt(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=Pc.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(c.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}l(Wt,"validateCondition");var Ge=class t{static{l(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every($r)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&$r(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw new Error("There is no significant line left to take");return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};var ue=class extends Error{static{l(this,"InvalidSyntaxJson")}};var Ne=Object.freeze({numericMode:"legacy"}),ii=Object.freeze({numericMode:"exact"}),Sa=Object.freeze({numericMode:"invalid"});function Vt(t){if(typeof t!="object"||t===null||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null||Reflect.ownKeys(t).length!==1||!Object.hasOwn(t,"numericMode"))throw new ue("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new ue("Malformed source numeric options.");return e==="exact"?ii:Ne}l(Vt,"validatedSourceOptions");var ga=new WeakSet;function xa(t){ga.add(t)}l(xa,"recordAuthoredDocument");function va(t){return ga.has(t)}l(va,"isAuthoredDocument");var he=class t{static{l(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=Ne;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 Dt(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 wc=O(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Oc=O(`^on${W}+([^\\n]+)$`),ba=O(`^where${W}+([^\\n]+)$`),$a=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function ka(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=Oc.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let u=n+1;u<e.length&&e[u].indent>i.indent;u++)o.push(e[u]);let s=o.filter(u=>u.indent===o[0]?.indent),a=s.filter(u=>["when","otherwise"].includes(D(u.content))),d=["click","double click","select"].includes(r[1].trim()),p=s.filter(u=>ba.test(u.content)),m=!1;for(let u of a){let y=D(u.content)==="when",h=y?wc.exec(u.content):null;if(y){m&&t.error(c.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(u));let S=Qe(t,h?.[1]??u.content.slice(4).trim(),f(u),!0);S!==null&&Wt(t,S),h!==null&&t.error(c.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",f(u))}else(m||u.content!=="otherwise")&&t.error(c.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",f(u)),m=!0;let x=o.indexOf(u),g=o[x+1];h===null&&(g===void 0||g.indent<=u.indent||!$a.has(D(g.content)))&&t.error(c.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",f(u))}if(a.length>0&&(d||t.error(c.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",f(i)),(p.length>0||s.some(u=>$a.has(D(u.content))))&&t.error(c.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",f(i)),a.some(u=>D(u.content)==="when")||t.error(c.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",f(i))),d)for(let u of p)Ic(t,u)}}l(ka,"validateInteractionBodies");function Ic(t,e){let n=new he(new Ge([]));n.sourceOptions=t.sourceOptions;let i=Qe(n,ba.exec(e.content)[1].trim(),f(e),!0);i!==null&&Wt(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(c.LegacyInteractionWhere,r,f(e)):t.information(c.LegacyInteractionWhere,r,f(e))}l(Ic,"deprecateWhere");var Ea=O("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Tc=O("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Rc=O("^field\\s+([\\w.]+)(?:\\s|$)"),Dc=O("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Mc=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),jc=O("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),Lc=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function qe(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=null,a=l(p=>{for(;n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();let m=o&&n.length===0?jc.exec(p.content):null;m!==null&&i.add(m[1]);let u=Ea.exec(p.content),y=Tc.exec(p.content);if(u!==null)n.push({command:u[1],kind:"form",indent:p.indent});else if(y!==null)n.push({command:y[2],kind:y[1],indent:p.indent});else if(Lc.has(D(p.content)))n.push({command:"",kind:"other",indent:p.indent});else{let h=n.at(-1);if(h===void 0||h.kind==="other")return;let x=(h.kind==="form"?Rc:h.kind==="execute"?Dc:Mc).exec(p.content);x!==null&&r.push({command:h.command,property:oe(x[1]),scope:t.scope,location:f(p)})}},"recognize");a(e);let d=[e];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){for(t.reader.takeSignificant();n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();Ea.test(e.content)&&D(p.content)==="description"&&n.at(-1)?.kind==="form"?s=G(t,p,s,`Form '${e.content.split(O("\\s+"))[1]}'`):p.content.startsWith("```")?t.skipFencedBody():(d.push(p),a(p))}ka(t,d);for(let p of r)t.inputUses.push(i.has(p.command)?{...p,isParameter:!0}:p)}l(qe,"collectInputUses");function $e(t){return O(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}l($e,"sourceStreamPattern");var Nc=$e("^[A-Za-z_]\\w*(?![\\s\\S])"),qc=$e("^[\\w.]+(?![\\s\\S])");function Cr(t){return typeof t=="string"&&Nc.test(t)}l(Cr,"isSourceStreamName");function ri(t){return typeof t=="string"&&qc.test(t)}l(ri,"isSourceStreamTypeName");var Bc=O(`^id\\s+"(${z})"$`),Yc=$e("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Fc=$e("^eventsource\\s+([A-Za-z_]\\w*)$"),Uc=$e("^stream\\s+([A-Za-z_]\\w*)$");function Ca(t,e){let n=Fc.exec(e.content)?.[1]??"";n===""&&rt(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(Wc(t,a));break;case"identifier":r=Pa(t,a,"identifier",r);break;case"description":o=G(t,a,o,`Event source '${n}'`,!0);break;case"id":s=Aa(t,a,n,s);break;default:rt(t,a,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(a.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:s,location:f(e)}}l(Ca,"parseEventSource");function Wc(t,e){let n=Uc.exec(e.content)?.[1]??"";n===""&&rt(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,d=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?(rt(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=f(p),r=Vc(t,p)):(i=Pa(t,p,"streamId",i),o=i!==null);break;case"description":a=G(t,p,a,`Stream '${n}'`,!0);break;case"id":d=Aa(t,p,n,d);break;default:rt(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:d,directiveLocations:s,location:f(e)}}l(Wc,"parseEventStream");function Pa(t,e,n,i){let r=Yc.exec(e.content);return r===null||i!==null?rt(t,e,`Declare at most one '${n} <Type>'.`):(i=je(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Ve(t,i,e)),fn(t,e,c.InvalidEventSourceDeclaration),i}l(Pa,"parseType");function Aa(t,e,n,i){let r=Bc.exec(e.content),o=r===null?null:Q(r[1]);return o===null||o.trim()===""||i!==null?rt(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(c.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),fn(t,e,c.InvalidEventSourceDeclaration),i}l(Aa,"parsePin");function wa(t,e,n,i){let[r,o]=n.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:f(e)};if(i)return t.error(c.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,d=[],p=!1,m={};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),u.content==="streamId"){a!==null||p?(t.error(c.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent)):(p=!0,m.streamId=f(u),d=Pr(t,u,c.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(u.content);if(y===null||a!==null||p)t.error(c.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent);else{let h={...f(u),column:u.indent+1+u.content.indexOf(y[1],u.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ae(y[1],h,t),location:f(u)},fn(t,u,c.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:d,directiveLocations:m}}l(wa,"parseCommandStream");function Vc(t,e){let n=[],i=$e("^([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){rt(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=je(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Ve(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),fn(t,r,c.InvalidEventSourceDeclaration)}return n.length===0&&rt(t,e,"A streamId part block cannot be empty."),n}l(Vc,"parseStreamIdParts");function Pr(t,e,n){let i=[],r=$e("^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$");for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=r.exec(o.content);if(s===null){t.error(n,"Expected '<part> = <source>' in a streamId part block.",f(o)),t.skipBlock(o.indent);continue}let a={...f(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ae(s[2],a,t),location:f(o)}),fn(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}l(Pr,"parseRouteParts");function fn(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",f(i)),t.skipBlock(e.indent))}l(fn,"rejectChildren");function rt(t,e,n){t.error(c.InvalidEventSourceDeclaration,n,f(e))}l(rt,"invalid");var zc=O("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Oa=l(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),ye=l(t=>Oa(t).length>0,"isFileDirective"),oi=l(t=>ye(t)&&!zc.test(Oa(t)),"isFileDirectiveAmongProperties");var Qc=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function ai(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||Qc.has(n)))return!1}return!0}l(ai,"isBlankImplementationHint");var Ia=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),zt=l(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),mn=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function ht(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(c.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,f(e)),{kind:"FileReferenceSyntax",path:n,location:f(e)}}l(ht,"parseFile");var Ar=l(t=>t.raw.trim()==="```","isClosingCodeFence");function Be(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(c.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(c.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(c.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,f(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(c.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Ar(o))break;let s=0;for(;s<i.indent&&o.raw[s]===" ";)s++;r.push(o.raw.substring(s))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
|
|
18
|
+
`),location:f(e)}}l(Be,"parseCode");function Ta(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(c.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return Gc(t,e,n);let i=zt(n)?ht(t,n):null,r=i===null&&mn(t,n)?Be(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(c.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",f(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:f(e)}}return t.error(c.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}l(Ta,"parseHandler");function Gc(t,e,n){let i=yn(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"?c.InvalidImplementationBlock:c.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),mn(t,r)?Be(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}l(Gc,"parseImplementation");function yn(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(c.InvalidImplementationBlock,"Expected 'implementation' with no operand.",f(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||Ia.test(s.content)){let a=Ia.exec(s.content),d=a===null?null:Q(a[1]);ai(d)?t.error(c.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:d,location:f(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(c.InvalidImplementationHint,"A hint cannot have children.",f(p)),t.skipBlock(s.indent))}else if(zt(s)||s.content.startsWith("```")){o&&t.error(c.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=zt(s)?ht(t,s):null,d=a===null?Be(t,s):null;o||(i=a,r=d),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(c.InvalidImplementationBlock,"A file directive cannot have children.",f(p)),t.skipBlock(s.indent))}else t.error(c.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,f(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:f(e)}}}l(yn,"parseImplementationWrapper");var _c=O("^system\\s+([A-Za-z_]\\w*)$"),Zc=O("^operation\\s+([A-Za-z_]\\w*)$"),Kc=O("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),wr=O("^uses\\s+([A-Za-z_]\\w*)$"),Jc=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Hc=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function hn(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}l(hn,"rejectOperationChildren");function Ra(t,e){let n=_c.exec(e.content);n===null&&t.error(c.InvalidSystemDeclaration,"Expected 'system <Name>'.",f(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=G(t,r,i,`System '${n?.[1]??""}'`):(t.error(c.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",f(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:f(e)}}l(Ra,"parseSystem");function si(t,e,n=!1){let i=(n?Kc:Zc).exec(e.content),r=i?.[1]??"";i===null&&t.error(c.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),d=null,p=null,m=[],u=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let x=Jc.exec(h.content),g=n&&x!==null?{...h,content:x[1].trimEnd()}:h;if(x===null&&Hc.has(D(h.content))){t.error(c.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!wr.test(h.content)&&Ze(g)!==void 0){let S=Le(t,g);n&&x===null&&t.error(c.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),S.isSubject&&t.error(c.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",f(h)),(S.isIdentifier||S.isGenerated)&&t.error(c.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(S.name)&&t.error(c.DuplicateDeclaration,`Operation '${r}' already declares input '${S.name}'.`,f(h)),y.add(S.name),m.push(S),n&&x!==null&&u.push({kind:"PropertyMappingSyntax",property:S.name,source:ae(x[2],{...f(h),column:h.indent+h.content.length-x[2].length+1},t),location:f(h)}),hn(t,h,c.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=G(t,h,o,`Operation '${r}'`);else if(wr.test(h.content))s!==null?t.error(c.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=wr.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),hn(t,h,c.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let S=Xc(t,h);h.content==="execute"?d!==null?t.error(c.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):d=S:p!==null?t.error(c.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):p=S}else t.error(c.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,f(h)),t.skipBlock(h.indent)}return s===null&&t.error(c.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:d,compensate:p,location:f(e)},mappings:u}}l(si,"parseOperation");function Xc(t,e){let n=null,i=null,r=null,o=null,s=!1;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(a.content)==="description"){n=G(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(c.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let d=yn(t,a);s||(i=d.file,r=d.code,o=d.implementation),s=!0}else if(ye(a)||a.content.startsWith("```")){s&&t.error(c.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let d=ye(a)?ht(t,a):null,p=d===null?Be(t,a):null;s||(i=d,r=p),s=!0,d!==null&&hn(t,a,c.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(c.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",f(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:f(e)}}l(Xc,"parseOperationPhase");var ed=O("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),td=O("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),nd=O("^specification\\s+([A-Za-z_]\\w*)$"),id=O("^given caller as ([A-Za-z_]\\w*)$"),rd="([A-Z]\\w*(?:\\.\\w+)*)",od="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Qt=l((t,e="")=>Z(`^${t}\\s+${rd}${e}${od}$`.replaceAll("\\s",W)),"stepPattern"),ad=Qt("given"),sd=Qt("when\\s+append"),ld=Qt("when"),cd=Qt("then"),dd=O("^then\\s+query\\b"),Da=O("^(?:given|then)\\s+readmodel\\b"),pd=Qt("given\\s+readmodel"),ud=Qt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Ma=O("^then\\s+no\\b"),fd=O(`^then\\s+error\\s+"(${z})"$`),Tr=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),md=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),yd=O("^given\\s+clock\\b"),hd=O("^given\\s+capture\\b"),Sd=O("^when\\s+clock\\b"),gd=O("^when\\s+trigger\\b"),xd=O("^when\\s+capture\\b"),vd=O("^when\\s+query\\b"),$d=O("^then\\s+result\\b"),bd=O("^then\\s+no\\s+result\\b"),kd=Z("^when\\s+redelivered\\b"),Ed=Z("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Cd=O("^then\\s+no\\s+events\\b"),Pd=O('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Ad=O("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),wd=O("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Od=O("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Id=O("^then\\s+result(\\s+exactly)?$"),ja=Z("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Td=Z(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`),Rd=Z("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function Rr(t,e){let n=nd.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i=null,r=[],o=[],s={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(u)||Dd(t,u,s))continue;let y=Ma.test(u.content)?"then":D(u.content);if(y==="parameter"){let h=na(t,u);h!==null&&r.push(h)}else if(y==="case"){let h=ia(t,u);h!==null&&o.push(h)}else y==="description"?i=G(t,u,i,`Specification '${n}'`):y==="given"?Md(t,u,s):y==="when"?qd(t,u,s,n):y==="then"?Bd(t,u,s):(t.error(c.UnknownSpecificationDirective,`Unexpected '${D(u.content)}' in specification body`,f(u)),t.skipBlock(u.indent))}s.noEventsLine!==void 0&&(s.whenAppended!==null||s.thenEvents.length>0||s.thenEventsInAnyOrder||s.thenErrors.length>0||s.thenDenied!==null)&&t.error(c.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(s.noEventsLine));let{whenDeclared:a,noEventsLine:d,...p}=s,m={kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...p,...r.length===0?{}:{parameters:r},...o.length===0?{}:{cases:o},location:f(e)};return ra(m,t),m}l(Rr,"parseSpecification");function Dd(t,e,n){if(!ed.test(e.content))return!1;let i=td.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(c.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),Se(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=jt(t,o,Tr,c.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else hn(t,e,c.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:f(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:f(e)});return!0}l(Dd,"parseOperationStep");function Md(t,e,n){if(yd.test(e.content))n.givenClock!==null?(t.error(c.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),Se(t,e.indent)):n.givenClock=La(t,e,"given");else if(hd.test(e.content)){let i=Na(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(c.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent);else if(e.content.startsWith("given caller as")){let i=id.exec(e.content);i===null&&t.error(c.InvalidSpecificationCallerPersona,"Expected 'given caller as <Persona>'.",f(e));let r=t.peekChild(e.indent);r!==void 0&&t.error(c.InvalidSpecificationCallerPersona,"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.",f(r)),Se(t,e.indent),i!==null&&(n.givenCallerPersona={kind:"SpecificationCallerPersonaSyntax",name:i[1],location:f(e)})}else n.givenCaller=Nd(t,e);else if(Da.test(e.content)){let i=qa(t,e,pd,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Dr(t,e,ad,"given");i!==void 0&&n.given.push(i)}}l(Md,"parseGiven");var jd=O(`^role${W}+"(${z})"$`),Ld=O(`^claim${W}+"(${z})"${W}*=${W}*"(${z})"$`);function Nd(t,e){if(e.content!=="given caller")return t.error(c.InvalidSpecificationCaller,"Expected exactly 'given caller'.",f(e)),t.skipBlock(e.indent),null;let n=!1,i=[],r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=jd.exec(o.content),a=Ld.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(Q(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:Q(a[1]),value:Q(a[2]),location:f(o)}):t.error(Lt(o.content)?c.InvalidSpecificationCaseReference:c.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,f(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:f(e)}}l(Nd,"parseCaller");function qd(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let d=n.whenAppended!==null||r?c.ConflictingSpecificationActions:c.DuplicateSpecificationWhen;t.error(d,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),Se(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Dr(t,e,sd,"when append")??null;return}if(kd.test(e.content)){let d=Ed.exec(e.content);d===null?(t.error(c.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),Se(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:d[1],reaction:d[2],...Ir(t,e,void 0,void 0,"when redelivered"),location:f(e)};return}if(Sd.test(e.content)){n.whenClock=La(t,e,"when");return}if(gd.test(e.content)){n.whenTrigger=Or(t,e,Ad,c.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(d,p)=>({kind:"SpecificationTriggerSyntax",trigger:d,values:p,location:f(e)}));return}if(xd.test(e.content)){n.whenCapture=Na(t,e,"when");return}if(vd.test(e.content)){n.whenQuery=Or(t,e,Od,c.InvalidSpecificationQueryAction,"when query","when query <Query>",(d,p)=>({kind:"SpecificationWhenQuerySyntax",query:d,arguments:p,location:f(e)}));return}let o=ld.exec(e.content);if(o===null){t.error(c.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),Se(t,e.indent);return}let s=[],a=Ir(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}l(qd,"parseWhen");function Bd(t,e,n){if(Cd.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(c.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",f(e)):(n.thenNoEvents=!0,n.noEventsLine=e);let o=t.peekChild(e.indent);o!==void 0&&t.error(c.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),Se(t,e.indent);return}if(br.test(e.content)){let o=ta(t,e);n.thenReturns!==null?t.error(c.InvalidReturnExpectation,"A specification declares at most one return expectation.",f(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(c.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,Se(t,e.indent);return}if($d.test(e.content)){Fd(t,e,n);return}if(bd.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(c.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},Se(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(c.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),Se(t,e.indent)):n.thenDenied!==null?t.error(c.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",f(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:f(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:f(e)});return}if(e.content.startsWith("then error case.")){let o=Ie(e.content.substring(11),{...f(e),column:f(e).column+11},t);o.kind==="CaseValueExpressionSyntax"&&n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,caseValue:o,location:f(e)});return}let i=fd.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:Q(i[1]),location:f(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(c.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),Se(t,e.indent);return}if(Ma.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=Yd(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=ja.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=Ie(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax"||s.kind==="CaseValueExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:f(e)})}t.skipOpaqueBlock(e.indent);return}if(dd.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=l((u,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(u,y,f(h)),t.skipBlock(h.indent)},"reject"),a=Rd.exec(e.content);if(a===null)return s(c.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let d=[],p=[],m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!m?d.push(...Sn(t.valueContext,u,!0)):u.content==="arguments"?s(c.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,u):u.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:Sn(t.valueContext,u,!0),exactly:!1,location:f(u)}):s(c.UnknownSpecificationQueryDirective,`Unexpected '${D(u.content)}' in 'then query' body - expected arguments or result`,u),m||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:d,results:p,exactly:a[2]!==void 0,location:f(e)});return}if(Da.test(e.content)){let o=qa(t,e,ud,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Dr(t,e,cd,"then");r!==void 0&&n.thenEvents.push(r)}l(Bd,"parseThen");function Yd(t,e){let n=ja.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(c.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),Se(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Td.test(i)?Ie(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax"||o.kind==="CaseValueExpressionSyntax");s||t.error(c.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(c.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(d)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}l(Yd,"parseAbsentReadModel");function Se(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}l(Se,"skipBody");function La(t,e,n){let i=Pd.exec(e.content);return Se(t,e.indent),i===null||i[1]!==n?(t.error(Lt(e.content)?c.InvalidSpecificationCaseReference:c.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,f(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:f(e)}}l(La,"parseClock");function Na(t,e,n){return Or(t,e,wd,c.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}l(Na,"parseCapture");function Or(t,e,n,i,r,o,s){let a=n.exec(e.content);return a===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,f(e)),Se(t,e.indent),null):s(a[1],Sn(t,e))}l(Or,"parseNamedStep");function Fd(t,e,n){let i=Id.exec(e.content);if(i===null){t.error(c.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),Se(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:Sn(t,e),exactly:i[1]!==void 0,location:f(e)})}l(Fd,"parseResult");function qa(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(c.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),Se(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:Sn(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}l(qa,"parseReadModelStep");function Dr(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(c.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),Se(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...Ir(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}l(Dr,"parseEventStep");var Mr=$e("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),Ud=O("^streamId\\s*=(?!=|>)\\s*(.+)$");function Ir(t,e,n,i,r){let o=[];ci(t,e,i,o);let s=null,a,d,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Wn.test(m.content)){let y=jt(t,m,Vn,c.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let u=Tr.exec(m.content);if(u!==null)gn(t,o,Ba(t,m,u));else if(D(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(c.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(p){t.error(c.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=Mr.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(d={kind:"SpecificationNoStreamSyntax",location:f(m)},p=!0,li(t,m)):y!==null?(a=jr(t,m,y),p=!0):(t.error(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(D(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(c.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(c.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=Ie(y,f(m),t)}else t.error(c.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...d===void 0?{}:{noStream:d}}}l(Ir,"parseValuesWithEventSource");function jr(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(c.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=f(a),r=Pr(t,a,c.InvalidSpecificationStream).map(m=>m.source.kind==="PathExpressionSyntax"&&m.source.path.startsWith("case.")?{...m,source:Ie(m.source.path,m.source.location,t)}:m));continue}let d=Ud.exec(a.content);if(d===null||i!==null||o){t.error(c.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let p={...f(a),column:a.indent+1+a.content.indexOf(d[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:Ie(d[1],p,t),location:f(a)},li(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...f(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:f(e)}}l(jr,"parseSpecificationStream");function li(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(c.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}l(li,"rejectSpecificationRouteChildren");function Sn(t,e,n=!1,i){let r=[];ci(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"?md:Tr).exec(o.content);if(s===null){t.error(c.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}gn(t,r,Ba(t,o,s,n))}return r}l(Sn,"parseValues");function Ba(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:Ie(n[2],f(e),t,i),location:f(e)}}l(Ba,"mappingOf");var Wd=Z("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",W)),Vd=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",W));function ot(t,e){let n=Wd.exec(e.content);if(n===null)return t.error(c.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:f(e)};let i=zd(t,e,void 0,!0,n[1]);for(let r of Nt(i))t.error(c.InvalidSpecificationCaseReference,"Case references are not permitted in example bodies.",r.location);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}l(ot,"parseExample");function ci(t,e,n,i){if(n?.groups?.property===void 0)return;let r=n.groups.property,o=n.groups.value,s=e.content.length-o.length,a=f(e),d=Mt(t,o,{...a,column:a.column+s},c.InvalidSpecificationValue);d!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:d,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}l(ci,"addInlineValue");function gn(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(c.DuplicateSpecificationAssignment,`Property '${n.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,n.location);return}e.push(n)}l(gn,"addFixtureValue");function zd(t,e,n,i=!1,r){let o=[],s=[],a=null,d=null,p,m;ci(t,e,n,o);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(u.content)==="description"){d=G(t,u,d,`Example '${r}'`);continue}if(i&&Wn.test(u.content)){let h=jt(t,u,Vn,c.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):gn(t,s,h,o));continue}let y=Vd.exec(u.content);if(r!==void 0&&y===null&&(D(u.content)==="stream"||u.content.startsWith("no stream"))){let h=Mr.exec(u.content);p!==void 0||m!==void 0?(t.error(c.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(u)),t.skipOpaqueBlock(u.indent)):u.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:f(u)},li(t,u)):h!==null?p=jr(t,u,h):(t.error(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",f(u)),t.skipOpaqueBlock(u.indent));continue}if(y!==null)gn(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:Ie(y[2],f(u),t),location:f(u)},s);else if(D(u.content)==="for"){let h=u.content.substring(3).trim();h.length===0?t.error(c.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(u)):a!==null?t.error(c.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(u)):a=Ie(h,f(u),t)}else t.error(c.InvalidSpecificationValue,`Invalid property mapping '${u.content}' - expected '<property> = <value>'`,f(u))}return{values:o,for:a,generatedValues:s,description:d,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}l(zd,"parseFixtureBody");var Ya=["StateChange","StateView","Automation","Translate"];var de;(function(t){t.Inbound="Inbound",t.Outbound="Outbound"})(de||(de={}));var Lr="events",Nr="from";function xn(t){return t.syntaxKind===Lr}l(xn,"isEventsSource");function Fa(t){return xn(t)?t.settings.filter(e=>e.name===Nr):[]}l(Fa,"consumedEvents");var se;(function(t){t.Private="Private",t.Public="Public"})(se||(se={}));var Qd=new RegExp(`^${W}*$`),vn=l(t=>Qd.test(t),"isBlankPublicEventOrigin");function di(t){if(t.kind==="EventSyntax"||t.kind==="ImportSyntax"){let e=t,n=e.visibility===void 0?se.Private:e.visibility;if(n!==se.Private&&n!==se.Public)return"Event visibility must be Private or Public.";if(e.origin!=null&&(typeof e.origin!="string"||vn(e.origin)))return"An event or import origin must be a nonblank quoted string.";if(e.origin!=null&&n!==se.Public)return"An event or import with an origin is a public contract.";if(t.kind==="ImportSyntax"&&n===se.Public&&e.origin==null)return"A public contract import requires an origin."}if(t.kind==="SliceSyntax"){let e=t;if(e.direction!=null&&e.type!=="Translate")return"Only a Translate slice may declare a direction.";if(e.direction!=null&&e.direction!==de.Inbound&&e.direction!==de.Outbound)return"A translation direction must be Inbound or Outbound."}}l(di,"publicEventMetadataError");var $n=["tag"];var Gd=O(`^id\\s+"(${z})"$`),Gt=class{static{l(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(D(n.content)){case"id":{let r=Gd.exec(n.content),o=r===null?"":Q(r[1]);return o.trim().length===0||this.value.id!==null?e.error(c.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(c.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=G(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=Pe(e,n,this.value.documentation,`Event '${this.name}'`,c.InvalidEventDocumentation),!0;default:return!1}}};var _d=O("^type\\s+([A-Za-z_]\\w*)$"),Zd=O(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${z})")?$`),Kd=O("^readmodel\\s+([A-Za-z_]\\w*)$"),Ua=4294967295,Jd=O("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Hd=O("^[A-Za-z_]\\w*$"),Wa=l(t=>D(t.content)==="description"&&Ze(t)===void 0,"isDescription");function qr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}l(qr,"withoutIdentifier");function Va(t,e){let n=_d.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,f(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Wa(o)){r=G(t,o,r,`Type '${n}'`);continue}if(oi(o))continue;let s=Le(t,o);if(s===void 0){t.error(c.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(qr(t,s,o,c.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(c.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}l(Va,"parseType");function za(t,e){let n=Zd.exec(e.content),i=n?.groups?.name??"";n===null&&t.error(c.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,f(e));let r=n?.groups?.origin===void 0?null:Q(n.groups.origin),o=n?.groups?.public!==void 0||r!==null?se.Public:se.Private;r!==null&&vn(r)&&t.error(c.InvalidEventDeclaration,"An event origin must be a nonblank quoted string",f(e));let s=n?.groups?.generation!==void 0,a=1;if(s){let u=Number(n.groups.generation);!Number.isSafeInteger(u)||u===0||u>=Ua?t.error(c.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Ua-1}`,f(e)):a=u}let d=[],p=[],m=new Gt(i);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),oi(u))continue;if($n.includes(D(u.content))){let h=bn(t,u);h!==void 0&&p.push(h);continue}let y=Le(t,u);if(y===void 0){m.tryParse(t,u)||t.error(c.InvalidPropertyDeclaration,`Invalid property '${u.content}' - expected '<name> <Type>'`,f(u));continue}d.push(qr(t,y,u,c.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:d,tags:p,visibility:o,origin:r,generation:a,hasGenerationMarker:s,...m.value,location:f(e)}}l(za,"parseEvent");function bn(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&Jd.test(i)&&t.warning(c.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,f(e)),i.length===0){t.error(c.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(Hd.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=ae(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(c.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,f(e));return}return{kind:"TagSyntax",value:r,location:f(e)}}l(bn,"parseTag");function Qa(t,e){let n=Kd.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,f(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Wa(s))r=G(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&Ze(s)===void 0)o=Pe(t,s,o,`Read model '${n}'`);else{if(oi(s))continue;{let a=Le(t,s);if(a===void 0){t.error(c.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,f(s));continue}i.push(qr(t,a,s,c.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,documentation:o,location:f(e)}}l(Qa,"parseReadModel");var Xd=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function be(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(c.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let s=t.substring(1,t.length-1),a=0;for(let d=0;d<s.length;d++){if(s[d]!=="$"||s[d+1]!=="{")continue;d>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,d),location:e});let p=s.indexOf("}",d);if(p<0)return n.error(c.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:be(s.substring(d+2,p),e,n),location:e}),d=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 Me(i,e,n);if(t.startsWith("literal ")){let o=pn(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(c.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=pn(t,e,n);return r!==void 0?r:Xd.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(c.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}l(be,"parseProjectionExpression");var ui=l(t=>({legacy:O(t),native:Z(t)}),"grammar"),ep=ui("^capture\\s+([A-Za-z_]\\w*)$"),tp=/^[A-Za-z_][\w.]*$/,np=ui("^append\\s+([A-Z]\\w*)$"),ip=ui("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),rp=ui("^nested\\s+([\\w.]+)$"),pi=l((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),op=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ap=Z("^([a-z_]\\w*)\\s*=\\s*(.+)$"),sp=Z(`^"(${z})"\\s*=>\\s*(\\w+)$`),lp=Z(`^split\\s+(\\S+)\\s+by\\s+"(${z})"$`),cp=new RegExp(Z(`"${z}"|[\\w.]+`).source,"gu"),dp=Z("^[\\w.]+$");function Br(t,e){let n=t;t=t.valueContext;let i=pi(t,ep).exec(e.content)?.[1]??"";i===""&&t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"source":r=pp(t,m,n);break;case"key":o=m.content.substring(3).trim();break;case"map":s.push(..._a(t,m));break;case"append":Za(t,m,a);break;case"children":{let u=pi(t,ip).exec(m.content);if(u===null){t.error(c.InvalidChildrenDeclaration,`Invalid children declaration '${m.content}' - expected 'children <collection> identified by <key>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Ga(t,m);u!==null&&d.push({kind:"CaptureChildrenSyntax",property:u[1],identifiedBy:u[2],...y,location:f(m)});break}case"nested":{let u=pi(t,rp).exec(m.content);if(u===null){t.error(c.InvalidNestedDeclaration,`Invalid nested declaration '${m.content}' - expected 'nested <Property>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Ga(t,m);u!==null&&p.push({kind:"CaptureNestedSyntax",property:u[1],...y,location:f(m)});break}default:t.error(c.UnknownCaptureDirective,`Unexpected '${m.content}' in capture body`,f(m)),t.skipOpaqueBlock(m.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:i,source:r,key:o,map:s,appends:a,children:d,nested:p,location:f(e)}}l(Br,"parseCapture");function pp(t,e,n){let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);i.push({kind:"CaptureSourceSettingSyntax",name:s,value:o.content.substring(s.length).trim(),location:f(o)})}let r=e.content.substring(6).trim();return r===Lr&&up(n,e,i),{kind:"CaptureSourceSyntax",syntaxKind:r,settings:i,location:f(e)}}l(pp,"parseSource");function up(t,e,n){n.length===0&&t.error(c.InvalidCaptureEventsSource,"'source events' needs at least one 'from <Event>' line naming a public event to consume",f(e));let i=new Set;for(let r of n)r.name!==Nr?t.error(c.InvalidCaptureEventsSource,`'source events' accepts only 'from <Event>' lines, got '${r.name}'`,r.location):tp.test(r.value)?i.has(r.value)?t.error(c.InvalidCaptureEventsSource,`Event '${r.value}' is already consumed by this 'source events'`,r.location):i.add(r.value):t.error(c.InvalidCaptureEventsSource,`Invalid event '${r.value}' - expected 'from <Event>', optionally qualified with dots`,r.location)}l(up,"validateEventsSource");function _a(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=f(i);if(D(i.content)==="split"){let u=lp.exec(i.content);if(u===null){t.error(c.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(),dp.test(h.content)?y.push(h.content):t.error(c.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));u!==null&&n.push({kind:"CaptureSplitSyntax",source:be(u[1],r,t),separator:Q(u[2]),targets:y,location:r});continue}let o=ap.exec(i.content);if(o===null){t.error(c.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let s=o[2].trim(),a=s.startsWith("`")?s.indexOf("`",1):-1,d=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||d||s.substring(a+1).trim()==="")?s.substring(0,a+1):d?s.substring(0,s.length-10).trimEnd():s,m=[];if(d)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let y=sp.exec(u.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:Q(y[1]),to:y[2],location:f(u)}):t.error(c.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,f(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:be(p,r,t),translations:m,location:r})}return n}l(_a,"parseMap");function Ga(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=_a(t,r):D(r.content)==="append"?Za(t,r,i):(t.error(c.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}l(Ga,"mapAndAppends");function Za(t,e,n){let i=pi(t,np).exec(e.content);if(i===null){t.error(c.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=l((d,p=!1)=>{let m=f(d);if(D(d.content)==="tag"){let y=bn(t.valueContext,d,!1);y!==void 0&&o.push(y);return}let u=op.exec(d.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:oe(u[1]),source:Me(u[2],m,t.valueContext),location:m}):t.error(p?c.InvalidPropertyMapping:c.UnknownAppendDirective,`Unexpected '${d.content}' in append body`,m)},"mapping");for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(d.content)==="when"){s=fp(t,d);for(let p=t.peekChild(d.indent);p!==void 0;p=t.peekChild(d.indent))t.reader.takeSignificant(),a(p,!0)}else a(d);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}l(Za,"pushAppend");function fp(t,e){let n=e.content.substring(4).trim(),i=f(e),r=l((d,p=[],m=null,u=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:d,properties:p,fromValue:m,toValue:u,expression:y,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(c.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(c.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${z}"|[^\\s]+`,"gu"):cp)??[]],s=l(d=>d.startsWith('"')&&d.endsWith('"')?Q(d.substring(1,d.length-1)):d,"unquote");if(o.length===0)return t.error(c.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(c.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(c.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(c.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let d=1;d<o.length-1;d+=2){if(o[d]!==o[1])return t.error(c.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[d+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}l(fp,"parseWhen");var Yr=O("^returns\\s+(@?[A-Za-z_]\\w*)$"),mp=O("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Fr(t,e){let n=f(e);if(e.content!=="returns"){let r=Yr.exec(e.content);if(r===null)return t.error(c.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(c.InvalidCommandResponse,"A scalar response cannot have child directives.",f(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:oe(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=mp.exec(r.content);if(o===null){Ze({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(c.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",f(r)):t.error(c.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",f(r)),t.skipBlock(r.indent);continue}let s=f(r),a=o[2]===void 0?null:je(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Ve(t,a,r),i.push({kind:"ResponseFieldSyntax",name:oe(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:oe(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let d=t.peekChild(r.indent);d!==void 0&&(t.error(c.InvalidCommandResponse,"A response field cannot have child directives.",f(d)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}l(Fr,"parseCommandResponse");var fi=new WeakMap;function mi(t){let e=Z(`^reads${W}+([A-Z]\\w*)(?:${W}+as${W}+([a-z_]\\w*))?(?:${W}+by${W}+([a-z_]\\w*))?$`).exec(t.content);if(!(e===null||["as","by","reads"].includes(e[2])))return{kind:"ReadsSyntax",readModel:e[1],alias:e[2]??null,by:e[3]??null,location:f(t)}}l(mi,"captureReads");function Ka(t){return new he(t.reader.fork(),t.path,t.languages)}l(Ka,"fork");function Ja(t,e){if(e.content!=="concurrency")return;let n=Ka(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),D(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=Z(`^(sourceType|streamType|streamId)${W}+([A-Za-z_]\\w*)$`).exec(s.content);a!==null&&(r[a[1]]??=a[2]);break}case"events":{if(o!==void 0)break;let a=s.content.slice(6).split(",").map(d=>d.replace(new RegExp(`^${W}+|${W}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(d=>Z("^[A-Z]\\w*$").test(d))&&(o=a);break}default:n.skipBlock(s.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:f(e)}}l(Ja,"captureConcurrency");function Ha(t,e){let n=Z(`^reducer${W}+([A-Za-z_]\\w*)${W}*=>${W}*([A-Za-z_]\\w*)$`).exec(e.content),i=Ka(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),D(o.content)==="description"){G(i,o,null,"Reducer");continue}let s=Z(`^on${W}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:f(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:f(e)}}l(Ha,"captureReducer");var yp=O("^produces\\s+operation(?:\\s|$)"),hp=O("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),Sp=O("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Xa=O("^produces\\s+when\\s+(.+)$"),gp=O("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),xp=O("^for\\s+(\\S.*)$"),vp=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),$p=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),bp=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function kn(t,e,n=!1){if(yp.test(e.content)){if(!n){t.error(c.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let x=si(t,e,!0);return{kind:"ProducesSyntax",when:null,event:x.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:x.operation,mappings:x.mappings,for:null,tags:[],location:f(e)}}let i=hp.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(c.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(c.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",f(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(Xa.test(e.content)){o=Qe(t,Xa.exec(e.content)[1],f(e));let x=t.peekChild(e.indent);if(x===void 0||!gp.test(x.content)){t.error(c.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=x,s=x.content,a=x.indent+1}else{let x=Sp.exec(e.content);if(x===null){t.error(c.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=x[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let d=[],p=new Set,m=[],u=[],y=new Gt(s),h=null;for(let x=t.peekChild(r.indent);x!==void 0;x=t.peekChild(r.indent)){t.reader.takeSignificant();let g=D(x.content),S=f(x);if(bp.has(g)){t.error(c.ReservedProductionMetadata,`'${g}' is system-assigned production metadata and cannot be supplied here`,S),t.skipOpaqueBlock(x.indent);continue}if(i!==null&&(g==="generation"||g==="origin")){t.error(g==="generation"?c.InlineEventGeneration:c.ReservedProductionMetadata,g==="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(x.indent);continue}if(g==="tag"){let A=bn(t,x,!1);A!==void 0&&u.push(A);continue}let C=xp.exec(x.content);if(C!==null){h!==null?t.error(c.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,S):h=ae(C[1],S,t);continue}let $=(i===null?vp:$p).exec(x.content),P=$===null||i===null?void 0:Le(t,{...x,content:$[1].trimEnd()});if($!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(c.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(c.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,S),p.add(A),d.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??oe($[1]),source:ae($[2],{...S,column:x.indent+x.content.length-$[2].length+1},t),location:S})}else(i===null||!y.tryParse(t,x))&&t.error(c.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${x.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,S)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...f(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?u:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:d,tags:u,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}l(kn,"parseProduces");var kp=O("^command\\s+([A-Za-z_]\\w*)$"),Ep=$e("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Cp=O("\\bseverity\\s+(\\S+)$"),ts=O(`\\bmessage\\s+(?:"(${z})"|(\\$strings\\.\\S*))$`),Pp=O("^([\\w.]+)\\s+(.+)$"),Ap=O("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),wp=$e("^[A-Za-z_]\\w*$"),Op=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),Ip={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},ns={information:"Information",warning:"Warning",error:"Error"},Tp=new Set(["reads","concurrency"]),Rp=new Set(["description","documentation","handler","concurrency"]);function is(t,e){let n=new Set,i=new he(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,es(i,e,void 0,n),es(t,e,n)}l(is,"parseCommand");function es(t,e,n,i){let r=kp.exec(e.content)?.[1]??"";r===""&&t.error(c.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,d=[],p=[],m=[],u=[],y,h=null,x=null,g=null,S=null,C=null,$=[];for(let b=t.peekChild(e.indent);b!==void 0;b=t.peekChild(e.indent)){t.reader.takeSignificant();let w=D(b.content),T=Ze(b);if(T!==void 0&&(Rp.has(w)||w==="validate"&&b.content!=="validate csharp"))a=yi(t,o,T,r,b,a);else if(w==="returns"){let I=Yr.exec(b.content);I!==null&&!I[1].startsWith("@")&&T!==void 0?n===void 0?(o.push(T),s.push({line:b,candidate:T,response:null})):n.has(T.type.name)?s.push({line:b,candidate:null,response:Fr(t,b)}):a=yi(t,o,T,r,b,a):T!==void 0?a=yi(t,o,T,r,b,a):Un(t,b)?t.skipBlock(b.indent):s.push({line:b,candidate:null,response:Fr(t,b)})}else if(w==="stream"&&Ep.test(b.content)&&T!==void 0&&t.streamCandidates?.hasSource(T.type.name.split(".")[0])===!0){let[I,j]=T.type.name.split("."),N=t.streamCandidates.hasPropertyType(T.type.name)&&t.streamCandidates.hasUniqueStream(I,j),L=wa(t,b,T,N);(C!==null||$.length>0)&&t.error(c.InvalidCommandStream,"A command declares at most one stream route.",f(b)),N||C!==null?$.push(L):C=L}else if(w==="description")h=G(t,b,h,`Command '${r}'`);else if(w==="documentation")x=Pe(t,b,x,`Command '${r}'`);else if(w==="authorize")g=Je(g,yt(t,b));else if(w==="validate"){let I=Ur(t,b,"command");I!==void 0&&d.push(I)}else if(w==="produces"){let I=kn(t,b,!0);I!==void 0&&p.push(I)}else if(w==="handler")S=Ta(t,b);else if(Tp.has(w)){let I=mi(b);I!==void 0&&u.push(I),w==="concurrency"&&y===void 0&&(y=Ja(t,b));let j=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(b.content);j!==null&&m.push({readModel:j[1],alias:j[2]??null}),Op.test(b.content)&&t.error(c.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(b)),t.skipOpaqueBlock(b.indent)}else T!==void 0?a=yi(t,o,T,r,b,a):(Un(t,b),t.error(c.UnknownCommandDirective,`Unexpected '${b.content}' in command body`,f(b)),t.skipBlock(b.indent))}let P=new Set(s.flatMap(b=>b.candidate===null?[]:[b.candidate])),A=new Set(o.filter(b=>!P.has(b)).map(b=>b.name));s.some(b=>b.candidate!==null&&!A.has(b.candidate.type.name)&&b.candidate.type.name!=="returns")&&A.add("returns");for(let b of A)i?.add(b);let v=null,k=new Set;for(let b of s){let w=b.response;if(b.candidate!==null){if(!A.has(b.candidate.type.name))continue;k.add(b.candidate),w={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:b.candidate.type.name,location:b.candidate.type.location},location:f(b.line)}}w!==null&&(v!==null?t.error(c.InvalidCommandResponse,"A command declares at most one unconditional response.",f(b.line)):v=w)}S!==null&&p.length>0&&t.error(c.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let E={kind:"CommandSyntax",name:r,description:h,documentation:x,authorize:g,properties:o.filter(b=>!k.has(b)),validations:d,produces:p,handler:S,response:v,stream:C,streamCandidates:$,location:f(e)};return fi.set(E,m),it.set(E,{reads:u,concurrency:y}),E}l(es,"parseCommandBody");function yi(t,e,n,i,r,o){return Ve(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(c.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,n.location),n={...n,isIdentifier:!1}),e.push(n),o??(n.isIdentifier?n:void 0)}l(yi,"addProperty");function Ur(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=Be(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:f(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(c.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=Qe(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,u="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let x=ts.exec(h.content);x!==null&&x.index===0?m=x[1]!==void 0?Q(x[1]):x[2]:D(h.content)==="severity"?(y||(u=ns[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:u,location:f(a)});continue}let d=Dp(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);d!==void 0&&r.push(d)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=Be(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(c.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}l(Ur,"parseValidate");function Dp(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=jp(e.content),s=Lp(i,e,r);if(s===void 0)return;let a=Pp.exec(s.content);if(a===null){i.error(c.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let d=Np(i,a[2],e);if(d===void 0)return;let p=d.kind==="Rule"?Mp(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:d.kind,value:d.value,message:o,severity:s.severity,...p,location:f(e)}}l(Dp,"parseValidationRule");function Mp(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?yn(t,i):{file:zt(i)?ht(t,i):null,code:!zt(i)&&mn(t,i)?Be(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(c.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,f(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?c.InvalidImplementationBlock:c.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),mn(t,s)?Be(t,s):t.skipBlock(s.indent);return o}l(Mp,"parseRuleImplementation");function jp(t){let e=ts.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?Q(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}l(jp,"splitMessage");function Lp(t,e,n){let i=Cp.exec(n);if(i===null)return{content:n,severity:"Error"};let r=ns[i[1]];if(r===void 0){t.error(c.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}l(Lp,"splitSeverity");function Np(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Ap.exec(e);if(i===null){t.error(c.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!wp.test(r)){t.error(c.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,f(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:f(n)}}}return{kind:Ip[i[1]],value:ae(i[2],f(n),t)}}l(Np,"parseRule");var qp=O("^constraint\\s+([A-Za-z_]\\w*)$"),Bp=O("^unique\\s+event\\s+([A-Z]\\w*)$"),Yp=O("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Fp=O("^released\\s+by\\s+([A-Z]\\w*)$"),Up=O(`^message\\s+"(${z})"$`),Wp=l(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function rs(t,e){let n=qp.exec(e.content);n===null&&t.error(c.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,d=null,p=null,m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(u.content)==="description"){p=G(t,u,p,`Constraint '${i}'`);continue}let y=Fp.exec(u.content),h=Up.exec(u.content);y!==null?s.has(y[1])?t.error(c.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${y[1]}'`,f(u)):(o.push(y[1]),s.add(y[1])):h!==null?d!==null?t.error(c.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(u)):d=Q(h[1]):u.content==="ignore casing"?(m&&t.error(c.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(u)),m=!0):Vp(t,i,u,r,a)}for(let u of o.filter(y=>a.has(y)))t.error(c.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${u}'`,f(e));return r.length===0&&(t.error(c.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(hi(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||d!==null||m)&&t.error(c.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:d,ignoreCasing:m,description:p}}l(rs,"parseConstraint");function Vp(t,e,n,i,r){let o=zp(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(c.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=Wp(o);if(s!==void 0&&r.has(s)){t.error(c.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}l(Vp,"addRule");function zp(t,e,n){let i=f(n),r=Bp.exec(n.content);if(r!==null)return hi(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=Yp.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(c.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return hi(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(ye(n)){t.warning(c.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 hi(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(c.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}l(zp,"parseRule");function hi(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}l(hi,"rule");var Qp=O("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),Gp=O("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),_p=O("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),Zp=O("^with\\s+(@?[\\w.]+)$"),Kp=O("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),Jp=O("^nested\\s+(@?[\\w.]+)$"),Hp=O("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Xp=O("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),eu=O("^clear\\s+with\\s+(@?[\\w.]+)$"),tu=O("^variant\\s+(@?[\\w.]+)\\s*$"),nu=O("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),iu=O("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),ru=O("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),ou=O("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),os=O("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),au={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Vr(t,e){let n=Qp.exec(e.content);if(n===null)return t.error(c.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o=null,s="Inherit",a=null,d=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(p))continue;let m=D(p.content);if(m==="description")o=G(t,p,o,`Projection '${i}'`);else if(m==="sequence")r=p.content.substring(8).trim();else if(m==="automap")s="Enabled";else if(p.content==="no automap")s="Disabled";else if(m==="key")a=ss(t,p);else if(m==="variant")d.push(mu(t,p));else{let u=zr(t,p,!1);u!==void 0&&d.push(u)}}return su(t,d,i),d.length===0&&t.error(c.EmptyProjection,`Projection '${i}' must contain at least one directive`,f(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:s,key:a,blocks:d,description:o,location:f(e)}}l(Vr,"parseProjection");function su(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(c.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(c.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}l(su,"reportVariantConflicts");function zr(t,e,n){let i=f(e);switch(D(e.content)){case"from":return lu(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Wr(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}=Wr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return cu(t,e);case"children":return du(t,e);case"nested":return pu(t,e);case"remove":return uu(t,e);case"clear":return n||t.error(c.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),fu(t,e);default:t.error(c.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}l(zr,"parseBlock");function lu(t,e){let n=[];for(let s of Ho(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(c.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let d=Gp.exec(a);if(d===null){t.error(c.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:oe(d[1]),key:d[2]===void 0?null:be(d[2],f(e),t),location:f(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=ss(t,s):a==="parent"?o=be(s.content.substring(6),f(s),t):ls(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}l(lu,"parseFrom");function cu(t,e){let n=_p.exec(e.content);if(n===null)return t.error(c.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,f(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:f(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Zp.exec(r.content);if(o===null){t.error(c.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Wr(t,r);i.push({kind:"JoinEventSyntax",event:oe(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:oe(n[1]),on:oe(n[2]),events:i,location:f(e)}}l(cu,"parseJoin");function du(t,e){let n=Kp.exec(e.content);if(n===null)return t.error(c.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,f(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let{autoMap:i,blocks:r}=as(t,e);return{kind:"ChildrenSyntax",property:oe(n[1]),identifiedBy:be(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}l(du,"parseChildren");function pu(t,e){let n=Jp.exec(e.content);if(n===null)return t.error(c.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,f(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let i=oe(n[1]),{autoMap:r,blocks:o}=as(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(c.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}l(pu,"parseNested");function as(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=zr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}l(as,"parseChildBlocks");function uu(t,e){let n=Xp.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:oe(n[1]),key:n[2]===void 0?null:be(n[2],f(e),t),location:f(e)};let i=Hp.exec(e.content);if(i===null){t.error(c.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,f(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),D(o.content)==="parent"?r=be(o.content.substring(6),f(o),t):t.error(c.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:oe(i[1]),key:i[2]===void 0?null:be(i[2],f(e),t),parentKey:r,location:f(e)}}l(uu,"parseRemove");function fu(t,e){let n=eu.exec(e.content);return n===null?(t.error(c.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:oe(n[1]),location:f(e)}}l(fu,"parseClearWith");function mu(t,e){let n=tu.exec(e.content);if(n===null)return t.error(c.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:f(e)};let i=oe(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(yu(t,s));else if(a==="variant")t.error(c.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let d=zr(t,s,!1);d!==void 0&&o.push(d)}}return r.length===0&&t.error(c.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}l(mu,"parseVariant");function yu(t,e){let n=nu.exec(e.content);return n===null?(t.error(c.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:f(e)}):{kind:"ProjectionEntersOnSyntax",event:oe(n[1]),key:n[2]===void 0?null:be(n[2],f(e),t),location:f(e)}}l(yu,"parseEntersOn");function ss(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:be(n,f(e),t),location:f(e)};let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),o.content==="}")continue;let s=os.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=be(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(c.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:oe(s[1]),expression:a,location:f(o)})}let r=t.reader.peekSignificant();return r!==void 0&&r.indent===e.indent&&r.content==="}"&&t.reader.takeSignificant(),t.sourceOptions.numericMode==="exact"&&i.length===0&&t.error(c.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}l(ss,"parseKey");function Wr(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)||ls(t,o,r);return{autoMap:i,mappings:r}}l(Wr,"parseMappingBlock");function ls(t,e,n){let i=f(e),r=iu.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:au[r[1]],property:oe(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(c.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=ru.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:oe(o[2]),value:be(o[3],i,t),location:i});return}let s=ou.exec(e.content)??os.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:oe(s[1]),source:be(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(c.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}l(ls,"pushMapping");var hu=O("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Su=O("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),gu=O("^scoped\\s+to\\s+([a-z_]\\w*)$"),xu=new Set(["performer"]);function ds(t,e){let n=hu.exec(e.content);if(n===null)return t.error(c.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:je("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=je(n[3],{...f(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||Ve(t,r,e);let o=null,s=[],a=null,d=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=D(m.content);if(u==="description")a=G(t,m,a,`Query '${i}'`);else if(u==="by"){let y=cs(t,m,"by");y!==void 0&&(o!==null&&t.error(c.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(u==="filter"){let y=cs(t,m,"filter");y!==void 0&&s.push(y)}else u==="authorize"?p=Je(p,yt(t,m)):u==="scoped"?d=vu(t,m,d,i)??d:xu.has(u)?t.skipOpaqueBlock(m.indent):(t.error(c.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,f(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:d,authorize:p,location:f(e)}}l(ds,"parseQuery");function cs(t,e,n){let i=Su.exec(e.content.substring(n.length).trim());if(i===null){t.error(c.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,f(e));return}let r=e.content.indexOf(i[1],n.length),o=je(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Ve(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ae(i[3],f(e),t.valueContext),location:f(e)}}l(cs,"parseParameter");function vu(t,e,n,i){let r=gu.exec(e.content);if(r===null){t.error(c.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(c.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}l(vu,"parseScope");var $u=O("^@?[a-z_]\\w*\\s+[\\w.]+");function Qr(t,e){let n=Le(t,e);if(n!==void 0){n.isGenerated&&t.error(c.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(c.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}$u.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(c.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}l(Qr,"parseTriggerData");function ps(t,e){let n=t.triggerData.length;for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),D(i.content)==="description"?G(t,i,null,`Trigger '${e.content}'`):ye(i)||Qr(t,i);return t.triggerData.slice(n)}l(ps,"parseTriggerDeclaration");var bu=O("^reaction\\s+([A-Za-z_]\\w*)$"),ku=O("^when\\s+([A-Za-z_]\\w*)$"),Eu=O("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Cu=O("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Pu=new Set(["when","every","at"]),Au=O("^invokes\\s+([A-Z]\\w*)$"),wu=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Gr=Z("^on\\s+refused\\b(?=$|\\s+by\\b)"),Ou=Z("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),Iu=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function us(t,e){let n=bu.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=null,s=[],a=new Set,d=!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=G(t,p,i,`Reaction '${n}'`);continue}if(m==="documentation"){r=Pe(t,p,r,`Reaction '${n}'`);continue}if(m==="where"){o=Qe(t,p.content.substring(5).trim(),f(p));continue}if(Gr.test(p.content)){t.error(c.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent),d=!0;continue}if(!Pu.has(m)){t.error(c.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,f(p)),t.skipBlock(p.indent),d=!0;continue}let u=Mu(t,p);if(u===void 0){d=!0;continue}let y=Du(u);if(a.has(y)){t.error(c.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,f(p)),t.skipBlock(p.indent);continue}a.add(y),s.push(Tu(t,p,u))}return s.length===0&&!d&&t.error(c.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:f(e)}}l(us,"parseReaction");function Tu(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=G(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let u=kn(t,p);u!==void 0&&r.push(u)}else if(m==="invokes"){let u=Au.exec(p.content);if(u===null)t.error(c.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,f(p)),t.skipBlock(p.indent);else{let y=new he(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,qe(y,p),t.inputUses.push(...y.inputUses);let h=[],x=[];for(let g=t.peekChild(p.indent);g!==void 0;g=t.peekChild(p.indent)){if(t.reader.takeSignificant(),Gr.test(g.content)){let C=Ru(t,g);C!==void 0&&x.push(C);continue}let S=wu.exec(g.content);S!==null?h.push({kind:"PropertyMappingSyntax",property:S[1].replaceAll("@",""),source:Me(S[2],f(g),t.valueContext),location:f(g)}):t.error(c.InvalidPropertyMapping,`Invalid property mapping '${g.content}' - expected '<property> = <source>'`,f(g))}o.push({kind:"InvokesSyntax",command:u[1],mappings:h,onRefused:x,location:f(p)})}}else if(Gr.test(p.content))t.error(c.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let u=mi(p);u!==void 0&&s.push(u),Iu.test(p.content)&&t.error(c.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let u=t.triggerData.length;Qr(t,p);for(let y of t.triggerData.slice(u))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let d={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return it.set(d,{reads:s,data:a}),d}l(Tu,"parseTrigger");function Ru(t,e){let n=Ou.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(c.InvalidRefusalBranch,"Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.",f(e)),t.skipBlock(e.indent);return}let i=[],r=!1,o=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(c.InvalidRefusalBranchBody,"A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.",f(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(c.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=kn(t,s);a!==void 0?i.push(a):o=!0}else t.error(c.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",f(s)),t.skipBlock(s.indent),o=!0;return!r&&i.length===0&&!o&&t.error(c.InvalidRefusalBranchBody,"A refusal branch must acknowledge or produce an event.",f(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:f(e)}}l(Ru,"parseRefusal");function Du(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}l(Du,"sourceKey");function Mu(t,e){let n=f(e);switch(D(e.content)){case"when":{let i=ku.exec(e.content);if(i===null){t.error(c.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=Eu.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(c.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:Nu(i[2]),location:n}}default:return ju(t,e)}}l(Mu,"parseTriggerSource");function ju(t,e){let n=f(e),i=Cu.exec(e.content),r=i===null?void 0:Lu(i[1]);if(i===null||r===void 0){t.error(c.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(c.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${e.content}' - a day of the month is between 1 and 31`,n),t.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:null,dayOfMonth:o,location:n}}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:i[2]??null,dayOfMonth:null,location:n}}l(ju,"parseSchedule");function Lu(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}l(Lu,"timeOf");function Nu(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}l(Nu,"unitOf");var qu=O("^(data|query|component)\\s+(\\S+)(.*)$"),Bu=O("^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$"),Yu=O("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),Fu=O('^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$'),Uu=O("^mode\\s+(oneWay|twoWay)\\b(.*)$"),Wu=O("^null\\s+(propagate|clear|preserve)\\b(.*)$"),Vu=O("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function _t(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"||r==="literal"?fs(t,`from ${i}`,n):fs(t,i,n)}l(_t,"parseFromClause");function fs(t,e,n){let i=e.trim();if(!i.startsWith("from "))return _r(t,at("DataContext",i,n),"",n);let r=i.substring(5).trim();if(r.startsWith("literal ")){let a=Bu.exec(r);return a===null?(t.error(c.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from literal <value>'`,n),{...at("Invalid",r,n),rawText:i}):_r(t,{...at("Literal","",n),literal:ae(a[1],n,t)},a[2]??"",n)}let o=qu.exec(r);if(o===null)return t.error(c.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,n),{...at("Invalid",r,n),rawText:i};let s=zu(t,o[1],o[2],i,n);return _r(t,s,o[3],n)}l(fs,"parseUiBinding");function zu(t,e,n,i,r){return e==="data"?at("DataContext",n,r):e==="query"?Qu(t,n,i,r):Gu(t,n,i,r)}l(zu,"parseBindingSource");function Qu(t,e,n,i){let r=Yu.exec(e);return r===null?(t.error(c.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...at("Invalid",e,i),rawText:n}):{...at("QueryResult",r[2]??"",i),query:r[1]}}l(Qu,"queryBinding");function Gu(t,e,n,i){let r=Fu.exec(e);if(r===null)return t.error(c.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...at("Invalid",e,i),rawText:n};let o=r[1]??r[2],s=r[3];return{...at("ComponentProperty",s,i),componentId:o,componentPropertyPath:s}}l(Gu,"componentBinding");function _r(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=Uu.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=Wu.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let d=Vu.exec(o);if(d!==null){r={...r,expectedValueType:d[1]},o=d[2].trim();continue}return t.error(c.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}l(_r,"withModifiers");function at(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}l(at,"create");var At=`(?:"(${z})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,_u=O("^screen\\s+([A-Za-z_]\\w*)$"),Zu=O("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Ku=O("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),ms=O(`^label\\s+${At}$`),Ju=O(`^action\\s+${At}$`),Hu=O("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Xu=O(`^route\\s+${At}$`),ef=O("^outlet\\s+([A-Za-z_]\\w*)$"),tf=O("^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$"),ys=O("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),nf=O("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),rf=O(`^id\\s+(?:"(${z})"|(\\S+))$`),of=O("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),af=O("^property\\s+([\\w.]+)\\s*=\\s+(.+)$"),sf=O("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),lf=O(`^presentation\\s+([A-Za-z_]\\w*)\\s+${At}$`),cf=O("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),df=O("^[a-z_]\\w*$"),pf=O(`^title\\s+${At}$`),uf=O(`^column\\s+([\\w.]+)(?:\\s+label\\s+${At})?$`),ff=O("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),mf=O(`^field\\s+([\\w.]+)\\s+label\\s+${At}$`),st=l((t,e)=>t[e]!==void 0?Q(t[e]):t[e+1],"operandText"),yf=l(t=>["on","uses"].includes(D(t.content)),"isInteraction"),hf=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function hs(t,e){let n=_u.exec(e.content);n===null&&t.error(c.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[],r=[],o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="contribute"){let a=Sf(t,s);a!==void 0&&r.push(a)}else D(s.content)==="description"?o=G(t,s,o,`Screen '${n?.[1]??""}'`):ye(s)||Ss(t,s,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,description:o,...r.length>0?{contributions:r}:{},location:f(e)}}l(hs,"parseScreen");function Sf(t,e){let n=tf.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid screen contribution '${e.content}' - expected 'contribute to <Point> [order <n>]'`,f(e)),t.skipBlock(e.indent);return}return{kind:"ScreenContributionSyntax",contributionPoint:n[1],order:n[2]===void 0?null:Number(n[2]),directives:gi(t,e),location:f(e)}}l(Sf,"parseScreenContribution");function Ss(t,e,n){let i=gf(t,e);i!==void 0&&n.push(i)}l(Ss,"pushDirective");function gi(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),Ss(t,i,n);return n}l(gi,"parseDirectives");function gf(t,e){switch(D(e.content)){case"data":return xf(t,e);case"action":return vf(t,e);case"template":return $f(t,e);case"section":return bf(t,e);case"title":return kf(t,e);case"table":return Ef(t,e);case"summary":return Cf(t,e);case"component":return Pf(t,e);case"toolbar":return Tf(t,e);case"navigate":return Si(t,e.content,e);case"on":return qe(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(hf(t,e))return Mf(t,e);t.error(c.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}l(gf,"parseDirective");function xf(t,e){let n=Zu.exec(e.content);if(n===null){t.error(c.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:je(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}l(xf,"parseData");function vf(t,e){let n=Ju.exec(e.content);if(n!==null)return ha(t,e,st(n,1),Si);let i=Ku.exec(e.content);if(i===null){t.error(c.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,f(e)),t.skipBlock(e.indent);return}let r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=ms.exec(s.content);a!==null?r=st(a,1):D(s.content)==="navigate"?o=Si(t,s.content,s)??null:t.error(c.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,f(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:f(e)}}l(vf,"parseAction");function Si(t,e,n){let i=Hu.exec(e);if(i===null){t.error(c.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}let r=[],o=null,s=null;for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let d=ys.exec(a.content);if(d!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:d[1],binding:_t(t,d[2],f(a)),location:f(a)});continue}let p=Xu.exec(a.content);if(p!==null){o=st(p,1);continue}let m=ef.exec(a.content);if(m!==null){s=m[1];continue}t.error(c.InvalidNavigation,`Unexpected '${a.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,f(a))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,...s===null?{}:{outlet:s},parameters:r,location:f(n)}}l(Si,"parseNavigate");function $f(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(),!df.test(r.content)){t.error(c.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:gi(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}l($f,"parseTemplateReference");function bf(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:gi(t,e),location:f(e)}}l(bf,"parseSection");function kf(t,e){let n=pf.exec(e.content);return n===null?(t.error(c.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:st(n,1),location:f(e)}}l(kf,"parseTitle");function Ef(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=uf.exec(o.content),a=ff.exec(o.content);if(s!==null){let d=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:d?st(s,2):null,location:f(o)})}else a!==null?r=Si(t,a[1],o)??null:D(o.content)==="on"?qe(t,o):yf(o)?t.skipOpaqueBlock(o.indent):t.error(c.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,f(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:f(e)}}l(Ef,"parseTable");function Cf(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=mf.exec(r.content);if(o===null){t.error(c.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:st(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}l(Cf,"parseSummary");function Pf(t,e){let n=nf.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"context":i=Af(t,m);break;case"id":r=Of(t,m);break;case"property":wf(t,m,s);break;case"icon":o=m.content.substring(4).trim();break;case"presentation":gs(t,m,d);break;case"exposes":If(t,m,a);break;case"outlet":p.push({kind:"ComponentOutletSyntax",name:m.content.substring(6).trim(),directives:gi(t,m),location:f(m)});break;case"on":qe(t,m);break;case"uses":t.skipOpaqueBlock(m.indent);break;default:t.error(c.UnknownScreenDirective,`Unexpected '${m.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,f(m)),t.skipBlock(m.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],stableId:r,context:i,properties:s,exposes:a,presentation:d,icon:o,outlets:p,location:f(e)}}l(Pf,"parseComponent");function Af(t,e){return Df(t,e.content.substring(7).trim(),e)}l(Af,"parseUiContext");function wf(t,e,n){let i=of.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:_t(t,i[2],f(e)),value:null,location:f(e)});return}let r=af.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:ae(r[2],f(e),t),location:f(e)});return}t.error(c.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,f(e))}l(wf,"parseComponentProperty");function Of(t,e){let n=rf.exec(e.content);return n===null?(t.error(c.UnknownScreenDirective,`Invalid component id '${e.content}' - expected 'id "stable-id"'`,f(e)),null):st(n,1)}l(Of,"parseStableId");function If(t,e,n){let i=sf.exec(e.content);if(i===null){t.error(c.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,f(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:_t(t,i[2],f(e)),location:f(e)})}l(If,"parseExposedValue");function gs(t,e,n){let i=lf.exec(e.content);if(i===null){t.error(c.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,f(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:st(i,2),location:f(e)})}l(gs,"parsePresentationValue");function Tf(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=Rf(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:f(e)}}l(Tf,"parseToolbar");function Rf(t,e){let n=cf.exec(e.content);if(n===null){t.error(c.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=ms.exec(d.content);if(p!==null){i=st(p,1);continue}let m=ys.exec(d.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:_t(t,m[2],f(d)),location:f(d)});continue}if(D(d.content)==="icon"){r=d.content.substring(4).trim();continue}gs(t,d,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:f(e)}}l(Rf,"parseToolbarItem");function Df(t,e,n){return _t(t,e,f(n))}l(Df,"parseUiBindingValue");function Mf(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(c.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(c.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=Yt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}l(Mf,"parseCode");var jf=O("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),Lf=new Set(["reducer"]);function xs(t,e){let n=jf.exec(e.content),i="StateChange",r="";n===null?t.error(c.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Ya.includes(n[1])?i=n[1]:t.error(c.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,f(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=!1,d=null,p=null,m=[],u=[],y=[],h=[],x=[],g=[],S=[],C=[],$=[],P=[],A=[],v=[],k=[],E=[];for(let w=t.peekChild(e.indent);w!==void 0;w=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ye(w))continue;let T=w.content.split(/[ \t]/,1)[0],I=T==="public"||T==="direction"?T:D(w.content);if(I==="description")d=G(t,w,d,`Slice '${r}'`);else if(I==="documentation")p=Pe(t,w,p,`Slice '${r}'`);else if(I==="purpose")Ft(t,w,A);else if(I==="operation")u.push(si(t,w).operation);else if(I==="direction"){let j=/^direction\s+(inbound|outbound)$/.exec(w.content);a||i!=="Translate"||j===null?t.error(c.InvalidSliceDeclaration,"Declare direction inbound or direction outbound once, inside a Translate slice only",f(w)):s=j[1]==="inbound"?de.Inbound:de.Outbound,a=!0}else I==="event"||I==="public"?m.push(za(t,w)):I==="command"?y.push(is(t,w)):I==="query"?h.push(ds(t,w)):I==="projection"?x.push(Vr(t,w)):I==="capture"?S.push(Br(t,w)):I==="reaction"?g.push(us(t,w)):I==="constraint"?C.push(rs(t,w)):I==="example"?P.push(ot(t,w)):I==="specification"?$.push(Rr(t,w)):I==="readmodel"?v.push(Qa(t,w)):I==="screen"?k.push(hs(t,w)):Lf.has(I)?(E.push(Ha(t,w)),t.skipOpaqueBlock(w.indent)):(t.warning(c.UnknownSliceDirective,`Unknown construct '${I}' in slice '${r}'`,f(w)),t.skipBlock(w.indent))}t.scope=o;let b={kind:"SliceSyntax",type:i,name:r,direction:s,description:d,documentation:p,examples:P,purposes:A,events:m,operations:u,commands:y,queries:h,projections:x,captures:S,reactions:g,constraints:C,specifications:$,readModels:v,screens:k,location:f(e)};return it.set(b,{reducers:E}),b}l(xs,"parseSlice");var Nf=O("^feature\\s+([A-Za-z_]\\w*)$"),qf=new Set(["on","uses","contribute"]),Zr="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",En=class{static{l(this,"FeatureBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=[];#l=null;#a=null;#n=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#l=G(e,n,this.#l,`Feature '${this.name}'`),!0;case"documentation":return this.#a=Pe(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return ni(e,n,this.#r,c.UnknownFeatureDirective),!0;case"purpose":return Ft(e,n,this.#o),!0;case"authorize":return this.#n=Je(this.#n,yt(e,n)),!0;case"import":return Ut(e,n,this.#i),!0;case"feature":return this.#e.push(xi(e,n)),!0;case"example":return this.#s.push(ot(e,n)),!0;case"slice":return this.#t.push(xs(e,n)),!0;default:return qf.has(i)?(qe(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#l,documentation:this.#a,authorize:this.#n,dependsOn:this.#r,purposes:this.#o,features:this.#e,slices:this.#t,examples:this.#s,fileImports:this.#i,isPlacement:n,location:e}}};function xi(t,e){let n=Nf.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new En(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(c.UnknownFeatureDirective,`Unexpected '${D(o.content)}' in feature body - expected ${Zr}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}l(xi,"parseFeature");var Kr=O("^module\\s+([A-Za-z_]\\w*)$"),Bf=new Set(["on","uses","screen","dialog","form","contribute"]),Jr="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",Cn=class{static{l(this,"ModuleBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=null;#l=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#o=G(e,n,this.#o,`Module '${this.name}'`),!0;case"documentation":return this.#l=Pe(e,n,this.#l,`Module '${this.name}'`),!0;case"depends":return ni(e,n,this.#i,c.UnknownModuleDirective),!0;case"purpose":return Ft(e,n,this.#r),!0;case"authorize":return this.#a=Je(this.#a,yt(e,n)),!0;case"import":return Ut(e,n,this.#s),!0;case"example":return this.#t.push(ot(e,n)),!0;case"feature":return this.#e.push(xi(e,n)),!0;default:return Bf.has(i)?(qe(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(c.UnknownModuleDirective,`Unexpected '${D(i.content)}' in module body - expected ${Jr}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#o,documentation:this.#l,authorize:this.#a,dependsOn:this.#i,purposes:this.#r,features:this.#e,examples:this.#t,fileImports:this.#s,isPlacement:n,location:e}}};function Hr(t,e){let n=Kr.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new Cn(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}l(Hr,"parseModule");var Uf=new WeakMap,_e=l(t=>JSON.stringify(t),"authoredOrderKey");function Pn(t){return Uf.get(t)??new Map}l(Pn,"authoredOrderOf");var St=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var lt=class extends Error{static{l(this,"InvalidDependencyQuery")}};var Ye=class{static{l(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.exposures?.forEach(n=>{this.visitNode(n),n.properties.forEach(i=>this.visitNode(i))}),e.instanceContributions?.forEach(n=>{this.visitNode(n),n.contributions.forEach(i=>{this.visitNode(i),i.value!==null&&this.visitExpression(i.value),i.items.forEach(r=>{this.visitNode(r),r.values.forEach(o=>{this.visitNode(o),this.visitExpression(o.value)})})})}),e.purposes?.forEach(n=>this.visitPurpose(n)),e.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n))}visitPurpose(e){this.visitNode(e),e.transfers.forEach(n=>this.visitPurposeTransfer(n))}visitPurposeReference(e){this.visitNode(e)}visitPurposeTransfer(e){this.visitNode(e)}visitPolicy(e){this.visitNode(e),e.condition!==null&&this.visitPolicyCondition(e.condition),e.code!==null&&this.visitCodeBlock(e.code),e.file!==null&&this.visitFileReference(e.file)}visitPolicyCondition(e){this.visitNode(e),e.kind==="ClaimConditionSyntax"&&e.matches!==null&&this.visitExpression(e.matches),e.kind==="NotPolicyConditionSyntax"&&this.visitPolicyCondition(e.operand),e.kind==="LogicalPolicyConditionSyntax"&&(this.visitPolicyCondition(e.left),this.visitPolicyCondition(e.right))}visitSeed(e){this.visitNode(e),e.groups.forEach(n=>{this.visitNode(n),n.events.forEach(i=>{this.visitNode(i),i.properties.forEach(r=>this.visitPropertyMapping(r))})})}visitPersona(e){this.visitNode(e)}visitAuthorize(e){this.visitNode(e),this.visitPolicyRequirement(e.requirement)}visitPolicyRequirement(e){this.visitNode(e),e.kind==="LogicalPolicyRequirementSyntax"&&(this.visitPolicyRequirement(e.left),this.visitPolicyRequirement(e.right))}visitDomain(e){this.visitNode(e)}visitImport(e){this.visitNode(e)}visitFileImport(e){this.visitNode(e)}visitConcept(e){this.visitNode(e),e.attributes.forEach(n=>this.visitNode(n)),e.validations?.forEach(n=>this.visitValidate(n))}visitType(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitDependsOn(e){this.visitNode(e)}visitModule(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n))}visitFeature(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n)),e.slices.forEach(n=>this.visitSlice(n))}visitSlice(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.commands.forEach(n=>this.visitCommand(n)),e.operations?.forEach(n=>this.visitOperation(n)),e.events.forEach(n=>this.visitEvent(n)),e.constraints.forEach(n=>this.visitConstraint(n)),e.queries.forEach(n=>this.visitQuery(n)),e.projections.forEach(n=>this.visitProjection(n)),e.readModels.forEach(n=>this.visitReadModel(n)),e.captures.forEach(n=>this.visitCapture(n)),e.reactions.forEach(n=>this.visitReaction(n)),e.screens.forEach(n=>this.visitScreen(n)),e.specifications.forEach(n=>this.visitSpecification(n))}visitTriggerData(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type)}visitReads(e){this.visitNode(e)}visitConcurrency(e){this.visitNode(e)}visitReducer(e){this.visitNode(e),e.rules.forEach(n=>this.visitReducerRule(n))}visitReducerRule(e){this.visitNode(e),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitForm(e){this.visitNode(e),e.populate!==null&&this.visitNode(e.populate),e.fields.forEach(n=>this.visitNode(n)),e.columns?.forEach(n=>this.visitNode(n)),e.layout!==null&&e.layout!==void 0&&(this.visitNode(e.layout),e.layout.columns.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width),n.minWidth!==null&&this.visitNode(n.minWidth),n.maxWidth!==null&&this.visitNode(n.maxWidth)}),e.layout.columnGap!==null&&this.visitNode(e.layout.columnGap),e.layout.rowGap!==null&&this.visitNode(e.layout.rowGap),e.layout.placements.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width)})),e.onSubmit!==null&&this.visitScreenDirective(e.onSubmit)}visitCommand(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.stream!=null&&this.visitCommandStream(e.stream),e.streamCandidates?.forEach(n=>this.visitCommandStream(n)),e.validations.forEach(n=>this.visitValidate(n)),e.produces.forEach(n=>this.visitProduces(n)),e.handler!=null&&this.visitHandler(e.handler),e.response!=null&&this.visitCommandResponse(e.response)}visitEventSource(e){this.visitNode(e),e.identifier!==null&&this.visitTypeRef(e.identifier),e.streams.forEach(n=>this.visitEventStream(n))}visitEventStream(e){this.visitNode(e),e.streamId!==null&&this.visitTypeRef(e.streamId),e.streamIdParts.forEach(n=>this.visitEventStreamIdPart(n))}visitEventStreamIdPart(e){this.visitNode(e),this.visitTypeRef(e.type)}visitCommandStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n)),e.propertyCandidate!==null&&this.visitProperty(e.propertyCandidate)}visitSystem(e){this.visitNode(e)}visitOperation(e){this.visitNode(e),e.inputs.forEach(n=>this.visitProperty(n)),e.execute!==null&&this.visitOperationPhase(e.execute),e.compensate!==null&&this.visitOperationPhase(e.compensate)}visitOperationPhase(e){this.visitNode(e),e.implementation!==null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitSpecificationOperationFailure(e){this.visitNode(e)}visitSpecificationCompensated(e){this.visitNode(e)}visitSpecificationOperation(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitHandler(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitImplementation(e){this.visitNode(e),e.hints.forEach(n=>this.visitImplementationHint(n))}visitImplementationHint(e){this.visitNode(e)}visitFileReference(e){this.visitNode(e)}visitCodeBlock(e){this.visitNode(e)}visitCommandResponse(e){e.kind==="ScalarCommandResponseSyntax"?this.visitScalarCommandResponse(e):this.visitRecordCommandResponse(e)}visitScalarCommandResponse(e){this.visitNode(e),this.visitPropertyResponseSource(e.source)}visitRecordCommandResponse(e){this.visitNode(e),e.fields.forEach(n=>this.visitResponseField(n))}visitResponseField(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type),this.visitPropertyResponseSource(e.source)}visitPropertyResponseSource(e){this.visitNode(e)}visitSpecificationReturn(e){e.kind==="ScalarSpecificationReturnSyntax"?this.visitScalarSpecificationReturn(e):this.visitRecordSpecificationReturn(e)}visitScalarSpecificationReturn(e){this.visitNode(e),this.visitExpression(e.value)}visitRecordSpecificationReturn(e){this.visitNode(e),e.fields.forEach(n=>this.visitPropertyMapping(n))}visitValidate(e){this.visitNode(e),e.kind==="DeclarativeValidateSyntax"?(e.rules.forEach(n=>this.visitValidationRule(n)),e.requirements?.forEach(n=>{this.visitNode(n),this.visitCondition(n.condition)})):e.code!=null&&this.visitCodeBlock(e.code)}visitValidationRule(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.value!==null&&this.visitExpression(e.value),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitEvent(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.tags.forEach(n=>this.visitTag(n))}visitTag(e){this.visitNode(e),this.visitExpression(e.value)}visitReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitConstraint(e){this.visitNode(e),e.kind==="FileConstraintSyntax"&&this.visitNode(e.file),e.additionalRules.forEach(n=>this.visitConstraint(n))}visitQuery(e){this.visitNode(e),this.visitTypeRef(e.returnType),e.by!==null&&this.visitQueryParameter(e.by),e.filters.forEach(n=>this.visitQueryParameter(n)),e.authorize!==null&&this.visitAuthorize(e.authorize)}visitQueryParameter(e){this.visitNode(e),this.visitTypeRef(e.type),e.source!=null&&this.visitExpression(e.source)}visitKey(e){this.visitNode(e),e.kind==="ExpressionKeySyntax"?this.visitExpression(e.expression):e.parts.forEach(n=>{this.visitNode(n),this.visitExpression(n.expression)})}visitProjection(e){this.visitNode(e),e.key!=null&&this.visitKey(e.key),e.blocks.forEach(n=>this.visitProjectionBlock(n))}visitProjectionBlock(e){switch(this.visitNode(e),e.kind){case"FromSyntax":e.events.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.key!=null&&this.visitKey(e.key),e.parentKey!=null&&this.visitExpression(e.parentKey),e.mappings.forEach(n=>this.visitMapping(n));break;case"EverySyntax":case"AllSyntax":e.mappings.forEach(n=>this.visitMapping(n));break;case"JoinSyntax":e.events.forEach(n=>this.visitJoinEvent(n));break;case"ProjectionVariantSyntax":e.entersOn.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"ChildrenSyntax":e.identifiedBy!==void 0&&this.visitExpression(e.identifiedBy),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"NestedSyntax":e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"RemoveWithSyntax":e.parentKey!=null&&this.visitExpression(e.parentKey),e.key!=null&&this.visitExpression(e.key);break;case"RemoveViaJoinSyntax":e.key!=null&&this.visitExpression(e.key);break}}visitJoinEvent(e){this.visitNode(e),e.mappings.forEach(n=>this.visitMapping(n))}visitMapping(e){this.visitNode(e),e.source!==void 0&&this.visitExpression(e.source),e.value!==void 0&&this.visitExpression(e.value)}visitCondition(e){this.visitNode(e),e.kind==="ComparisonConditionSyntax"?this.visitExpression(e.right):(this.visitCondition(e.left),this.visitCondition(e.right))}visitReaction(e){this.visitNode(e),e.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)),e.contributions?.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))})}visitScreenDirective(e){if(e.kind==="ScreenGuardedActionSyntax"){this.visitScreenGuardedAction(e);return}switch(this.visitNode(e),e.kind){case"ScreenDataSyntax":this.visitTypeRef(e.type);break;case"ScreenActionSyntax":e.navigate!==null&&this.visitScreenDirective(e.navigate);break;case"ScreenNavigateSyntax":e.parameters.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)});break;case"ScreenTemplateReferenceSyntax":e.slots.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(n=>this.visitScreenDirective(n));break;case"ScreenTableSyntax":e.columns.forEach(n=>this.visitNode(n)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(n=>this.visitNode(n));break;case"ScreenComponentSyntax":e.context!==null&&this.visitUiBinding(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitUiBinding(n.binding),n.value!==null&&this.visitExpression(n.value)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)}),e.presentation.forEach(n=>this.visitNode(n)),e.outlets.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenToolbarSyntax":e.items.forEach(n=>{this.visitNode(n),n.parameters.forEach(i=>{this.visitNode(i),this.visitUiBinding(i.binding)}),n.presentation.forEach(i=>this.visitNode(i))});break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitScreenGuardedAction(e){this.visitNode(e),e.alternatives.forEach(n=>this.visitScreenActionAlternative(n)),e.otherwise!==null&&this.visitScreenActionOtherwise(e.otherwise),e.navigate!==null&&this.visitScreenDirective(e.navigate)}visitScreenActionAlternative(e){this.visitNode(e),this.visitCondition(e.condition),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitScreenActionOtherwise(e){this.visitNode(e),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitInteractionArgument(e){this.visitNode(e)}visitSpecification(e){this.visitNode(e),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.parameters?.forEach(n=>{this.visitNode(n),this.visitTypeRef(n.type)}),e.cases?.forEach(n=>{this.visitNode(n),n.values.forEach(i=>this.visitPropertyMapping(i))}),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(n=>this.visitSpecificationOperationFailure(n)),e.thenOperations?.forEach(n=>this.visitSpecificationOperation(n)),e.thenCompensated?.forEach(n=>this.visitSpecificationCompensated(n)),e.givenCallerPersona!=null&&this.visitNode(e.givenCallerPersona),e.givenCaller!=null&&(this.visitNode(e.givenCaller),e.givenCaller.claims.forEach(n=>this.visitNode(n))),e.given.forEach(n=>this.visitSpecificationEvent(n)),e.givenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(n=>this.visitSpecificationCapture(n)),e.whenAppended!==null&&this.visitSpecificationEvent(e.whenAppended),e.whenRedelivered!=null&&this.visitSpecificationRedelivery(e.whenRedelivered),e.whenClock!==null&&this.visitSpecificationClock(e.whenClock),e.whenTrigger!==null&&this.visitSpecificationTrigger(e.whenTrigger),e.whenCapture!==null&&this.visitSpecificationCapture(e.whenCapture),e.whenQuery!==null&&this.visitSpecificationWhenQuery(e.whenQuery),e.thenEvents.forEach(n=>this.visitSpecificationEvent(n)),e.thenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.thenAbsentReadModels?.forEach(n=>{this.visitNode(n),this.visitExpression(n.key)}),e.thenQueries?.forEach(n=>{this.visitNode(n),n.arguments.forEach(i=>this.visitPropertyMapping(i)),n.results.forEach(i=>this.visitSpecificationQueryResult(i))}),e.thenResults.forEach(n=>this.visitSpecificationQueryResult(n)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(n=>{this.visitNode(n),n.caseValue!=null&&this.visitExpression(n.caseValue)})}visitSpecificationRedelivery(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationExample(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.generatedValues.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationNoStream(e){this.visitNode(e)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(n=>this.visitPropertyMapping(n)),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitPropertyMapping(e){this.visitNode(e),this.visitExpression(e.source)}visitProperty(e){this.visitNode(e),this.visitTypeRef(e.type)}visitTypeRef(e){this.visitNode(e)}visitUiBinding(e){this.visitNode(e),e.literal!==null&&this.visitExpression(e.literal)}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 Wf={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 $i(t){let e=new vi;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}l($i,"sliceReferences");function bs(t,e){let n=new vi(e);return t.projections.forEach(i=>n.visitProjection(i)),ve(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}l(bs,"buildingReadModelReferences");function to(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...to(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?to(e.blocks):[])}l(to,"variants");var vi=class extends Ye{static{l(this,"SliceReferenceCollector")}readModel;references=[];shared=[];specification;projection=!1;constructor(e){super(),this.readModel=e}matches(e){return e.toLowerCase()===this.readModel?.toLowerCase()}visitSlice(e){super.visitSlice(e),ve(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=ve(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=ve(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=to(e.blocks);if(n.length===0?!this.matches(e.readModel??e.name):!n.some(i=>this.matches(i.name)))return}this.projection=!0,super.visitProjection(e),this.projection=!1}visitSpecification(e){this.specification=e,super.visitSpecification(e),this.specification=void 0}visitNode(e){let n=l((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:Wf[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 An(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=l(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let d=[],p;do p=i.pop(),r.delete(p),d.push(p);while(p!==a);o.push(d.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}l(An,"stronglyConnectedGroups");var ks=["usesFactsFrom","reactsTo","decidesFrom"],Xe=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),no=l((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),io=l((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),oo=l((t,e)=>t.rank-e.rank||Xe(t.key,e.key),"compareNodes"),wn=l(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(oo),"distinctNodes"),Es=l((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||St.indexOf(t.kind)-St.indexOf(e.kind)||t.producer.rank-e.producer.rank||Xe(t.location.path??"",e.location.path??"")||Xe(t.role,e.role)||Xe(t.name,e.name),"compareEvidence");function ao(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...ao(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?ao(e.blocks):[])}l(ao,"variants");var Zt=class t{static{l(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=io("application","",[],-1);static for(e,n=Pn(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=ze(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=l(($,P)=>$.map((A,v)=>({syntax:A,index:v,rank:n.get(_e([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,v)=>A.rank-v.rank||A.index-v.index).map(A=>A.syntax),"ordered"),r=l(($,P)=>{let A=this.add("feature",$.name,P);for(let v of i($.slices,A))this.slices.push({node:this.add("slice",v.name,A),syntax:v});for(let v of i($.features,A))r(v,A)},"feature");for(let $ of i(e.modules,this.root)){let P=this.add("module",$.name,this.root);for(let A of i($.features,P))r(A,P)}let o=new Map,s=new Map,a=l(($,P,A,v)=>{let k=no(P,A);$.has(k)||$.set(k,[]);let E=$.get(k);E.includes(v)||E.push(v);let b=no(P,[...v.scope,A].join("."));$.has(b)||$.set(b,[]);let w=$.get(b);w.includes(v)||w.push(v)},"declare");for(let{node:$,syntax:P}of this.slices){for(let A of le(P))a(o,"Event",A.name,$);for(let A of P.commands)a(o,"Command",A.name,$);for(let A of P.reactions)a(o,"Reaction",A.name,$);for(let A of P.queries)a(o,"Query",A.name,$);for(let A of P.screens)a(o,"Screen",A.name,$);for(let A of P.readModels)a(o,"ReadModel",A.name,$);for(let A of P.projections){let v=ao(A.blocks);v.length===0&&a(s,"ReadModel",A.readModel??A.name,$);for(let k of v)a(s,"ReadModel",k.name,$)}for(let A of ve(P).reducers??[])a(s,"ReadModel",A.readModel,$)}let d=new Set((e.declaredTriggers??[]).map($=>$.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map($=>$.name.toLowerCase())),m=new Set((e.policies??[]).map($=>$.name.toLowerCase())),u=e.imports.filter($=>$.qualifiedName.includes(".")).slice().sort(($,P)=>Xe($.location.path??"",P.location.path??"")||$.location.line-P.location.line||$.location.column-P.location.column||Xe($.qualifiedName,P.qualifiedName)),y=new Map,h=[],x=[],g=new Set,S=0;for(let{node:$,syntax:P}of this.slices){let A=$i(P);S+=A.shared.filter(v=>(v.kind==="type"?p:m).has(v.name.toLowerCase())).length;for(let v of A.references){let k=no(v.targetKind,v.name),b=(v.targetKind==="ReadModel"&&s.has(k)?s:o).get(k);if(b!==void 0&&b.length>0){let T=b[0];T!==$&&h.push({consumer:$,producer:T,kind:v.kind,role:v.role,name:v.name,ambiguous:b.length>1,alternatives:b.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}let w=v.targetKind==="Event"?u.filter(T=>T.qualifiedName.slice(T.qualifiedName.lastIndexOf(".")+1).toLowerCase()===v.name.toLowerCase()):[];if(w.length>0){let T=[];for(let I of w){g.add(I.qualifiedName);let j=I.qualifiedName.slice(0,I.qualifiedName.lastIndexOf(".")),N=`context:${j}`;if(!y.has(N)){let q=io("context",N,[j],this.modelNodes.length);this.modelNodes.push(q),y.set(N,q)}let L=y.get(N);T.includes(L)||T.push(L)}h.push({consumer:$,producer:T[0],kind:"outsideTheModel",role:v.role,name:v.name,ambiguous:T.length>1,alternatives:T.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}if(v.role==="trigger"&&d.has(v.name.toLowerCase())){S++;continue}x.push({consumer:$,kind:v.kind,role:v.role,name:v.name,location:v.location})}}let C=new Map;for(let $ of h.sort(Es)){let P=JSON.stringify([$.consumer.key,$.producer.key,$.kind]);C.has(P)||C.set(P,[]),C.get(P).push($)}this.edges=[...C.values()].map($=>({consumer:$[0].consumer,producer:$[0].producer,kind:$[0].kind,evidence:$})),this.unresolved=x.sort(($,P)=>$.consumer.rank-P.consumer.rank||$.location.line-P.location.line||$.location.column-P.location.column||St.indexOf($.kind)-St.indexOf(P.kind)||Xe($.location.path??"",P.location.path??"")||Xe($.name,P.name)),this.excludedReferences=S,this.unusedImports=[...new Set(u.filter($=>!g.has($.qualifiedName)).map($=>$.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new lt(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new lt(`Unsupported target level '${n}'.`);if(o<0)throw new lt("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let d of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(d,m))){let m=JSON.stringify([d.key,p.key]);s.has(m)||s.set(m,{source:d,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,d)=>a.source.rank-d.source.rank||a.target.rank-d.target.rank||Xe(a.source.key,d.source.key)||Xe(a.target.key,d.target.key)).map(a=>{let d=a.evidence.sort(Es),p={};for(let m of St){let u=d.filter(y=>y.kind===m).length;u>0&&(p[m]=u)}return{source:a.source,target:a.target,sliceEdges:new Set(d.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:d.length,byKind:p,consumers:wn(d.map(m=>m.consumer)),producers:wn(d.map(m=>m.producer)),evidence:d.slice(0,o),evidenceCount:d.length,evidenceTruncated:d.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new lt(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Cs(n)),r=wn(i.flatMap(o=>[o.source,o.target]));return Ps(ro(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Ps(ro(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let d=this.children.get(a.key),p=n.filter(S=>S.container===a),m=new Map(d.map(S=>[S.key,S])),u=An(ro(d,p)).map(S=>S.map(C=>m.get(C)).sort(oo)).sort((S,C)=>S[0].rank-C[0].rank),y=new Map(u.flatMap((S,C)=>S.map($=>[$.key,C]))),h=new Map(d.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 u)for(let C=1;C<S.length;C++)h.get(S[C].key).add(S[C-1].key);let x=new Set(d.map(S=>S.key)),g=[];for(;x.size>0;){let S=[...x].filter(C=>h.get(C).size===0).sort((C,$)=>oo(m.get(C),m.get($)))[0];g.push(m.get(S)),x.delete(S);for(let C of x)h.get(C).delete(S)}i.push({container:a,children:g,changed:d.some((S,C)=>S!==g[C])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=l(a=>{if(a.kind==="slice")o.push(a);else for(let d of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(d)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new lt(`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],d=[];for(let p=0;p<a.length;p++)for(let m of o.filter(u=>u.source.address===a[p]).sort((u,y)=>u.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),d.push(m.target),a.push(m.target.address));return wn(d)}add(e,n,i){let r=[...i.scope,n],o=r.join("."),s=`${e}:${o}`,a=this.byKey.get(s);if(a!==void 0)return a;let d=io(e,o,r,this.modelNodes.length);return this.modelNodes.push(d),this.byKey.set(s,d),this.parents.set(s,i),this.children.get(i.key).push(d),e!=="slice"&&this.children.set(s,[]),d}ancestors(e){let n=[];for(let i=this.parents.get(e.key);i!==void 0;i=this.parents.get(i.key))n.push(i);return n}disjoint(e,n){return e.key!==n.key&&!this.ancestors(e).includes(n)&&!this.ancestors(n).includes(e)}at(e,n){return[e,...this.ancestors(e)].filter(i=>i.kind===n)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind==="module"||e.kind==="feature")]}evidence(e,n){let i=As(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(Cs(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 As(t){let e=new Set(t??St);if([...e].some(n=>!St.includes(n)))throw new lt("Unsupported dependency kind.");return e}l(As,"selectedKinds");function Cs(t){return[...As(t??ks)].filter(e=>ks.includes(e))}l(Cs,"selectedOrderingKinds");function ro(t,e){let n=new Map(t.map(i=>[i.key,new Set]));for(let i of e)n.get(i.source.key).add(i.target.key);return n}l(ro,"adjacency");function Ps(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return An(t).filter(r=>r.length>1).map(r=>({container:n,members:wn(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}l(Ps,"groupsOf");var Vf=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],et=l((t,e)=>e===t||e.startsWith(t+"."),"contains"),Kt=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),zf=l((t,e)=>Kt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||Kt(t.kind,e.kind)||Kt(t.consumer.address,e.consumer.address)||Kt(t.producer.address,e.producer.address)||Kt(t.role,e.role)||Kt(t.name,e.name),"orderedEvidence"),Jt=class{static{l(this,"DeclaredDependencies")}static for(e){let n=new Map,i=l((u,y)=>{let h=u.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(x=>i([...u,x.name],x))},"inventory");if(e.modules.forEach(u=>i([u.name],u)),![...n.values()].some(u=>u.dependencies.length))return{containers:[],diagnostics:[]};let r=Zt.for(e,new Map),o=r.nodes.filter(u=>u.kind==="module"||u.kind==="feature"),s=Te.containersOf(e),a=l((u,y)=>{let h=Te.resolve(u,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),d=[],p=[],m=l((u,y,h,x)=>p.push({code:u,severity:y,message:h,location:x}),"finding");for(let u of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(u.address),h=y.dependencies.map(S=>{let C=a(S.target,u.scope),$=C!==void 0&&!et(u.address,C)&&!et(C,u.address);return{syntax:S,resolved:C,status:$?"unused":"invalid"}}),x=[],g=new Map;for(let S of r.edges.flatMap(C=>C.evidence).filter(C=>Vf.includes(C.kind)&&et(u.address,C.consumer.address)).sort(zf)){let C=[S.producer,...S.alternatives].filter(A=>!et(u.address,A.address)&&!et(A.scope.slice(0,-1).join("."),u.address));if(!C.length)continue;let $=h.filter(A=>A.status!=="invalid"&&C.some(v=>et(A.resolved,v.address)));for(let A of $)A.status=S.ambiguous&&A.status!=="used"?"provisional":"used";let P=S.ambiguous?"provisional":$.length?"declared":"undeclared";if(x.push({evidence:S,status:P,coveringDeclarations:$.map(A=>A.syntax)}),P==="undeclared"){let A=S.producer.scope[0];g.has(A)||g.set(A,[]),g.get(A).push(S)}}for(let S of g.values()){let C=S[0].producer.scope.slice(0,-1),$=C.findIndex((k,E)=>S.some(b=>E>=b.producer.scope.length-1||b.producer.scope[E]!==k));$>=0&&(C=C.slice(0,$));let P=C.join("."),A=et(u.address,P)||et(P,u.address)?[...new Set(S.map(k=>k.producer.scope.slice(0,-1).map((E,b)=>k.producer.scope.slice(0,b+1).join(".")).find(E=>!et(u.address,E)&&!et(E,u.address))))]:[P],v=S.map(k=>`${k.kind} ${k.role} '${k.name}' at ${k.location.path??""}:${k.location.line}:${k.location.column}`).join("; ");m(c.UndeclaredDependency,"warning",`Container '${u.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${v}`,y.location)}for(let S of h)S.status==="unused"&&m(c.UnusedDependencyDeclaration,"information",`Dependency '${S.syntax.target}' on '${u.address}' is not used by any counted explicit reference`,S.syntax.location),S.status!=="invalid"&&n.get(S.resolved).dependencies.some(C=>a(C.target,S.resolved.split("."))===u.address)&&m(c.MutualDependencyDeclarations,"information",`Containers '${u.address}' and '${S.resolved}' declare each other`,S.syntax.location);d.push({container:u,location:y.location,declarations:h,edges:x})}return{containers:d,diagnostics:p}}static validate(e,n){for(let i of this.for(e).diagnostics)n[i.severity==="warning"?"warning":"information"](i.code,i.message,i.location)}};var bi=class extends Ye{static{l(this,"PublicEventUsageCollector")}command=!1;uses=[];allEvents=[];projectionTargets=[];eventSources=[];visitProjection(e){e.readModel!=null&&this.projectionTargets.push({target:e.readModel,node:e}),super.visitProjection(e)}visitReducer(e){this.projectionTargets.push({target:e.readModel,node:e}),super.visitReducer(e)}visitCaptureSource(e){xn(e)&&(this.eventSources.push(e),Fa(e).forEach(n=>this.uses.push({name:n.value,node:n,output:!1,command:!1}))),super.visitCaptureSource(e)}visitSlice(e){super.visitSlice(e),ve(e).reducers?.forEach(n=>this.visitReducer(n))}visitCommand(e){this.command=!0,super.visitCommand(e),this.command=!1}visitProduces(e){e.inlineOperation==null&&this.uses.push({name:e.event,node:e,output:!0,command:this.command})}visitCaptureAppend(e){this.inputOrOutput(e.event,e,!0)}visitJoinEvent(e){this.inputOrOutput(e.event,e)}visitReducerRule(e){this.inputOrOutput(e.event,e)}visitConstraint(e){e.releasedBy.forEach(n=>this.inputOrOutput(n,e)),e.kind!=="FileConstraintSyntax"&&this.inputOrOutput(e.event,e),super.visitConstraint(e)}visitProjectionBlock(e){switch(e.kind){case"FromSyntax":e.events.forEach(n=>this.inputOrOutput(n.event,n));break;case"ClearWithSyntax":case"RemoveWithSyntax":case"RemoveViaJoinSyntax":this.inputOrOutput(e.event,e);break;case"AllSyntax":this.allEvents.push(e);break}super.visitProjectionBlock(e)}visitReactionTrigger(e){e.source.kind==="NamedTriggerSourceSyntax"&&this.inputOrOutput(e.source.name,e.source),super.visitReactionTrigger(e)}visitSpecification(e){}inputOrOutput(e,n,i=!1){this.uses.push({name:e,node:n,output:i,command:!1})}};var so=class extends Ye{static{l(this,"PublicEventMetadataValidator")}context;constructor(e){super(),this.context=e}visitNode(e){let n=di(e);if(n===void 0)return;let i=e.kind==="EventSyntax"?c.InvalidEventDeclaration:e.kind==="ImportSyntax"?c.InvalidImportDeclaration:c.InvalidSliceDeclaration;this.context.error(i,n,e.location)}};function ws(t,e){new so(e).visitApplication(t)}l(ws,"validatePublicEventMetadata");function ki(t,e){ws(t,e);let n=new re(t);if(!n.declarations.some(r=>r.node.kind==="EventSyntax"&&(r.node.visibility===se.Public||r.node.origin!=null))&&!t.imports.some(r=>r.visibility===se.Public||r.origin!=null)&&!n.slices.some(({slice:r})=>r.direction!=null||Gf(r)||_f(r,n)))return;let i=new re(t,n.declarations.filter(r=>r.kind===H.Event));for(let{slice:r,scope:o}of n.slices)Qf(t,r,o,n,i,e);for(let r of t.seeds?.flatMap(o=>o.groups.flatMap(s=>s.events))??[]){let o=co(t,i,[],r.event,r,!0,e);if(o?.visibility!==se.Public)continue;let s=o.origin==null?c.PublicEventRequiresOutboundTranslation:c.ForeignPublicEventProduced;e.error(s,`Seed cannot append public event '${r.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,r.location)}}l(ki,"validatePublicEventUsage");function Qf(t,e,n,i,r,o){let s=new bi;s.visitSlice(e);let a=[],d=e.type==="Translate"&&e.direction===de.Outbound,p=new Set(e.readModels.map(u=>u.name));for(let{target:u,node:y}of s.projectionTargets){let h=p.has(u)?void 0:co(t,r,n,u,y,!1,o);if(h!==void 0){if(!d){o.error(c.EventTargetOutsideOutboundTranslation,`'${u}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,y.location);continue}a.push({node:h,output:!0}),lo(e,u,y,!0,!1,h,o)}}if(!(e.type==="Translate"&&e.direction===de.Inbound)&&!d)for(let u of s.eventSources)o.error(c.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${e.name}'.`,u.location);for(let u of s.uses){let y=co(t,u.node.kind==="ProducesSyntax"?i:r,n,u.name,u.node,u.output,o);y!==void 0&&(a.push({node:y,output:u.output}),lo(e,u.name,u.node,u.output,u.command,y,o))}for(let u of s.allEvents){let y=i.declarations.filter(h=>h.kind===H.Event).map(h=>h.node);for(let h of[...y,...t.imports.filter(x=>x.visibility===se.Public)])a.push({node:h,output:!1}),lo(e,h.kind==="ImportSyntax"?h.qualifiedName:h.name,u,!1,!1,h,o)}if(e.type!=="Translate"||(e.direction==null&&(le(e).some(u=>u.visibility===se.Public)||a.some(u=>u.node.visibility===se.Public))&&o.error(c.PublicTranslationRequiresDirection,"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.",e.location),e.direction!==de.Outbound))return;let m=new Set(a.filter(u=>u.output&&u.node.visibility===se.Public&&u.node.origin==null).map(u=>u.node)).size;m!==1&&o.error(c.OutboundPublicEventCount,`Outbound Translate slice '${e.name}' must produce exactly one local public event type; found ${m}.`,e.location);for(let u of e.captures)o.error(c.TranslationConstructDirection,"An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.",u.location)}l(Qf,"validateSlice");function lo(t,e,n,i,r,o,s){let a=o.origin!=null,d=o.visibility===se.Public,p=l((m,u)=>s.error(m,u,n.location),"error");i?(r&&d&&p(c.CommandProducesPublicEvent,`Command cannot produce public event '${e}'; publish through an outbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&!d&&p(c.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${e}'.`),a&&p(c.ForeignPublicEventProduced,`Foreign public event '${e}' cannot be produced locally; translate it into a private local event.`),d&&!a&&(t.type!=="Translate"||t.direction!==de.Outbound)&&p(c.PublicEventRequiresOutboundTranslation,`Local public event '${e}' may only be produced by an explicitly outbound Translate slice.`),t.type==="Translate"&&(t.direction??de.Inbound)===de.Inbound&&(d||a)&&p(c.InboundTranslationOutput,`Inbound translation must produce private local events, not '${e}'.`)):(a&&(t.type!=="Translate"||t.direction!==de.Inbound)&&p(c.ForeignPublicEventConsumer,`Foreign public event '${e}' may only be consumed by an explicitly inbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&(d||a)&&p(c.OutboundTranslationInput,`Outbound translation must consume private local events, not '${e}'.`),t.type==="Translate"&&t.direction===de.Inbound&&(!d||!a)&&p(c.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${e}'.`))}l(lo,"validateUse");function co(t,e,n,i,r,o,s){let a=e.resolveFromScope(i,n);if(a.declaration?.node.kind==="EventSyntax")return a.declaration.node;if(a.kind===H.Operation)return;if(a.kind===H.Ambiguous){s.warning(c.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,r.location);return}let d=t.imports.filter(p=>p.qualifiedName.split(".").at(-1)===i||p.qualifiedName===i);if(d.length===1){let p=d[0],m=e.resolveFromScope(p.qualifiedName,n);if(m.declaration?.node.kind==="EventSyntax")return m.declaration.node;if(m.kind===H.Ambiguous){s.warning(c.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,r.location);return}return p.visibility===se.Public?p:void 0}d.length>1?s.warning(c.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,r.location):(o&&r.kind!=="CaptureAppendSyntax"||r.kind==="CaptureSourceSettingSyntax")&&!s.diagnostics.some(p=>p.code===c.UnknownEvent&&p.location.path===r.location.path&&p.location.line===r.location.line&&p.location.column===r.location.column)&&s.warning(c.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,r.location)}l(co,"resolve");function Gf(t){return t.captures.some(e=>e.source!=null&&xn(e.source))}l(Gf,"usesEventSource");function _f(t,e){return[...t.projections.map(i=>i.readModel),...(ve(t).reducers??[]).map(i=>i.readModel)].some(i=>i!=null&&e.declarations.some(r=>r.kind===H.Event&&r.name===i))}l(_f,"targetsEvent");function Ei(t,e,n,i=!1){let r=[],o=[],s=Ne,a=!1,d=!1,p=!1,m=new Map,u=new he(new Ge([]),e,n).languages;for(let h of t){let x=h;if(x.number===1&&x.raw.startsWith("\uFEFF")){let g=x.raw.substring(1),S=g.length-g.trimStart().length,C=sn(g.substring(S),i);x={...x,indent:S,contentOffset:1,content:(C<0?g.substring(S):g.substring(S,S+C)).trimEnd()}}if(p){Ar(x)&&(p=!1),r.push(x);continue}if(x.content.startsWith("```")&&(["```","```text","```markdown"].includes(x.content)||u.has(x.content.substring(3)))&&(p=!0),!p&&x.indent===0&&D(x.content)==="numbers"){let g=x.content!=="numbers exact"?c.InvalidNumericDirective:a?c.DuplicateNumericDirective:d?c.LateNumericDirective:void 0;g!==void 0?(o.push({severity:"error",code:g,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f(x)}),s=Object.freeze({numericMode:"invalid"})):s=ii,a=!0,r.push({...x,content:""});continue}!p&&x.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(x.content)&&m.set(x.number,{severity:"error",code:c.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f(x)}),d||=x.content.trim().length>0,r.push(x)}let y=new he(new Ge(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}l(Ei,"sourceContext");function Ci(t,e){let n=[],i=l(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(le))r.set(a.name,(r.get(a.name)??0)+1);let o=new Set(t.imports.map(a=>a.qualifiedName.split(".").at(-1))),s=new re(t);for(let{slice:a,command:d}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=d.produces.filter(y=>s.isEventProduction(y,a)),m=d.properties.find(y=>y.isIdentifier)?.name,u=pr(d,{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(c.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),u&&y.for===null&&e.error(c.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${d.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let x=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||x!==m))for(let g 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 '${g.property}' although it already identifies the event source`;h===null?e.information(c.EventSourceIdInPayload,S,g.location):e.warning(c.EventSourceIdInPayload,S,g.location)}}}}l(Ci,"validateInlineEvents");function Pi(t,e){let n=new re(t),i=zn(t),r=ne(t.concepts),o=new Map([...ne(t.types)].map(([$,P])=>[$,ne(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map($=>$.qualifiedName.split(".").at(-1))),d=new Map;for(let $ of t.imports){let P=$.qualifiedName.split(".").at(-1);d.set(P,[...d.get(P)??[],$.qualifiedName])}let p=l($=>{let P=new Map,A=new Map;for(let v of $){let k=P.get(v.name)??[];k.push(v),P.set(v.name,k)}return(v,k)=>{let E=JSON.stringify([v,k]);if(A.has(E))return A.get(E);let b=l(j=>{let N=j.split("."),L=P.get(N.at(-1))??[],q=N.slice(0,-1);if(q.length>0)return L.filter(V=>q.length<=V.scope.length&&q.every((K,J)=>V.scope[V.scope.length-q.length+J]===K));for(let V=k.length;V>=0;V--){let K=L.filter(J=>V<=J.scope.length&&k.slice(0,V).every((U,_)=>J.scope[_]===U));if(K.length>0)return K}return[]},"candidates"),w=b(v),T=d.get(v)??[];w.length===0&&T.length===1&&(w=b(T[0]));let I=w.length===1?w[0].node:null;return A.set(E,I),I}},"scoped"),m=p(n.slices.flatMap(({slice:$,scope:P})=>$.readModels.map(A=>({name:A.name,scope:P,node:A})))),u=p(n.slices.flatMap(({slice:$,scope:P})=>$.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:$}})))),y=new Map;for(let $ of t.systems??[])y.has($.name)&&e.error(c.InvalidSystemDeclaration,`System '${$.name}' is declared more than once.`,$.location),y.set($.name,(y.get($.name)??0)+1);let h=l(($,P,A=!0)=>{let[v,...k]=P.split("."),E=$.filter(I=>I.name===v);if(E.length!==1)return{type:null,missing:E.length===0};let b=E[0].type;if(k.length===0)return{type:b,missing:!1};let w=o.get(b.name);if(w===void 0)return{type:null,missing:s.has(b.name)};let T=h([...w.values()],k.join("."),A);return T.type===null?T:{type:{...T.type,isOptional:A&&b.isOptional||T.type.isOptional,isCollection:b.isCollection||T.type.isCollection},missing:!1}},"pathType"),x=l(($,P,A,v,k=new Set)=>{if(A.has(P)||$.isOptional&&!v.has(P))return!0;if($.isCollection||k.has($.name))return!1;let E=o.get($.name);return E===void 0?v.has(P)&&!s.has($.name):[...E.values()].every(b=>x(b.type,`${P}.${b.name}`,A,v,new Set([...k,$.name])))},"covered"),g=l(($,P)=>{if($.kind==="ListExpressionSyntax"&&P.isCollection)return $.items.every(v=>g(v,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return $.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(v=>(v.type.isOptional||$.members.some(k=>k.name===v.name))&&$.members.filter(k=>k.name===v.name).every(k=>g(k.value,v.type)))},"completeValue"),S=l($=>$.kind==="LiteralExpressionSyntax"?typeof $.value!="number"||Number.isFinite($.value):$.kind==="ObjectExpressionSyntax"?$.members.every(P=>S(P.value)):$.kind==="ListExpressionSyntax"&&$.items.every(S),"concrete"),C=l(($,P,A,v,k)=>{let E=new Set,b=new Set($.map(T=>T.property)),w=new Set;for(let T of $){let I=T.property.split(".");for(let j=1;j<=I.length;j++)w.add(I.slice(0,j).join("."))}for(let T of $){E.has(T.property)&&e.error(c.InvalidOperationMapping,`Duplicate operation input mapping '${T.property}'.`,T.location),E.add(T.property);let I=h(P.inputs,T.property,!1);if(I.missing&&e.error(c.InvalidOperationMapping,`Operation '${P.name}' declares no input '${T.property}'.`,T.location),I.type===null)continue;let j=T.property.split(".");for(let N=1;N<j.length;N++)b.has(j.slice(0,N).join("."))&&e.error(c.InvalidOperationMapping,`Operation input mapping '${T.property}' overlaps a whole input mapping.`,T.location);if(A!==null&&T.source.kind==="PathExpressionSyntax"){let N=h(A.properties,T.source.path),L=T.source.path.split("."),q=(fi.get(A)??[]).filter(J=>(J.alias??J.readModel)===L[0]);if(N.missing&&q.length>0){N={type:null,missing:!1};let J=q.length===1?m(q[0].readModel,k):null;L.length>1&&J!==null&&(N=h(J.properties,L.slice(1).join(".")))}N.missing&&e.error(c.InvalidOperationMapping,`Command '${A.name}' declares no source '${T.source.path}'.`,T.source.location);let V=N.type,K=I.type;V!==null&&s.has(V.name)&&s.has(K.name)&&(V.name!==K.name||V.isCollection!==K.isCollection||V.isOptional&&!K.isOptional)&&e.error(c.InvalidOperationMapping,`Source '${T.source.path}' is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(T.source.kind)&&(!ke(T.source,I.type,r,o)||v&&!g(T.source,I.type))&&e.error(c.InvalidOperationMapping,`Value is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}if(v)for(let T of P.inputs)x(T.type,T.name,E,w)||e.error(c.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${T.name}'.`,P.location)},"validateMappings");for(let{slice:$,scope:P}of n.slices){let A=Yn($),v=new Set(le($).map(k=>k.name));for(let k of A){v.has(k.name)&&e.error(c.ProductionDeclarationCollision,`Operation '${k.name}' collides with another event or operation in slice '${$.name}'.`,k.location),v.add(k.name),k.uses.length>0&&y.get(k.uses)!==1&&e.error(c.InvalidSystemReference,`Operation '${k.name}' must use one declared system; '${k.uses}' does not resolve uniquely.`,k.usesLocation??k.location);for(let E of k.inputs)!s.has(E.type.name)&&!a.has(E.type.name)&&e.warning(c.UnknownType,`Unknown type '${E.type.name}' on input '${E.name}' of operation '${k.name}'.`,E.type.location)}for(let k of $.commands)for(let E of k.produces){let b=n.resolve(E.event,$);b.kind===H.Ambiguous&&b.candidates.some(w=>w.kind===H.Operation)&&e.error(c.InvalidProductionReference,`Production '${E.event}' is ambiguous.`,E.location),E.event.includes(".")&&b.kind!==H.Operation&&e.error(c.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",E.location),b.declaration?.node.kind==="OperationSyntax"&&((E.for!==null||E.tags.length>0)&&e.error(c.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",E.location),C(E.mappings,b.declaration.node,k,!0,P))}for(let k of $.reactions.flatMap(E=>E.triggers).flatMap(E=>E.produces)){let E=n.resolve(k.event,$);E.kind===H.Ambiguous&&E.candidates.some(b=>b.kind===H.Operation)&&e.error(c.InvalidProductionReference,`Production '${k.event}' is ambiguous.`,k.location),k.event.includes(".")&&n.resolve(k.event,$).kind!==H.Operation&&e.error(c.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",k.location),n.isOperation(k,$)&&e.error(c.OperationOutsideCommand,"Operations can only be produced by commands.",k.location)}for(let k of $.specifications){let E=[...k.givenOperationFailures??[],...k.thenOperations??[],...k.thenCompensated??[]];if(E.length===0)continue;let b=u(i(k.when,P)?.commandType??"",P);(b===null||k.whenAppended!==null||k.whenQuery!==null||k.whenTrigger!==null||k.whenClock!==null||k.whenCapture!==null)&&e.error(c.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",k.location);let w=new Map;for(let T of E){if(T.kind==="SpecificationOperationSyntax")for(let N of T.values)S(N.source)||e.error(c.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let I=n.resolve(T.operation,$).declaration?.node;if(I?.kind!=="OperationSyntax"){e.error(c.InvalidOperationSpecification,`'${T.operation}' does not resolve uniquely to a declared operation.`,T.location);continue}let j=w.get(I)??new Set;if(j.has(T.kind)&&e.error(c.InvalidOperationSpecification,`Duplicate operation step '${T.operation}'.`,T.location),j.add(T.kind),w.set(I,j),T.kind==="SpecificationCompensatedSyntax"&&I.compensate===null&&e.error(c.InvalidOperationSpecification,`Operation '${T.operation}' declares no compensation.`,T.location),b!==null&&b.command.handler==null){let N=b.command.produces.map(L=>n.resolve(L.event,b.slice));N.every(L=>L.kind===H.Event||L.kind===H.Operation)&&!N.some(L=>L.declaration?.node===I)&&e.error(c.InvalidOperationSpecification,`Command '${b.command.name}' does not produce operation '${T.operation}'.`,T.location)}T.kind==="SpecificationOperationSyntax"&&C(T.values,I,null,!1,P)}}}}l(Pi,"validateOperations");var Os=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],Zf=O("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),Kf=O(`^"(${z})"$`);function po(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}l(po,"complianceWireName");function Jf(t){let e=po(t);return e==="sensitive"?"secret":e}l(Jf,"canonicalComplianceName");function Is(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return Rs(t,e,i),i.map(r=>{let o=po(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(c.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,f(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:f(e)}})}l(Is,"parseComplianceMarkers");function Ts(t,e,n,i){let r=Zf.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",d=po(o),p=Jf(o);if(Rs(t,e,[o]),!["pii","sensitive"].includes(d)||o==="@personal"||o==="@secret")return t.error(c.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,f(e)),!0;let m=i.findIndex(y=>y.name===d);if(m<0)return t.error(c.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${p} ${s}' without the marker - write 'concept ${n} : <Type> ${p}'`,f(e)),!0;let u=i[m];switch(s){case"reason":{let y=Kf.exec(a);return y===null?(t.error(c.UnknownConceptDirective,`Invalid '${p} reason' - expected '${p} reason "<text>"'`,f(e)),!0):u.reason!==null?(t.error(c.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${p}' - at most one is allowed`,f(e)),!0):(i[m]={...u,reason:Q(y[1])},!0)}case"scope":return d!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(c.InvalidSecretScope,`Invalid '${p} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,f(e)),!0):u.scope!=null?(t.error(c.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,f(e)),!0):(i[m]={...u,scope:a},i.some(y=>y.name==="pii")&&t.warning(c.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,f(e)),!0);case"special":case"criminal":return d!=="pii"||(s==="special"?!Os.includes(a):a.length>0)?(t.error(c.InvalidPersonalDataQualifier,`Invalid '${p} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${Os.join(", ")}`,f(e)),!0):s==="special"&&u.specialCategory!=null?(t.error(c.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,f(e)),!0):(i[m]=s==="special"?{...u,specialCategory:a}:{...u,criminal:!0},!0);default:return!1}}l(Ts,"parseComplianceDirective");function Rs(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(c.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",f(e))}l(Rs,"reportLegacy");var Hf=Z("^policy\\s+([A-Za-z_]\\w*)$");function Ds(t,e){let n=t;t=t.valueContext;let i=Hf.exec(e.content)?.[1]??"";i===""&&t.error(c.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1,d=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(p.content)==="description")d=G(n,p,d,`Policy '${i}'`);else if(D(p.content)==="require"){let m=p.content.substring(7).trim();for(let h=t.peekChild(p.indent);h!==void 0;h=t.peekChild(p.indent))t.reader.takeSignificant(),m+=` ${h.content}`;let u=Xf(t,m);u.includes("not")&&(t=n);let y=em(t,u,f(p));a?t.error(c.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(p)):r=y,a=!0}else if(D(p.content)==="file"){let m=ht(t,p);o===null&&s===null?s=m:t.error(c.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else if(p.content.startsWith("```")||t.languages.has(p.content)){let m=Be(t,p);o===null&&s===null?o=m:t.error(c.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else t.error(c.UnknownPolicyDirective,`Unexpected '${p.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(p)),t.skipOpaqueBlock(p.indent);return r!==null&&(o!==null||s!==null)&&t.error(c.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(c.PolicyWithoutRequirement,`Policy '${i}' must declare a 'require' condition, a file reference or an inline code block`,f(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,description:d,location:f(e)}}l(Ds,"parsePolicy");function Xf(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Z(`"${z}"|\\(|\\)|${n}`).source,"gu"))??[]]}l(Xf,"tokenizePolicyCondition");function em(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=l(u=>u!==void 0&&u.startsWith('"')&&u.endsWith('"'),"quoted"),s=l(u=>Q(u.substring(1,u.length-1)),"unquote"),a=l(()=>{if(e[r]==="not"){r++;let x=a();return x===null?null:{kind:"NotPolicyConditionSyntax",operand:x,location:n}}if(e[r]==="("){r++;let x=p();return e[r]===")"?r++:i&&t.error(c.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),x}let u=e[r++];if(u==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(u!=="role"&&u!=="claim")return t.error(u===void 0?c.ExpectedPolicyCondition:c.UnexpectedTokenInPolicyCondition,u===void 0?"Expected a policy condition":`Unexpected '${u}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(u==="role"?c.ExpectedRoleName:c.ExpectedClaimName,`Expected a quoted ${u} name after '${u}'`,n),null;if(u==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(c.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(c.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:Me(h,n,t),location:n}},"group"),d=l(()=>{let u=a();for(;u!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"And",right:y,location:n}}return u},"and"),p=l(()=>{let u=d();for(;u!==null&&e[r]==="or";){r++;let y=d();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"Or",right:y,location:n}}return u},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(c.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}l(em,"parsePolicyCondition");var tm=new RegExp(`^for\\s+"(${z})"$`,"u"),nm=Z("^[A-Z]\\w*$"),im=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Ms(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(c.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:f(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=tm.exec(i.content);if(r===null){t.error(c.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,f(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let s=t.peekChild(i.indent);s!==void 0;s=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!nm.test(s.content)){t.error(c.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let d=t.peekChild(s.indent);d!==void 0;d=t.peekChild(s.indent)){t.reader.takeSignificant();let p=im.exec(d.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:Me(p[2],f(d),t),location:f(d)}):t.error(c.InvalidSeedPropertyAssignment,`Invalid property assignment '${d.content}' - expected '<property> = <value>'`,f(d))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:Q(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}l(Ms,"parseSeed");var uo=`(?:([A-Za-z_]\\w*)|"(${z})")\\.(\\w+(?:\\.\\w+)*)`,rm=O("^exposure\\s+for\\s+([A-Za-z_]\\w*)$"),om=O("^instance\\s+([A-Za-z_]\\w*)$"),am=O(`^property\\s+${uo}(?:\\s+label\\s+"(${z})")?(?:\\s+operations\\s+([\\w-]+(?:\\s*,\\s*[\\w-]+)*))?(?:\\s+fields\\s+(\\w+(?:\\s*,\\s*\\w+)*))?(?:\\s+reexposes\\s+([A-Za-z_]\\w*))?$`),sm=O(`^set\\s+${uo}\\s*=\\s*(.+)$`),lm=O(`^items\\s+${uo}$`),cm=O(`^item\\s+(?:([A-Za-z_][\\w-]*)|"(${z})")$`),dm=O("^([A-Za-z_]\\w*)\\s*=\\s*(.+)$"),pm=["add","remove","reorder","edit-fields"],um=`'property <component>.<path> [label "<text>"] [operations <add|remove|reorder|edit-fields>, ...] [fields <field>, ...] [reexposes <Owner>]'`,Ai=l((t,e)=>t[e]??Q(t[e+1]),"reference"),js=l(t=>t.trim()==="none"?[]:t.split(",").map(e=>e.trim()).filter(e=>e.length>0),"list");function Ls(t,e){let n=rm.exec(e.content);n===null&&t.error(c.InvalidExposureDeclaration,`Invalid exposure declaration '${e.content}' - expected 'exposure for <Owner>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=fm(t,r);o!==void 0&&i.push(o)}return{kind:"ExposureSyntax",owner:n?.[1]??e.content,properties:i,location:f(e)}}l(Ls,"parseExposure");function Ns(t,e){let n=om.exec(e.content);n===null&&t.error(c.InvalidInstanceContribution,`Invalid instance declaration '${e.content}' - expected 'instance <Screen or Template>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=mm(t,r);o!==void 0&&i.push(o)}return{kind:"InstanceContributionsSyntax",instance:n?.[1]??e.content,contributions:i,location:f(e)}}l(Ns,"parseInstance");function fm(t,e){let n=am.exec(e.content);if(n===null){t.error(c.InvalidExposureDeclaration,`Invalid exposed property '${e.content}' - expected ${um}`,f(e));return}let i=n[5]===void 0?[]:js(n[5]),r=i.find(o=>!pm.includes(o));if(r!==void 0){t.error(c.InvalidExposureDeclaration,`Unknown collection operation '${r}' - expected add, remove, reorder, edit-fields or none`,f(e));return}return{kind:"ExposedPropertySyntax",component:Ai(n,1),path:n[3],label:n[4]===void 0?null:Q(n[4]),isCollection:n[5]!==void 0,operations:i,restrictsFields:n[6]!==void 0,editableFields:n[6]===void 0?[]:js(n[6]),reExposes:n[7]??null,location:f(e)}}l(fm,"parseExposedProperty");function mm(t,e){let n=sm.exec(e.content);if(n!==null)return t.skipBlock(e.indent),{kind:"InstanceContributionSyntax",component:Ai(n,1),path:n[3],value:ae(n[4],f(e),t),items:[],location:f(e)};let i=lm.exec(e.content);if(i!==null){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=ym(t,o);s!==void 0&&r.push(s)}return{kind:"InstanceContributionSyntax",component:Ai(i,1),path:i[3],value:null,items:r,location:f(e)}}t.error(c.InvalidInstanceContribution,`Invalid instance contribution '${e.content}' - expected 'set <component>.<path> = <value>' or 'items <component>.<path>'`,f(e)),t.skipBlock(e.indent)}l(mm,"parseContribution");function ym(t,e){let n=cm.exec(e.content);if(n===null){t.error(c.InvalidInstanceContribution,`Invalid contributed item '${e.content}' - expected 'item <id>'`,f(e)),t.skipBlock(e.indent);return}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=dm.exec(r.content);if(o===null){t.error(c.InvalidInstanceContribution,`Invalid item value '${r.content}' - expected '<field> = <value>'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ContributedItemValueSyntax",field:o[1],value:ae(o[2],f(r),t),location:f(r)})}return{kind:"ContributedItemSyntax",id:Ai(n,1),values:i,location:f(e)}}l(ym,"parseItem");var hm=O("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Ys=O(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${z})")?$`),Sm=O("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),gm=O("^@?[a-z_]\\w*$"),xm=O("^persona\\s+([A-Za-z_]\\w*)$"),vm=O("^policy\\s+([A-Za-z_]\\w*)$"),$m=/^[ ]*\t/,qs=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Fs=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),bm=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function wi(t,e,n=Pt){Am(t,e);let i=n.length===1?new Cn(n[0]):void 0,r=n.length>1?new En(n[n.length-1]):void 0,o=i??r,s=null,a=[],d=[],p=[],m=[],u=[],y=[],h=[],x=[],g=[],S=[],C=[],$=[],P=[],A=[],v=[],k=!1;for(let b=t.reader.peekSignificant();b!==void 0;b=t.reader.peekSignificant()){t.reader.takeSignificant();let w=D(b.content);if(w==="domain"){t.authoredDeclarations=!0,s=Pm(t,b,s,k);continue}if(k||=Bs(w,b,n),t.authoredDeclarations||=w!=="import"&&Bs(w,b,n),w==="import"&&fa(b.content))o!==void 0?o.tryParse(t,b):Ut(t,b,d);else if(w==="import"){let T=Ys.exec(b.content);if(T===null)t.error(c.InvalidImportDeclaration,`Invalid import '${b.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,f(b));else{let I=T.groups?.origin===void 0?null:Q(T.groups.origin);I!==null&&vn(I)&&t.error(c.InvalidImportDeclaration,"An import origin must be a nonblank quoted string",f(b)),a.push({kind:"ImportSyntax",qualifiedName:T[1],origin:I,visibility:I===null?se.Private:se.Public,location:f(b)})}}else if(w==="example")o!==void 0?o.tryParse(t,b):$.push(ot(t,b));else if(w==="eventsource")y.push(Ca(t,b));else if(w==="system")u.push(Ra(t,b));else if(w==="concept")p.push(wm(t,b));else if(w==="type")m.push(Va(t,b));else if(w==="module"&&!un(n))km(t,b,n,i);else if(w==="module")h.push(Hr(t,b));else if(w==="persona")x.push(Om(t,b));else if(w==="seed")C.push(Ms(t.valueContext,b));else if(w==="purpose"&&o!==void 0)o.tryParse(t,b);else if(w==="purpose")S.push(pa(t,b));else if(w==="policy")g.push(Ds(t,b));else if(w==="exposure")A.push(Ls(t,b));else if(w==="instance")v.push(Ns(t,b));else if(w==="trigger"){let T=ps(t,b),I=/^trigger\s+([A-Za-z_]\w*)$/.exec(b.content)?.[1];I!==void 0&&P.push({name:I,data:T})}else Fs.has(w)?w==="behavior"||w==="layout"?qe(t,b):t.skipOpaqueBlock(b.indent):o?.tryParse(t,b)!==!0&&Em(t,b,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(Cm(n,r.build(t.start,!0),t.start));let E={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:m,systems:u,eventSources:y,examples:$,modules:h,personas:x,policies:g,purposes:S,seeds:C,declaredTriggers:P,fileImports:d,...A.length>0?{exposures:A}:{},...v.length>0?{instanceContributions:v}:{},location:t.start};return t.authoredDeclarations&&xa(E),E}l(wi,"parseApplication");function Bs(t,e,n){return t==="import"?Ys.test(e.content):t==="module"?un(n):t==="purpose"||t==="example"||t==="exposure"||t==="instance"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||Fs.has(t)}l(Bs,"declaresConstruct");function km(t,e,n,i){let r=Kr.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(c.ModuleInPlacedFile,`This file is imported into ${ti(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}l(km,"parseModuleInPlacedFile");function Em(t,e,n){let i=D(e.content);if(un(n)){let r=bm.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(c.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?Jr:Zr;t.error(c.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${ti(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}l(Em,"reportUnexpectedTopLevel");function Cm(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}l(Cm,"place");function Pm(t,e,n,i){let r=hm.exec(e.content);return r===null?(t.error(c.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(c.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(c.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}l(Pm,"parseDomain");function Am(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&$m.test(i.raw)&&t.warning(c.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",Xo(i))}}l(Am,"warnOnTabIndentation");function wm(t,e){let n=Sm.exec(e.content);if(n===null)return t.error(c.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=Is(t,e,o);r!=="Enum"&&!qs.includes(r)&&t.error(c.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${qs.join(", ")} or Enum`,f(e));let a=[],d=null,p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(m.content)==="description"&&(r!=="Enum"||m.content!=="description"||t.peekChild(m.indent)?.content.startsWith("```")===!0))d=G(t,m,d,`Concept '${i}'`);else{if(ye(m))continue;if(D(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(c.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let u=Ur(t,m,"concept");u!==void 0&&p.push(u)}else Ts(t,m,i,s)||(r==="Enum"&&gm.test(m.content)?a.push(oe(m.content)):r==="Enum"?t.error(c.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(c.UnknownConceptDirective,`Unexpected '${m.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,f(m)),t.skipBlock(m.indent)))}return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:p,description:d,location:f(e)}}l(wm,"parseConcept");function Om(t,e){let n=xm.exec(e.content)?.[1]??"";n===""&&t.error(c.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,f(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=G(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=vm.exec(o.content);a===null?t.error(c.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(c.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,f(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:f(e)}}l(Om,"parsePersona");var Ht=class t{static{l(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=Pt,i){return this.capturePlaced([...e].map(r=>({lines:r,placement:n})),i)}static capturePlaced(e,n){let i=new Map,r=new Set,o=new Set;for(let{lines:a,placement:d}of e){let p=Ei(a,a[0]?.path,n);p.scope=d;let m=wi(p,a,d);for(let u of m.types)r.add(u.name);for(let u of m.concepts)r.add(u.name);for(let u of m.imports)o.add(u.qualifiedName);for(let u of m.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.streams.map(y=>y.name)])}let s=new Set([...o].filter(a=>r.has(a.substring(a.lastIndexOf(".")+1))));return new t(i,s)}};var ge;(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"})(ge||(ge={}));function Us(t){return t.length===0?{value:null,failure:ge.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:ge.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:ge.NotNfc}:{value:t,failure:null}}l(Us,"tryFormatText");function Ws(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:ge.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}}l(Ws,"tryFormatUuidText");function Oi(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:ge.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:ge.OutOfRange}:{value:n.toString(),failure:null}}l(Oi,"tryFormatInteger");function Ii(t){switch(t){case ge.Empty:return"A stream id text literal cannot be empty.";case ge.NotNfc:return"A stream id text literal must be Unicode NFC.";case ge.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case ge.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case ge.NotIntegral:return"A stream id integer must be a finite integral value.";case ge.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case ge.Arity:return"A composite stream id must match the declared part count of at least two.";case ge.Escape:return"A composite stream id permits only %25 and %7C escapes.";case ge.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}l(Ii,"streamIdFailureMessage");function Ti(t,e,n,i,r,o,s){if(n){o.error(r,"A composite stream requires a streamId part block, not a scalar mapping.",i);return}let a=t.streamIdParts;for(let p of a.filter(m=>!e.some(u=>u.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let d=new Set;for(let p of e){let m=a.find(u=>u.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):d.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(d.add(p.property),s(p,m.type))}}l(Ti,"validateStreamIdParts");function Ri(t,e,n){let i=ne(n.concepts),r=ne(n.types),o=new Map([...r].map(([a,d])=>[a,ne(d.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!ke(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?On(t,e,n)?.value??null:null}l(Ri,"formatSpecificationStreamId");function Vs(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Re(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==pe.Unique||s.kind!==pe.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],d=l((p,m,u)=>{let y=Ri(p,u,i),h=Ri(m,u,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 u=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return u.length===1&&y.length===1?d(u[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:d(t.streamId?.source,e.streamId?.source,a.streamId)}l(Vs,"matchesSpecificationRoute");function Qs(t,e){let n=new re(t).slices.flatMap(({slice:s})=>s.specifications.flatMap(a=>a.cases??[]));if(n.length===0)return zs(t,e);let i=new he(new Ge([]));zs(t,i);let r=new Set,o=new Set;for(let s of i.diagnostics){let a=JSON.stringify([s.code,s.location.path,s.location.line,s.location.column,s.message]);if(o.has(a))continue;o.add(a);let d=s.code===c.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(d===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 '${d.name}': ${s.message}`,s.location),r.add(p)}}}l(Qs,"validateSpecificationStreams");function zs(t,e){let n=qt(t).resolvedExamples,i=Qn(t);t=i.application;let r=new re(t),o=new Set,s=n.flatMap($=>{if($.kind!=="event")return($.kind==="command"||$.kind==="readmodel")&&($.example.stream!=null||$.example.noStream!=null)&&e.error(c.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",($.example.stream??$.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:$.name,values:$.example.values,for:$.example.for,stream:$.example.stream,noStream:$.example.noStream,location:$.example.location};return o.add(P),[{scope:$.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Re(t),d=ne(t.concepts),p=ne(t.types),m=new Map([...p].map(([$,P])=>[$,ne(P.properties)])),u=l(($,P)=>ke($,P,d,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...d.keys(),...p.keys()]),h=l(($,P)=>y.has($.name)&&y.has(P.name)?$.name===P.name&&$.isCollection===P.isCollection&&(!$.isOptional||P.isOptional):null,"nominallyCompatible"),x=l(($,P)=>Ri($,P,t),"formatStreamId"),g=l(($,P)=>{let A=r.resolve($,P).declaration;return A?.node.kind==="EventSyntax"?A.node:null},"eventOf"),S=[];for(let{slice:$}of r.slices){for(let P of $.commands)for(let A of P.produces){if(!r.isEventProduction(A,$))continue;let v=g(A.event,$);if(v===null)continue;let k=Bt(P,A,t,{resolver:r,slice:$});S.push({event:v,command:P,type:k})}for(let P of $.reactions.flatMap(A=>A.triggers).flatMap(A=>A.produces)){let A=g(P.event,$);A!==null&&S.push({event:A,command:null,type:null})}for(let P of $.captures)for(let A of[...P.appends,...P.children.flatMap(v=>v.appends),...P.nested.flatMap(v=>v.appends)]){let v=g(A.event,$);v!==null&&S.push({event:v,command:null,type:null})}}let C=[...s.flatMap($=>r.slices.filter(P=>P.scope.join(".")===$.scope.join(".")).map(({slice:P,scope:A})=>({slice:P,scope:A,specification:$.specification}))),...r.slices.flatMap(({slice:$,scope:P})=>$.specifications.map(A=>({slice:$,scope:P,specification:A})))];for(let{slice:$,scope:P,specification:A}of C){let v=r.slices.flatMap(I=>I.slice.commands.map(j=>({command:j,scope:I.scope}))),k=A.when?.commandType.split(".")??[],E=k.slice(0,-1),b=v.filter(I=>I.command.name===k.at(-1)&&E.every((j,N)=>I.scope[I.scope.length-E.length+N]===j)),w=E.length>0&&b.length===1?b[0].command:null;for(let I=P.length;E.length===0&&I>=0&&w===null;I--){let j=b.filter(N=>P.slice(0,I).every((L,q)=>N.scope[q]===L));if(j.length>0){w=j.length===1?j[0].command:null;break}}let T=[...A.given.map(I=>({node:I,required:!0,expected:!1})),...A.whenAppended===null?[]:[{node:A.whenAppended,required:!0,expected:!1}],...A.thenEvents.map(I=>({node:I,required:!1,expected:!o.has(I)})),...A.whenRedelivered==null?[]:[{node:{...A.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:I,required:j,expected:N}of T){let L=i.specifications.flatMap(F=>F.steps).find(F=>F.effective===I),q=L?.route?.origin!=="example",V=q||I.for!==L?.example?.for,K=l((F,ce,fe)=>{e.error(F,L?.example==null?ce:`${ce} Example '${L.example.name}' is used here.`,L?.example==null?fe:L.authored.location)},"contextualError");if(I.stream==null&&I.noStream==null)continue;j&&I.noStream!=null&&K(c.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",I.noStream.location);let J=null,U=g(I.eventType,$),_=S.filter(F=>F.event===U);if(I.stream!=null){let F=I.stream,ce=a.resolve(F.eventSource,F.stream);if(ce.kind!==pe.Unique){let me={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[ce.kind];q&&e.error(c.InvalidSpecificationStreamRoute,`Stream '${F.eventSource}.${F.stream}' is ${me}; routing requires one physical source and stream.`,F.location);continue}let fe=ce.sources[0],Ae=ce.streams[0],$t=l((me,xe)=>{let R=me.source,M=On(R,xe,t);M?.failure!=null?e.error(c.InvalidSpecificationStreamRoute,Ii(M.failure),R.location):(R.kind!=="LiteralExpressionSyntax"||R.value===null||xe!==null&&!u(R,xe))&&e.error(c.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",R.location)},"validateLiteral");if(q&&(Ae.streamIdParts.length>0?Ti(Ae,F.streamIdParts,F.streamId!==null,F.location,c.InvalidSpecificationStreamRoute,e,$t):F.streamIdParts.length>0?e.error(c.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",F.location):(Ae.streamId===null!=(F.streamId===null)&&e.error(c.InvalidSpecificationStreamRoute,Ae.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",F.location),F.streamId!==null&&$t(F.streamId,Ae.streamId))),J=fe.identifier,J===null){let me=_.map(R=>R.type),xe=new Set(me.filter(R=>R!==null).map(R=>`${R.name}:${R.isOptional}:${R.isCollection}`));me.length===0||me.some(R=>R===null)||xe.size!==1?q&&e.error(c.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${fe.name}'; the event's producers do not supply one unambiguous destination type.`,F.location):J=me[0]}let bt=!1;if(L?.example?.stream!=null&&I.for!==null&&I.for===L.example.for){let me=a.resolve(L.example.stream.eventSource,L.example.stream.stream);if(me.kind===pe.Unique){let xe=_.map(B=>B.type),R=new Set(xe.filter(B=>B!==null).map(B=>`${B.name}:${B.isOptional}:${B.isCollection}`)),M=me.sources[0].identifier??(xe.length>0&&!xe.some(B=>B===null)&&R.size===1?xe[0]:null);M!==null&&(bt=I.for.kind!=="LiteralExpressionSyntax"||I.for.value===null||M.isCollection||M.isOptional||!u(I.for,M))}}j&&I.for===null?K(c.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",F.location):V&&!bt&&I.for!==null&&(I.for.kind!=="LiteralExpressionSyntax"||I.for.value===null||J!==null&&(J.isCollection||J.isOptional||!u(I.for,J)))&&K(c.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",I.for.location)}if(!N||w===null||_.length===0||_.some(F=>F.command!==w))continue;let ie=w.stream?.propertyCandidate===null?w.stream:null,Ee=I.noStream!=null?ie!=null:ie==null||ie.eventSource!==I.stream.eventSource||ie.stream!==I.stream.stream;if(!Ee&&I.stream!=null&&ie!=null){let F=a.resolve(I.stream.eventSource,I.stream.stream),ce=F.kind===pe.Unique?F.streams[0]:null;if(ce!==null&&ce.streamIdParts.length>0){if(ie.streamId===null&&I.stream.streamId===null&&ie.streamIdParts.length>0&&I.stream.streamIdParts.length>0)for(let fe of ce.streamIdParts){let Ae=ie.streamIdParts.filter(xe=>xe.property===fe.name),$t=I.stream.streamIdParts.filter(xe=>xe.property===fe.name);if(Ae.length!==1||$t.length!==1)continue;let bt=x(Ae[0].source,fe.type),me=x($t[0].source,fe.type);bt!==null&&me!==null&&bt!==me&&(Ee=!0)}}else if(ce?.streamId!=null&&ie.streamIdParts.length===0&&I.stream.streamIdParts.length===0){let fe=x(ie.streamId?.source,ce.streamId),Ae=x(I.stream.streamId?.source,ce.streamId);fe!==null&&Ae!==null&&fe!==Ae&&(Ee=!0)}}I.for?.kind==="LiteralExpressionSyntax"&&_.every(F=>F.type!==null&&(J!==null?h(F.type,J)===!1:!u(I.for,F.type)))&&(Ee=!0),Ee&&K(c.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(I.stream??I.noStream).location)}}}l(zs,"validateRoutes");var In=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function fo(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&In.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}l(fo,"supportsStreamIdentity");function On(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:ne(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?Ws(i):Us(i):typeof i=="number"?Oi(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?Oi(NaN):Oi(BigInt(i.value),!1):null}l(On,"formatStreamIdLiteral");function Di(t,e){let n=ne(t.concepts),i=ne(t.types),r=new Set([...In,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,ne(h.properties)])),s=l((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=l((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(S=>S.name===y.name)){e.error(c.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let x=t.concepts.filter(S=>S.name===y.name),g=x.length===1?x[0].type:x.length===0&&In.has(y.name)?y.name:null;h&&g!==null&&!fo(y,t)&&e.error(c.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),g===null&&!t.imports.some(S=>S.qualifiedName===y.name||S.qualifiedName.split(".").at(-1)===y.name)&&e.warning(c.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),d=new Set;for(let y of t.eventSources??[]){d.has(y.name)&&e.error(c.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),d.add(y.name),a(y.identifier,!1);let h=new Set;for(let x of y.streams){h.has(x.name)&&e.error(c.InvalidEventSourceDeclaration,`Stream '${y.name}.${x.name}' has multiple declarations under this source.`,x.location),h.add(x.name),a(x.streamId,!0);let g=x.streamIdParts;if(g.length>0){g.length<2&&e.error(c.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",x.directiveLocations?.streamId??x.location);for(let S of new Set(g.map(C=>C.name)))for(let C of g.filter($=>$.name===S).slice(1))e.error(c.InvalidEventSourceDeclaration,`Stream id part '${C.name}' is declared more than once.`,C.location);for(let S of g)a(S.type,!0)}}}let p=l((y,h)=>{let[x,...g]=h.split(".");if(y===null)return{property:null,missing:!1};let S=y.filter(P=>P.name===x);if(S.length!==1)return{property:null,missing:S.length===0};let C=S[0];if(g.length===0)return{property:C,missing:!1};if(In.has(C.type.name)||n.has(C.type.name)&&!i.has(C.type.name))return{property:null,missing:!0};let $=p(i.get(C.type.name)?.properties??null,g.join("."));return $.property===null?$:{property:{...$.property,type:{...$.property.type,isCollection:C.type.isCollection||$.property.type.isCollection,isOptional:C.type.isOptional||$.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Re(t),u=new re(t);for(let{slice:y}of u.slices)for(let h of y.commands){let x=h.stream;if(x==null||x.propertyCandidate!==null)continue;let g=m.resolve(x.eventSource,x.stream);if(g.kind!==pe.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[g.kind];e.error(c.InvalidCommandStream,`Stream '${x.eventSource}.${x.stream}' is ${A}; routing requires one physical source and stream.`,x.location);continue}let S=g.sources[0],C=g.streams[0],$=h.properties.filter(A=>A.isIdentifier);S.identifier!==null&&$.length===1&&s($[0].type,S.identifier)===!1&&e.error(c.InvalidCommandStream,`Command identifier '${$[0].name}' does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,$[0].location);for(let A of h.produces.filter(v=>u.isEventProduction(v,y))){if(S.identifier===null)continue;let v=Bt(h,A,t,{resolver:u,slice:y});if(v===null||A.for===null&&A.inlineEvent!==null&&$.length===1&&s($[0].type,S.identifier)===!1)continue;let k=A.for===null&&A.inlineEvent===null&&!h.properties.some(w=>w.isGenerated&&w.isIdentifier),E=n.get(S.identifier.name)?.type??(In.has(S.identifier.name)?S.identifier.name:null);(k?E===null?null:E==="Uuid":s(v,S.identifier))===!1&&e.error(c.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=l((A,v)=>{let k=A.source;if(k.kind==="PathExpressionSyntax"){let E=p(h.properties,k.path);(E.missing||E.property!==null&&s(E.property.type,v)===!1)&&e.error(c.InvalidCommandStream,`Stream id source '${k.path}' is absent or incompatible with nominal type '${v.name}'.`,k.location)}else if(k.kind==="LiteralExpressionSyntax"&&k.value!==null){let E=On(k,v,t);E?.failure!=null?e.error(c.InvalidCommandStream,Ii(E.failure),k.location):ke(k,v,n,o)||e.error(c.InvalidCommandStream,`Stream id value is incompatible with nominal type '${v.name}'.`,k.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(k.kind)||k.kind==="LiteralExpressionSyntax"&&k.value===null)&&e.error(c.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",k.location)},"validateMapping");if(C.streamIdParts.length>0){Ti(C,x.streamIdParts,x.streamId!==null,x.location,c.InvalidCommandStream,e,P);continue}if(x.streamIdParts.length>0){e.error(c.InvalidCommandStream,"A streamId part block requires a composite stream.",x.location);continue}(C.streamId===null&&x.streamId!==null||C.streamId!==null&&x.streamId===null)&&e.error(c.InvalidCommandStream,C.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",x.location),!(C.streamId===null||x.streamId===null)&&P(x.streamId,C.streamId)}Qs(t,e)}l(Di,"validateEventSources");function Mi(t,e){let n=new re(t),i=n.slices,r=new Set(t.imports.map(g=>g.qualifiedName)),o=new Set([...i.flatMap(({slice:g})=>le(g).map(S=>S.name)),...t.imports.map(g=>g.qualifiedName.split(".").at(-1))]),s=ne(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(g=>g.name)].filter(g=>!s.has(g))),d=l((g,S)=>{let[C,...$]=S.split(".");if(g===null)return{value:null,missing:!1};let P=g.filter(v=>v.name===C);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return $.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:d(s.get(A.type.name)?.properties??null,$.join("."))},"property"),p=i.flatMap(({slice:g,scope:S})=>g.readModels.map(C=>({node:C,scope:S}))),m=l((g,S)=>{let C=l(A=>{let v=A.split("."),k=p.filter(b=>b.node.name===v.at(-1)),E=v.slice(0,-1);if(E.length>0)return k.filter(b=>E.length<=b.scope.length&&E.every((w,T)=>b.scope[b.scope.length-E.length+T]===w));for(let b=S.length;b>=0;b--){let w=k.filter(T=>b<=T.scope.length&&S.slice(0,b).every((I,j)=>T.scope[j]===I));if(w.length>0)return w}return[]},"candidates"),$=C(g),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===g);return $.length===0&&P.length===1&&($=C(P[0].qualifiedName)),$.length===1?$[0].node.properties:null},"viewProperties"),u=l((g,S,C)=>{let $=n.resolve(g,C);o.has(g)||r.has(g)||$.declaration?.kind===H.Event||$.candidates.some(A=>A.kind===H.Event)||e.warning(c.UnknownEvent,`Unknown event '${g}' - declare it with 'event ${g}'`,S)},"unknownEvent"),y=l((g,S)=>{for(let C of g)(C.kind==="RemoveWithSyntax"||C.kind==="RemoveViaJoinSyntax")&&u(C.event,C.location,S),"blocks"in C&&y(C.blocks,S)},"removals"),h=new Set,x=l((g,S,C=!1,$=!1)=>{let P=l((v,k)=>{let E=d(S,v),b=JSON.stringify([k.path,k.line,k.column]);return E.missing&&!h.has(b)&&(h.add(b),e.warning(c.UnknownReadModelProperty,`Projection target '${v}' is not a declared ${C?"element":"read-model"} property`,k)),E.value},"validate"),A=$||g.some(v=>v.kind==="FromSyntax"||v.kind==="JoinSyntax"||v.kind==="AllSyntax");for(let v of g){let k=v.kind==="EverySyntax"&&!A?[]:"mappings"in v?v.mappings:v.kind==="JoinSyntax"?v.events.flatMap(E=>E.mappings):[];for(let E of k)P(E.property,E.location);if(v.kind==="ChildrenSyntax"||v.kind==="NestedSyntax"){let E=P(v.property,v.location);x(v.blocks,E===null?null:s.get(E.type.name)?.properties??null,!0)}}},"walk");for(let{slice:g}of i){for(let S of g.projections)y(S.blocks,g);for(let S of g.captures)for(let C of[...S.appends,...S.children.flatMap($=>$.appends),...S.nested.flatMap($=>$.appends)])u(C.event,C.location,g)}for(let{slice:g,scope:S}of i)for(let C of g.projections){let $=C.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");$.length===0&&x(C.blocks,m(C.readModel??C.name,S));for(let P of $){let A=m(P.name,S);x(C.blocks.filter(k=>k.kind==="ChildrenSyntax"||k.kind==="NestedSyntax"),A);let v=P.entersOn.length>0||C.blocks.some(k=>k.kind==="FromSyntax"||k.kind==="JoinSyntax"||k.kind==="AllSyntax");x(P.blocks,A,!1,v)}}}l(Mi,"validateProjectionTargets");function ji(t,e){let n=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="pii")).map(u=>u.name)),i=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="sensitive")).map(u=>u.name)),r=ne(t.types),o=new re(t),s=new Set(t.imports.map(u=>u.qualifiedName.split(".").at(-1))),a=new Map;for(let u of t.declaredTriggers??[]){let y=a.get(u.name)??[];y.push(u.data),a.set(u.name,y)}let d=l((u,y,h="an event source identifier")=>{if(n.has(u.name)||i.has(u.name)){let x=n.has(u.name)?"pii":"secret";e.error(c.PiiNotSupportedOnIdentifier,`Concept '${u.name}' is ${x} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${x} value as a property`,y)}},"validate"),p=l((u,y)=>{let[h,...x]=y.split("."),g=u.filter(C=>C.name===h);if(g.length!==1)return null;let S=g[0];return x.length===0?S:p(r.get(S.type.name)?.properties??[],x.join("."))},"property");for(let u of t.eventSources??[]){u.identifier!=null&&d(u.identifier,u.identifier.location);for(let y of u.streams){y.streamId!==null&&d(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)d(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Re(t);for(let{slice:u}of o.slices){for(let y of u.commands){for(let h of y.properties.filter(x=>x.isIdentifier))d(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(x=>x.propertyCandidate===null)){let x=m.resolve(h.eventSource,h.stream),g=x.kind===pe.Unique?x.streams[0]:void 0,S=[...h.streamId===null?[]:[{mapping:h.streamId,target:g?.streamId}],...h.streamIdParts.map(C=>({mapping:C,target:g?.streamIdParts.find($=>$.name===C.property)?.type}))];for(let{mapping:C,target:$}of S){if(C.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,C.source.path);P!==null&&(P.type.name===$?.name&&(n.has(P.type.name)||i.has(P.type.name))||d(P.type,C.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(x=>o.isEventProduction(x,u))){if(h.for?.kind!=="PathExpressionSyntax")continue;let x=p(y.properties,h.for.path);x!==null&&!x.isIdentifier&&d(x.type,h.for.location)}}for(let y of u.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let x=o.resolve(y.source.name,u).declaration?.node,g=(ve(y).data??[]).flatMap(C=>C.type===null?[]:[{kind:"PropertySyntax",name:C.name,type:C.type,isIdentifier:!1,location:C.location}]),S=[x?.kind==="EventSyntax"?x.properties:[],g];x?.kind!=="EventSyntax"&&!s.has(y.source.name)&&S.push(...a.get(y.source.name)??[]);for(let C of y.produces.filter($=>o.isEventProduction($,u))){if(C.for?.kind!=="PathExpressionSyntax")continue;let $=C.for.path,P=S.map(A=>p(A,$)).find(A=>A!==null&&(n.has(A.type.name)||i.has(A.type.name)));P!=null&&d(P.type,C.for.location)}}}}l(ji,"validateIdentifierCompliance");function Li(t,e){let n=l((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(c.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(c.ReadModelSubjectNotSupported,"Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.",o.location);for(let r of le(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(c.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(c.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(c.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let d=t.concepts.filter(m=>m.name===a.name);d.some(m=>m.attributes.some(u=>["pii","sensitive"].includes(u.name)))&&e.error(c.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let p=d.length===1?d[0].type:d.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;d.length===0&&p===null&&t.imports.some(m=>m.qualifiedName===a.name||m.qualifiedName.split(".").at(-1)===a.name)&&e.warning(c.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(d.some(m=>m.type==="Enum")||p!==null&&!fo(a,t))&&e.error(c.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}l(Li,"validateEventSubjects");var Ni=class extends Ye{static{l(this,"RefusalValueWalker")}declarations;context;slice=null;branch=null;properties=null;target=null;mapping=!1;constructor(e,n){super(),this.declarations=e,this.context=n}visitSlice(e){this.slice=e,super.visitSlice(e),this.slice=null}visitInvocationRefusal(e){this.branch=e,super.visitInvocationRefusal(e),this.branch=null}visitProduces(e){if(this.branch===null||this.slice===null){super.visitProduces(e);return}this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.when!=null&&this.visitCondition(e.when),e.tags.forEach(n=>this.visitTag(n)),this.properties=this.declarations.event(e.event,this.slice)?.properties??null,e.mappings.forEach(n=>this.visitPropertyMapping(n)),this.properties=null}visitPropertyMapping(e){this.mapping=this.branch!==null,this.target=this.declarations.property(this.properties,e.property)?.type??null,super.visitPropertyMapping(e),this.target=null,this.mapping=!1}visitObjectMember(e){let n=this.target;this.target=this.declarations.property(n===null?null:this.declarations.types.get(n.name)?.properties??null,e.name)?.type??null,super.visitObjectMember(e),this.target=n}visitExpression(e){e.kind==="RefusalExpressionSyntax"&&(!this.mapping||this.branch===null||!["reason","constraint","message"].includes(e.member)||e.member==="constraint"&&this.branch.selector!=="constraint"?this.context.error(c.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(c.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 Im(){return!0}l(Im,"invocationHasNoDeclaredIdentity");function Tm(t){let e=new Set,n=l((i,r)=>{let o=r||i.authorize!==null;o&&i.slices.forEach(s=>e.add(s)),i.features.forEach(s=>n(s,o))},"collect");return t.modules.forEach(i=>i.features.forEach(r=>n(r,i.authorize!==null))),e}l(Tm,"authorizationGatedSlices");function qi(t,e){let n=new Ke(ze(t));new Ni(n,e).visitApplication(n.application);let i=Tm(n.application);for(let{slice:r}of n.slices){let o=l(d=>n.resolve(d,r,p=>p.constraints),"constraintOf"),s=l((d,p)=>d===p||o(d)!==null&&o(d)?.node===o(p)?.node,"sameConstraint"),a=l((d,p)=>d.selector==="any"&&["any","validation","constraint"].includes(p.selector)||d.selector===p.selector&&(d.selector!=="constraint"||d.constraint===null||p.constraint!==null&&s(d.constraint,p.constraint)),"covers");for(let d of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(d.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),u=[];for(let y of d.onRefused??[]){if(u.some(C=>a(C,y))&&e.warning(c.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",y.location),u.push(y),y.selector==="authorization"&&Im()&&m&&e.warning(c.AuthorizationRefusalWithoutIdentity,`Command '${d.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(c.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${y.constraint}'.`,y.location);continue}if(p===null||p.node.handler!==null)continue;let x=[h.node,...h.node.additionalRules];if(x.some(C=>C.kind==="FileConstraintSyntax"))continue;let g=x.map(C=>C.kind==="FileConstraintSyntax"?null:n.event(C.event,h.slice)),S=p.node.produces.map(C=>n.event(C.event,p.slice));g.every(C=>C!==null)&&S.every(C=>C!==null)&&!g.some(C=>S.includes(C))&&e.warning(c.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${d.command}'.`,y.location)}}}}l(qi,"validateReactionRefusals");function Bi(t,e,n){let i=e===null||e.isCollection?void 0:n.concepts.get(e.name),r=i!==void 0&&i.type==="Enum"?i:null,o=l(a=>r!==null&&a.startsWith(`${r.name}.`)?a.substring(r.name.length+1):a,"member");if(e?.isCollection&&t.kind==="ListExpressionSyntax"&&n.compatible({...e,isCollection:!1},{...e,isCollection:!1})===!0){let a=t.items.map(d=>Bi(d,{...e,isCollection:!1,isOptional:!1},n));return a.some(d=>d===void 0)?void 0:{canonical:`[${a.map(Yi).join(",")}]`}}let s=e===null?void 0:n.types.get(e.name)?.properties;if(e!==null&&!e.isCollection&&t.kind==="ObjectExpressionSyntax"&&s!==void 0){let a=t.members.map(d=>{let p=n.property(s,d.name);return{name:d.name,value:p===null?void 0:Bi(d.value,p.type,n)}});return a.some(d=>d.value===void 0)?void 0:{canonical:`{${a.sort((d,p)=>d.name<p.name?-1:d.name>p.name?1:0).map(d=>`${JSON.stringify(d.name)}:${Yi(d.value)}`).join(",")}}`}}if(t.kind==="LiteralExpressionSyntax")return r!==null&&typeof t.value=="string"?o(t.value):t.value;if(t.kind==="PathExpressionSyntax"&&r!==null)return o(t.path)}l(Bi,"redeliveryValue");function Yi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:yr(t):JSON.stringify(t)}l(Yi,"canonical");function mo(t,e,n,i){let r=Bi(t,n,i),o=Bi(e,n,i);return r===void 0||o===void 0?null:Yi(r)===Yi(o)}l(mo,"sameRedeliveryValue");function Fi(t,e){t=ze(t);let n=new Ke(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(c.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let d=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Rm(m,o,s,n,t)),p=d.filter(m=>m===!0).length;d.some(m=>m===null)?e.error(c.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(c.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}l(Fi,"validateSpecificationRedelivery");function Rm(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:mo(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(d=>d.property===s.property);o.push(a.length===1?mo(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(Vs(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}l(Rm,"matches");var Gs=64;function _s(t,e){let n=[];for(let i of t.alternatives){let r=yo(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(c.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}l(_s,"validateGuardedActionShadowing");function yo(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=yo(t.left),n=yo(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])))}l(yo,"normalize");var Dm=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Ui(t,e){let n=new Ke(t);for(let{slice:i}of n.slices)for(let r of i.screens)ho(r.directives,[],i,n,e)}l(Ui,"validateGuardedActions");function ho(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":Mm(a,s,n,i,r);break;case"ScreenSectionSyntax":ho(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let d of a.slots)ho(d.directives,s,n,i,r);break}}l(ho,"validateContainer");function Ks(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}l(Ks,"viewProperties");function Mm(t,e,n,i,r){let o=e.length===1?Ks(e[0].type.name,n,i):null;e.length!==1&&r.warning(c.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 So(s.condition))Js(a.left,a.location,o,n,i,r);Zs(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&Zs(t.otherwise.command,t.otherwise.arguments,o,n,i,r),_s(t,r)}l(Mm,"validateAction");function Zs(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let d=s?.properties.filter(m=>m.name===a.name);d?.length===0&&o.warning(c.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=Js(a.binding,a.location,n,i,r,o,!0);d?.length===1&&p!==null&&d[0].type.isCollection!==p.type.isCollection&&o.warning(c.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}l(Zs,"validateArguments");function Js(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[d,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||d<a.length-1))return o.warning(c.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(d===a.length-1)return m[0];let u=m[0].type;if(n=r.types.get(u.name)?.properties??Ks(u.name,i,r),n===null)return(Dm.has(u.name)||r.application.concepts.some(y=>y.name===u.name)&&!r.application.types.some(y=>y.name===u.name))&&o.warning(c.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}l(Js,"validateItemPath");function So(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...So(t.left),...So(t.right)]}l(So,"comparisons");function Wi(t,e){let n=t.personas.map(r=>r.name),i=l(r=>{for(let o of r){i(o.features);for(let s of o.slices)for(let a of s.specifications){let d=a.givenCallerPersona;if(d!=null){let p=n.filter(m=>m===d.name).length;p!==1&&e.error(c.InvalidSpecificationCallerPersona,`${p===0?"Unknown":"Ambiguous"} persona '${d.name}' - declared personas: ${n.join(", ")}.`,d.location)}}}},"visit");for(let r of t.modules)i(r.features)}l(Wi,"validatePersonaCallers");function Vi(t,e){let n=new Set;for(let o of t.purposes??[])n.has(o.name)&&e.error(c.DuplicatePurposeDeclaration,`Duplicate purpose '${o.name}' - a purpose is declared once`,o.location),n.add(o.name);for(let o of t.purposes??[])o.interest!==null&&o.basis!=="legitimateInterests"?e.warning(c.PurposeInterestMismatch,`Purpose '${o.name}' declares an interest without basis legitimateInterests`,o.location):o.basis==="legitimateInterests"&&!o.interest?.trim()&&e.warning(c.PurposeInterestMismatch,`Purpose '${o.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`,o.location);let i=[],r=l(o=>{i.push(...o.purposes??[],...o.slices.flatMap(s=>s.purposes??[])),o.features.forEach(r)},"collect");for(let o of t.modules)i.push(...o.purposes??[]),o.features.forEach(r);for(let o of i)n.has(o.name)||e.warning(c.UnknownPurpose,`Unknown purpose '${o.name}' - declare it with 'purpose ${o.name}'`,o.location)}l(Vi,"validatePurposes");function wt(t){return Array.from(t,e=>{if(e==="\u0131"||e==="\u017F")return e;let n=e.codePointAt(0);if(n>=8064&&n<=8071||n>=8080&&n<=8087||n>=8096&&n<=8103)return String.fromCodePoint(n+8);if(n===8115)return"\u1FBC";if(n===8131)return"\u1FCC";if(n===8179)return"\u1FFC";let i=e.toUpperCase();return Array.from(i).length===1?i:e}).join("")}l(wt,"ordinalIgnoreCaseKey");function go(t){let e=Pn(t),n=l((h,x)=>h.map(g=>({syntax:g,rank:e.get(_e([...x,g.name]))??Number.MAX_SAFE_INTEGER})).sort((g,S)=>g.rank-S.rank).map(g=>g.syntax),"ordered"),i=[],r=l((h,x)=>{let g=[...x,h.name];for(let S of n(h.slices,g))i.push({syntax:S,scope:[...g,S.name],identity:[...g.map(C=>`container:${C}`),`slice:${S.name}`],index:i.length});for(let S of n(h.features,g))r(S,g)},"feature");for(let h of n(t.modules,[]))for(let x of n(h.features,[h.name]))r(x,[h.name]);let o=new Map(i.map(h=>[h,new Set([...le(h.syntax).map(x=>wt(x.name)),...h.syntax.commands.flatMap(x=>x.produces.map(g=>wt(g.event))),...h.syntax.reactions.flatMap(x=>x.triggers.flatMap(g=>g.produces.map(S=>wt(S.event))))])])),s=new Map;for(let h of i)for(let x of le(h.syntax)){let g=wt(x.name);s.has(g)||s.set(g,h)}let a=new Map;for(let h of i){let x=_e(h.scope);a.has(x)||a.set(x,h)}let d=new Map;for(let h of Zt.for(t,e).edges.filter(x=>x.kind==="decidesFrom"))for(let x of h.evidence){let g=_e([...h.consumer.scope,x.name.toLowerCase()]);d.has(g)||d.set(g,a.get(_e(h.producer.scope)))}let p=[];for(let h of i){let x=new Set,g=$i(h.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location,readModel:S.targetKind==="ReadModel"}));for(let S of g){let C=wt(S.event),$=`${S.readModel?"ReadModel":"Event"}:${C}`;if(x.has($))continue;x.add($);let P=S.readModel?d.get(_e([...h.scope,S.event.toLowerCase()])):s.get(C);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 v=h.identity.slice(0,A+1),k=new Set(i.filter(E=>v.every((b,w)=>E.identity[w]===b)).flatMap(E=>[...o.get(E)]));if(bs(P.syntax,S.event).some(E=>E.timeline&&E.kind==="usesFactsFrom"&&E.targetKind==="Event"&&k.has(wt(E.name))))continue}p.push({...S,consumer:h,producer:P,container:_e(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let m=l((h,x)=>h.consumer.index-x.consumer.index||h.location.line-x.location.line||h.location.column-x.location.column,"compare"),u=new Set,y=[];for(let h of new Set(p.map(x=>x.container))){let x=p.filter(S=>S.container===h),g=new Map;for(let S of x)g.has(S.left)||g.set(S.left,new Set),g.has(S.right)||g.set(S.right,new Set),g.get(S.left).add(S.right);for(let S of An(g).filter(C=>C.length>1)){let C=new Set(S),$=x.filter(v=>C.has(v.left)&&C.has(v.right));$.forEach(v=>u.add(v));let P=$.filter(v=>v.consumer.index<v.producer.index).sort(m)[0];if(P===void 0)continue;let A=l(v=>Math.min(...$.flatMap(k=>[k.consumer,k.producer]).filter(k=>{let E=JSON.parse(h);return k.identity[E.length]===v}).map(k=>k.index)),"memberIndex");S.sort((v,k)=>A(v)-A(k)),y.push({edge:P,diagnostic:{severity:"information",code:c.TimelineCycleGroup,message:`Timeline group ${S.map(v=>`${v.startsWith("slice:")?"slice":h===_e([])?"module":"feature"} '${v.slice(v.indexOf(":")+1)}'`).join(", ")} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:P.location}})}}for(let h of p){if(h.consumer.index>=h.producer.index||u.has(h))continue;let x=h.consumer.scope.slice(0,-1),S=h.producer.scope.length>h.consumer.scope.length&&x.every(($,P)=>h.producer.scope[P]===$)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.",C=h.readModel?`reads read model '${h.event}' built by`:`uses event '${h.event}' produced by`;y.push({edge:h,diagnostic:{severity:"information",code:c.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${C} slice '${h.producer.syntax.name}' drawn after it.${S}`,location:h.location}})}return y.sort((h,x)=>m(h.edge,x.edge)).map(h=>h.diagnostic)}l(go,"timelineOrderDiagnostics");function He(t,e,n=Pt,i=!0,r,o){let s=Tt(t,!1,e),a=Ei(s,e,o);a.scope=n,a.streamCandidates=r??Ht.capture([s],n,o);let d=wi(a,s,n);if(i){Vi(d,a),Ci(d,a),Hn(d,a),Pi(d,a),ki(d,a),Kn(d,a);let p=ze(d);_n(p,a),Di(d,a),Mi(d,a),ji(p,a),Li(d,a),qi(d,a),Fi(d,a),Ui(d,a),Wi(d,a),d=ei(d,a),Jt.validate(d,a);for(let m of Jn(d))a.information(m.code,m.message,m.location);for(let m of go(d))a.information(m.code,m.message,m.location)}return{value:d,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}l(He,"parseForAuthoring");function YO(t){return t===c.LegacyOptionalSuffix||t===c.LegacyComplianceMarker||t===c.RedundantEventId||t===c.PublicTranslationRequiresDirection}l(YO,"isQuickFixDiagnostic");function vo(t,e){return e.code!==c.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}l(vo,"legacyOptionalTypeLength");function FO(t,e={}){let n=He(t,void 0,e.placement),i=new Set(Array.from({length:14},(v,k)=>`PLAY0${607+k}`)),r=l(v=>v.success||v.diagnostics.every(k=>k.severity!=="error"||i.has(k.code)),"acceptable"),o=l(v=>new Set(v.diagnostics.filter(k=>k.severity==="error").map(k=>k.code)),"errorCodes");if(!r(n))return()=>[];let s=Tt(t),a=new Map,d=new Map;new class extends Ye{visitEvent(v){a.set(v.location.line,v)}visitSlice(v){d.set(v.location.line,v),super.visitSlice(v)}}().visitApplication(n.value);let m=new Map,u=new Map,y=new Map,h;for(let v of s)h=a.get(v.number)??h,h!==void 0&&y.set(v.number,h);for(let v of n.diagnostics){m.set(v.code,(m.get(v.code)??0)+1);let k=s[v.location.line-1],E=vo(k.raw,v);if(E>0)u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:k.startOffset+v.location.column+E-2,length:1,text:" optional"}]}});else if(v.code===c.LegacyComplianceMarker){let b=jm(k.raw,k.startOffset);b!==void 0&&u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[b]}})}else if(v.code===c.PublicTranslationRequiresDirection){let b=d.get(k.number),w=/^\s*/.exec(k.raw)[0],T=t.includes(`\r
|
|
19
19
|
`)?`\r
|
|
20
20
|
`:`
|
|
21
|
-
`,I=[de.Inbound,de.Outbound].map(j=>({direction:j,text:`${T}${w} direction ${j===de.Inbound?"inbound":"outbound"}`})).filter(j=>{let N=xo(t,[{start:k.startOffset+k.raw.length,length:0,text:j.text}]),L=He(N,void 0,e.placement),q=o(n);return r(L)&&![...o(L)].some(V=>V===c.PublicTranslationRequiresDirection||!q.has(V))});if(I.length===1){let[{direction:j,text:N}]=I;u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:`Declare 'direction ${j===de.Inbound?"inbound":"outbound"}'`,scope:"occurrence",edits:[{start:k.startOffset+k.raw.length,length:0,text:N}]},change:{node:b,replacement:{...b,direction:j}}})}}else if(v.code===c.RedundantEventId&&an(k.raw)<0){let b=y.get(k.number);if(b?.id!==b?.name||b===void 0)continue;u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:k.startOffset,length:(s[k.number]?.startOffset??t.length)-k.startOffset,text:""}]},change:{node:b,replacement:{...b,id:null}}})}}let x=[c.LegacyOptionalSuffix,c.LegacyComplianceMarker],g=In(n),S=new Map,E,$=new Set,P=new Map,A=l((v,k)=>{let C=xo(t,v.edits);if(C===void 0)return;let b=He(C,void 0,e.placement);if(!(!r(b)||In(b)!==(k===void 0?g:In(n,[k]))))return b.diagnostics.filter(w=>w.code===v.diagnosticCode).length===(m.get(v.diagnosticCode)??0)-v.edits.length?v:void 0},"verify");return(v,k)=>{let C=typeof v=="number"||v===void 0?void 0:v,b=x.filter(N=>C===void 0?k===void 0||k===N:C.some(L=>L.diagnosticCode===N));for(let N of b.filter(L=>!$.has(L))){let L=[...u.values()].filter(q=>q.fix.diagnosticCode===N);if(L.length>0){let q=A({diagnosticCode:N,title:N===c.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:L.flatMap(V=>V.fix.edits)});q!==void 0&&P.set(N,q)}$.add(N)}let w=b.flatMap(N=>P.has(N)?[P.get(N)]:[]);if(C!==void 0){if(E===void 0){E=new Map;let L=s.flatMap(K=>u.has(K.number)?[u.get(K.number)]:[]),q=L.flatMap(K=>K.fix.edits),V=xo(t,q);if(q.length>0&&V!==void 0){let K=He(V,void 0,e.placement),J=L.flatMap(U=>U.change===void 0?[]:[U.change]);if(r(K)&&In(K)===In(n,J)){let U=new Map,_=new Map;for(let ie of K.diagnostics)U.set(ie.code,(U.get(ie.code)??0)+1);for(let ie of L)_.set(ie.fix.diagnosticCode,(_.get(ie.fix.diagnosticCode)??0)+ie.fix.edits.length);if([..._].every(([ie,Ce])=>(U.get(ie)??0)===(m.get(ie)??0)-Ce))for(let ie of L)E.set(ie.line,ie.fix)}}}let N=new Map;for(let L of C){let q=E.get(L.line);q?.diagnosticCode===L.diagnosticCode&&N.set(L.line,q)}return[...N.values(),...w]}let T=typeof v=="number"?v:void 0,I=T===void 0?void 0:u.get(T),j;return I!==void 0&&T!==void 0&&(k===void 0||I.fix.diagnosticCode===k)&&(S.has(T)||(S.size===32&&S.delete(S.keys().next().value),S.set(T,A(I.fix,I.change))),j=S.get(T)),[...j===void 0?[]:[j],...w]}}l(BO,"prepareQuickFixes");function Mm(t,e){let n=O("^(\\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=O("^(\\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"}}l(Mm,"complianceMarkerEdit");function In(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}l(In,"verificationShape");function xo(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}l(xo,"applyQuickFixEdits");var Ht=class{static{l(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(p=>p.source.streams).filter(p=>p.name===n),o=i.length>1||r.length>1,s=!this.complete||i.some(p=>!p.placementResolved),a=o?"ambiguous":s?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",d=[];return i.length>1&&d.push("Multiple physical parent sources claim the exact name."),r.length>1&&d.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&d.push("A physical parent has unresolved import placement."),this.complete||d.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:d}}};var jm=$e("^[A-Za-z_]\\w*$"),tt=l((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),X=l(t=>{throw new ue(t)},"refuse"),gt=l((t,e,n)=>{if(!Array.isArray(t))return X(n);for(let i=0;i<t.length;i++)tt(t[i],e)||X(n)},"collection");function Xt(t){let e=ci(t);if(e!==void 0&&X(e),t.kind==="ConceptSyntax"){let n=t;for(let i of n.validations??[])i.kind==="DeclarativeValidateSyntax"&&i.rules.some(r=>r.implementation!=null)&&X("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let n=t;n.implementation!=null&&(tt(n.implementation,"ImplementationSyntax")||X("A named rule requires an ImplementationSyntax wrapper."),(n.rule!=="Rule"||n.value?.kind!=="PathExpressionSyntax"||!tt(n.value,"PathExpressionSyntax")||typeof n.value.path!="string"||jm.exec(n.value.path)?.[0]!==n.value.path)&&X("An implementation wrapper requires a valid named rule."),n.file!=null&&n.code!=null&&X("A named rule has at most one file or inline payload."),n.file!=null&&(!tt(n.file,"FileReferenceSyntax")||typeof n.file.path!="string")&&X("A named rule file requires a FileReferenceSyntax payload with a string path."),n.code!=null&&(!tt(n.code,"CodeBlockSyntax")||typeof n.code.language!="string"||typeof n.code.code!="string")&&X("A named rule inline payload requires a CodeBlockSyntax with string language and code."),Xt(n.implementation))}if(t.kind==="ProducesSyntax"){let n=t,i=n.inlineOperation;if(i!=null){n.inlineEvent!=null&&X("A production cannot declare both an event and an operation."),(n.when!=null||n.event!==i.name||n.for!=null||(n.tags??[]).length>0)&&X("An inline operation requires a matching unconditional target without event metadata."),gt(i.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),gt(n.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),i.inputs.length!==n.mappings.length&&X("Inline operation inputs and mappings must correspond in order.");for(let r=0;r<i.inputs.length;r++)i.inputs[r].name!==n.mappings[r].property&&X("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let n=t;n.file!=null&&n.code!=null&&X("An operation phase has at most one file or inline payload."),n.implementation!=null&&Xt(n.implementation)}if(t.kind==="HandlerSyntax"){let n=t;n.implementation!=null&&n.file!=null&&n.code!=null&&X("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let n=t;gt(n.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let i=0;i<n.hints.length;i++)Xt(n.hints[i])}if(t.kind==="ImplementationHintSyntax"){let n=t;(typeof n.text!="string"||oi(n.text))&&X("An implementation hint must be nonblank.")}$o(t)}l(Xt,"validateSyntaxInvariants");function $o(t){let e=l(i=>{Er(i)||X("Event source and stream names must be identifiers.")},"name"),n=l((i,r)=>{gt(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&X("A route cannot map both scalar and composite stream ids."),r.forEach(o=>e(o.property))},"mappings");if(t.kind==="ApplicationSyntax"){let i=t.eventSources;i!==void 0&>(i,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(t.kind==="EventSourceSyntax"||t.kind==="EventStreamSyntax"){let i=t;e(i.name),i.id!==null&&(typeof i.id!="string"||i.id.trim()==="")&&X("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!tt(r,"TypeRefSyntax")&&X("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&X("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!ii(r.name)&&X("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?gt(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(gt(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&X("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>$o(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),tt(i.type,"TypeRefSyntax")||X("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&X("Source identifiers and stream ids require nonoptional scalar type references."),ii(i.type.name)||X("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&X("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!tt(i.stream,"CommandStreamSyntax")&&X("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&>(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($o(s),s.propertyCandidate===null&&i.stream==null&&X("A duplicate route candidate requires an authoritative route."),s.propertyCandidate!==null)for(let a=0;a<i.properties.length;a++)i.properties[a]===s.propertyCandidate&&X("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"||t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax"){let i=t;i.stream!=null&&i.noStream!=null&&X("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!tt(i.stream,"SpecificationStreamSyntax")&&X("A specification stream requires a specification stream node."),i.noStream!=null&&!tt(i.noStream,"SpecificationNoStreamSyntax")&&X("An unrouted expectation requires a specification no stream node.")}if(t.kind==="SpecificationStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A specification stream maps only streamId."),n(i.streamId,i.streamIdParts)}if(t.kind==="CommandStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A command stream maps only streamId."),n(i.streamId,i.streamIdParts);let r=i.propertyCandidate;r!==null&&(r.name!=="stream"||r.type.name!==`${i.eventSource}.${i.stream}`||r.type.isCollection||r.type.isOptional||r.isGenerated||r.isIdentifier||i.streamId!==null||i.streamIdParts.length>0)&&X("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}l($o,"validateSourceStream");var ct={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","ExposureSyntax","ExposedPropertySyntax","InstanceContributionsSyntax","InstanceContributionSyntax","ContributedItemSyntax","ContributedItemValueSyntax","ScreenContributionSyntax","TemplateSlotContentSyntax","CommandFormLayoutSyntax","FormLayoutColumnSyntax","FormFieldPlacementSyntax","FormWidthSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationParameterSyntax","SpecificationCaseSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionAlternativeSyntax","InteractionOtherwiseSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","InvocationRefusalSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotPolicyConditionSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","PurposeSyntax","PurposeReferenceSyntax","PurposeTransferSyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PresentationValueSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionSyntax","ReactionTriggerSyntax","RefusalExpressionSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenNavigationParameterSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenComponentSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenToolbarSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","TemplateAssignmentSyntax","TemplateExposedValueSyntax","TemplateOutletSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerPersonaSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","ToolbarItemSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiBindingSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","exposures","fileImports","imports","instanceContributions","layouts","modules","personas","policies","purposes","seeds","sourceOptions","numericMode","systems","templates","themes","triggers","types","uiProfiles","triggerName","children","columns","gap","grow","rows","span","syntaxKind","height","root","width","growFactor","name","mode","overrides","variants","alias","providers","requirement","type","bindings","description","file","order","parameters","event","tags","when","appends","identifiedBy","map","source","translations","settings","separator","targets","key","nested","from","to","expression","fromValue","properties","toValue","parameter","blocks","claim","matches","matchesSubject","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","content","displayName","exposes","outlets","restrictsScopes","scopes","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","origin","visibility","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","owner","component","editableFields","isCollection","operations","reExposes","restrictsFields","instance","items","field","slot","columnGap","placements","rowGap","index","maxWidth","minWidth","column","columnSpan","row","rowSpan","unit","composeUsing","by","query","columnMode","fields","for","generationMode","layout","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","trigger","amount","onRefused","acknowledge","constraint","selector","on","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","authorization","basis","basisReference","conditionReference","erasureException","interest","recipients","retention","subjects","transfers","destination","safeguard","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","isSubject","filters","isObservable","performer","returnType","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","context","icon","presentation","stableId","outlet","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","direction","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","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","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","literal","nullBehavior","rawText","defaultSizeClass","icons","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,27,46,53,54,56,113,114,126,128,153,156,199,220,224],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,30,48,50,100,192,221],["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",93],["array",18],["ref",70],["array",20],["ref",67],["array",22],["ref",99],["array",24],["ref",72],["array",26],["ref",112],["array",28],["union",29,8],["ref",118],["array",31],["ref",130],["array",33],["union",34,8],["ref",133],["array",36],["ref",134],["array",38],["ref",191],["array",40],["union",41,8],["enum","legacy","exact"],["object",[[21,43,!0]]],["ref",90],["array",45],["ref",193],["array",47],["ref",227],["array",49],["union",50,8],["ref",229],["array",52],["union",53,8],["ref",231],["array",55],["union",56,8],["ref",233],["array",58],["union",59,8],["object",[[4,9,!1],[5,11,!1],[6,13,!1],[7,15,!1],[8,17,!1],[9,19,!1],[10,21,!1],[11,23,!1],[12,25,!1],[13,27,!1],[14,30,!1],[15,32,!1],[16,35,!1],[17,37,!1],[18,39,!1],[19,42,!1],[20,44,!1],[22,46,!1],[23,48,!1],[24,51,!1],[25,54,!1],[26,57,!1],[27,60,!1]]],["object",[[28,0,!0]]],["ref",4,6],["array",63],["integer",-2147483648,2147483647],["union",65,8],["number"],["union",67,8],["enum","Flat","Row","Column","Grid"],["object",[[29,64,!1],[30,66,!1],[31,66,!1],[32,68,!1],[33,66,!1],[34,66,!1],[35,69,!0]]],["union",0,8],["object",[[36,71,!1],[37,63,!0],[38,71,!1]]],["boolean"],["object",[[32,73,!1],[39,68,!1],[36,66,!1],[40,0,!0],[34,66,!1],[38,66,!1]]],["enum","Flow","Freeform"],["ref",5],["array",76],["union",77,8],["union",63,8],["ref",239],["array",80],["union",81,8],["object",[[41,75,!0],[42,78,!1],[37,79,!1],[43,82,!1]]],["object",[]],["object",[[44,71,!1],[40,0,!0]]],["ref",9],["array",86],["object",[[45,87,!1]]],["ref",117,132],["object",[[46,89,!0]]],["object",[[40,0,!0],[1,0,!0]]],["ref",230],["union",92,8],["object",[[40,0,!0],[47,93,!1]]],["ref",104],["array",95],["ref",68],["union",97,8],["ref",13],["array",99],["object",[[48,96,!1],[49,71,!1],[50,98,!1],[40,71,!1],[51,66,!1],[52,100,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[35,102,!0]]],["ref",142],["array",104],["ref",222],["array",106],["union",107,8],["ref",25],["union",109,8],["object",[[53,0,!0],[3,105,!1],[54,108,!1],[55,110,!1]]],["ref",16],["array",112],["ref",18,22],["array",114],["object",[[56,113,!1],[57,0,!0],[58,115,!1],[0,0,!0]]],["ref",24],["array",117],["object",[[0,0,!0],[59,1,!0],[60,118,!1]]],["object",[[56,113,!1],[58,115,!1],[0,0,!0]]],["ref",20],["array",121],["object",[[61,122,!1],[35,0,!0]]],["array",0],["object",[[62,0,!0],[59,1,!0],[63,124,!1]]],["ref",17],["array",126],["ref",19],["array",128],["ref",21],["union",130,8],["object",[[56,113,!1],[29,127,!1],[64,71,!1],[58,115,!1],[40,0,!0],[65,129,!1],[59,131,!1],[20,44,!1]]],["object",[[66,0,!0],[67,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[68,71,!1],[69,71,!1],[70,124,!1],[35,134,!0],[71,71,!1]]],["object",[[0,71,!1]]],["object",[[72,0,!0]]],["ref",1,28,31,62,86,110,122,140,162,163],["array",138],["object",[[2,3,!0],[73,139,!1],[57,1,!0],[0,0,!0]]],["union",1,8],["object",[[74,0,!0],[75,141,!1],[76,73,!0]]],["object",[[0,0,!0]]],["object",[[53,0,!0]]],["ref",103],["array",145],["ref",32,45,63,120,121,124,125,152,161,196],["array",147],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[81,0,!0],[82,0,!0]]],["ref",232],["object",[[83,151,!0],[40,0,!0]]],["ref",167,169,172,173,174,176,178,179,180,181,183,184,186,187,188],["array",153],["object",[[84,154,!1],[40,0,!0]]],["union",151,8],["object",[[83,156,!1],[0,0,!0],[1,141,!1]]],["ref",33],["object",[[81,158,!0]]],["ref",11],["union",160,8],["ref",44],["union",162,8],["ref",87],["union",164,8],["ref",137],["array",166],["ref",143],["array",168],["ref",158],["array",170],["union",171,8],["ref",146,147],["union",173,8],["ref",39],["union",175,8],["array",175],["ref",37,49],["array",178],["object",[[85,161,!1],[86,163,!1],[49,71,!1],[87,71,!1],[88,165,!1],[40,0,!0],[89,167,!1],[70,169,!1],[90,172,!1],[91,174,!1],[92,176,!1],[93,177,!1],[94,179,!1]]],["union",168,8],["union",104,8],["object",[[95,0,!0],[96,181,!1],[92,0,!0],[97,182,!1],[98,105,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[99,0,!0],[100,184,!0],[101,1,!0]]],["ref",111],["array",186],["object",[[102,187,!1],[47,0,!0]]],["object",[[103,73,!1],[40,0,!0],[104,71,!1],[105,71,!1],[106,71,!1]]],["ref",42],["array",190],["union",179,8],["object",[[107,191,!1],[49,71,!1],[50,98,!1],[40,0,!0],[47,0,!0],[94,192,!1],[108,124,!1]]],["object",[[95,73,!0],[109,71,!1],[110,71,!1],[111,71,!1],[112,124,!1]]],["object",[[77,146,!1],[113,0,!0],[114,73,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[115,0,!0]]],["ref",178],["union",197,8],["object",[[116,0,!0],[117,71,!1],[118,198,!1],[51,66,!1]]],["ref",164],["array",200],["union",201,8],["ref",238],["array",203],["object",[[119,202,!1],[120,204,!1]]],["ref",7],["union",206,8],["ref",77],["array",208],["ref",194],["array",210],["ref",195],["array",212],["ref",198],["array",214],["ref",237],["array",216],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[123,209,!1],[49,71,!1],[124,71,!1],[125,211,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["object",[[40,0,!0]]],["object",[[132,0,!0]]],["ref",59],["array",221],["object",[[49,71,!1],[133,71,!1],[134,93,!1],[40,0,!0],[135,222,!1]]],["object",[[40,0,!0],[47,92,!0]]],["ref",58],["array",225],["object",[[49,71,!1],[133,71,!1],[40,0,!0],[97,93,!1],[98,226,!1]]],["object",[[53,0,!0],[64,141,!1]]],["integer",0,4294967295],["enum","Private","Public"],["object",[[49,71,!1],[87,71,!1],[50,98,!1],[136,229,!1],[137,73,!1],[133,71,!1],[40,0,!0],[138,71,!1],[70,169,!1],[54,108,!1],[139,230,!1]]],["object",[[2,3,!0],[140,73,!0],[3,5,!1]]],["object",[[77,146,!1],[141,0,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[68,1,!0]]],["ref",47],["array",235],["union",236,8],["ref",236],["array",238],["ref",65],["array",240],["ref",135],["array",242],["ref",197],["array",244],["object",[[85,161,!1],[5,11,!1],[142,237,!1],[143,239,!1],[49,71,!1],[87,71,!1],[9,19,!1],[144,241,!1],[11,23,!1],[145,73,!0],[40,0,!0],[18,243,!1],[146,245,!1],[23,48,!1],[131,217,!1]]],["ref",66,234,235],["array",247],["object",[[147,248,!1],[49,71,!1],[50,97,!0],[148,73,!0],[113,71,!1],[40,0,!0],[149,124,!1]]],["object",[[150,0,!0]]],["object",[[117,71,!1],[0,0,!0]]],["ref",71],["array",252],["object",[[151,0,!0],[70,253,!1]]],["object",[[152,0,!0],[153,124,!1],[154,73,!0],[117,71,!1],[155,124,!1],[115,0,!0],[156,71,!1],[157,73,!0]]],["ref",73],["array",256],["object",[[142,257,!1],[158,0,!0]]],["ref",74],["array",259],["object",[[152,0,!0],[159,260,!1],[115,0,!0],[1,141,!1]]],["ref",75],["array",262],["object",[[133,0,!0],[108,263,!1]]],["object",[[160,0,!0],[1,1,!0]]],["object",[[116,0,!0],[84,154,!1],[51,66,!1]]],["object",[[84,154,!1],[161,0,!0]]],["ref",81],["union",268,8],["ref",79],["array",270],["ref",80],["array",272],["object",[[162,269,!1],[30,271,!1],[163,273,!1],[164,269,!1]]],["object",[[165,65,!0],[166,269,!1],[167,269,!1],[38,269,!1]]],["object",[[168,65,!0],[169,66,!1],[160,0,!0],[170,65,!0],[171,66,!1],[38,269,!1]]],["enum","Fraction","Pixels","Percent","Auto"],["object",[[172,277,!0],[1,68,!1]]],["object",[[173,71,!1],[66,71,!1],[117,71,!1],[0,0,!0]]],["object",[[174,71,!1],[175,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",69],["array",282],["ref",82],["array",284],["ref",78],["union",286,8],["ref",83,84],["union",288,8],["object",[[5,11,!1],[176,281,!0],[30,283,!1],[49,71,!1],[177,285,!1],[178,0,!0],[179,281,!0],[180,287,!1],[40,0,!0],[181,198,!1],[182,289,!1],[131,217,!1]]],["ref",60],["array",291],["ref",41,64],["union",293,8],["object",[[183,292,!1],[64,294,!1],[3,5,!1],[184,141,!1]]],["union",158,8],["ref",88],["union",297,8],["object",[[81,296,!1],[50,98,!1],[185,298,!1]]],["ref",89],["array",300],["object",[[186,301,!1]]],["object",[[187,0,!0]]],["object",[[49,71,!1],[40,0,!0]]],["ref",92],["union",305,8],["object",[[188,306,!1],[49,71,!1],[189,306,!1],[190,169,!1],[40,0,!0],[191,0,!0]]],["object",[[81,296,!1],[49,71,!1],[50,98,!1],[185,298,!1]]],["ref",212],["union",309,8],["ref",211],["union",311,8],["object",[[49,71,!1],[178,141,!1],[192,105,!1],[40,0,!0],[193,310,!1],[92,312,!1],[47,0,!0],[108,105,!1]]],["object",[[40,0,!0],[108,105,!1]]],["object",[[194,0,!0]]],["object",[[194,0,!0],[108,105,!1]]],["object",[[138,71,!1],[195,0,!0],[139,230,!1]]],["ref",40,115],["object",[[196,148,!1],[197,318,!0]]],["object",[[196,148,!1]]],["object",[[83,0,!0],[40,0,!0]]],["ref",101],["array",322],["ref",102],["union",324,8],["ref",3,15,55,105],["object",[[196,148,!1],[198,323,!1],[197,71,!1],[199,325,!1],[200,326,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[201,65,!0],[172,328,!0]]],["ref",108],["array",330],["object",[[141,0,!0],[3,105,!1],[202,331,!1]]],["object",[[203,73,!0],[204,71,!1],[89,167,!1],[205,0,!0]]],["object",[[2,3,!0],[53,0,!0],[3,5,!1]]],["ref",109],["array",335],["object",[[183,336,!1],[206,0,!0],[0,0,!0]]],["object",[[68,1,!0],[0,0,!0]]],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[125,211,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["array",1],["object",[[159,340,!1]]],["union",0,73,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[207,344,!0],[1,345,!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",[[207,347,!0],[1,348,!0]]],["union",342,343,346,349],["object",[[1,350,!1]]],["enum","And","Or"],["object",[[99,318,!0],[100,352,!0],[101,318,!0]]],["ref",8,29,116,123,165],["object",[[99,354,!0],[100,352,!0],[101,354,!0]]],["object",[[99,89,!0],[100,352,!0],[101,89,!0]]],["ref",51],["array",357],["union",358,8],["ref",85],["array",360],["union",361,8],["ref",185],["array",363],["object",[[85,161,!1],[5,11,!1],[142,237,!1],[143,239,!1],[49,71,!1],[208,359,!1],[87,71,!1],[9,19,!1],[144,241,!1],[11,23,!1],[209,362,!1],[145,73,!0],[40,0,!0],[18,243,!1],[210,364,!1],[23,48,!1],[131,217,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[211,0,!0]]],["object",[[2,3,!0],[73,139,!1],[0,0,!0]]],["object",[[212,354,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[77,146,!1],[213,369,!0],[113,0,!0],[114,73,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[77,146,!1],[214,0,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["ref",127],["array",372],["object",[[215,373,!1]]],["object",[[40,0,!0],[1,1,!0]]],["object",[[81,296,!1],[50,98,!1]]],["object",[[49,71,!1],[40,0,!0],[17,124,!1]]],["object",[[216,73,!1],[217,71,!1],[218,71,!1],[219,0,!0],[220,66,!1],[221,66,!1]]],["union",354,8],["object",[[81,296,!1],[197,379,!1],[49,71,!1],[50,98,!1],[40,0,!0]]],["ref",136],["array",381],["object",[[222,71,!1],[223,71,!1],[224,71,!1],[197,71,!1],[225,71,!1],[49,71,!1],[226,71,!1],[227,71,!1],[40,0,!0],[228,124,!1],[229,71,!1],[230,124,!1],[231,382,!1]]],["object",[[232,0,!0],[233,0,!0]]],["ref",61],["union",385,8],["ref",91],["union",387,8],["union",318,8],["object",[[53,0,!0],[178,141,!1],[234,386,!1],[235,388,!1],[3,105,!1],[54,108,!1],[55,389,!1]]],["object",[[2,3,!0],[73,139,!1],[49,71,!1],[50,98,!1],[64,294,!1],[40,0,!0],[236,71,!1],[237,71,!1],[20,44,!1]]],["ref",138],["array",392],["object",[[73,139,!1],[238,393,!1],[40,0,!0]]],["object",[[0,0,!0],[59,1,!0]]],["object",[[239,73,!1],[240,73,!1],[241,73,!1],[40,0,!0],[47,92,!0]]],["ref",144],["object",[[40,0,!0],[59,397,!0],[47,93,!1]]],["object",[[59,397,!0]]],["ref",145],["array",400],["object",[[177,401,!1]]],["object",[[1,1,!0]]],["object",[[177,105,!1]]],["object",[[40,0,!0],[59,141,!1],[47,92,!0]]],["ref",150],["union",406,8],["array",406],["ref",129],["union",409,8],["object",[[85,161,!1],[174,407,!1],[49,71,!1],[242,408,!1],[243,73,!1],[40,0,!0],[244,410,!1],[245,92,!0],[105,71,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[200,0,!0]]],["ref",155],["array",413],["object",[[49,71,!1],[87,71,!1],[40,0,!0],[25,414,!1],[246,389,!1]]],["ref",228],["array",416],["ref",107],["array",418],["union",419,8],["union",167,8],["ref",106,119,166],["object",[[81,296,!1],[247,417,!1],[49,71,!1],[50,98,!1],[248,420,!1],[89,421,!1],[90,172,!1],[59,422,!0]]],["object",[[249,0,!0]]],["object",[[49,71,!1],[87,71,!1],[50,98,!1],[40,0,!0],[70,169,!1]]],["object",[[44,71,!1],[174,71,!1],[236,0,!0]]],["object",[[81,296,!1],[49,71,!1],[53,0,!0],[50,98,!1]]],["ref",159],["array",428],["object",[[49,71,!1],[40,0,!0],[236,0,!0],[120,429,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[175,0,!0]]],["object",[[53,0,!0],[64,141,!1],[184,141,!1]]],["enum","Error","Information","Warning"],["object",[[197,318,!0],[113,71,!1],[250,433,!0]]],["object",[[251,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",436,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[252,66,!1],[253,437,!1],[254,438,!0]]],["object",[[141,0,!0],[117,71,!1],[118,198,!1]]],["ref",170],["array",441],["ref",171],["union",443,8],["object",[[198,442,!1],[117,0,!0],[118,198,!1],[199,444,!1]]],["object",[[77,146,!1],[141,0,!0],[197,318,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[77,146,!1],[141,71,!1],[255,447,!0]]],["object",[[256,10,!0]]],["ref",34],["array",450],["ref",35],["array",452],["ref",141],["array",454],["ref",36],["array",456],["object",[[5,11,!1],[152,0,!0],[257,156,!1],[125,451,!1],[258,71,!1],[40,0,!0],[126,453,!1],[259,455,!1],[70,457,!1],[260,71,!1],[131,217,!1]]],["object",[[174,71,!1],[175,0,!0],[47,92,!0]]],["object",[[117,0,!0],[0,0,!0]]],["ref",168],["array",461],["object",[[174,71,!1],[261,71,!1],[52,462,!1],[262,71,!1],[211,0,!0]]],["ref",177],["array",464],["object",[[177,465,!1],[263,0,!0]]],["ref",76],["array",467],["object",[[142,468,!1],[49,71,!1],[84,154,!1],[50,98,!1],[40,0,!0]]],["ref",175],["array",470],["object",[[5,11,!1],[30,471,!1],[264,198,!1],[263,0,!0],[131,217,!1]]],["ref",180],["array",473],["object",[[40,0,!0],[129,474,!1]]],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[123,209,!1],[49,71,!1],[124,71,!1],[125,211,!1],[265,71,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["ref",223],["array",477],["object",[[159,478,!1],[40,0,!0]]],["object",[[191,216,!0]]],["object",[[53,0,!0],[70,105,!1]]],["ref",189],["array",482],["object",[[266,0,!0],[183,483,!1]]],["ref",190],["array",485],["object",[[267,486,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[263,0,!0],[1,0,!0]]],["ref",23],["array",489],["ref",38],["array",491],["enum","Inbound","Outbound"],["union",493,8],["array",385],["array",387],["ref",139],["array",497],["ref",151],["array",499],["ref",154],["array",501],["ref",157],["array",503],["union",504,8],["ref",160],["array",506],["union",507,8],["ref",182],["array",509],["ref",217],["array",511],["enum","StateChange","StateView","Automation","Translate"],["object",[[268,490,!1],[269,492,!1],[270,248,!1],[49,71,!1],[271,494,!1],[87,71,!1],[183,495,!1],[9,19,!1],[50,98,!1],[40,0,!0],[155,496,!1],[272,498,!1],[18,243,!1],[273,500,!1],[274,502,!1],[275,505,!1],[276,508,!1],[277,510,!1],[278,512,!1],[23,48,!1],[47,513,!0]]],["object",[[279,71,!1],[40,0,!0]]],["object",[[64,1,!0],[40,0,!0]]],["object",[[47,0,!0],[1,0,!0]]],["ref",201],["array",518],["object",[[280,73,!0],[281,519,!1],[282,124,!1]]],["object",[[283,0,!0],[284,105,!1]]],["object",[[285,0,!0]]],["object",[[286,0,!0],[178,141,!1],[192,105,!1],[287,71,!1],[108,105,!1]]],["ref",27],["union",524,8],["object",[[288,525,!1],[40,71,!1]]],["object",[[289,0,!0],[178,141,!1],[287,71,!1],[193,310,!1],[92,312,!1],[108,105,!1]]],["object",[[95,0,!0],[92,0,!0],[97,182,!1],[98,105,!1]]],["object",[[290,73,!0],[70,105,!1]]],["ref",213],["array",530],["object",[[77,105,!1],[290,73,!0],[175,0,!0],[291,531,!1]]],["object",[[290,73,!0],[287,71,!1],[40,0,!0],[70,105,!1]]],["object",[[289,0,!0],[178,141,!1],[193,310,!1],[292,0,!0],[92,312,!1],[108,105,!1]]],["ref",95],["array",535],["ref",209],["array",537],["ref",203],["union",539,8],["ref",202],["union",541,8],["ref",204],["array",543],["ref",205],["union",545,8],["ref",96],["array",547],["ref",215],["array",549],["union",550,8],["ref",94],["array",552],["ref",200],["array",554],["ref",98],["array",556],["ref",207],["union",558,8],["ref",208],["array",560],["ref",210],["union",562,8],["ref",97],["array",564],["ref",214],["array",566],["ref",148,149],["union",568,8],["ref",206],["union",570,8],["union",537,8],["union",543,8],["ref",219],["union",574,8],["ref",216],["union",576,8],["ref",218],["union",578,8],["object",[[293,536,!1],[49,71,!1],[9,19,!1],[50,98,!1],[294,538,!1],[295,540,!1],[296,542,!1],[297,544,!1],[298,546,!1],[299,548,!1],[300,551,!1],[40,0,!0],[52,553,!1],[20,44,!1],[301,555,!1],[302,557,!1],[303,559,!1],[304,561,!1],[305,538,!1],[306,73,!0],[307,73,!1],[308,563,!1],[309,565,!1],[310,567,!1],[311,551,!1],[312,531,!1],[313,569,!1],[55,571,!1],[314,572,!1],[315,573,!1],[316,546,!1],[317,575,!1],[318,577,!1],[319,579,!1]]],["object",[[200,0,!0],[108,105,!1]]],["object",[[77,105,!1],[175,0,!0]]],["object",[[64,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[258,71,!1],[117,71,!1],[40,0,!0],[52,462,!1],[259,455,!1],[35,584,!0],[263,0,!0]]],["ref",225,226],["array",586],["object",[[102,587,!1]]],["object",[[320,124,!1],[40,0,!0]]],["object",[[247,417,!1],[49,71,!1],[50,98,!1],[40,0,!0]]],["object",[[154,73,!0],[321,73,!0],[40,0,!0]]],["object",[[49,71,!1],[50,98,!1],[40,0,!0],[70,169,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty","Literal"],["enum","OneWay","TwoWay"],["union",594,8],["enum","Propagate","Clear","Preserve"],["union",596,8],["object",[[322,593,!0],[323,71,!1],[324,71,!1],[325,71,!1],[326,141,!1],[41,595,!1],[327,597,!1],[115,0,!0],[175,71,!1],[328,71,!1]]],["object",[[329,71,!1],[330,124,!1],[180,71,!1],[40,0,!0],[331,124,!1],[332,124,!1],[333,71,!1]]],["object",[[147,248,!1],[49,71,!1],[53,0,!0],[148,73,!0],[113,71,!1],[40,0,!0],[149,124,!1]]],["object",[[334,124,!1],[147,248,!1],[49,71,!1],[53,0,!0],[148,73,!0],[113,71,!1],[40,0,!0],[0,0,!0],[149,124,!1]]],["object",[[263,0,!0]]],["ref",12],["array",603],["object",[[77,604,!1],[256,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[81,296,!1],[50,98,!1],[185,298,!1],[113,71,!1],[0,0,!0],[335,606,!0],[250,433,!0],[1,141,!1]]],["ref",131],["array",608],["object",[[36,0,!0],[336,609,!1],[38,0,!0]]]],contracts:[2,6,61,62,70,72,74,83,84,85,88,90,91,94,101,103,111,116,119,120,91,123,125,132,133,135,136,137,140,142,143,144,149,150,152,155,157,159,180,183,185,188,189,193,194,195,196,199,143,205,143,218,219,219,196,220,84,223,224,227,228,231,232,233,234,246,249,250,196,251,254,255,258,261,264,265,266,267,274,275,276,278,279,84,280,290,295,299,302,303,304,307,308,313,224,314,315,316,315,317,143,319,320,321,327,329,329,332,333,334,337,338,339,341,351,353,355,356,365,219,366,149,367,368,370,371,374,375,196,376,377,378,219,380,383,219,384,390,228,391,394,91,395,396,143,398,399,402,403,404,405,411,412,303,415,423,424,425,426,427,430,431,228,432,434,435,439,440,152,445,446,448,449,159,458,251,459,460,463,155,155,466,469,472,475,476,303,479,480,481,484,487,395,219,94,219,488,514,515,196,516,517,219,520,521,522,523,84,526,527,84,528,84,529,532,533,534,580,581,582,583,2,403,585,588,234,303,589,94,590,591,592,598,599,600,601,602,605,607,610]};var bo=ct.rules,Lm=new Map(bo.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),Hs=new Map(ct.kinds.map((t,e)=>[t,bo[ct.contracts[e]][1]])),Nm=new Map([...Hs].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ct.names[n])])])),Js=l(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function ko(t){let e=Hs.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!Xs(t,e))throw new ue(`Invalid typed members for syntax kind '${t.kind}'.`)}l(ko,"validateSyntaxMembers");function Vi(t,e){let n=zi(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new ue(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}l(Vi,"validateClosedSyntaxMembers");function zi(t){let e=Nm.get(t);if(e===void 0)throw new ue(`Unknown syntax kind '${t}'.`);return e}l(zi,"syntaxMemberNames");function Xs(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ct.names[n])?Co(t[ct.names[n]],i):!r)}l(Xs,"matchesMembers");function qm(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Co(t[n],e))return!1;return!0}l(qm,"allIndicesMatch");function Co(t,e){let[n,...i]=bo[e];switch(n){case"ref":return Js(t)&&typeof t.kind=="string"&&i.some(r=>ct.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Co(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)&&qm(t,i[0]);case"object":return Js(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ct.names[o]===r))&&Xs(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||Lm.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}l(Co,"matches");var Bm=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(","))])),Ym=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function Fm(t,e){return Bm[t]?.has(e)===!0||Ym.test(t)&&(e==="source"||e==="value")}l(Fm,"isExactOnlyMember");function el(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:Fm(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}l(el,"isLegacyOmittedMember");var Gi=l(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Qi=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),_i=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function Ki(t){let e=Um(t);return Eo(e,"legacy",0),Zi(e)}l(Ki,"toSyntaxJson");function Um(t){let e=new WeakMap,n=[];function i(o){if(typeof o!="object"||o===null)return o;if(e.has(o))return e.get(o);if(Array.isArray(o)){let d=tl();e.set(o,d);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{d[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return d}let s=Object.create(null);e.set(o,s);let a=Object.keys(o);!a.includes("kind")&&"kind"in o&&a.unshift("kind");for(let d=a.length-1;d>=0;d--)n.push(()=>{let p=a[d],m=o[p];p==="sourceOptions"&&n.push(()=>{typeof m=="object"&&m!==null&&(Object.getPrototypeOf(m)!==Object.prototype&&Object.getPrototypeOf(m)!==null||Reflect.ownKeys(m).length!==Object.keys(m).length)&&(s[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(m)});return s}l(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}l(Um,"snapshot");function tl(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}l(tl,"dataArray");function Zi(t,e="legacy",n=!1){if(Array.isArray(t)){let o=tl();for(let s=0;s<t.length;s++)o.push(Zi(t[s],e,n));return o}if(Gi(t)){if(_i.has(t.kind)&&(e=Wt(t.sourceOptions??Ne).numericMode),Xt(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&Vi(t,Qi),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&Vi(p.file,Qi),p.code!=null&&Vi(p.code,Qi))}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"?zi(t.kind):void 0,d=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&el(t,p))&&!Qi.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(Wm);for(let p of d){let m=s[p];(t.kind==="EventSyntax"||t.kind==="ImportSyntax")&&(p==="visibility"&&m==="Private"||p==="origin"&&m==null)||t.kind==="SliceSyntax"&&p==="direction"&&m==null||t.kind==="ConceptAttributeSyntax"&&(p==="scope"||p==="specialCategory")&&m==null||t.kind==="ConceptAttributeSyntax"&&p==="criminal"&&m===!1||t.kind==="PropertySyntax"&&p==="isSubject"&&m===!1||p==="description"&&m==null&&["ConceptSyntax","PolicySyntax","FileConstraintSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","ProjectionSyntax","ScreenSyntax","FormSyntax"].includes(t.kind)||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==="purposes"&&Array.isArray(m)&&m.length===0||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]=Zi(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]=Zi(i[o],e,n));return r}l(Zi,"write");function Eo(t,e,n){if(n>96&&e==="exact")throw new ue("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)Eo(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(_i.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Wt(i.sourceOptions):Ne;if(n>0&&e!==o.numericMode)throw new ue("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!_i.has(i.kind))throw new ue("Exact syntax requires a complete source root.");if(e==="exact"&&Gi(i)&&ko(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&sn(i.text))throw new ue("An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.");if(i.kind==="LiteralExpressionSyntax"&&Object.hasOwn(i,"value")){if(e==="exact"&&(typeof i.value=="number"||i.value!==null&&!["string","boolean","object"].includes(typeof i.value)))throw new ue("Exact source requires supported primitive values or an explicit ExactNumber literal.");if(typeof i.value=="object"&&i.value!==null){let o=i.value;if(o.literalType==="ExactNumber"){if(e!=="exact"||typeof o.value!="string"||nt(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new ue("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new ue("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&Gi(i)?zi(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||Gi(s)&&_i.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&Eo(s,e,n+1)}l(Eo,"validateNumbers");function Wm(t,e){return t<e?-1:t>e?1:0}l(Wm,"ordinal");function il(t){let e=[],n=t.map(g=>g.value),i=new Map,r=!1;for(let g of n)try{i.set(g,Object.hasOwn(g,"sourceOptions")?Wt(g.sourceOptions):Ne)}catch(S){if(!(S instanceof ue))throw S;r=!0,e.push(Ji(c.IncompatibleNumericSource,S.message,g.location))}let o=n.filter(g=>i.get(g)?.numericMode==="exact"||Vm(g)),s=i.get(o[0])??Ne;for(let g of o.slice(1))i.get(g)?.numericMode!==s.numericMode&&(r=!0,e.push(Ji(c.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",g.location)));r&&(s=ha);let a=new Map,d=Tn(n.flatMap(g=>g.concepts),"declaration of",e,void 0,a),p=Tn(n.flatMap(g=>g.types),"declaration of",e,void 0,a),m=n.map(g=>g.domain).filter(g=>g!==null);for(let g of m.slice(1))e.push(Ji(c.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${Rn(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,g.location));let u=zm(n.flatMap(g=>g.modules),e),y=Tn(n.flatMap(g=>g.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:m[0]??null,imports:Ao(n.flatMap(g=>g.imports),g=>g.qualifiedName),concepts:d,types:p,examples:n.flatMap(g=>g.examples??[]),systems:n.flatMap(g=>g.systems??[]),purposes:Tn(n.flatMap(g=>g.purposes??[]),"purpose",e),eventSources:n.flatMap(g=>g.eventSources??[]),declaredTriggers:n.flatMap(g=>g.declaredTriggers??[]),modules:u,personas:y,policies:n.flatMap(g=>g.policies??[]),seeds:n.flatMap(g=>g.seeds??[]),fileImports:n.flatMap(g=>g.fileImports),...nl("exposures",n.flatMap(g=>g.exposures??[])),...nl("instanceContributions",n.flatMap(g=>g.instanceContributions??[])),location:n[0]?.location??{line:1,column:1}},x=[...t.flatMap(g=>g.diagnostics),...e];return{value:h,diagnostics:x,success:!x.some(g=>g.severity==="error")}}l(il,"mergeDocuments");function Vm(t){if(xa(t)||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.length??0)>0||(t.purposes?.length??0)>0||(t.seeds?.length??0)>0||(t.systems?.length??0)>0||(t.eventSources?.length??0)>0||(t.examples?.length??0)>0)return!0;let e=l(n=>!n.isPlacement||(n.examples?.length??0)>0||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||(n.examples?.length??0)>0||n.features.some(e))}l(Vm,"hasDeclarations");function zm(t,e){return ll(t).map(al).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Po)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Ao(n.flatMap(i=>i.purposes??[]),i=>i.name),description:dl(n,`module '${n[0].name}'`,e),documentation:cl(n,`module '${n[0].name}'`,e),authorize:sl(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:ol(n),features:rl(n.flatMap(i=>i.features),e)})}l(zm,"mergeModules");function rl(t,e){return ll(t).map(al).map(n=>n.length===1?Po(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Ao(n.flatMap(i=>i.purposes??[]),i=>i.name),description:dl(n,`feature '${n[0].name}'`,e),documentation:cl(n,`feature '${n[0].name}'`,e),authorize:sl(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:ol(n),features:rl(n.flatMap(i=>i.features),e),slices:Tn(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}l(rl,"mergeFeatures");function ol(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}l(ol,"groupDependencies");function al(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}l(al,"placedLast");function Po(t){return{...t,isPlacement:!1,features:t.features.map(Po)}}l(Po,"unplaced");function sl(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(Ki(s))===JSON.stringify(Ki(r)));if(o!==void 0){n.push(wo(c.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${Rn(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>Je(r,o),null)}l(sl,"combineAuthorization");function Ao(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}l(Ao,"firstOfEach");function ll(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}l(ll,"groupByName");function cl(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(wo(c.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${Rn(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}l(cl,"firstDocumentation");function dl(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(wo(c.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${Rn(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}l(dl,"firstDescription");function Tn(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(Ji(c.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${Rn(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}l(Tn,"declaredInOneFile");var Rn=l(t=>t??"another file","describe"),Ji=l((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),wo=l((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function nl(t,e){return e.length===0?{}:{[t]:e}}l(nl,"presentOnly");function ul(t,e){return _m(t,e).result}l(ul,"parsePlacedDocuments");function _m(t,e){let n=Jt.capturePlaced(t.filter(x=>x.isPlacementResolved!==!1).map(x=>({lines:It(x.source,!1,x.path),placement:x.placement})),e),i=t.map(x=>He(x.source,x.path,x.isPlacementResolved===!1?[]:x.placement,!1,n,e)),r=i.flatMap((x,g)=>(x.value.eventSources??[]).map(S=>({source:S,placementResolved:t[g].isPlacementResolved!==!1}))),o=t.every(x=>x.isPlacementResolved!==!1)&&i.every(x=>!Ht.hasUnknownExtent(x.diagnostics)),s=i.map((x,g)=>t[g].isPlacementResolved===!1?{...x,value:{...x.value,eventSources:[]}}:x),a=il(s),d=new he(new Qe([]),void 0,e);a.value.sourceOptions!==void 0&&(d.sourceOptions=a.value.sourceOptions),Zn(a.value,d);let p=Ve(a.value);Ri(a.value,d),Ei(a.value,d),bi(a.value,d),Ci(a.value,d),Jn(a.value,d),Gn(p,d,s.flatMap(x=>x.inputUses)),Di(a.value,d),Mi(p,d),ji(a.value,d),Ni(a.value,d),Yi(a.value,d),Fi(a.value,d),Ui(a.value,d),Wi(a.value,d);let m=Xn(a.value,d);Kt.validate(m,d);for(let x of Kn(m))d.information(x.code,x.message,x.location);let u=a.diagnostics,y=new Set(u.map(pl)),h=[...u,...d.diagnostics.filter(x=>!y.has(pl(x)))];return{result:{...a,value:m,diagnostics:h,success:!h.some(x=>x.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((x,g)=>[t[g].path,x.value]))}}l(_m,"parsePlacedDocumentsWithSyntax");function pl(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}l(pl,"diagnosticKey");var fl=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,ml=l(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function Zm(){let t="";for(let e=0;e<=65535;e++){if(!fl.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&fl.test(String.fromCharCode(e+1));)e++;t+=ml(n)+(e>n?`-${ml(e)}`:"")}return t}l(Zm,"ranges");var wt=Zm();var Km=new RegExp(`^\\s*example\\s+[A-Z][${wt}]*\\s*:\\s*([${wt}.]*)$`),Jm=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${wt}.]*)$`);function yl(t,e,n,i,r,o){let s=t,a=[],d=o.some(v=>v.severity==="error")?o.some(v=>v.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],u=l((v,k)=>{if(v.location.path===e&&v.location.line>0)for(let C of i(v.location.line-1))p.set(C,k)},"own"),y=l((v,k)=>{for(let C of v??[])a.push({name:C.name,scope:k,example:C}),u(C,k)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(v=>({name:v.name,scope:[]})));let h=l((v,k)=>{for(let C of v){let b=[...k,C.name];u(C,b),y(C.examples,b);for(let w of C.slices){let T=[...k,C.name,w.name];u(w,T),y(w.examples,T);let I=new Map;for(let j of le(w))I.set(j.name,[...I.get(j.name)??[],j]);for(let j of I.values()){let N=Math.max(...j.map(L=>L.generation));a.push(...j.filter(L=>L.generation===N).map(L=>({name:L.name,scope:T,fixtureKind:"event"})))}a.push(...w.commands.map(j=>({name:j.name,scope:T,fixtureKind:"command"})),...w.readModels.map(j=>({name:j.name,scope:T,fixtureKind:"readmodel"})));for(let j of w.specifications)m.push({node:j,scope:T}),u(j,T),y(j.examples,T)}h(C.features,b)}},"features");for(let v of s.modules)u(v,[v.name]),y(v.examples,[v.name]),h(v.features,[v.name]);let x=l((v,k)=>{let C=v.split("."),b=a.filter(T=>T.name===C.at(-1)),w=C.slice(0,-1);if(w.length)return b.filter(T=>w.length<=T.scope.length&&w.every((I,j)=>T.scope[T.scope.length-w.length+j]===I));for(let T=k.length;T>=0;T--){let I=b.filter(j=>T<=j.scope.length&&k.slice(0,T).every((N,L)=>j.scope[L]===N));if(I.length)return I}return[]},"candidates"),g=l((v,k)=>{let C=x(v,k);return C.length===1?C[0]:void 0},"unique"),S=l(v=>v.example?g(v.example.type,v.scope)?.fixtureKind:v.fixtureKind,"kind"),E=l(v=>[...v.scope.filter(k=>!r.has(k)),v.name].join("."),"display"),$=l((v,k,C=!1,b="")=>a.flatMap(w=>{let T=S(w);if(!T||k&&T!==k||C&&w.example)return[];let I=[...w.scope,w.name].join("."),j=g(w.name,v)===w?w.name:I;if(g(j,v)!==w)return[];let N=b.split(".").slice(0,-1).join(".");return N&&!I.endsWith(`${N}.${w.name}`)?[]:j===I&&w.scope.some(L=>r.has(L))&&g(w.name,v)!==w?[]:[{label:g(w.name,v)===w?w.name:E(w),insertText:N?w.name:j,documentation:w.example?`Example of ${w.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${T}.`}]}),"targets"),P=l((v,k,C,b,w)=>{if(d)return d;let T=l((U,_,ie="")=>{if(new Set(U.map(F=>F.property)).size!==U.length||new Set(_.map(F=>F.property)).size!==_.length)return null;let Ce=new Map(U.map(F=>[F.property,{value:F,origin:"example",replaced:void 0}]));for(let F of _){let ce=Ce.get(F.property)?.value;Ce.delete(F.property),Ce.set(F.property,{value:F,origin:ce?"override":"authored",replaced:ce})}return[...Ce.values()].map(({value:F,origin:ce,replaced:fe})=>`${ie}${F.property} = ${dt(F.source)} \u2014 ${ce}${ce==="example"?` ${v.name}`:""}${fe?` (replaces ${dt(fe.source)} from ${v.name})`:""}`)},"merge"),I=T(v?.values??[],k),j=T(v?.generatedValues??[],C,"generated ");if(!I||!j)return"**Invalid duplicate assignments; no effective values selected.**";let N=b??v?.for,L=v?.stream??v?.noStream,q=w?.stream??w?.noStream,V=q??L,K=l(U=>U.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${U.eventSource}.${U.stream}${U.streamId?` streamId = ${dt(U.streamId.source)}`:U.streamIdParts.length?` streamId ${U.streamIdParts.map(_=>`${_.property} = ${dt(_.source)}`).join(", ")}`:""}`,"routeText"),J=V?[`${K(V)} \u2014 ${q?L?`override (replaces ${K(L)} from ${v.name})`:"authored":`example ${v.name}`}`]:[];return[...I,...j,...J,...N?[`for ${dt(N)} \u2014 ${b?v?.for?`override (replaces ${dt(v.for)} from ${v.name})`:"authored":`example ${v.name}`}`]:[]].join(`
|
|
22
|
-
`)},"effective"),A=new Map;for(let v of a.filter(k=>k.example?.location.path===e)){let k=v.example,
|
|
21
|
+
`,I=[de.Inbound,de.Outbound].map(j=>({direction:j,text:`${T}${w} direction ${j===de.Inbound?"inbound":"outbound"}`})).filter(j=>{let N=xo(t,[{start:k.startOffset+k.raw.length,length:0,text:j.text}]),L=He(N,void 0,e.placement),q=o(n);return r(L)&&![...o(L)].some(V=>V===c.PublicTranslationRequiresDirection||!q.has(V))});if(I.length===1){let[{direction:j,text:N}]=I;u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:`Declare 'direction ${j===de.Inbound?"inbound":"outbound"}'`,scope:"occurrence",edits:[{start:k.startOffset+k.raw.length,length:0,text:N}]},change:{node:b,replacement:{...b,direction:j}}})}}else if(v.code===c.RedundantEventId&&sn(k.raw)<0){let b=y.get(k.number);if(b?.id!==b?.name||b===void 0)continue;u.set(k.number,{line:k.number,fix:{diagnosticCode:v.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:k.startOffset,length:(s[k.number]?.startOffset??t.length)-k.startOffset,text:""}]},change:{node:b,replacement:{...b,id:null}}})}}let x=[c.LegacyOptionalSuffix,c.LegacyComplianceMarker],g=Tn(n),S=new Map,C,$=new Set,P=new Map,A=l((v,k)=>{let E=xo(t,v.edits);if(E===void 0)return;let b=He(E,void 0,e.placement);if(!(!r(b)||Tn(b)!==(k===void 0?g:Tn(n,[k]))))return b.diagnostics.filter(w=>w.code===v.diagnosticCode).length===(m.get(v.diagnosticCode)??0)-v.edits.length?v:void 0},"verify");return(v,k)=>{let E=typeof v=="number"||v===void 0?void 0:v,b=x.filter(N=>E===void 0?k===void 0||k===N:E.some(L=>L.diagnosticCode===N));for(let N of b.filter(L=>!$.has(L))){let L=[...u.values()].filter(q=>q.fix.diagnosticCode===N);if(L.length>0){let q=A({diagnosticCode:N,title:N===c.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:L.flatMap(V=>V.fix.edits)});q!==void 0&&P.set(N,q)}$.add(N)}let w=b.flatMap(N=>P.has(N)?[P.get(N)]:[]);if(E!==void 0){if(C===void 0){C=new Map;let L=s.flatMap(K=>u.has(K.number)?[u.get(K.number)]:[]),q=L.flatMap(K=>K.fix.edits),V=xo(t,q);if(q.length>0&&V!==void 0){let K=He(V,void 0,e.placement),J=L.flatMap(U=>U.change===void 0?[]:[U.change]);if(r(K)&&Tn(K)===Tn(n,J)){let U=new Map,_=new Map;for(let ie of K.diagnostics)U.set(ie.code,(U.get(ie.code)??0)+1);for(let ie of L)_.set(ie.fix.diagnosticCode,(_.get(ie.fix.diagnosticCode)??0)+ie.fix.edits.length);if([..._].every(([ie,Ee])=>(U.get(ie)??0)===(m.get(ie)??0)-Ee))for(let ie of L)C.set(ie.line,ie.fix)}}}let N=new Map;for(let L of E){let q=C.get(L.line);q?.diagnosticCode===L.diagnosticCode&&N.set(L.line,q)}return[...N.values(),...w]}let T=typeof v=="number"?v:void 0,I=T===void 0?void 0:u.get(T),j;return I!==void 0&&T!==void 0&&(k===void 0||I.fix.diagnosticCode===k)&&(S.has(T)||(S.size===32&&S.delete(S.keys().next().value),S.set(T,A(I.fix,I.change))),j=S.get(T)),[...j===void 0?[]:[j],...w]}}l(FO,"prepareQuickFixes");function jm(t,e){let n=O("^(\\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=O("^(\\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"}}l(jm,"complianceMarkerEdit");function Tn(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}l(Tn,"verificationShape");function xo(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}l(xo,"applyQuickFixEdits");var Xt=class{static{l(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(p=>p.source.streams).filter(p=>p.name===n),o=i.length>1||r.length>1,s=!this.complete||i.some(p=>!p.placementResolved),a=o?"ambiguous":s?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",d=[];return i.length>1&&d.push("Multiple physical parent sources claim the exact name."),r.length>1&&d.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&d.push("A physical parent has unresolved import placement."),this.complete||d.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:d}}};var Lm=$e("^[A-Za-z_]\\w*$"),tt=l((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),X=l(t=>{throw new ue(t)},"refuse"),gt=l((t,e,n)=>{if(!Array.isArray(t))return X(n);for(let i=0;i<t.length;i++)tt(t[i],e)||X(n)},"collection");function en(t){let e=di(t);if(e!==void 0&&X(e),t.kind==="ConceptSyntax"){let n=t;for(let i of n.validations??[])i.kind==="DeclarativeValidateSyntax"&&i.rules.some(r=>r.implementation!=null)&&X("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let n=t;n.implementation!=null&&(tt(n.implementation,"ImplementationSyntax")||X("A named rule requires an ImplementationSyntax wrapper."),(n.rule!=="Rule"||n.value?.kind!=="PathExpressionSyntax"||!tt(n.value,"PathExpressionSyntax")||typeof n.value.path!="string"||Lm.exec(n.value.path)?.[0]!==n.value.path)&&X("An implementation wrapper requires a valid named rule."),n.file!=null&&n.code!=null&&X("A named rule has at most one file or inline payload."),n.file!=null&&(!tt(n.file,"FileReferenceSyntax")||typeof n.file.path!="string")&&X("A named rule file requires a FileReferenceSyntax payload with a string path."),n.code!=null&&(!tt(n.code,"CodeBlockSyntax")||typeof n.code.language!="string"||typeof n.code.code!="string")&&X("A named rule inline payload requires a CodeBlockSyntax with string language and code."),en(n.implementation))}if(t.kind==="ProducesSyntax"){let n=t,i=n.inlineOperation;if(i!=null){n.inlineEvent!=null&&X("A production cannot declare both an event and an operation."),(n.when!=null||n.event!==i.name||n.for!=null||(n.tags??[]).length>0)&&X("An inline operation requires a matching unconditional target without event metadata."),gt(i.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),gt(n.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),i.inputs.length!==n.mappings.length&&X("Inline operation inputs and mappings must correspond in order.");for(let r=0;r<i.inputs.length;r++)i.inputs[r].name!==n.mappings[r].property&&X("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let n=t;n.file!=null&&n.code!=null&&X("An operation phase has at most one file or inline payload."),n.implementation!=null&&en(n.implementation)}if(t.kind==="HandlerSyntax"){let n=t;n.implementation!=null&&n.file!=null&&n.code!=null&&X("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let n=t;gt(n.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let i=0;i<n.hints.length;i++)en(n.hints[i])}if(t.kind==="ImplementationHintSyntax"){let n=t;(typeof n.text!="string"||ai(n.text))&&X("An implementation hint must be nonblank.")}$o(t)}l(en,"validateSyntaxInvariants");function $o(t){let e=l(i=>{Cr(i)||X("Event source and stream names must be identifiers.")},"name"),n=l((i,r)=>{gt(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&X("A route cannot map both scalar and composite stream ids."),r.forEach(o=>e(o.property))},"mappings");if(t.kind==="ApplicationSyntax"){let i=t.eventSources;i!==void 0&>(i,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(t.kind==="EventSourceSyntax"||t.kind==="EventStreamSyntax"){let i=t;e(i.name),i.id!==null&&(typeof i.id!="string"||i.id.trim()==="")&&X("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!tt(r,"TypeRefSyntax")&&X("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&X("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!ri(r.name)&&X("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?gt(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(gt(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&X("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>$o(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),tt(i.type,"TypeRefSyntax")||X("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&X("Source identifiers and stream ids require nonoptional scalar type references."),ri(i.type.name)||X("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&X("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!tt(i.stream,"CommandStreamSyntax")&&X("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&>(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($o(s),s.propertyCandidate===null&&i.stream==null&&X("A duplicate route candidate requires an authoritative route."),s.propertyCandidate!==null)for(let a=0;a<i.properties.length;a++)i.properties[a]===s.propertyCandidate&&X("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"||t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax"){let i=t;i.stream!=null&&i.noStream!=null&&X("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!tt(i.stream,"SpecificationStreamSyntax")&&X("A specification stream requires a specification stream node."),i.noStream!=null&&!tt(i.noStream,"SpecificationNoStreamSyntax")&&X("An unrouted expectation requires a specification no stream node.")}if(t.kind==="SpecificationStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A specification stream maps only streamId."),n(i.streamId,i.streamIdParts)}if(t.kind==="CommandStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A command stream maps only streamId."),n(i.streamId,i.streamIdParts);let r=i.propertyCandidate;r!==null&&(r.name!=="stream"||r.type.name!==`${i.eventSource}.${i.stream}`||r.type.isCollection||r.type.isOptional||r.isGenerated||r.isIdentifier||i.streamId!==null||i.streamIdParts.length>0)&&X("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}l($o,"validateSourceStream");var ct={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","IdentityExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamIdPartSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormColumnSyntax","ExposureSyntax","ExposedPropertySyntax","InstanceContributionsSyntax","InstanceContributionSyntax","ContributedItemSyntax","ContributedItemValueSyntax","ScreenContributionSyntax","TemplateSlotContentSyntax","CommandFormLayoutSyntax","FormLayoutColumnSyntax","FormFieldPlacementSyntax","FormWidthSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationParameterSyntax","SpecificationCaseSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionAlternativeSyntax","InteractionOtherwiseSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","InvocationRefusalSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotPolicyConditionSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","PurposeSyntax","PurposeReferenceSyntax","PurposeTransferSyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PresentationValueSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionSyntax","ReactionTriggerSyntax","RefusalExpressionSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenNavigationParameterSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenComponentSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenToolbarSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","TemplateAssignmentSyntax","TemplateExposedValueSyntax","TemplateOutletSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerPersonaSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","ToolbarItemSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiBindingSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","exposures","fileImports","imports","instanceContributions","layouts","modules","personas","policies","purposes","seeds","sourceOptions","numericMode","systems","templates","themes","triggers","types","uiProfiles","triggerName","children","columns","gap","grow","rows","span","syntaxKind","height","root","width","growFactor","name","mode","overrides","variants","alias","providers","requirement","type","bindings","description","file","order","parameters","event","tags","when","appends","identifiedBy","map","source","translations","settings","separator","targets","key","nested","from","to","expression","fromValue","properties","toValue","parameter","blocks","claim","matches","matchesSubject","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","content","displayName","exposes","outlets","restrictsScopes","scopes","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","origin","visibility","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","owner","component","editableFields","isCollection","operations","reExposes","restrictsFields","instance","items","field","slot","columnGap","placements","rowGap","index","maxWidth","minWidth","column","columnSpan","row","rowSpan","unit","composeUsing","by","query","columnMode","fields","for","generationMode","layout","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","trigger","amount","onRefused","acknowledge","constraint","selector","on","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","authorization","basis","basisReference","conditionReference","erasureException","interest","recipients","retention","subjects","transfers","destination","safeguard","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","isSubject","filters","isObservable","performer","returnType","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","context","icon","presentation","stableId","outlet","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","direction","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","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","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","literal","nullBehavior","rawText","defaultSizeClass","icons","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,27,46,47,54,55,57,114,115,127,129,154,157,200,221,225],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,30,49,51,101,193,222],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",43],["array",12],["ref",53],["union",14,8],["ref",58],["array",16],["ref",94],["array",18],["ref",71],["array",20],["ref",68],["array",22],["ref",100],["array",24],["ref",73],["array",26],["ref",113],["array",28],["union",29,8],["ref",119],["array",31],["ref",131],["array",33],["union",34,8],["ref",134],["array",36],["ref",135],["array",38],["ref",192],["array",40],["union",41,8],["enum","legacy","exact"],["object",[[21,43,!0]]],["ref",91],["array",45],["ref",194],["array",47],["ref",228],["array",49],["union",50,8],["ref",230],["array",52],["union",53,8],["ref",232],["array",55],["union",56,8],["ref",234],["array",58],["union",59,8],["object",[[4,9,!1],[5,11,!1],[6,13,!1],[7,15,!1],[8,17,!1],[9,19,!1],[10,21,!1],[11,23,!1],[12,25,!1],[13,27,!1],[14,30,!1],[15,32,!1],[16,35,!1],[17,37,!1],[18,39,!1],[19,42,!1],[20,44,!1],[22,46,!1],[23,48,!1],[24,51,!1],[25,54,!1],[26,57,!1],[27,60,!1]]],["object",[[28,0,!0]]],["ref",4,6],["array",63],["integer",-2147483648,2147483647],["union",65,8],["number"],["union",67,8],["enum","Flat","Row","Column","Grid"],["object",[[29,64,!1],[30,66,!1],[31,66,!1],[32,68,!1],[33,66,!1],[34,66,!1],[35,69,!0]]],["union",0,8],["object",[[36,71,!1],[37,63,!0],[38,71,!1]]],["boolean"],["object",[[32,73,!1],[39,68,!1],[36,66,!1],[40,0,!0],[34,66,!1],[38,66,!1]]],["enum","Flow","Freeform"],["ref",5],["array",76],["union",77,8],["union",63,8],["ref",240],["array",80],["union",81,8],["object",[[41,75,!0],[42,78,!1],[37,79,!1],[43,82,!1]]],["object",[]],["object",[[44,71,!1],[40,0,!0]]],["ref",9],["array",86],["object",[[45,87,!1]]],["ref",118,133],["object",[[46,89,!0]]],["object",[[40,0,!0],[1,0,!0]]],["ref",231],["union",92,8],["object",[[40,0,!0],[47,93,!1]]],["ref",105],["array",95],["ref",69],["union",97,8],["ref",13],["array",99],["object",[[48,96,!1],[49,71,!1],[50,98,!1],[40,71,!1],[51,66,!1],[52,100,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[35,102,!0]]],["ref",143],["array",104],["ref",223],["array",106],["union",107,8],["ref",25],["union",109,8],["object",[[53,0,!0],[3,105,!1],[54,108,!1],[55,110,!1]]],["ref",16],["array",112],["ref",18,22],["array",114],["object",[[56,113,!1],[57,0,!0],[58,115,!1],[0,0,!0]]],["ref",24],["array",117],["object",[[0,0,!0],[59,1,!0],[60,118,!1]]],["object",[[56,113,!1],[58,115,!1],[0,0,!0]]],["ref",20],["array",121],["object",[[61,122,!1],[35,0,!0]]],["array",0],["object",[[62,0,!0],[59,1,!0],[63,124,!1]]],["ref",17],["array",126],["ref",19],["array",128],["ref",21],["union",130,8],["object",[[56,113,!1],[29,127,!1],[64,71,!1],[58,115,!1],[40,0,!0],[65,129,!1],[59,131,!1],[20,44,!1]]],["object",[[66,0,!0],[67,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[68,71,!1],[69,71,!1],[70,124,!1],[35,134,!0],[71,71,!1]]],["object",[[0,71,!1]]],["object",[[72,0,!0]]],["ref",1,28,31,63,87,111,123,141,163,164],["array",138],["object",[[2,3,!0],[73,139,!1],[57,1,!0],[0,0,!0]]],["union",1,8],["object",[[74,0,!0],[75,141,!1],[76,73,!0]]],["object",[[0,0,!0]]],["object",[[53,0,!0]]],["ref",104],["array",145],["ref",32,45,64,121,122,125,126,153,162,197],["array",147],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[81,0,!0],[82,0,!0]]],["ref",233],["object",[[83,151,!0],[40,0,!0]]],["ref",168,170,173,174,175,177,179,180,181,182,184,185,187,188,189],["array",153],["object",[[84,154,!1],[40,0,!0]]],["union",151,8],["object",[[83,156,!1],[0,0,!0],[1,141,!1]]],["ref",33],["object",[[81,158,!0]]],["ref",11],["union",160,8],["ref",44],["union",162,8],["ref",88],["union",164,8],["ref",138],["array",166],["ref",144],["array",168],["ref",159],["array",170],["union",171,8],["ref",147,148],["union",173,8],["ref",39],["union",175,8],["array",175],["ref",37,50],["array",178],["object",[[85,161,!1],[86,163,!1],[49,71,!1],[87,71,!1],[88,165,!1],[40,0,!0],[89,167,!1],[70,169,!1],[90,172,!1],[91,174,!1],[92,176,!1],[93,177,!1],[94,179,!1]]],["union",168,8],["union",104,8],["object",[[95,0,!0],[96,181,!1],[92,0,!0],[97,182,!1],[98,105,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[99,0,!0],[100,184,!0],[101,1,!0]]],["ref",112],["array",186],["object",[[102,187,!1],[47,0,!0]]],["object",[[103,73,!1],[40,0,!0],[104,71,!1],[105,71,!1],[106,71,!1]]],["ref",42],["array",190],["union",179,8],["object",[[107,191,!1],[49,71,!1],[50,98,!1],[40,0,!0],[47,0,!0],[94,192,!1],[108,124,!1]]],["object",[[95,73,!0],[109,71,!1],[110,71,!1],[111,71,!1],[112,124,!1]]],["object",[[77,146,!1],[113,0,!0],[114,73,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[115,0,!0]]],["ref",179],["union",197,8],["object",[[116,0,!0],[117,71,!1],[118,198,!1],[51,66,!1]]],["ref",165],["array",200],["union",201,8],["ref",239],["array",203],["object",[[119,202,!1],[120,204,!1]]],["ref",7],["union",206,8],["ref",78],["array",208],["ref",195],["array",210],["ref",196],["array",212],["ref",199],["array",214],["ref",238],["array",216],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[123,209,!1],[49,71,!1],[124,71,!1],[125,211,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["object",[[40,0,!0]]],["object",[[132,0,!0]]],["ref",60],["array",221],["object",[[49,71,!1],[133,71,!1],[134,93,!1],[40,0,!0],[135,222,!1]]],["object",[[40,0,!0],[47,92,!0]]],["ref",59],["array",225],["object",[[49,71,!1],[133,71,!1],[40,0,!0],[97,93,!1],[98,226,!1]]],["object",[[53,0,!0],[64,141,!1]]],["integer",0,4294967295],["enum","Private","Public"],["object",[[49,71,!1],[87,71,!1],[50,98,!1],[136,229,!1],[137,73,!1],[133,71,!1],[40,0,!0],[138,71,!1],[70,169,!1],[54,108,!1],[139,230,!1]]],["object",[[2,3,!0],[140,73,!0],[3,5,!1]]],["object",[[77,146,!1],[141,0,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[68,1,!0]]],["ref",48],["array",235],["union",236,8],["ref",237],["array",238],["ref",66],["array",240],["ref",136],["array",242],["ref",198],["array",244],["object",[[85,161,!1],[5,11,!1],[142,237,!1],[143,239,!1],[49,71,!1],[87,71,!1],[9,19,!1],[144,241,!1],[11,23,!1],[145,73,!0],[40,0,!0],[18,243,!1],[146,245,!1],[23,48,!1],[131,217,!1]]],["ref",67,235,236],["array",247],["object",[[147,248,!1],[49,71,!1],[50,97,!0],[148,73,!0],[113,71,!1],[40,0,!0],[149,124,!1]]],["object",[[150,0,!0]]],["object",[[117,71,!1],[0,0,!0]]],["ref",72],["array",252],["object",[[151,0,!0],[70,253,!1]]],["object",[[152,0,!0],[153,124,!1],[154,73,!0],[117,71,!1],[155,124,!1],[115,0,!0],[156,71,!1],[157,73,!0]]],["ref",74],["array",256],["object",[[142,257,!1],[158,0,!0]]],["ref",75],["array",259],["object",[[152,0,!0],[159,260,!1],[115,0,!0],[1,141,!1]]],["ref",76],["array",262],["object",[[133,0,!0],[108,263,!1]]],["object",[[160,0,!0],[1,1,!0]]],["object",[[116,0,!0],[84,154,!1],[51,66,!1]]],["object",[[84,154,!1],[161,0,!0]]],["ref",82],["union",268,8],["ref",80],["array",270],["ref",81],["array",272],["object",[[162,269,!1],[30,271,!1],[163,273,!1],[164,269,!1]]],["object",[[165,65,!0],[166,269,!1],[167,269,!1],[38,269,!1]]],["object",[[168,65,!0],[169,66,!1],[160,0,!0],[170,65,!0],[171,66,!1],[38,269,!1]]],["enum","Fraction","Pixels","Percent","Auto"],["object",[[172,277,!0],[1,68,!1]]],["object",[[173,71,!1],[66,71,!1],[117,71,!1],[0,0,!0]]],["object",[[174,71,!1],[175,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",70],["array",282],["ref",83],["array",284],["ref",79],["union",286,8],["ref",84,85],["union",288,8],["object",[[5,11,!1],[176,281,!0],[30,283,!1],[49,71,!1],[177,285,!1],[178,0,!0],[179,281,!0],[180,287,!1],[40,0,!0],[181,198,!1],[182,289,!1],[131,217,!1]]],["ref",61],["array",291],["ref",41,65],["union",293,8],["object",[[183,292,!1],[64,294,!1],[3,5,!1],[184,141,!1]]],["union",158,8],["ref",89],["union",297,8],["object",[[81,296,!1],[50,98,!1],[185,298,!1]]],["ref",90],["array",300],["object",[[186,301,!1]]],["object",[[187,0,!0]]],["object",[[49,71,!1],[40,0,!0]]],["ref",93],["union",305,8],["object",[[188,306,!1],[49,71,!1],[189,306,!1],[190,169,!1],[40,0,!0],[191,0,!0]]],["object",[[81,296,!1],[49,71,!1],[50,98,!1],[185,298,!1]]],["ref",213],["union",309,8],["ref",212],["union",311,8],["object",[[49,71,!1],[178,141,!1],[192,105,!1],[40,0,!0],[193,310,!1],[92,312,!1],[47,0,!0],[108,105,!1]]],["object",[[40,0,!0],[108,105,!1]]],["object",[[194,0,!0]]],["object",[[194,0,!0],[108,105,!1]]],["object",[[138,71,!1],[195,0,!0],[139,230,!1]]],["ref",40,116],["object",[[196,148,!1],[197,318,!0]]],["object",[[196,148,!1]]],["object",[[83,0,!0],[40,0,!0]]],["ref",102],["array",322],["ref",103],["union",324,8],["ref",3,15,56,106],["object",[[196,148,!1],[198,323,!1],[197,71,!1],[199,325,!1],[200,326,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[201,65,!0],[172,328,!0]]],["ref",109],["array",330],["object",[[141,0,!0],[3,105,!1],[202,331,!1]]],["object",[[203,73,!0],[204,71,!1],[89,167,!1],[205,0,!0]]],["object",[[2,3,!0],[53,0,!0],[3,5,!1]]],["ref",110],["array",335],["object",[[183,336,!1],[206,0,!0],[0,0,!0]]],["object",[[68,1,!0],[0,0,!0]]],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[125,211,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["array",1],["object",[[159,340,!1]]],["union",0,73,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[207,344,!0],[1,345,!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",[[207,347,!0],[1,348,!0]]],["union",342,343,346,349],["object",[[1,350,!1]]],["enum","And","Or"],["object",[[99,318,!0],[100,352,!0],[101,318,!0]]],["ref",8,29,117,124,166],["object",[[99,354,!0],[100,352,!0],[101,354,!0]]],["object",[[99,89,!0],[100,352,!0],[101,89,!0]]],["ref",52],["array",357],["union",358,8],["ref",86],["array",360],["union",361,8],["ref",186],["array",363],["object",[[85,161,!1],[5,11,!1],[142,237,!1],[143,239,!1],[49,71,!1],[208,359,!1],[87,71,!1],[9,19,!1],[144,241,!1],[11,23,!1],[209,362,!1],[145,73,!0],[40,0,!0],[18,243,!1],[210,364,!1],[23,48,!1],[131,217,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[211,0,!0]]],["object",[[2,3,!0],[73,139,!1],[0,0,!0]]],["object",[[212,354,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[77,146,!1],[213,369,!0],[113,0,!0],[114,73,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["object",[[77,146,!1],[214,0,!0],[78,148,!1],[79,148,!1],[80,148,!1]]],["ref",128],["array",372],["object",[[215,373,!1]]],["object",[[40,0,!0],[1,1,!0]]],["object",[[81,296,!1],[50,98,!1]]],["object",[[49,71,!1],[40,0,!0],[17,124,!1]]],["object",[[216,73,!1],[217,71,!1],[218,71,!1],[219,0,!0],[220,66,!1],[221,66,!1]]],["union",354,8],["object",[[81,296,!1],[197,379,!1],[49,71,!1],[50,98,!1],[40,0,!0]]],["ref",137],["array",381],["object",[[222,71,!1],[223,71,!1],[224,71,!1],[197,71,!1],[225,71,!1],[49,71,!1],[226,71,!1],[227,71,!1],[40,0,!0],[228,124,!1],[229,71,!1],[230,124,!1],[231,382,!1]]],["object",[[232,0,!0],[233,0,!0]]],["ref",62],["union",385,8],["ref",92],["union",387,8],["union",318,8],["object",[[53,0,!0],[178,141,!1],[234,386,!1],[235,388,!1],[3,105,!1],[54,108,!1],[55,389,!1]]],["object",[[2,3,!0],[73,139,!1],[49,71,!1],[50,98,!1],[64,294,!1],[40,0,!0],[236,71,!1],[237,71,!1],[20,44,!1]]],["ref",139],["array",392],["object",[[73,139,!1],[238,393,!1],[40,0,!0]]],["object",[[0,0,!0],[59,1,!0]]],["object",[[239,73,!1],[240,73,!1],[241,73,!1],[40,0,!0],[47,92,!0]]],["ref",145],["object",[[40,0,!0],[59,397,!0],[47,93,!1]]],["object",[[59,397,!0]]],["ref",146],["array",400],["object",[[177,401,!1]]],["object",[[1,1,!0]]],["object",[[177,105,!1]]],["object",[[40,0,!0],[59,141,!1],[47,92,!0]]],["ref",151],["union",406,8],["array",406],["ref",130],["union",409,8],["object",[[85,161,!1],[174,407,!1],[49,71,!1],[242,408,!1],[243,73,!1],[40,0,!0],[244,410,!1],[245,92,!0],[105,71,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[200,0,!0]]],["ref",156],["array",413],["object",[[49,71,!1],[87,71,!1],[40,0,!0],[25,414,!1],[246,389,!1]]],["ref",229],["array",416],["ref",108],["array",418],["union",419,8],["union",167,8],["ref",107,120,167],["object",[[81,296,!1],[247,417,!1],[49,71,!1],[50,98,!1],[248,420,!1],[89,421,!1],[90,172,!1],[59,422,!0]]],["object",[[249,0,!0]]],["object",[[49,71,!1],[87,71,!1],[50,98,!1],[40,0,!0],[70,169,!1]]],["object",[[44,71,!1],[174,71,!1],[236,0,!0]]],["object",[[81,296,!1],[49,71,!1],[53,0,!0],[50,98,!1]]],["ref",160],["array",428],["object",[[49,71,!1],[40,0,!0],[236,0,!0],[120,429,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[175,0,!0]]],["object",[[53,0,!0],[64,141,!1],[184,141,!1]]],["enum","Error","Information","Warning"],["object",[[197,318,!0],[113,71,!1],[250,433,!0]]],["object",[[251,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",436,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[252,66,!1],[253,437,!1],[254,438,!0]]],["object",[[141,0,!0],[117,71,!1],[118,198,!1]]],["ref",171],["array",441],["ref",172],["union",443,8],["object",[[198,442,!1],[117,0,!0],[118,198,!1],[199,444,!1]]],["object",[[77,146,!1],[141,0,!0],[197,318,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[77,146,!1],[141,71,!1],[255,447,!0]]],["object",[[256,10,!0]]],["ref",34],["array",450],["ref",35],["array",452],["ref",142],["array",454],["ref",36],["array",456],["object",[[5,11,!1],[152,0,!0],[257,156,!1],[125,451,!1],[258,71,!1],[40,0,!0],[126,453,!1],[259,455,!1],[70,457,!1],[260,71,!1],[131,217,!1]]],["object",[[174,71,!1],[175,0,!0],[47,92,!0]]],["object",[[117,0,!0],[0,0,!0]]],["ref",169],["array",461],["object",[[174,71,!1],[261,71,!1],[52,462,!1],[262,71,!1],[211,0,!0]]],["ref",178],["array",464],["object",[[177,465,!1],[263,0,!0]]],["ref",77],["array",467],["object",[[142,468,!1],[49,71,!1],[84,154,!1],[50,98,!1],[40,0,!0]]],["ref",176],["array",470],["object",[[5,11,!1],[30,471,!1],[264,198,!1],[263,0,!0],[131,217,!1]]],["ref",181],["array",473],["object",[[40,0,!0],[129,474,!1]]],["object",[[121,207,!1],[5,11,!1],[122,71,!1],[123,209,!1],[49,71,!1],[124,71,!1],[125,211,!1],[265,71,!1],[40,0,!0],[126,213,!1],[127,73,!1],[128,124,!1],[129,215,!1],[130,71,!1],[131,217,!1]]],["ref",224],["array",477],["object",[[159,478,!1],[40,0,!0]]],["object",[[191,216,!0]]],["object",[[53,0,!0],[70,105,!1]]],["ref",190],["array",482],["object",[[266,0,!0],[183,483,!1]]],["ref",191],["array",485],["object",[[267,486,!1]]],["object",[[77,146,!1],[78,148,!1],[79,148,!1],[80,148,!1],[263,0,!0],[1,0,!0]]],["ref",23],["array",489],["ref",38],["array",491],["enum","Inbound","Outbound"],["union",493,8],["array",385],["array",387],["ref",140],["array",497],["ref",152],["array",499],["ref",155],["array",501],["ref",158],["array",503],["union",504,8],["ref",161],["array",506],["union",507,8],["ref",183],["array",509],["ref",218],["array",511],["enum","StateChange","StateView","Automation","Translate"],["object",[[268,490,!1],[269,492,!1],[270,248,!1],[49,71,!1],[271,494,!1],[87,71,!1],[183,495,!1],[9,19,!1],[50,98,!1],[40,0,!0],[155,496,!1],[272,498,!1],[18,243,!1],[273,500,!1],[274,502,!1],[275,505,!1],[276,508,!1],[277,510,!1],[278,512,!1],[23,48,!1],[47,513,!0]]],["object",[[279,71,!1],[40,0,!0]]],["object",[[64,1,!0],[40,0,!0]]],["object",[[47,0,!0],[1,0,!0]]],["ref",202],["array",518],["object",[[280,73,!0],[281,519,!1],[282,124,!1]]],["object",[[283,0,!0],[284,105,!1]]],["object",[[285,0,!0]]],["object",[[286,0,!0],[178,141,!1],[192,105,!1],[287,71,!1],[108,105,!1]]],["ref",27],["union",524,8],["object",[[288,525,!1],[40,71,!1]]],["object",[[289,0,!0],[178,141,!1],[287,71,!1],[193,310,!1],[92,312,!1],[108,105,!1]]],["object",[[95,0,!0],[92,0,!0],[97,182,!1],[98,105,!1]]],["object",[[290,73,!0],[70,105,!1]]],["ref",214],["array",530],["object",[[77,105,!1],[290,73,!0],[175,0,!0],[291,531,!1]]],["object",[[290,73,!0],[287,71,!1],[40,0,!0],[70,105,!1]]],["object",[[289,0,!0],[178,141,!1],[193,310,!1],[292,0,!0],[92,312,!1],[108,105,!1]]],["ref",96],["array",535],["ref",210],["array",537],["ref",204],["union",539,8],["ref",203],["union",541,8],["ref",205],["array",543],["ref",206],["union",545,8],["ref",97],["array",547],["ref",216],["array",549],["union",550,8],["ref",95],["array",552],["ref",201],["array",554],["ref",99],["array",556],["ref",208],["union",558,8],["ref",209],["array",560],["ref",211],["union",562,8],["ref",98],["array",564],["ref",215],["array",566],["ref",149,150],["union",568,8],["ref",207],["union",570,8],["union",537,8],["union",543,8],["ref",220],["union",574,8],["ref",217],["union",576,8],["ref",219],["union",578,8],["object",[[293,536,!1],[49,71,!1],[9,19,!1],[50,98,!1],[294,538,!1],[295,540,!1],[296,542,!1],[297,544,!1],[298,546,!1],[299,548,!1],[300,551,!1],[40,0,!0],[52,553,!1],[20,44,!1],[301,555,!1],[302,557,!1],[303,559,!1],[304,561,!1],[305,538,!1],[306,73,!0],[307,73,!1],[308,563,!1],[309,565,!1],[310,567,!1],[311,551,!1],[312,531,!1],[313,569,!1],[55,571,!1],[314,572,!1],[315,573,!1],[316,546,!1],[317,575,!1],[318,577,!1],[319,579,!1]]],["object",[[200,0,!0],[108,105,!1]]],["object",[[77,105,!1],[175,0,!0]]],["object",[[64,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[258,71,!1],[117,71,!1],[40,0,!0],[52,462,!1],[259,455,!1],[35,584,!0],[263,0,!0]]],["ref",226,227],["array",586],["object",[[102,587,!1]]],["object",[[320,124,!1],[40,0,!0]]],["object",[[247,417,!1],[49,71,!1],[50,98,!1],[40,0,!0]]],["object",[[154,73,!0],[321,73,!0],[40,0,!0]]],["object",[[49,71,!1],[50,98,!1],[40,0,!0],[70,169,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty","Literal"],["enum","OneWay","TwoWay"],["union",594,8],["enum","Propagate","Clear","Preserve"],["union",596,8],["object",[[322,593,!0],[323,71,!1],[324,71,!1],[325,71,!1],[326,141,!1],[41,595,!1],[327,597,!1],[115,0,!0],[175,71,!1],[328,71,!1]]],["object",[[329,71,!1],[330,124,!1],[180,71,!1],[40,0,!0],[331,124,!1],[332,124,!1],[333,71,!1]]],["object",[[147,248,!1],[49,71,!1],[53,0,!0],[148,73,!0],[113,71,!1],[40,0,!0],[149,124,!1]]],["object",[[334,124,!1],[147,248,!1],[49,71,!1],[53,0,!0],[148,73,!0],[113,71,!1],[40,0,!0],[0,0,!0],[149,124,!1]]],["object",[[263,0,!0]]],["ref",12],["array",603],["object",[[77,604,!1],[256,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[81,296,!1],[50,98,!1],[185,298,!1],[113,71,!1],[0,0,!0],[335,606,!0],[250,433,!0],[1,141,!1]]],["ref",132],["array",608],["object",[[36,0,!0],[336,609,!1],[38,0,!0]]]],contracts:[2,6,61,62,70,72,74,83,84,85,88,90,91,94,101,103,111,116,119,120,91,123,125,132,133,135,136,137,140,142,143,144,149,150,152,155,157,159,180,183,185,188,189,193,194,195,196,196,199,143,205,143,218,219,219,196,220,84,223,224,227,228,231,232,233,234,246,249,250,196,251,254,255,258,261,264,265,266,267,274,275,276,278,279,84,280,290,295,299,302,303,304,307,308,313,224,314,315,316,315,317,143,319,320,321,327,329,329,332,333,334,337,338,339,341,351,353,355,356,365,219,366,149,367,368,370,371,374,375,196,376,377,378,219,380,383,219,384,390,228,391,394,91,395,396,143,398,399,402,403,404,405,411,412,303,415,423,424,425,426,427,430,431,228,432,434,435,439,440,152,445,446,448,449,159,458,251,459,460,463,155,155,466,469,472,475,476,303,479,480,481,484,487,395,219,94,219,488,514,515,196,516,517,219,520,521,522,523,84,526,527,84,528,84,529,532,533,534,580,581,582,583,2,403,585,588,234,303,589,94,590,591,592,598,599,600,601,602,605,607,610]};var bo=ct.rules,Nm=new Map(bo.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),Xs=new Map(ct.kinds.map((t,e)=>[t,bo[ct.contracts[e]][1]])),qm=new Map([...Xs].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ct.names[n])])])),Hs=l(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function ko(t){let e=Xs.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!el(t,e))throw new ue(`Invalid typed members for syntax kind '${t.kind}'.`)}l(ko,"validateSyntaxMembers");function zi(t,e){let n=Qi(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new ue(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}l(zi,"validateClosedSyntaxMembers");function Qi(t){let e=qm.get(t);if(e===void 0)throw new ue(`Unknown syntax kind '${t}'.`);return e}l(Qi,"syntaxMemberNames");function el(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ct.names[n])?Eo(t[ct.names[n]],i):!r)}l(el,"matchesMembers");function Bm(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Eo(t[n],e))return!1;return!0}l(Bm,"allIndicesMatch");function Eo(t,e){let[n,...i]=bo[e];switch(n){case"ref":return Hs(t)&&typeof t.kind=="string"&&i.some(r=>ct.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Eo(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)&&Bm(t,i[0]);case"object":return Hs(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ct.names[o]===r))&&el(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||Nm.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}l(Eo,"matches");var Ym=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(","))])),Fm=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function Um(t,e){return Ym[t]?.has(e)===!0||Fm.test(t)&&(e==="source"||e==="value")}l(Um,"isExactOnlyMember");function tl(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:Um(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}l(tl,"isLegacyOmittedMember");var _i=l(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Gi=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),Zi=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function Ji(t){let e=Wm(t);return Co(e,"legacy",0),Ki(e)}l(Ji,"toSyntaxJson");function Wm(t){let e=new WeakMap,n=[];function i(o){if(typeof o!="object"||o===null)return o;if(e.has(o))return e.get(o);if(Array.isArray(o)){let d=nl();e.set(o,d);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{d[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return d}let s=Object.create(null);e.set(o,s);let a=Object.keys(o);!a.includes("kind")&&"kind"in o&&a.unshift("kind");for(let d=a.length-1;d>=0;d--)n.push(()=>{let p=a[d],m=o[p];p==="sourceOptions"&&n.push(()=>{typeof m=="object"&&m!==null&&(Object.getPrototypeOf(m)!==Object.prototype&&Object.getPrototypeOf(m)!==null||Reflect.ownKeys(m).length!==Object.keys(m).length)&&(s[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(m)});return s}l(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}l(Wm,"snapshot");function nl(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}l(nl,"dataArray");function Ki(t,e="legacy",n=!1){if(Array.isArray(t)){let o=nl();for(let s=0;s<t.length;s++)o.push(Ki(t[s],e,n));return o}if(_i(t)){if(Zi.has(t.kind)&&(e=Vt(t.sourceOptions??Ne).numericMode),en(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&zi(t,Gi),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&zi(p.file,Gi),p.code!=null&&zi(p.code,Gi))}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"?Qi(t.kind):void 0,d=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&tl(t,p))&&!Gi.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(Vm);for(let p of d){let m=s[p];(t.kind==="EventSyntax"||t.kind==="ImportSyntax")&&(p==="visibility"&&m==="Private"||p==="origin"&&m==null)||t.kind==="SliceSyntax"&&p==="direction"&&m==null||t.kind==="ConceptAttributeSyntax"&&(p==="scope"||p==="specialCategory")&&m==null||t.kind==="ConceptAttributeSyntax"&&p==="criminal"&&m===!1||t.kind==="PropertySyntax"&&p==="isSubject"&&m===!1||p==="description"&&m==null&&["ConceptSyntax","PolicySyntax","FileConstraintSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","ProjectionSyntax","ScreenSyntax","FormSyntax"].includes(t.kind)||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==="purposes"&&Array.isArray(m)&&m.length===0||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]=Ki(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]=Ki(i[o],e,n));return r}l(Ki,"write");function Co(t,e,n){if(n>96&&e==="exact")throw new ue("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)Co(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(Zi.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Vt(i.sourceOptions):Ne;if(n>0&&e!==o.numericMode)throw new ue("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!Zi.has(i.kind))throw new ue("Exact syntax requires a complete source root.");if(e==="exact"&&_i(i)&&ko(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&ln(i.text))throw new ue("An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.");if(i.kind==="LiteralExpressionSyntax"&&Object.hasOwn(i,"value")){if(e==="exact"&&(typeof i.value=="number"||i.value!==null&&!["string","boolean","object"].includes(typeof i.value)))throw new ue("Exact source requires supported primitive values or an explicit ExactNumber literal.");if(typeof i.value=="object"&&i.value!==null){let o=i.value;if(o.literalType==="ExactNumber"){if(e!=="exact"||typeof o.value!="string"||nt(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new ue("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new ue("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&_i(i)?Qi(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||_i(s)&&Zi.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&Co(s,e,n+1)}l(Co,"validateNumbers");function Vm(t,e){return t<e?-1:t>e?1:0}l(Vm,"ordinal");function rl(t){let e=[],n=t.map(g=>g.value),i=new Map,r=!1;for(let g of n)try{i.set(g,Object.hasOwn(g,"sourceOptions")?Vt(g.sourceOptions):Ne)}catch(S){if(!(S instanceof ue))throw S;r=!0,e.push(Hi(c.IncompatibleNumericSource,S.message,g.location))}let o=n.filter(g=>i.get(g)?.numericMode==="exact"||zm(g)),s=i.get(o[0])??Ne;for(let g of o.slice(1))i.get(g)?.numericMode!==s.numericMode&&(r=!0,e.push(Hi(c.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",g.location)));r&&(s=Sa);let a=new Map,d=Rn(n.flatMap(g=>g.concepts),"declaration of",e,void 0,a),p=Rn(n.flatMap(g=>g.types),"declaration of",e,void 0,a),m=n.map(g=>g.domain).filter(g=>g!==null);for(let g of m.slice(1))e.push(Hi(c.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${Dn(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,g.location));let u=Qm(n.flatMap(g=>g.modules),e),y=Rn(n.flatMap(g=>g.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:m[0]??null,imports:Ao(n.flatMap(g=>g.imports),g=>g.qualifiedName),concepts:d,types:p,examples:n.flatMap(g=>g.examples??[]),systems:n.flatMap(g=>g.systems??[]),purposes:Rn(n.flatMap(g=>g.purposes??[]),"purpose",e),eventSources:n.flatMap(g=>g.eventSources??[]),declaredTriggers:n.flatMap(g=>g.declaredTriggers??[]),modules:u,personas:y,policies:n.flatMap(g=>g.policies??[]),seeds:n.flatMap(g=>g.seeds??[]),fileImports:n.flatMap(g=>g.fileImports),...il("exposures",n.flatMap(g=>g.exposures??[])),...il("instanceContributions",n.flatMap(g=>g.instanceContributions??[])),location:n[0]?.location??{line:1,column:1}},x=[...t.flatMap(g=>g.diagnostics),...e];return{value:h,diagnostics:x,success:!x.some(g=>g.severity==="error")}}l(rl,"mergeDocuments");function zm(t){if(va(t)||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.length??0)>0||(t.purposes?.length??0)>0||(t.seeds?.length??0)>0||(t.systems?.length??0)>0||(t.eventSources?.length??0)>0||(t.examples?.length??0)>0)return!0;let e=l(n=>!n.isPlacement||(n.examples?.length??0)>0||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||(n.examples?.length??0)>0||n.features.some(e))}l(zm,"hasDeclarations");function Qm(t,e){return cl(t).map(sl).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Po)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Ao(n.flatMap(i=>i.purposes??[]),i=>i.name),description:pl(n,`module '${n[0].name}'`,e),documentation:dl(n,`module '${n[0].name}'`,e),authorize:ll(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:al(n),features:ol(n.flatMap(i=>i.features),e)})}l(Qm,"mergeModules");function ol(t,e){return cl(t).map(sl).map(n=>n.length===1?Po(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Ao(n.flatMap(i=>i.purposes??[]),i=>i.name),description:pl(n,`feature '${n[0].name}'`,e),documentation:dl(n,`feature '${n[0].name}'`,e),authorize:ll(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:al(n),features:ol(n.flatMap(i=>i.features),e),slices:Rn(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}l(ol,"mergeFeatures");function al(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}l(al,"groupDependencies");function sl(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}l(sl,"placedLast");function Po(t){return{...t,isPlacement:!1,features:t.features.map(Po)}}l(Po,"unplaced");function ll(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(Ji(s))===JSON.stringify(Ji(r)));if(o!==void 0){n.push(wo(c.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${Dn(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>Je(r,o),null)}l(ll,"combineAuthorization");function Ao(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}l(Ao,"firstOfEach");function cl(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}l(cl,"groupByName");function dl(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(wo(c.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${Dn(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}l(dl,"firstDocumentation");function pl(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(wo(c.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${Dn(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}l(pl,"firstDescription");function Rn(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(Hi(c.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${Dn(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}l(Rn,"declaredInOneFile");var Dn=l(t=>t??"another file","describe"),Hi=l((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),wo=l((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function il(t,e){return e.length===0?{}:{[t]:e}}l(il,"presentOnly");function fl(t,e){return Zm(t,e).result}l(fl,"parsePlacedDocuments");function Zm(t,e){let n=Ht.capturePlaced(t.filter(x=>x.isPlacementResolved!==!1).map(x=>({lines:Tt(x.source,!1,x.path),placement:x.placement})),e),i=t.map(x=>He(x.source,x.path,x.isPlacementResolved===!1?[]:x.placement,!1,n,e)),r=i.flatMap((x,g)=>(x.value.eventSources??[]).map(S=>({source:S,placementResolved:t[g].isPlacementResolved!==!1}))),o=t.every(x=>x.isPlacementResolved!==!1)&&i.every(x=>!Xt.hasUnknownExtent(x.diagnostics)),s=i.map((x,g)=>t[g].isPlacementResolved===!1?{...x,value:{...x.value,eventSources:[]}}:x),a=rl(s),d=new he(new Ge([]),void 0,e);a.value.sourceOptions!==void 0&&(d.sourceOptions=a.value.sourceOptions),Kn(a.value,d);let p=ze(a.value);Di(a.value,d),Pi(a.value,d),ki(a.value,d),Ci(a.value,d),Hn(a.value,d),_n(p,d,s.flatMap(x=>x.inputUses)),Mi(a.value,d),ji(p,d),Li(a.value,d),qi(a.value,d),Fi(a.value,d),Ui(a.value,d),Wi(a.value,d),Vi(a.value,d);let m=ei(a.value,d);Jt.validate(m,d);for(let x of Jn(m))d.information(x.code,x.message,x.location);let u=a.diagnostics,y=new Set(u.map(ul)),h=[...u,...d.diagnostics.filter(x=>!y.has(ul(x)))];return{result:{...a,value:m,diagnostics:h,success:!h.some(x=>x.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((x,g)=>[t[g].path,x.value]))}}l(Zm,"parsePlacedDocumentsWithSyntax");function ul(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}l(ul,"diagnosticKey");var ml=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,yl=l(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function Km(){let t="";for(let e=0;e<=65535;e++){if(!ml.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&ml.test(String.fromCharCode(e+1));)e++;t+=yl(n)+(e>n?`-${yl(e)}`:"")}return t}l(Km,"ranges");var Ot=Km();var Jm=new RegExp(`^\\s*example\\s+[A-Z][${Ot}]*\\s*:\\s*([${Ot}.]*)$`),Hm=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${Ot}.]*)$`);function hl(t,e,n,i,r,o){let s=t,a=[],d=o.some(v=>v.severity==="error")?o.some(v=>v.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],u=l((v,k)=>{if(v.location.path===e&&v.location.line>0)for(let E of i(v.location.line-1))p.set(E,k)},"own"),y=l((v,k)=>{for(let E of v??[])a.push({name:E.name,scope:k,example:E}),u(E,k)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(v=>({name:v.name,scope:[]})));let h=l((v,k)=>{for(let E of v){let b=[...k,E.name];u(E,b),y(E.examples,b);for(let w of E.slices){let T=[...k,E.name,w.name];u(w,T),y(w.examples,T);let I=new Map;for(let j of le(w))I.set(j.name,[...I.get(j.name)??[],j]);for(let j of I.values()){let N=Math.max(...j.map(L=>L.generation));a.push(...j.filter(L=>L.generation===N).map(L=>({name:L.name,scope:T,fixtureKind:"event"})))}a.push(...w.commands.map(j=>({name:j.name,scope:T,fixtureKind:"command"})),...w.readModels.map(j=>({name:j.name,scope:T,fixtureKind:"readmodel"})));for(let j of w.specifications)m.push({node:j,scope:T}),u(j,T),y(j.examples,T)}h(E.features,b)}},"features");for(let v of s.modules)u(v,[v.name]),y(v.examples,[v.name]),h(v.features,[v.name]);let x=l((v,k)=>{let E=v.split("."),b=a.filter(T=>T.name===E.at(-1)),w=E.slice(0,-1);if(w.length)return b.filter(T=>w.length<=T.scope.length&&w.every((I,j)=>T.scope[T.scope.length-w.length+j]===I));for(let T=k.length;T>=0;T--){let I=b.filter(j=>T<=j.scope.length&&k.slice(0,T).every((N,L)=>j.scope[L]===N));if(I.length)return I}return[]},"candidates"),g=l((v,k)=>{let E=x(v,k);return E.length===1?E[0]:void 0},"unique"),S=l(v=>v.example?g(v.example.type,v.scope)?.fixtureKind:v.fixtureKind,"kind"),C=l(v=>[...v.scope.filter(k=>!r.has(k)),v.name].join("."),"display"),$=l((v,k,E=!1,b="")=>a.flatMap(w=>{let T=S(w);if(!T||k&&T!==k||E&&w.example)return[];let I=[...w.scope,w.name].join("."),j=g(w.name,v)===w?w.name:I;if(g(j,v)!==w)return[];let N=b.split(".").slice(0,-1).join(".");return N&&!I.endsWith(`${N}.${w.name}`)?[]:j===I&&w.scope.some(L=>r.has(L))&&g(w.name,v)!==w?[]:[{label:g(w.name,v)===w?w.name:C(w),insertText:N?w.name:j,documentation:w.example?`Example of ${w.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${T}.`}]}),"targets"),P=l((v,k,E,b,w)=>{if(d)return d;let T=l((U,_,ie="")=>{if(new Set(U.map(F=>F.property)).size!==U.length||new Set(_.map(F=>F.property)).size!==_.length)return null;let Ee=new Map(U.map(F=>[F.property,{value:F,origin:"example",replaced:void 0}]));for(let F of _){let ce=Ee.get(F.property)?.value;Ee.delete(F.property),Ee.set(F.property,{value:F,origin:ce?"override":"authored",replaced:ce})}return[...Ee.values()].map(({value:F,origin:ce,replaced:fe})=>`${ie}${F.property} = ${dt(F.source)} \u2014 ${ce}${ce==="example"?` ${v.name}`:""}${fe?` (replaces ${dt(fe.source)} from ${v.name})`:""}`)},"merge"),I=T(v?.values??[],k),j=T(v?.generatedValues??[],E,"generated ");if(!I||!j)return"**Invalid duplicate assignments; no effective values selected.**";let N=b??v?.for,L=v?.stream??v?.noStream,q=w?.stream??w?.noStream,V=q??L,K=l(U=>U.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${U.eventSource}.${U.stream}${U.streamId?` streamId = ${dt(U.streamId.source)}`:U.streamIdParts.length?` streamId ${U.streamIdParts.map(_=>`${_.property} = ${dt(_.source)}`).join(", ")}`:""}`,"routeText"),J=V?[`${K(V)} \u2014 ${q?L?`override (replaces ${K(L)} from ${v.name})`:"authored":`example ${v.name}`}`]:[];return[...I,...j,...J,...N?[`for ${dt(N)} \u2014 ${b?v?.for?`override (replaces ${dt(v.for)} from ${v.name})`:"authored":`example ${v.name}`}`]:[]].join(`
|
|
22
|
+
`)},"effective"),A=new Map;for(let v of a.filter(k=>k.example?.location.path===e)){let k=v.example,E=k.location.line-1,b=Ce(n[E]??"").match(/^\s*example\s+/)?.[0];b&&A.set(E,{start:b.length+1,length:k.name.length,content:`**example ${C(v)} : ${k.type}**
|
|
23
23
|
|
|
24
|
-
${S(v)?P(k,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:v,scope:k}of m){let
|
|
24
|
+
${S(v)?P(k,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:v,scope:k}of m){let E=[...v.given.map(b=>({step:b,name:b.eventType,expected:"event",values:b.values,generated:[],destination:b.for,prefix:/^\s*given\s+/})),...v.givenReadModels.map(b=>({step:b,name:b.name,expected:"readmodel",values:b.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...v.when?[{step:v.when,name:v.when.commandType,expected:"command",values:v.when.values,generated:v.when.generatedValues??[],destination:v.when.for,prefix:/^\s*when\s+/}]:[],...v.whenAppended?[{step:v.whenAppended,name:v.whenAppended.eventType,expected:"event",values:v.whenAppended.values,generated:[],destination:v.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...v.thenEvents.map(b=>({step:b,name:b.eventType,expected:"event",values:b.values,generated:[],destination:b.for,prefix:/^\s*then\s+/})),...v.thenReadModels.map(b=>({step:b,name:b.name,expected:"readmodel",values:b.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:b,name:w,expected:T,values:I,generated:j,destination:N,prefix:L}of E.filter(q=>q.step.location.path===e)){let q=g(w,k),V=x(w,k).some(_=>_.example);if(!q?.example&&(q||!V))continue;let K=b.location.line-1,J=Ce(n[K]??"").match(L)?.[0].length;if(J===void 0)continue;let U=q?S(q)!==T?"**Example kind mismatch; no effective values selected.**":`**${T} ${q.example?.type??w}${q.example?` \u2014 example ${C(q)}`:""}**
|
|
25
25
|
|
|
26
26
|
${P(q.example,I,j,N,"eventType"in b?b:void 0)}
|
|
27
27
|
|
|
28
|
-
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(K,{start:J+1,length:w.length,content:U})}}return{eventExamples:a.filter(v=>v.example?.location.path===e&&S(v)==="event").map(v=>v.example),completions(v,k){let
|
|
28
|
+
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(K,{start:J+1,length:w.length,content:U})}}return{eventExamples:a.filter(v=>v.example?.location.path===e&&S(v)==="event").map(v=>v.example),completions(v,k){let E=p.get(v)??[],b=k.match(Jm);if(b)return $(E,void 0,!0,b[1]);if(!m.some(({node:N})=>N.location.path===e&&i(N.location.line-1).includes(v)))return null;let T=k.match(Hm);if(!T||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(T[3]))return null;let I=T[2]==="readmodel"?"readmodel":T[2]==="append"||T[1]!=="when"?"event":"command",j=$(E,I,!1,T[3]);return j.length?T[2]?j:[...Fo[T[1]],...j]:null},hover(v,k,E){let b=A.get(v);return b&&k>=b.start&&E<=b.start+b.length?b.content:null}}}l(hl,"exampleAnalysis");function dt(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(dt).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${dt(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"CaseValueExpressionSyntax":return`case.${t.parameter}`;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${t.path}`;case"IdentityExpressionSyntax":return`$identity.${t.path}`;case"EventContextExpressionSyntax":return`$eventContext.${t.path}`;case"RefusalExpressionSyntax":return`$refusal.${t.member}`;case"EventSourceIdExpressionSyntax":return"$eventSourceId";case"CausedByExpressionSyntax":return`$causedBy${t.property?`.${t.property}`:""}`;case"EnvironmentExpressionSyntax":return`$env.${t.name}`;case"StringsExpressionSyntax":return`$strings.${t.key}`;case"SourceItemExpressionSyntax":return`$.${t.path}`;case"TemplateExpressionSyntax":return"`"+t.parts.map(e=>e.kind==="TemplateTextSyntax"?e.text:"${"+dt(e.expression)+"}").join("")+"`"}}l(dt,"expressionText");var Xm=new RegExp(`^\\s*given caller as\\s+[${Ot}]*$`),ey=new RegExp(`^\\s*(?:given caller as|persona)\\s+([A-Za-z_][${Ot}]*)\\s*$`);function Sl(t,e){let n=t,i=new Map(n.personas.map(r=>[r.name,dn(r,n)]));return{completions(r,o){return Ce(o).length<o.length||!Xm.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=Ce(e[r]??""),d=ey.exec(a);if(!d||a.slice(o-1,s-1)!==d[1])return null;let p=i.get(d[1]);return p?p.refusal?`**${d[1]} caller** \u2014 ${p.refusal.reason}${p.refusal.policy?` in policy ${p.refusal.policy}`:""}. Use an explicit \`given caller\`.`:`**${d[1]} caller** \u2014 authenticated.
|
|
29
29
|
|
|
30
30
|
Roles: ${p.caller.roles.map(m=>JSON.stringify(m)).join(", ")||"(none)"}.
|
|
31
31
|
|
|
32
32
|
Claims: ${p.caller.claims.map(m=>`${JSON.stringify(m.type)} = ${JSON.stringify(m.value)}`).join(", ")||"(none)"}.
|
|
33
33
|
|
|
34
|
-
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}}}l(
|
|
34
|
+
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}}}l(Sl,"personaAnalysis");function gl(t,e,n,i,r){let o=t,s=e,a=Te.containersOf(o).filter(u=>![...u.scope,u.name].some(y=>r.has(y))),d=new Map,p=new Map,m=l((u,y,h)=>{for(let x of u){let g=[...y,x.name];if(h){if(x.location.path===n&&x.location.line>0)for(let S of i(x.location.line-1))d.set(S,g)}else{let S=g.join(".");p.set(S,[...p.get(S)??[],...(x.dependsOn??[]).map(C=>({target:C.target,...C.location}))])}m(x.features,g,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(u,y,h){let x=d.get(u)??h;if(!x?.length||x.some(S=>r.has(S))||!a.some(S=>[...S.scope,S.name].join(".")===x.join(".")))return[];let g=new Set((p.get(x.join("."))??[]).filter(S=>S.path!==n||S.line!==u+1).map(S=>Te.resolve(S.target,x,a).resolved));return Te.candidates(x,a).flatMap(({container:S,reference:C,tier:$})=>{if(g.has(S))return[];let P=[...S.scope,S.name].join(".");if(y&&(C=y+S.name,Te.resolve(C,x,a).resolved!==S))return[];let A=S.scope.length===0?"module":$===0?"sibling feature":$!=="qualified"?`feature of ${S.scope.join(".")}`:`feature in ${S.scope.join(".")}`,v=a.indexOf(S);return[{label:y?S.name:C,insertText:y?S.name:C,documentation:`${P} \u2014 ${A}.`,detail:A,sortText:`${String($==="qualified"?x.length:$).padStart(6,"0")}:${String(v).padStart(6,"0")}`}]})}}}l(gl,"dependencyTargetAnalysis");var aD="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",Mn=new Map;function ty(t,e){let n=we(t),i=t.flatMap((u,y)=>!n[y]&&te(u)===0&&/^\w/.test(u)?[u.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(u=>["feature","slice","command","event","operation","reaction","specification"].includes(u)))return{source:t.join(`
|
|
35
35
|
`),locations:t.map((u,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((u,y)=>{!n[y]&&te(u)===0&&/^\w/.test(u)&&(s=/^(?:concept|type|import|domain|system|eventsource|policy|persona)\b/.test(u)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,d=e.slice(0,a),p=[...r.map(u=>t[u]),...d,...o.map(u=>" ".repeat(a*2)+t[u])].join(`
|
|
36
|
-
`),m=[...r.map(u=>({line:u+1,column:0})),...d.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:a*2}))];return{source:p,locations:m}}l(
|
|
36
|
+
`),m=[...r.map(u=>({line:u+1,column:0})),...d.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:a*2}))];return{source:p,locations:m}}l(ty,"authoringSource");function ny(t,e,n,i="current.play",r=!0){let o=e.map((R,M)=>typeof R=="string"?{path:`other-${M}.play`,source:R}:R).filter(R=>R.path!==i),s=[{path:i,source:t.join(`
|
|
37
37
|
`),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(R=>[...R.source.matchAll(/\w+/g)].map(M=>M[0]).concat(R.placement??[]))),d=l(R=>{let M=R;for(let B=1;a.has(M);B++)M=`${R}${B}`;return a.add(M),M},"fresh"),p=d("EditorAuthoring"),m=d("FragmentFeature"),u=new Set([p,m]),y=s.map((R,M)=>{let B=M===0?t:R.source.split(`
|
|
38
|
-
`),Y=d(`Fragment${M}`);u.add(Y);let pt=R.placement?.length?{source:R.source,locations:B.map((
|
|
39
|
-
`)[R.location.line-1];return M?.locations.some(Y=>Y.line===0)&&B!==void 0&&te(B)===0}),v=g.diagnostics.filter(R=>R.location.path===i).flatMap(R=>(P(R.location),R.location.line>0?[R]:[])),k=new re(g.value),
|
|
40
|
-
`),n=Mn.get(e);if(n)return n;let i=en(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=xt(t);let o=we(t),s=t,a=o,d=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],u=m.trim(),y=te(m),h=s[p].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(h&&y===0){let k=h[1],C=k.split(".").pop()??k;r.imports.push({qualifiedName:k,shortName:C,line:p});continue}let x=u.match(oy);if(x){let k=jn(t,o,p,y).map(w=>t[w].trim()),C={};for(let w of k){let T=w.match(gl);T&&C[T[1]]===void 0&&(C[T[1]]=T[2])}let b=x[2]==="Enum"?k.filter(w=>!gl.test(w)):[];r.concepts.push({name:x[1],primitive:x[2],attributes:x[3].trim().split(/\s+/).filter(Boolean),attributeReasons:C,enumValues:b,line:p});continue}let g=u.match(/^type\s+(\w+)\s*$/);if(g){r.types.push({name:g[1],properties:Ro(t,jn(t,o,p,y),No),line:p});continue}let S=u.match(/^policy\s+(\w+)\s*$/);if(S){let k=jn(t,o,p,y).filter(C=>!o[C]).map(C=>t[C].trim());r.policies.push({name:S[1],requires:k,line:p});continue}let E=s[p].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if(E){let k=u.startsWith("produces "),C=tn(s,a,p,y),b=k?C:C.filter(w=>Io(s[w],w)===void 0);r.events.push({name:E.groups.name,...E.groups.generation?{generation:Number(E.groups.generation)}:{},...E.groups.public||E.groups.origin?{visibility:se.Public}:{},...E.groups.origin?{origin:Q(E.groups.origin.slice(1,-1))}:{},inline:k,properties:Ro(k?d:s,b,k?py:dy),line:p});continue}let $=i.commands.get(p);if($){let k=tn(t,o,p,y),C=k.filter(b=>/^\s*produces\b/.test(t[b])&&!i.operationProductionLines?.has(b));r.commands.push({name:$.name,properties:$.properties.map(b=>({name:b.name,type:`${b.type.name}${b.type.isCollection?"[]":""}${b.type.isOptional?" optional":""}`,typeReference:{name:b.type.name,isCollection:b.type.isCollection,isOptional:b.type.isOptional},sourceType:To(t[b.type.location.line-1],b.type.location.column),isIdentifier:b.isIdentifier||/\sidentifier\s*$/.test(t[b.location.line-1]),...b.isGenerated?{isGenerated:!0}:{},line:b.location.line-1})),response:$.response,productionHeaders:C,produces:C.flatMap(b=>{let w=s[b].trim(),T=/^produces\s+event\b/.test(w),I=/^produces\s+when\b/.test(w),j=I?tn(s,a,b,te(s[b]))[0]:b;if(j===void 0)return[];let N=I?s[j].trim():w.match(T?/^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 L=tn(s,a,j,te(s[j])),q=L.map(J=>s[J].trim().match(/^for(?:\s+(.*))?$/)).filter(J=>J!==null),V=q.length===0?void 0:q.length===1?q[0][1]??"":"",K=L.flatMap(J=>{let U=s[J].trim().match(T?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return U===null?[]:[{name:U[1].replace(/^@/,""),source:U[2],line:J}]});return[{name:N,inline:T,conditional:I,line:b,target:V,mappings:K}]}),reads:k.filter(b=>!o[b]).map(b=>({line:b,match:t[b].match(sy)})).filter(b=>b.match!==null).map(({line:b,match:w})=>({view:w[1],...w[2]?{alias:w[2]}:{},...w[3]?{by:w[3]}:{},line:b})),line:p});continue}let P=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let k=jn(t,o,p,y).map(C=>({index:C,match:t[C].match(uy)})).filter(C=>C.match!==null).map(({index:C,match:b})=>({name:b[1],type:b[2],typeReference:nn(b[2]),sourceType:To(t[C],t[C].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:C}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:nn(P[2]),parameters:k,line:p});continue}let A=u.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let v=u.match(/^trigger\s+(\w+)\s*$/);v&&y===0&&r.triggers.push({name:v[1],line:p})}return Mn.size>=16&&Mn.delete(Mn.keys().next().value),Mn.set(e,r),r}l(Ln,"scanDocument");function Hi(...t){return{authoringSources:t.flatMap(e=>e.authoringSources??[]),...t.some(e=>e.authoringDocuments)?{authoringDocuments:t.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:t.flatMap(e=>e.eventSources??[]),imports:t.flatMap(e=>e.imports),concepts:t.flatMap(e=>e.concepts),types:t.flatMap(e=>e.types),policies:t.flatMap(e=>e.policies),events:t.flatMap(e=>e.events),commands:t.flatMap(e=>e.commands),queries:t.flatMap(e=>e.queries),screens:t.flatMap(e=>e.screens),triggers:t.flatMap(e=>e.triggers)}}l(Hi,"mergeSymbols");function xl(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...Hi(Ln(t),e??Hi()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}l(xl,"symbolsForBuffer");function Xi(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}l(Xi,"knownEventNames");var fy=["Startup","Shutdown"];function CD(t){return[...Xi(t),...t.triggers.map(e=>e.name),...fy]}l(CD,"knownTriggerNames");function Do(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}l(Do,"knownTypeNames");function Mo(t){let e=t.properties.filter(o=>o.isIdentifier&&!vt(o).isOptional&&!vt(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}l(Mo,"productionDestinations");function RD(t,e){let n=en(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=xt(t);return Ln(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(d=>d.target!==void 0||d.inline);return(r.produces??[]).flatMap(d=>d.target!==void 0||d.inline&&(o===void 0||/\bgeneration\b/.test(i[d.line]))?[]:!d.inline&&a?[]:[{line:d.line,column:i[d.line].length+1,label:d.inline?`for ${o}`:"for <new event source>"}])})}l(RD,"destinationHints");var ee={commandProducesPublicEvent:"PLAY0607",publicEventRequiresOutboundTranslation:"PLAY0608",outboundPublicEventCount:"PLAY0609",foreignPublicEventConsumer:"PLAY0610",outboundTranslationInput:"PLAY0611",inboundTranslationOutput:"PLAY0612",foreignPublicEventProduced:"PLAY0613",publicTranslationRequiresDirection:"PLAY0614",translationConstructDirection:"PLAY0615",inboundTranslationInput:"PLAY0616",outboundTranslationOutput:"PLAY0617",eventTargetOutsideOutboundTranslation:"PLAY0618",eventsSourceOutsideInboundTranslation:"PLAY0619",invalidCaptureEventsSource:"PLAY0620",invalidDescription:"PLAY0145",emptyDescription:"PLAY0146",duplicateDescription:"PLAY0147",unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",invalidPurposeDeclaration:"PLAY0596",invalidPurposeVocabulary:"PLAY0597",duplicatePurposeField:"PLAY0598",duplicatePurposeDeclaration:"PLAY0599",unknownPurpose:"PLAY0600",purposeInterestMismatch:"PLAY0601",personalDataWithoutPurpose:"PLAY0602",specialDataWithoutCondition:"PLAY0603",criminalDataWithoutAuthorization:"PLAY0604",purposeWithoutBasis:"PLAY0605",unusedPurpose:"PLAY0606",duplicateEventSubject:"PLAY0590",invalidSubjectType:"PLAY0591",protectedSubjectType:"PLAY0592",invalidSubjectOwner:"PLAY0593",readModelSubjectNotSupported:"PLAY0594",invalidSubjectModifierOrder:"PLAY0595",conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",invalidSpecificationCallerPersona:"PLAY0572",unsynthesizablePersonaCaller:"PLAY0573",personaWithoutGate:"PLAY0574",gateWithoutPersona:"PLAY0575",ambiguousPersonaCaller:"PLAY0576",invalidSpecificationParameter:"PLAY0577",invalidSpecificationCase:"PLAY0578",duplicateSpecificationParameter:"PLAY0579",duplicateSpecificationCase:"PLAY0580",incompleteSpecificationTable:"PLAY0581",invalidSpecificationCaseAssignment:"PLAY0582",invalidSpecificationCaseValue:"PLAY0583",invalidSpecificationCaseReference:"PLAY0584",optionalSpecificationParameterTarget:"PLAY0585",specificationCaseNameCollision:"PLAY0586",incompatibleSpecificationParameterType:"PLAY0587",unusedSpecificationParameter:"PLAY0588",singularSpecificationTableExpansion:"PLAY0589",invalidActionAlternative:"PLAY0341",guardedActionWithoutAlternatives:"PLAY0342",misplacedActionOtherwise:"PLAY0343",unsupportedActionConditionOperand:"PLAY0344",unknownActionSubjectField:"PLAY0345",unresolvedActionSubject:"PLAY0346",unreachableActionAlternative:"PLAY0347",unknownActionArgumentProperty:"PLAY0348",invalidRefusalBranch:"PLAY0538",invalidRefusalBranchBody:"PLAY0539",unreachableRefusalBranch:"PLAY0540",invalidRefusalValue:"PLAY0541",unknownRefusalConstraint:"PLAY0542",unmatchedRedeliveredOccurrence:"PLAY0543",unknownRedeliveryReaction:"PLAY0544",invalidNoEventsExpectation:"PLAY0545",indeterminateNegatedClaimTarget:"PLAY0546",invalidAbsentReadModelStep:"PLAY0453",unknownConstraintProperty:"PLAY0391",invalidSpecificationExample:"PLAY0518",duplicateSpecificationAssignment:"PLAY0519",unknownReadModelProperty:"PLAY0514",piiNotSupportedOnIdentifier:"PLAY0515",invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",invalidSpecificationStream:"PLAY0547",specificationStreamOnCommand:"PLAY0548",invalidSpecificationStreamRoute:"PLAY0549",invalidSpecificationStreamEventSource:"PLAY0550",specificationStreamContradictsCommand:"PLAY0551",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",invalidSpecificationExampleBody:"PLAY0526",undeclaredDependency:"PLAY0552",unusedDependencyDeclaration:"PLAY0553",invalidDependencyTarget:"PLAY0554",repeatedDependencyDeclaration:"PLAY0555",mutualDependencyDeclarations:"PLAY0556",authorizationRefusalWithoutIdentity:"PLAY0557",invalidDocumentation:"PLAY0558",conflictingDocumentationAcrossFiles:"PLAY0559",unsupportedInteractionAlternatives:"PLAY0560",mixedInteractionAlternatives:"PLAY0561",interactionAlternativeWithoutActions:"PLAY0562",inlineInteractionAlternative:"PLAY0563",legacyInteractionWhere:"PLAY0564",ambiguousReference:"PLAY0198",invalidImplementationBlock:"PLAY0492",invalidImplementationHint:"PLAY0493",conflictingImplementationSources:"PLAY0494",eventSourceIdInPayload:"PLAY0469",explicitProducesTargetsRequired:"PLAY0470",redundantEventId:"PLAY0471",invalidEventId:"PLAY0472",inlineEventCollision:"PLAY0473",inlineEventOutsideCommand:"PLAY0474",inlineEventGeneration:"PLAY0475",reservedProductionMetadata:"PLAY0476",invalidEventDocumentation:"PLAY0477",tabIndentation:"PLAY0006",unknownPrimitiveType:"PLAY0008",unknownSliceType:"PLAY0028",duplicateCommandIdentifier:"PLAY0036",unknownContextPath:"PLAY0153",unknownContextCausedByProperty:"PLAY0154",unknownContextIdentityProperty:"PLAY0155",unclosedCodeBlock:"PLAY0164",unknownType:"PLAY0165",unknownEvent:"PLAY0166",unknownPolicy:"PLAY0167",duplicateDeclaration:"PLAY0168",unknownEventContextMember:"PLAY0295",unknownEventContextPath:"PLAY0296",eventContextPathBelowCollection:"PLAY0297",missingEventContextPath:"PLAY0298",unresolvedDynamicKeySource:"PLAY0299",invalidFileImport:"PLAY0454",omittedProductionDestination:"PLAY0478",legacyOptionalSuffix:"PLAY0479",invalidOptionalModifierOrder:"PLAY0480",optionalReadsNotSupported:"PLAY0481",unavailableResponseExecution:"PLAY0268",generatedPropertyOutsideCommand:"PLAY0482",invalidGeneratedType:"PLAY0483",invalidGeneratedModifierOrder:"PLAY0484",generatedPropertyInput:"PLAY0485",invalidCommandResponse:"PLAY0486",invalidResponseSource:"PLAY0487",duplicateResponseField:"PLAY0488",invalidResponseShape:"PLAY0489",invalidGeneratedFixture:"PLAY0490",invalidReturnExpectation:"PLAY0491"};var my=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,yy=/^import\s+"/;function $l(t){return yy.test(t.trim())}l($l,"isFileImportLine");function jo(t,e){let n=te(t),i=t.slice(n).match(my);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}l(jo,"fileImportOn");function ND(t){let e=we(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=jo(t[i],i);r&&n.push(r)}return n}l(ND,"fileImports");var vl=l(t=>t.split("/").slice(0,-1),"folderOf");function hy(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}l(hy,"relativeTo");function qD(t,e){let n=vl(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=hy(n,r),s=vl(o);i.add(o),i.add([...s,"*.play"].join("/"));for(let a=0;a<=s.length;a++)i.add([...s.slice(0,a),"**","*.play"].join("/"))}return[...i].sort()}l(qD,"importablePaths");var Sy=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),gy=/^id\s+"((?:[^"\\]|\\.)*)"$/;function bl(t,e,n,i=new Set){t=xt(t);let r=[],o=we(t),s=xy(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),d=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)d.set(h.name,(d.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=l((y,h,x,g="error")=>{r.push({line:y,startColumn:te(t[y])+1,endColumn:t[y].length+1,code:h,message:x,severity:g})},"report");for(let y of e.events){let h=tn(t,o,y.line,te(t[y.line]));if(y.inline){let S=new Set;for(let E of y.properties)S.has(E.name)&&m(E.line,ee.duplicateDeclaration,`Event '${y.name}' already declares property '${E.name}'.`),S.add(E.name);a.has(y.line)||m(y.line,ee.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((d.get(y.name)??0)>1||p.has(y.name))&&m(y.line,ee.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let x=!1,g=!1;for(let S of h){let E=t[S].trim(),$=E.split(/\s+/)[0];if(y.inline&&$==="generation"&&m(S,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&$==="origin"&&m(S,ee.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(E)){if($==="id"){let P=E.match(gy);x||P===null||P[1].trim().length===0?m(S,ee.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(S,ee.redundantEventId,"This id repeats the event name; remove it.","information"),x=!0}if($==="documentation"){let P=S+1;for(;P<t.length&&t[P].trim().length===0;)P++;(g||E!=="documentation"||t[P]?.trim()!=="```markdown"||te(t[P])<=te(t[S])||!s.has(P))&&m(S,ee.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),g=!0}}}}let u=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=te(t[y]);for(;u.length>0&&u[u.length-1].indent>=h;)u.pop();let x=t[y].trim().split(/\s+/)[0];Sy.has(x)&&u.at(-1)?.event&&m(y,ee.reservedProductionMetadata,`'${x}' is system-assigned production metadata.`),x==="produces"&&u.push({indent:h,event:!i.has(y)&&!/^\s*produces\s+operation\b/.test(t[y])})}for(let y of e.commands){let{identifier:h,mixed:x}=Mo(y);for(let g of y.produces??[]){x&&g.target===void 0&&m(g.line,ee.explicitProducesTargetsRequired,`Production '${g.name}' must state for explicitly when destinations differ.`);let S=g.target??(g.inline?h:void 0);if(!(h===void 0||S!==h))for(let E of g.mappings.filter($=>$.source===h))m(E.line,ee.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,g.inline?"warning":"information")}}return r}l(bl,"validateInlineEvents");function xy(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let s=t[o].trim();i===void 0?(i=o,r=!1):s==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):s.length>0&&(r=!0)}return n}l(xy,"nonemptyMarkdownBlocks");function Fe(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}l(Fe,"issue");function _e(t,e,n,i,r,o){let s=n.indexOf(i)+1;return Fe(t,e,s,i.length,r,o)}l(_e,"tokenIssue");function vy(t,e,n){let i=[],r=new Set([...Do(e,qn),...Do(n,[])]),o=l((a,d)=>{for(let p of a.filter(m=>!r.has(vt(m).name))){let m=vt(p).name;i.push(Fe("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${d} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${d} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,ee.unknownType))}},"checkProperties");for(let a of e.types)o(a.properties,`type '${a.name}'`);for(let a of e.events)o(a.properties,`event '${a.name}'`);for(let a of e.queries)o(a.parameters,`query '${a.name}'`);for(let a of e.commands){o(a.properties,`command '${a.name}'`);let d=a.properties.filter(p=>p.isIdentifier);for(let p of d.slice(1))i.push(_e("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${d[0].name}' as identifier \u2014 only one property can be the identifier.`,ee.duplicateCommandIdentifier))}let s=new Map;for(let a of[...e.concepts,...e.types]){if(s.get(a.name)===void 0){s.set(a.name,a.line);continue}i.push(_e("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,ee.duplicateDeclaration))}return i}l(vy,"validateDeclarations");function dM(t,e={}){let n=we(t),i=Ln(t),r=e.application??Hi(),o=xl(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=en(t,o.authoringDocuments??o.authoringSources?.filter(C=>C!==t.join(`
|
|
41
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(C=>C.location.line-1)),d={...i,commands:i.commands.map(C=>({...C,properties:C.properties.filter(b=>!a.has(b.line)),produces:C.produces?.filter(b=>!s.operationProductionLines?.has(b.line)),productionHeaders:C.productionHeaders?.filter(b=>!s.operationProductionLines?.has(b))}))},p=new Set([...Xi(d),...Xi(r)]),m=new Set([...d.policies,...r.policies].map(C=>C.name)),u=vy(t,d,r);u.push(...$y(t,d));let y=new Set([c.LegacyOptionalSuffix,c.InvalidOptionalModifierOrder,c.OptionalReadsNotSupported]),h=new Set([c.UnexpectedTokenInPolicyCondition,c.ExpectedPolicyCondition,c.UnclosedPolicyConditionGroup,c.ExpectedRoleName,c.ExpectedClaimName,c.ExpectedClaimMatches,c.ExpectedClaimMatchTarget]),x=new Set([c.UnknownEvent,c.UnknownReadModelProperty,c.PiiNotSupportedOnIdentifier]),g=new Set([c.EventFromLaterSlice,c.TimelineCycleGroup]),S=new Set([c.UndeclaredDependency,c.UnusedDependencyDeclaration,c.InvalidDependencyTarget,c.RepeatedDependencyDeclaration,c.MutualDependencyDeclarations,c.AmbiguousReference]),E=new Set([c.InvalidEventDeclaration,c.InvalidImportDeclaration,c.InvalidSliceDeclaration,c.InvalidDescription,c.DuplicateDescription,c.EmptyDescription,c.DuplicateEventSubject,c.InvalidSubjectType,c.ProtectedSubjectType,c.InvalidSubjectOwner,c.ReadModelSubjectNotSupported,c.InvalidSubjectModifierOrder,c.UnsupportedInteractionAlternatives,c.MixedInteractionAlternatives,c.InteractionAlternativeWithoutActions,c.InlineInteractionAlternative,c.LegacyInteractionWhere,c.InvalidSpecificationParameter,c.InvalidSpecificationCase,c.DuplicateSpecificationParameter,c.DuplicateSpecificationCase,c.IncompleteSpecificationTable,c.InvalidSpecificationCaseAssignment,c.InvalidSpecificationCaseValue,c.InvalidSpecificationCaseReference,c.OptionalSpecificationParameterTarget,c.SpecificationCaseNameCollision,c.IncompatibleSpecificationParameterType,c.UnusedSpecificationParameter,c.SingularSpecificationTableExpansion,c.InvalidSpecificationCallerPersona,c.UnsynthesizablePersonaCaller,c.PersonaWithoutGate,c.GateWithoutPersona,c.AmbiguousPersonaCaller,c.InvalidDocumentation,c.ConflictingDocumentationAcrossFiles,c.InvalidAbsentReadModelStep,c.UnknownConstraintProperty,c.OmittedProductionDestination,c.InvalidSpecificationExample,c.DuplicateSpecificationAssignment]),$=new Set([c.InvalidPurposeDeclaration,c.InvalidPurposeVocabulary,c.DuplicatePurposeField,c.DuplicatePurposeDeclaration,c.UnknownPurpose,c.PurposeInterestMismatch,c.PersonalDataWithoutPurpose,c.SpecialDataWithoutCondition,c.CriminalDataWithoutAuthorization,c.PurposeWithoutBasis,c.UnusedPurpose,c.UnknownConceptDirective,c.AttributeReasonWithoutAttribute,c.DuplicateAttributeReason,c.LegacyComplianceMarker,c.UnknownComplianceMarker,c.InvalidSecretScope,c.DuplicateSecretScope,c.SecretScopeIgnoredForPii,c.InvalidPersonalDataQualifier,c.DuplicateSpecialCategory]),P=new Set;for(let C of e.compilerDiagnostics??s.diagnostics){if(!$.has(C.code)&&!y.has(C.code)&&!h.has(C.code)&&!x.has(C.code)&&!g.has(C.code)&&!S.has(C.code)&&!E.has(C.code)&&C.code!==c.InvalidSpecificationExampleBody&&C.code!==c.UnknownRuleImplementationDirective&&C.code!==c.InvalidValidationRule&&C.code!==c.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$/.test(C.code))continue;let b=C.location.line-1;if(C.code===c.OmittedProductionDestination&&u.some(T=>T.code===C.code&&T.line===b))continue;if(C.code===c.UnknownEvent){if(P.has(b))continue;P.add(b)}let w=vo(t[b],C)||t[b].length-C.location.column+1;u.push(Fe(C.severity,b,C.location.column,w,C.message,C.code))}let A=l((C,b,w)=>{!p.has(w)&&!P.has(C)&&u.push(_e("warning",C,b,w,`Unknown event type '${w}' \u2014 declare it in a slice or import it.`,ee.unknownEvent))},"checkEvent"),v=-1;for(let C=0;C<t.length;C++){let b=t[C],w=b.trim();if(n[C]||w.length===0)continue;let T=b.match(/^[ ]*(\t+)/);if(T&&u.push(Fe("warning",C,T[0].length-T[1].length+1,T[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",ee.tabIndentation)),v>=0){if(te(b)>v&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(w)){for(let U of w.split(/\s+/).filter(_=>_!=="or"))m.has(U)||u.push(_e("warning",C,b,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy));continue}v=-1}let I=by(t,n,C);I&&u.push(I);let j=w.match(/^slice\s+(\w+)/);j&&!ir.includes(j[1])&&u.push(_e("error",C,b,j[1],`Unknown slice type '${j[1]}' \u2014 expected ${ir.join(", ")}.`,ee.unknownSliceType));let N=w.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!qn.includes(N[1])&&u.push(_e("error",C,b,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${qn.join(", ")} or Enum.`,ee.unknownPrimitiveType));let L=w.match(/^authorize\s+(.*)$/);if(L){v=te(b);for(let U of L[1].split(/\s+/).filter(_=>_!=="or"&&_.length>0))m.has(U)||u.push(_e("warning",C,b,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy))}let q=w.match(/^on\s+([A-Z]\w*)\s*$/);q&&A(C,b,q[1]);let V=w.match(/^produces\s+([A-Z]\w*)\s*$/);if(V&&!s.operationProductionLines?.has(C)&&A(C,b,V[1]),/^produces\s+when\b/.test(w)&&!s.operationProductionLines?.has(C))for(let U=C+1;U<t.length;U++){let _=t[U];if(!(n[U]||_.trim().length===0)){if(te(_)>te(b)){let ie=_.trim().match(/^([A-Z]\w*)\s*$/);ie&&A(U,_,ie[1])}break}}let K=w.match(/^unique\s+event\s+([A-Z]\w*)/);K&&A(C,b,K[1]);let J=w.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);J&&A(C,b,J[1]);for(let U of b.match(/\$context\.[\w.]+/g)??[]){let _=U.substring(9).split(".");er.includes(_[0])?_[0]==="causedBy"&&_.length>1&&!tr.includes(_[1])?u.push(_e("warning",C,b,U,`Unknown $context.causedBy property '${_[1]}' \u2014 expected ${tr.join(", ")}.`,ee.unknownContextCausedByProperty)):_[0]==="identity"&&_.length>1&&!nr.includes(_[1])&&u.push(_e("warning",C,b,U,`Unknown $context.identity property '${_[1]}' \u2014 expected ${nr.join(", ")}.`,ee.unknownContextIdentityProperty)):u.push(_e("warning",C,b,U,`Unknown $context path '${_.join(".")}' \u2014 expected one of ${er.join(", ")}.`,ee.unknownContextPath))}}u.push(...Cy(t,n)),u.push(...bl(t,d,r,s.operationProductionLines));let k=t.map((C,b)=>({line:C,index:b})).filter(({line:C})=>/^\s*```(?:[a-z]+)?\s*$/.test(C));if(k.length%2===1){let C=k[k.length-1];u.push(Fe("error",C.index,1,C.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",ee.unclosedCodeBlock))}return u}l(dM,"validateLines");function $y(t,e){let n=[];t=xt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!vt(o).isOptional&&!vt(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(Fe("information",s,te(t[s])+1,t[s].trim().length,`Plain 'produces ${o.name}' omits its destination \u2014 use 'for ${r[0].name}' to explicitly select the command's identifier.`,ee.omittedProductionDestination))}}return n}l($y,"validateProductionDestinations");function by(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||jo(i,n))return;let o=te(i);if(!(!(o>0&&["module","feature"].includes(qo(t,e,n,o)[0]))&&!$l(i)))return Fe("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,ee.invalidFileImport)}l(by,"validateImport");var ky=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Cy(t,e){let n=[],i=l(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let d of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=d[0].substring(d[1]?.length??0),m=d[2];if(m.length===0){d[1]&&n.push(Fe("error",r,(d.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(lr("").expected)}.`,ee.missingEventContextPath));continue}let u=m.substring(1),y=lr(u),h=(d.index??0)+(d[1]?.length??0)+1;switch(y.status){case"missing":n.push(Fe("error",r,h,p.length,`'$eventContext.${u}' names no member - expected one of ${i(y.expected)}.`,ee.missingEventContextPath));break;case"unknownMember":n.push(Fe("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${u}' - expected one of ${i(y.expected)}.`,ee.unknownEventContextMember));break;case"unknownSubPath":{let x=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(Fe("warning",r,h,p.length,`Unknown event context path '$eventContext.${u}' - '${y.member?.name}' (${y.member?.type}) has ${x}.`,ee.unknownEventContextPath));break}case"belowCollection":n.push(Fe("error",r,h,p.length,`'$eventContext.${u}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,ee.eventContextPathBelowCollection));break}}let s=o.trim().match(ky)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(_e("warning",r,o,s,`Dynamic dictionary key '$${a}' in '${s}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${a}' becomes the key.`,ee.unresolvedDynamicKeySource))}return n}l(Cy,"validateEventContextPaths");export{kl as a,Ey as b,Py as c,No as d,Ay as e,er as f,tr as g,ir as h,qn as i,wy as j,Cl as k,Oy as l,wt as m,nn as n,Ty as o,c as p,$e as q,Er as r,ii as s,qO as t,BO as u,Ee as v,te as w,rr as x,we as y,qo as z,My as A,jy as B,xt as C,Qy as D,or as E,ar as F,sr as G,El as H,Yy as I,Fy as J,Uy as K,Pl as L,Al as M,Hy as N,Xy as O,eh as P,th as Q,nh as R,ih as S,rh as T,oh as U,ah as V,sh as W,lh as X,Ol as Y,ch as Z,hh as _,Sh as $,gh as aa,Il as ba,xh as ca,vh as da,$h as ea,bh as fa,Tl as ga,kh as ha,Ch as ia,Eh as ja,Ph as ka,Ah as la,wh as ma,Oh as na,Ih as oa,Th as pa,Rh as qa,Dh as ra,Mh as sa,jh as ta,Fo as ua,Rl as va,Lh as wa,Nh as xa,qh as ya,Bh as za,Yh as Aa,Dl as Ba,Fh as Ca,Ml as Da,Uh as Ea,Wh as Fa,Vh as Ga,zh as Ha,Qh as Ia,rD as Ja,en as Ka,Oo as La,lD as Ma,Io as Na,cD as Oa,vt as Pa,tn as Qa,Ln as Ra,Hi as Sa,xl as Ta,Xi as Ua,fy as Va,CD as Wa,Do as Xa,Mo as Ya,RD as Za,ee as _a,$l as $a,jo as ab,ND as bb,qD as cb,dM as db,Cy as eb};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
`),Y=d(`Fragment${M}`);u.add(Y);let pt=R.placement?.length?{source:R.source,locations:B.map((It,qn)=>({line:qn+1,column:0}))}:ty(B,[`module ${p}`,` feature ${m}`,` slice StateChange ${Y}`]);return{...R,...pt,placement:R.placement??[]}}),h=y[0],x=new Map(y.map(R=>[R.path,R.locations])),g=fl([...y.slice(1),h]),S=new Map,C=new Map,$=new WeakSet,P=l(R=>{if(R===null||typeof R!="object"||$.has(R))return;if($.add(R),Array.isArray(R)){R.forEach(P);return}let M=R;if(typeof M.path=="string"&&typeof M.line=="number"&&typeof M.column=="number"){let B=x.get(M.path)?.[M.line-1];B&&(M.line=B.line,M.column=Math.max(1,M.column-B.column));return}for(let B of Object.values(M))P(B);M.location?.path===i&&(M.kind==="CommandSyntax"&&S.set(M.location.line-1,R),M.kind==="SpecificationSyntax"&&C.set(M.location.line-1,R))},"walk");P(g.value),P(g.physicalEventSources);for(let R of g.diagnostics)P(R.location);let A=g.diagnostics.some(R=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(R.code))return!1;let M=y.find(Y=>Y.path===R.location.path),B=s.find(Y=>Y.path===R.location.path)?.source.split(`
|
|
39
|
+
`)[R.location.line-1];return M?.locations.some(Y=>Y.line===0)&&B!==void 0&&te(B)===0}),v=g.diagnostics.filter(R=>R.location.path===i).flatMap(R=>(P(R.location),R.location.line>0?[R]:[])),k=new re(g.value),E=new Set(k.slices.flatMap(({slice:R})=>[...R.commands.flatMap(M=>M.produces),...R.reactions.flatMap(M=>M.triggers).flatMap(M=>M.produces)].filter(M=>M.location.path===i&&!k.isEventProduction(M,R)).map(M=>M.location.line-1)));for(let R of v)R.code==="PLAY0499"&&E.add(R.location.line-1);let b=k.declarations.filter(R=>R.kind===H.Operation).map(R=>({...R.node,scope:R.scope.filter(M=>!u.has(M))})),w=new Map,T=we(t),I=l(R=>{let M=[],B=te(t[R]);for(let Y=R;Y<t.length&&!(Y>R&&!T[Y]&&Ce(t[Y]).trim()&&te(t[Y])<=B);Y++)M.push(Y);return M},"range");for(let{slice:R,scope:M}of k.slices){if(R.location.path===i&&R.location.line>0)for(let B of I(R.location.line-1))w.set(B,{scope:M});for(let B of R.specifications.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of I(B.location.line-1))w.set(Y,{scope:M});for(let B of R.commands.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of I(B.location.line-1))w.set(Y,{scope:M,commandLine:B.location.line-1})}let j=new Map(k.declarations.map(R=>[R.node.location,R.scope]));for(let R of b.filter(M=>M.location.path===i)){let M=j.get(R.location);for(let B of I(R.location.line-1))w.set(B,{...w.get(B),scope:M,operation:R})}let N=new Map(b.map(R=>[R.location,R])),L=l((R,M)=>{let B=Ce(t[R.line-1]??""),Y=B.slice(R.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return Y&&B.slice(R.column-1+Y.length,R.column-1+Y.length+M.length)===M?{...R,column:R.column+Y.length}:R},"referenceLocation"),q=[];for(let{slice:R}of k.slices){for(let M of R.commands)for(let B of M.produces){if(B.location.path!==i)continue;let Y=k.resolve(B.event,R),pt=Y.declaration?N.get(Y.declaration.node.location)??null:null,It={name:B.event,location:B.location,targetLocation:B.targetLocation??B.location,kind:Y.kind,declaration:pt,mappings:B.mappings};if(q.push(It),Y.kind===H.Operation)for(let qn of I(B.location.line-1)){let Lo=w.get(qn);Lo&&w.set(qn,{...Lo,production:It})}}for(let M of R.specifications)for(let B of[...M.givenOperationFailures??[],...M.thenOperations??[],...M.thenCompensated??[]]){if(B.location.path!==i)continue;let Y=k.resolve(B.operation,R);q.push({name:B.operation,location:B.location,targetLocation:L(B.location,B.operation),kind:Y.kind,declaration:Y.declaration?N.get(Y.declaration.node.location)??null:null,mappings:[]})}}let V={declarations:b,systems:g.value.systems??[],references:q,contexts:w,types:g.value.types,concepts:g.value.concepts,targets:l(R=>{let M=k.slices.find(B=>B.scope.length===R.length&&B.scope.every((Y,pt)=>Y===R[pt]))?.slice;return M?b.flatMap(B=>{let Y=k.resolve(B.name,M).declaration?.node.location===B.location?B.name:[...B.scope,B.name].join(".");return k.resolve(Y,M).kind===H.Operation&&k.resolve(Y,M).declaration?.node.location===B.location?[{name:Y,declaration:B}]:[]}):[]},"targets")},K=g.physicalEventSources.map(R=>R.source),J=new Xt(g.physicalEventSources,g.sourceInventoryComplete&&!A),U=new Map,_=l((R,M)=>{let B=JSON.stringify([R,M]),Y=U.get(B);return Y||(Y=J.resolve(R,M),U.set(B,Y)),{...Y,source:Y.state==="unique"?Y.sources[0]:void 0,stream:Y.state==="unique"?Y.streams[0]:void 0}},"resolve"),ie=new Set(g.value.imports.map(R=>R.qualifiedName)),Ee=K.flatMap(R=>R.streams.filter(M=>_(R.name,M.name).state==="unique"&&!ie.has(`${R.name}.${M.name}`)).map(M=>({name:`${R.name}.${M.name}`,source:R,stream:M}))),F=new Map,ce=[];for(let R of S.values()){for(let M of I(R.location.line-1))F.set(M,{command:R});for(let M of[...R.produces,...R.validations,...R.handler?[R.handler]:[]])for(let B of I(M.location.line-1))F.delete(B);if(R.stream){ce.push(R.stream);for(let M of I(R.stream.location.line-1))F.set(M,{command:R,route:R.stream})}}let fe=hl(g.value,i,t,I,u,g.diagnostics),Ae=[...[...C.values()].flatMap(R=>[...R.given.map(M=>({event:M,expectation:!1})),...R.whenAppended?[{event:R.whenAppended,expectation:!1}]:[],...R.thenEvents.map(M=>({event:M,expectation:!0})),...R.whenRedelivered?[{event:R.whenRedelivered,expectation:!0}]:[]]),...(fe.eventExamples??[]).map(R=>({event:R,expectation:!0}))];for(let R of Ae){let M=R.event;for(let B of I(M.location.line-1))F.set(B,R);if(M.stream){ce.push(M.stream);for(let B of I(M.stream.location.line-1))F.set(B,{...R,route:M.stream})}}for(let R of K.filter(M=>M.location.path===i)){for(let M of I(R.location.line-1))F.set(M,{source:R});for(let M of R.streams)for(let B of I(M.location.line-1))F.set(B,{source:R,stream:M})}let $t=[...S.values()].flatMap(R=>R.streamCandidates??[]).filter(R=>R.propertyCandidate!==null),bt={declarations:K,routes:ce,ambiguousCandidates:$t,contexts:F,targets:Ee,resolve:_},me,xe={completions(R,M,B){if(me===void 0){let Y=He(h.source,i,h.placement,!1).value,pt=l(It=>{P(It.location),It.features.forEach(pt)},"remapDependencyHeaders");Y.modules.forEach(pt),me=gl(g.value,Y,i,I,u)}return me.completions(R,M,B)}};return{commands:S,specifications:C,diagnostics:v,operationProductionLines:E,operations:V,eventSources:bt,examples:fe,personas:Sl(g.value,t),dependencies:xe}}l(ny,"analyze");function tn(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=Mn.get(o);return s===void 0&&(s=ny(t,e,n,i,r),Mn.size>=16&&Mn.delete(Mn.keys().next().value),Mn.set(o,s)),s}l(tn,"responseAnalysis");var Oo="file",iy=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,ry=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function dD(t){return ry.test(t)}l(dD,"isAbsoluteFileReferencePath");function oy(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}l(oy,"withoutComment");function Io(t,e){let n=te(t),i=oy(t.slice(n)).trimEnd();if(rr(i)!==Oo)return;let r=i.slice(Oo.length),o=r.trim();if(o.length===0||iy.test(o))return;let s=r.length-r.trimStart().length,a=n+Oo.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}l(Io,"fileReferenceOn");function pD(t){let e=we(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Io(t[i],i);r&&n.push(r)}return n}l(pD,"fileReferences");function xt(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=Ce(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}l(xt,"eventAnalysisSource");var ay=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,sy=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,xl=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,ly=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,cy=["authorize","produces","reads"],dy=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,py=$n,uy=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],fy=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function vt(t){return t.typeReference??rn(t.type)}l(vt,"propertyTypeReference");function To(t,e){let n=t.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:n,startColumn:e,endColumn:e+n.length}}l(To,"sourceTypeAt");function Ro(t,e,n){return e.map(i=>({index:i,match:t[i].match(sy)})).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:rn(r[2]),sourceType:To(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}))}l(Ro,"propertiesIn");function Ln(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(te(s)<=i)break;r.push(o)}}return r}l(Ln,"collectBody");function nn(t,e,n,i){let r=Ln(t,e,n,i).filter(a=>!e[a]&&!/^\s*(?:\/\/|#)/.test(t[a]));if(!/^\s*command\b/.test(t[n]))return r;let o,s=!1;return r.filter(a=>{let d=te(t[a]),p=t[a].trim();return o!==void 0&&d>o&&(!s||dy.test(p))?!1:(o=p!=="validate csharp"&&Ro(t,[a],cy).length>0||/^description(?:\s|$)/.test(p)?void 0:d,s=/^authorize(?:\s|$)/.test(p),!0)})}l(nn,"directBody");var jn=new Map;function Nn(t){let e=t.join(`
|
|
40
|
+
`),n=jn.get(e);if(n)return n;let i=tn(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=xt(t);let o=we(t),s=t,a=o,d=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],u=m.trim(),y=te(m),h=s[p].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(h&&y===0){let k=h[1],E=k.split(".").pop()??k;r.imports.push({qualifiedName:k,shortName:E,line:p});continue}let x=u.match(ay);if(x){let k=Ln(t,o,p,y).map(w=>t[w].trim()),E={};for(let w of k){let T=w.match(xl);T&&E[T[1]]===void 0&&(E[T[1]]=T[2])}let b=x[2]==="Enum"?k.filter(w=>!xl.test(w)):[];r.concepts.push({name:x[1],primitive:x[2],attributes:x[3].trim().split(/\s+/).filter(Boolean),attributeReasons:E,enumValues:b,line:p});continue}let g=u.match(/^type\s+(\w+)\s*$/);if(g){r.types.push({name:g[1],properties:Ro(t,Ln(t,o,p,y),No),line:p});continue}let S=u.match(/^policy\s+(\w+)\s*$/);if(S){let k=Ln(t,o,p,y).filter(E=>!o[E]).map(E=>t[E].trim());r.policies.push({name:S[1],requires:k,line:p});continue}let C=s[p].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if(C){let k=u.startsWith("produces "),E=nn(s,a,p,y),b=k?E:E.filter(w=>Io(s[w],w)===void 0);r.events.push({name:C.groups.name,...C.groups.generation?{generation:Number(C.groups.generation)}:{},...C.groups.public||C.groups.origin?{visibility:se.Public}:{},...C.groups.origin?{origin:Q(C.groups.origin.slice(1,-1))}:{},inline:k,properties:Ro(k?d:s,b,k?uy:py),line:p});continue}let $=i.commands.get(p);if($){let k=nn(t,o,p,y),E=k.filter(b=>/^\s*produces\b/.test(t[b])&&!i.operationProductionLines?.has(b));r.commands.push({name:$.name,properties:$.properties.map(b=>({name:b.name,type:`${b.type.name}${b.type.isCollection?"[]":""}${b.type.isOptional?" optional":""}`,typeReference:{name:b.type.name,isCollection:b.type.isCollection,isOptional:b.type.isOptional},sourceType:To(t[b.type.location.line-1],b.type.location.column),isIdentifier:b.isIdentifier||/\sidentifier\s*$/.test(t[b.location.line-1]),...b.isGenerated?{isGenerated:!0}:{},line:b.location.line-1})),response:$.response,productionHeaders:E,produces:E.flatMap(b=>{let w=s[b].trim(),T=/^produces\s+event\b/.test(w),I=/^produces\s+when\b/.test(w),j=I?nn(s,a,b,te(s[b]))[0]:b;if(j===void 0)return[];let N=I?s[j].trim():w.match(T?/^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 L=nn(s,a,j,te(s[j])),q=L.map(J=>s[J].trim().match(/^for(?:\s+(.*))?$/)).filter(J=>J!==null),V=q.length===0?void 0:q.length===1?q[0][1]??"":"",K=L.flatMap(J=>{let U=s[J].trim().match(T?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return U===null?[]:[{name:U[1].replace(/^@/,""),source:U[2],line:J}]});return[{name:N,inline:T,conditional:I,line:b,target:V,mappings:K}]}),reads:k.filter(b=>!o[b]).map(b=>({line:b,match:t[b].match(ly)})).filter(b=>b.match!==null).map(({line:b,match:w})=>({view:w[1],...w[2]?{alias:w[2]}:{},...w[3]?{by:w[3]}:{},line:b})),line:p});continue}let P=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let k=Ln(t,o,p,y).map(E=>({index:E,match:t[E].match(fy)})).filter(E=>E.match!==null).map(({index:E,match:b})=>({name:b[1],type:b[2],typeReference:rn(b[2]),sourceType:To(t[E],t[E].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:E}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:rn(P[2]),parameters:k,line:p});continue}let A=u.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let v=u.match(/^trigger\s+(\w+)\s*$/);v&&y===0&&r.triggers.push({name:v[1],line:p})}return jn.size>=16&&jn.delete(jn.keys().next().value),jn.set(e,r),r}l(Nn,"scanDocument");function Xi(...t){return{authoringSources:t.flatMap(e=>e.authoringSources??[]),...t.some(e=>e.authoringDocuments)?{authoringDocuments:t.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:t.flatMap(e=>e.eventSources??[]),imports:t.flatMap(e=>e.imports),concepts:t.flatMap(e=>e.concepts),types:t.flatMap(e=>e.types),policies:t.flatMap(e=>e.policies),events:t.flatMap(e=>e.events),commands:t.flatMap(e=>e.commands),queries:t.flatMap(e=>e.queries),screens:t.flatMap(e=>e.screens),triggers:t.flatMap(e=>e.triggers)}}l(Xi,"mergeSymbols");function vl(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...Xi(Nn(t),e??Xi()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}l(vl,"symbolsForBuffer");function er(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}l(er,"knownEventNames");var my=["Startup","Shutdown"];function PD(t){return[...er(t),...t.triggers.map(e=>e.name),...my]}l(PD,"knownTriggerNames");function Do(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}l(Do,"knownTypeNames");function Mo(t){let e=t.properties.filter(o=>o.isIdentifier&&!vt(o).isOptional&&!vt(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}l(Mo,"productionDestinations");function MD(t,e){let n=tn(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=xt(t);return Nn(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(d=>d.target!==void 0||d.inline);return(r.produces??[]).flatMap(d=>d.target!==void 0||d.inline&&(o===void 0||/\bgeneration\b/.test(i[d.line]))?[]:!d.inline&&a?[]:[{line:d.line,column:i[d.line].length+1,label:d.inline?`for ${o}`:"for <new event source>"}])})}l(MD,"destinationHints");var ee={commandProducesPublicEvent:"PLAY0607",publicEventRequiresOutboundTranslation:"PLAY0608",outboundPublicEventCount:"PLAY0609",foreignPublicEventConsumer:"PLAY0610",outboundTranslationInput:"PLAY0611",inboundTranslationOutput:"PLAY0612",foreignPublicEventProduced:"PLAY0613",publicTranslationRequiresDirection:"PLAY0614",translationConstructDirection:"PLAY0615",inboundTranslationInput:"PLAY0616",outboundTranslationOutput:"PLAY0617",eventTargetOutsideOutboundTranslation:"PLAY0618",eventsSourceOutsideInboundTranslation:"PLAY0619",invalidCaptureEventsSource:"PLAY0620",invalidDescription:"PLAY0145",emptyDescription:"PLAY0146",duplicateDescription:"PLAY0147",unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",invalidPurposeDeclaration:"PLAY0596",invalidPurposeVocabulary:"PLAY0597",duplicatePurposeField:"PLAY0598",duplicatePurposeDeclaration:"PLAY0599",unknownPurpose:"PLAY0600",purposeInterestMismatch:"PLAY0601",personalDataWithoutPurpose:"PLAY0602",specialDataWithoutCondition:"PLAY0603",criminalDataWithoutAuthorization:"PLAY0604",purposeWithoutBasis:"PLAY0605",unusedPurpose:"PLAY0606",duplicateEventSubject:"PLAY0590",invalidSubjectType:"PLAY0591",protectedSubjectType:"PLAY0592",invalidSubjectOwner:"PLAY0593",readModelSubjectNotSupported:"PLAY0594",invalidSubjectModifierOrder:"PLAY0595",conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",invalidSpecificationCallerPersona:"PLAY0572",unsynthesizablePersonaCaller:"PLAY0573",personaWithoutGate:"PLAY0574",gateWithoutPersona:"PLAY0575",ambiguousPersonaCaller:"PLAY0576",invalidSpecificationParameter:"PLAY0577",invalidSpecificationCase:"PLAY0578",duplicateSpecificationParameter:"PLAY0579",duplicateSpecificationCase:"PLAY0580",incompleteSpecificationTable:"PLAY0581",invalidSpecificationCaseAssignment:"PLAY0582",invalidSpecificationCaseValue:"PLAY0583",invalidSpecificationCaseReference:"PLAY0584",optionalSpecificationParameterTarget:"PLAY0585",specificationCaseNameCollision:"PLAY0586",incompatibleSpecificationParameterType:"PLAY0587",unusedSpecificationParameter:"PLAY0588",singularSpecificationTableExpansion:"PLAY0589",invalidActionAlternative:"PLAY0341",guardedActionWithoutAlternatives:"PLAY0342",misplacedActionOtherwise:"PLAY0343",unsupportedActionConditionOperand:"PLAY0344",unknownActionSubjectField:"PLAY0345",unresolvedActionSubject:"PLAY0346",unreachableActionAlternative:"PLAY0347",unknownActionArgumentProperty:"PLAY0348",invalidRefusalBranch:"PLAY0538",invalidRefusalBranchBody:"PLAY0539",unreachableRefusalBranch:"PLAY0540",invalidRefusalValue:"PLAY0541",unknownRefusalConstraint:"PLAY0542",unmatchedRedeliveredOccurrence:"PLAY0543",unknownRedeliveryReaction:"PLAY0544",invalidNoEventsExpectation:"PLAY0545",indeterminateNegatedClaimTarget:"PLAY0546",invalidAbsentReadModelStep:"PLAY0453",unknownConstraintProperty:"PLAY0391",invalidSpecificationExample:"PLAY0518",duplicateSpecificationAssignment:"PLAY0519",unknownReadModelProperty:"PLAY0514",piiNotSupportedOnIdentifier:"PLAY0515",invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",invalidSpecificationStream:"PLAY0547",specificationStreamOnCommand:"PLAY0548",invalidSpecificationStreamRoute:"PLAY0549",invalidSpecificationStreamEventSource:"PLAY0550",specificationStreamContradictsCommand:"PLAY0551",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",invalidSpecificationExampleBody:"PLAY0526",undeclaredDependency:"PLAY0552",unusedDependencyDeclaration:"PLAY0553",invalidDependencyTarget:"PLAY0554",repeatedDependencyDeclaration:"PLAY0555",mutualDependencyDeclarations:"PLAY0556",authorizationRefusalWithoutIdentity:"PLAY0557",invalidDocumentation:"PLAY0558",conflictingDocumentationAcrossFiles:"PLAY0559",unsupportedInteractionAlternatives:"PLAY0560",mixedInteractionAlternatives:"PLAY0561",interactionAlternativeWithoutActions:"PLAY0562",inlineInteractionAlternative:"PLAY0563",legacyInteractionWhere:"PLAY0564",ambiguousReference:"PLAY0198",invalidImplementationBlock:"PLAY0492",invalidImplementationHint:"PLAY0493",conflictingImplementationSources:"PLAY0494",eventSourceIdInPayload:"PLAY0469",explicitProducesTargetsRequired:"PLAY0470",redundantEventId:"PLAY0471",invalidEventId:"PLAY0472",inlineEventCollision:"PLAY0473",inlineEventOutsideCommand:"PLAY0474",inlineEventGeneration:"PLAY0475",reservedProductionMetadata:"PLAY0476",invalidEventDocumentation:"PLAY0477",tabIndentation:"PLAY0006",unknownPrimitiveType:"PLAY0008",unknownSliceType:"PLAY0028",duplicateCommandIdentifier:"PLAY0036",unknownContextPath:"PLAY0153",unknownContextCausedByProperty:"PLAY0154",unknownContextIdentityProperty:"PLAY0155",unclosedCodeBlock:"PLAY0164",unknownType:"PLAY0165",unknownEvent:"PLAY0166",unknownPolicy:"PLAY0167",duplicateDeclaration:"PLAY0168",unknownEventContextMember:"PLAY0295",unknownEventContextPath:"PLAY0296",eventContextPathBelowCollection:"PLAY0297",missingEventContextPath:"PLAY0298",unresolvedDynamicKeySource:"PLAY0299",invalidFileImport:"PLAY0454",omittedProductionDestination:"PLAY0478",legacyOptionalSuffix:"PLAY0479",invalidOptionalModifierOrder:"PLAY0480",optionalReadsNotSupported:"PLAY0481",unavailableResponseExecution:"PLAY0268",generatedPropertyOutsideCommand:"PLAY0482",invalidGeneratedType:"PLAY0483",invalidGeneratedModifierOrder:"PLAY0484",generatedPropertyInput:"PLAY0485",invalidCommandResponse:"PLAY0486",invalidResponseSource:"PLAY0487",duplicateResponseField:"PLAY0488",invalidResponseShape:"PLAY0489",invalidGeneratedFixture:"PLAY0490",invalidReturnExpectation:"PLAY0491"};var yy=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,hy=/^import\s+"/;function bl(t){return hy.test(t.trim())}l(bl,"isFileImportLine");function jo(t,e){let n=te(t),i=t.slice(n).match(yy);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}l(jo,"fileImportOn");function BD(t){let e=we(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=jo(t[i],i);r&&n.push(r)}return n}l(BD,"fileImports");var $l=l(t=>t.split("/").slice(0,-1),"folderOf");function Sy(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}l(Sy,"relativeTo");function YD(t,e){let n=$l(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Sy(n,r),s=$l(o);i.add(o),i.add([...s,"*.play"].join("/"));for(let a=0;a<=s.length;a++)i.add([...s.slice(0,a),"**","*.play"].join("/"))}return[...i].sort()}l(YD,"importablePaths");var gy=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),xy=/^id\s+"((?:[^"\\]|\\.)*)"$/;function kl(t,e,n,i=new Set){t=xt(t);let r=[],o=we(t),s=vy(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),d=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)d.set(h.name,(d.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=l((y,h,x,g="error")=>{r.push({line:y,startColumn:te(t[y])+1,endColumn:t[y].length+1,code:h,message:x,severity:g})},"report");for(let y of e.events){let h=nn(t,o,y.line,te(t[y.line]));if(y.inline){let S=new Set;for(let C of y.properties)S.has(C.name)&&m(C.line,ee.duplicateDeclaration,`Event '${y.name}' already declares property '${C.name}'.`),S.add(C.name);a.has(y.line)||m(y.line,ee.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((d.get(y.name)??0)>1||p.has(y.name))&&m(y.line,ee.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let x=!1,g=!1;for(let S of h){let C=t[S].trim(),$=C.split(/\s+/)[0];if(y.inline&&$==="generation"&&m(S,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&$==="origin"&&m(S,ee.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(C)){if($==="id"){let P=C.match(xy);x||P===null||P[1].trim().length===0?m(S,ee.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(S,ee.redundantEventId,"This id repeats the event name; remove it.","information"),x=!0}if($==="documentation"){let P=S+1;for(;P<t.length&&t[P].trim().length===0;)P++;(g||C!=="documentation"||t[P]?.trim()!=="```markdown"||te(t[P])<=te(t[S])||!s.has(P))&&m(S,ee.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),g=!0}}}}let u=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=te(t[y]);for(;u.length>0&&u[u.length-1].indent>=h;)u.pop();let x=t[y].trim().split(/\s+/)[0];gy.has(x)&&u.at(-1)?.event&&m(y,ee.reservedProductionMetadata,`'${x}' is system-assigned production metadata.`),x==="produces"&&u.push({indent:h,event:!i.has(y)&&!/^\s*produces\s+operation\b/.test(t[y])})}for(let y of e.commands){let{identifier:h,mixed:x}=Mo(y);for(let g of y.produces??[]){x&&g.target===void 0&&m(g.line,ee.explicitProducesTargetsRequired,`Production '${g.name}' must state for explicitly when destinations differ.`);let S=g.target??(g.inline?h:void 0);if(!(h===void 0||S!==h))for(let C of g.mappings.filter($=>$.source===h))m(C.line,ee.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,g.inline?"warning":"information")}}return r}l(kl,"validateInlineEvents");function vy(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let s=t[o].trim();i===void 0?(i=o,r=!1):s==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):s.length>0&&(r=!0)}return n}l(vy,"nonemptyMarkdownBlocks");function Ue(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}l(Ue,"issue");function Fe(t,e,n,i,r,o){let s=n.indexOf(i)+1;return Ue(t,e,s,i.length,r,o)}l(Fe,"tokenIssue");function $y(t,e,n){let i=[],r=new Set([...Do(e,Bn),...Do(n,[])]),o=l((a,d)=>{for(let p of a.filter(m=>!r.has(vt(m).name))){let m=vt(p).name;i.push(Ue("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${d} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${d} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,ee.unknownType))}},"checkProperties");for(let a of e.types)o(a.properties,`type '${a.name}'`);for(let a of e.events)o(a.properties,`event '${a.name}'`);for(let a of e.queries)o(a.parameters,`query '${a.name}'`);for(let a of e.commands){o(a.properties,`command '${a.name}'`);let d=a.properties.filter(p=>p.isIdentifier);for(let p of d.slice(1))i.push(Fe("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${d[0].name}' as identifier \u2014 only one property can be the identifier.`,ee.duplicateCommandIdentifier))}let s=new Map;for(let a of[...e.concepts,...e.types]){if(s.get(a.name)===void 0){s.set(a.name,a.line);continue}i.push(Fe("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,ee.duplicateDeclaration))}return i}l($y,"validateDeclarations");function uM(t,e={}){let n=we(t),i=Nn(t),r=e.application??Xi(),o=vl(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=tn(t,o.authoringDocuments??o.authoringSources?.filter(E=>E!==t.join(`
|
|
41
|
+
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(E=>E.location.line-1)),d={...i,commands:i.commands.map(E=>({...E,properties:E.properties.filter(b=>!a.has(b.line)),produces:E.produces?.filter(b=>!s.operationProductionLines?.has(b.line)),productionHeaders:E.productionHeaders?.filter(b=>!s.operationProductionLines?.has(b))}))},p=new Set([...er(d),...er(r)]),m=new Set([...d.policies,...r.policies].map(E=>E.name)),u=$y(t,d,r);u.push(...by(t,d));let y=new Set([c.LegacyOptionalSuffix,c.InvalidOptionalModifierOrder,c.OptionalReadsNotSupported]),h=new Set([c.UnexpectedTokenInPolicyCondition,c.ExpectedPolicyCondition,c.UnclosedPolicyConditionGroup,c.ExpectedRoleName,c.ExpectedClaimName,c.ExpectedClaimMatches,c.ExpectedClaimMatchTarget]),x=new Set([c.UnknownEvent,c.UnknownReadModelProperty,c.PiiNotSupportedOnIdentifier]),g=new Set([c.EventFromLaterSlice,c.TimelineCycleGroup]),S=new Set([c.UndeclaredDependency,c.UnusedDependencyDeclaration,c.InvalidDependencyTarget,c.RepeatedDependencyDeclaration,c.MutualDependencyDeclarations,c.AmbiguousReference]),C=new Set([c.InvalidEventDeclaration,c.InvalidImportDeclaration,c.InvalidSliceDeclaration,c.InvalidDescription,c.DuplicateDescription,c.EmptyDescription,c.DuplicateEventSubject,c.InvalidSubjectType,c.ProtectedSubjectType,c.InvalidSubjectOwner,c.ReadModelSubjectNotSupported,c.InvalidSubjectModifierOrder,c.UnsupportedInteractionAlternatives,c.MixedInteractionAlternatives,c.InteractionAlternativeWithoutActions,c.InlineInteractionAlternative,c.LegacyInteractionWhere,c.InvalidSpecificationParameter,c.InvalidSpecificationCase,c.DuplicateSpecificationParameter,c.DuplicateSpecificationCase,c.IncompleteSpecificationTable,c.InvalidSpecificationCaseAssignment,c.InvalidSpecificationCaseValue,c.InvalidSpecificationCaseReference,c.OptionalSpecificationParameterTarget,c.SpecificationCaseNameCollision,c.IncompatibleSpecificationParameterType,c.UnusedSpecificationParameter,c.SingularSpecificationTableExpansion,c.InvalidSpecificationCallerPersona,c.UnsynthesizablePersonaCaller,c.PersonaWithoutGate,c.GateWithoutPersona,c.AmbiguousPersonaCaller,c.InvalidDocumentation,c.ConflictingDocumentationAcrossFiles,c.InvalidAbsentReadModelStep,c.UnknownConstraintProperty,c.OmittedProductionDestination,c.InvalidSpecificationExample,c.DuplicateSpecificationAssignment]),$=new Set([c.InvalidPurposeDeclaration,c.InvalidPurposeVocabulary,c.DuplicatePurposeField,c.DuplicatePurposeDeclaration,c.UnknownPurpose,c.PurposeInterestMismatch,c.PersonalDataWithoutPurpose,c.SpecialDataWithoutCondition,c.CriminalDataWithoutAuthorization,c.PurposeWithoutBasis,c.UnusedPurpose,c.UnknownConceptDirective,c.AttributeReasonWithoutAttribute,c.DuplicateAttributeReason,c.LegacyComplianceMarker,c.UnknownComplianceMarker,c.InvalidSecretScope,c.DuplicateSecretScope,c.SecretScopeIgnoredForPii,c.InvalidPersonalDataQualifier,c.DuplicateSpecialCategory]),P=new Set;for(let E of e.compilerDiagnostics??s.diagnostics){if(!$.has(E.code)&&!y.has(E.code)&&!h.has(E.code)&&!x.has(E.code)&&!g.has(E.code)&&!S.has(E.code)&&!C.has(E.code)&&E.code!==c.InvalidSpecificationExampleBody&&E.code!==c.UnknownRuleImplementationDirective&&E.code!==c.InvalidValidationRule&&E.code!==c.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$/.test(E.code))continue;let b=E.location.line-1;if(E.code===c.OmittedProductionDestination&&u.some(T=>T.code===E.code&&T.line===b))continue;if(E.code===c.UnknownEvent){if(P.has(b))continue;P.add(b)}let w=vo(t[b],E)||t[b].length-E.location.column+1;u.push(Ue(E.severity,b,E.location.column,w,E.message,E.code))}let A=l((E,b,w)=>{!p.has(w)&&!P.has(E)&&u.push(Fe("warning",E,b,w,`Unknown event type '${w}' \u2014 declare it in a slice or import it.`,ee.unknownEvent))},"checkEvent"),v=-1;for(let E=0;E<t.length;E++){let b=t[E],w=b.trim();if(n[E]||w.length===0)continue;let T=b.match(/^[ ]*(\t+)/);if(T&&u.push(Ue("warning",E,T[0].length-T[1].length+1,T[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",ee.tabIndentation)),v>=0){if(te(b)>v&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(w)){for(let U of w.split(/\s+/).filter(_=>_!=="or"))m.has(U)||u.push(Fe("warning",E,b,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy));continue}v=-1}let I=ky(t,n,E);I&&u.push(I);let j=w.match(/^slice\s+(\w+)/);j&&!ir.includes(j[1])&&u.push(Fe("error",E,b,j[1],`Unknown slice type '${j[1]}' \u2014 expected ${ir.join(", ")}.`,ee.unknownSliceType));let N=w.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!Bn.includes(N[1])&&u.push(Fe("error",E,b,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${Bn.join(", ")} or Enum.`,ee.unknownPrimitiveType));let L=w.match(/^authorize\s+(.*)$/);if(L){v=te(b);for(let U of L[1].split(/\s+/).filter(_=>_!=="or"&&_.length>0))m.has(U)||u.push(Fe("warning",E,b,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy))}let q=w.match(/^on\s+([A-Z]\w*)\s*$/);q&&A(E,b,q[1]);let V=w.match(/^produces\s+([A-Z]\w*)\s*$/);if(V&&!s.operationProductionLines?.has(E)&&A(E,b,V[1]),/^produces\s+when\b/.test(w)&&!s.operationProductionLines?.has(E))for(let U=E+1;U<t.length;U++){let _=t[U];if(!(n[U]||_.trim().length===0)){if(te(_)>te(b)){let ie=_.trim().match(/^([A-Z]\w*)\s*$/);ie&&A(U,_,ie[1])}break}}let K=w.match(/^unique\s+event\s+([A-Z]\w*)/);K&&A(E,b,K[1]);let J=w.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);J&&A(E,b,J[1]);for(let U of b.match(/\$identity\.[\w.]+/g)??[]){let _=U.substring(10).split(".")[0];kt.includes(_)||u.push(Fe("warning",E,b,U,`Unknown $identity property '${_}' \u2014 expected ${kt.join(", ")}.`,ee.unknownContextIdentityProperty))}for(let U of b.match(/\$context\.[\w.]+/g)??[]){let _=U.substring(9).split(".");tr.includes(_[0])?_[0]==="causedBy"&&_.length>1&&!nr.includes(_[1])?u.push(Fe("warning",E,b,U,`Unknown $context.causedBy property '${_[1]}' \u2014 expected ${nr.join(", ")}.`,ee.unknownContextCausedByProperty)):_[0]==="identity"&&_.length>1&&!kt.includes(_[1])&&u.push(Fe("warning",E,b,U,`Unknown $context.identity property '${_[1]}' \u2014 expected ${kt.join(", ")}.`,ee.unknownContextIdentityProperty)):u.push(Fe("warning",E,b,U,`Unknown $context path '${_.join(".")}' \u2014 expected one of ${tr.join(", ")}.`,ee.unknownContextPath))}}u.push(...Cy(t,n)),u.push(...kl(t,d,r,s.operationProductionLines));let k=t.map((E,b)=>({line:E,index:b})).filter(({line:E})=>/^\s*```(?:[a-z]+)?\s*$/.test(E));if(k.length%2===1){let E=k[k.length-1];u.push(Ue("error",E.index,1,E.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",ee.unclosedCodeBlock))}return u}l(uM,"validateLines");function by(t,e){let n=[];t=xt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!vt(o).isOptional&&!vt(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(Ue("information",s,te(t[s])+1,t[s].trim().length,`Plain 'produces ${o.name}' omits its destination \u2014 use 'for ${r[0].name}' to explicitly select the command's identifier.`,ee.omittedProductionDestination))}}return n}l(by,"validateProductionDestinations");function ky(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||jo(i,n))return;let o=te(i);if(!(!(o>0&&["module","feature"].includes(qo(t,e,n,o)[0]))&&!bl(i)))return Ue("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,ee.invalidFileImport)}l(ky,"validateImport");var Ey=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Cy(t,e){let n=[],i=l(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let d of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=d[0].substring(d[1]?.length??0),m=d[2];if(m.length===0){d[1]&&n.push(Ue("error",r,(d.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(lr("").expected)}.`,ee.missingEventContextPath));continue}let u=m.substring(1),y=lr(u),h=(d.index??0)+(d[1]?.length??0)+1;switch(y.status){case"missing":n.push(Ue("error",r,h,p.length,`'$eventContext.${u}' names no member - expected one of ${i(y.expected)}.`,ee.missingEventContextPath));break;case"unknownMember":n.push(Ue("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${u}' - expected one of ${i(y.expected)}.`,ee.unknownEventContextMember));break;case"unknownSubPath":{let x=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(Ue("warning",r,h,p.length,`Unknown event context path '$eventContext.${u}' - '${y.member?.name}' (${y.member?.type}) has ${x}.`,ee.unknownEventContextPath));break}case"belowCollection":n.push(Ue("error",r,h,p.length,`'$eventContext.${u}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,ee.eventContextPathBelowCollection));break}}let s=o.trim().match(Ey)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Fe("warning",r,o,s,`Dynamic dictionary key '$${a}' in '${s}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${a}' becomes the key.`,ee.unresolvedDynamicKeySource))}return n}l(Cy,"validateEventContextPaths");export{El as a,Py as b,Ay as c,No as d,wy as e,tr as f,nr as g,ir as h,Bn as i,Oy as j,Cl as k,Iy as l,Ot as m,rn as n,Ry as o,c as p,$e as q,Cr as r,ri as s,YO as t,FO as u,Ce as v,te as w,rr as x,we as y,qo as z,jy as A,Ly as B,xt as C,Gy as D,or as E,ar as F,sr as G,Pl as H,Fy as I,Uy as J,Wy as K,Al as L,wl as M,Xy as N,eh as O,th as P,nh as Q,ih as R,rh as S,oh as T,ah as U,sh as V,lh as W,ch as X,Il as Y,dh as Z,gh as _,xh as $,vh as aa,Tl as ba,$h as ca,bh as da,kh as ea,Eh as fa,Rl as ga,Ch as ha,Ph as ia,Ah as ja,wh as ka,Oh as la,Ih as ma,Th as na,Rh as oa,Dh as pa,Mh as qa,jh as ra,Lh as sa,Nh as ta,Fo as ua,Dl as va,qh as wa,Bh as xa,Yh as ya,Fh as za,Uh as Aa,Ml as Ba,Wh as Ca,jl as Da,Vh as Ea,zh as Fa,Qh as Ga,Gh as Ha,_h as Ia,aD as Ja,tn as Ka,Oo as La,dD as Ma,Io as Na,pD as Oa,vt as Pa,nn as Qa,Nn as Ra,Xi as Sa,vl as Ta,er as Ua,my as Va,PD as Wa,Do as Xa,Mo as Ya,MD as Za,ee as _a,bl as $a,jo as ab,BD as bb,YD as cb,uM as db,Cy as eb};
|
|
42
|
+
//# sourceMappingURL=chunk-OPU6YCT3.js.map
|