Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimmer/compiler

Package Overview
Dependencies
Maintainers
14
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/compiler - npm Package Compare versions

Comparing version 0.90.0 to 0.90.1

2

dist/prod/index.js

@@ -1,2 +0,2 @@

import{assertNever as e,dict as t,expect as r,isPresentArray as n,values as s,assert as a,NS_XMLNS as l,NS_XML as o,NS_XLINK as i,exhausted as c,mapPresentArray as u,unreachable as p,getLast as m,LOCAL_LOGGER as d,assertPresentArray as h}from"@glimmer/util";import{VariableResolutionContext as f,SexpOpcodes as k,WellKnownTagNames as y,WellKnownAttrNames as g}from"@glimmer/wire-format";import{node as A,generateSyntaxError as v,ASTv2 as w,KEYWORDS_TYPES as x,isKeyword as b,SourceSlice as E,src as C,maybeLoc as B,loc as S,normalize as O}from"@glimmer/syntax";import{CurriedTypes as H}from"@glimmer/vm";import{CurriedTypes as P}from"@glimmer/vm/index";let T=function(e){return e.Block="Block",e.Call="Call",e.Element="Element",e.AppendPath="AppendPath",e.AppendExpr="AppendExpr",e.Literal="Literal",e.Modifier="Modifier",e.DynamicComponent="DynamicComponent",e.Comment="Comment",e.Splat="Splat",e.Keyword="Keyword",e}({}),N=function(e){return e.Local="Local",e.Free="Free",e.Arg="Arg",e.Block="Block",e.This="This",e}({});function L(n){if(Array.isArray(n))return function(e){if(!Array.isArray(e))return!1;const t=e[0];if("number"==typeof t)switch(t){case U.Literal:case U.Get:case U.Concat:case U.HasBlock:case U.HasBlockParams:return!0;default:return!1}if("("===t[0])return!0;return!1}(n)?J(n):function(e){if(Array.isArray(e)&&"string"==typeof e[0])switch(e[0][0]){case"(":case"#":case"<":case"!":return!0;default:return!1}return!1}(n)?function(e){const n=e[0];switch(n[0]){case"(":{let t=null,r=null;return 3===e.length?(t=Z(e[1]),r=Q(e[2])):2===e.length&&(Array.isArray(e[1])?t=Z(e[1]):r=Q(e[1])),{kind:T.Call,head:G(n),params:t,hash:r,trusted:!1}}case"#":{const{head:t,params:r,hash:n,blocks:s,blockParams:a}=F(e);return{kind:T.Block,head:t,params:r,hash:n,blocks:s,blockParams:a}}case"!":{const t=e[0].slice(1),{params:r,hash:n,blocks:s,blockParams:a}=F(e);return{kind:T.Keyword,name:t,params:r,hash:n,blocks:s,blockParams:a}}case"<":{let s=t(),a=[];return 3===e.length?(s=R(e[1]),a=q(e[2])):2===e.length&&(Array.isArray(e[1])?a=q(e[1]):s=R(e[1])),{kind:T.Element,name:r(W(n),`BUG: expected ${n} to look like a tag name`),attrs:s,block:a}}default:throw new Error(`Unreachable ${JSON.stringify(e)} in normalizeSugaryArrayStatement`)}}(n):function(e){switch(e[0]){case U.Literal:return{kind:T.Literal,value:e[1]};case U.Append:return J(e[1],e[2]);case U.Modifier:return{kind:T.Modifier,params:Z(e[1]),hash:Q(e[2])};case U.DynamicComponent:return{kind:T.DynamicComponent,expr:K(e[1]),hash:Q(e[2]),block:q(e[3])};case U.Comment:return{kind:T.Comment,value:e[1]}}}(n);if("string"==typeof n)return I(D(n),!1);throw e(n)}function I(e,t){return e.type===Y.GetPath?{kind:T.AppendPath,path:e,trusted:t}:{kind:T.AppendExpr,expr:e,trusted:t}}function $(e){const t=/^(#|!)(.*)$/u.exec(e);if(null===t)throw new Error("Unexpected missing # in block head");return D(t[2])}function G(e){const t=/^\((.*)\)$/u.exec(e);if(null===t)throw new Error("Unexpected missing () in call head");return D(t[1])}function M(e,t=[]){const r=V(e);return n(t)?{type:Y.GetPath,path:{head:r,tail:t}}:{type:Y.GetVar,variable:r}}function D(e){const{kind:t,name:r}=V(e),[s,...a]=r.split("."),l={kind:t,name:s,mode:"loose"};return n(a)?{type:Y.GetPath,path:{head:l,tail:a}}:{type:Y.GetVar,variable:l}}function V(e){let t,r;if(/^this(?:\.|$)/u.test(e))return{kind:N.This,name:e,mode:"loose"};switch(e[0]){case"^":t=N.Free,r=e.slice(1);break;case"@":t=N.Arg,r=e.slice(1);break;case"&":t=N.Block,r=e.slice(1);break;default:t=N.Local,r=e}return{kind:t,name:r,mode:"loose"}}function F(e){const r=e[0];let n=t(),s=null,a=null,l=null;return 2===e.length?n=j(e[1]):3===e.length?(Array.isArray(e[1])?s=Z(e[1]):({hash:a,blockParams:l}=_(e[1])),n=j(e[2])):4===e.length&&(s=Z(e[1]),({hash:a,blockParams:l}=_(e[2])),n=j(e[3])),{head:$(r),params:s,hash:a,blockParams:l,blocks:n}}function _(e){if(null===e)return{hash:null,blockParams:null};let r=null,n=null;return function(e,t){Object.keys(e).forEach((r=>{const n=e[r];t(r,n)}))}(e,((e,s)=>{"as"===e?n=Array.isArray(s)?s:[s]:(r=r||t(),r[e]=K(s))})),{hash:r,blockParams:n}}function j(e){return Array.isArray(e)?{default:q(e)}:z(e,q)}function q(e){return e.map((e=>L(e)))}function R(e){return z(e,(e=>function(e){if("splat"===e)return{expr:T.Splat,trusted:!1};return{expr:K(e),trusted:!1}}(e).expr))}function z(e,r){const n=t();return Object.keys(e).forEach((t=>{n[t]=r(e[t],t)})),n}function W(e){const t=/^<([\d\-a-z][\d\-A-Za-z]*)>$/u.exec(e);return t?.[1]??null}let U=function(e){return e[e.Literal=0]="Literal",e[e.Comment=1]="Comment",e[e.Append=2]="Append",e[e.Modifier=3]="Modifier",e[e.DynamicComponent=4]="DynamicComponent",e[e.Get=5]="Get",e[e.Concat=6]="Concat",e[e.HasBlock=7]="HasBlock",e[e.HasBlockParams=8]="HasBlockParams",e}({}),Y=function(e){return e.Literal="Literal",e.Call="Call",e.GetPath="GetPath",e.GetVar="GetVar",e.Concat="Concat",e.HasBlock="HasBlock",e.HasBlockParams="HasBlockParams",e}({});function J(t,r=!1){if(null==t)return{expr:{type:Y.Literal,value:t},kind:T.AppendExpr,trusted:!1};if(Array.isArray(t))switch(t[0]){case U.Literal:return{expr:{type:Y.Literal,value:t[1]},kind:T.AppendExpr,trusted:!1};case U.Get:return I(M(t[1],t[2]),r);case U.Concat:return{expr:{type:Y.Concat,params:Z(t.slice(1))},kind:T.AppendExpr,trusted:r};case U.HasBlock:return{expr:{type:Y.HasBlock,name:t[1]},kind:T.AppendExpr,trusted:r};case U.HasBlockParams:return{expr:{type:Y.HasBlockParams,name:t[1]},kind:T.AppendExpr,trusted:r};default:if(X(t))return{expr:ee(t),kind:T.AppendExpr,trusted:r};throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return I(D(t),r);case"boolean":case"number":return{expr:{type:Y.Literal,value:t},kind:T.AppendExpr,trusted:!0};default:throw e(t)}}}function K(t){if(null==t)return{type:Y.Literal,value:t};if(Array.isArray(t))switch(t[0]){case U.Literal:return{type:Y.Literal,value:t[1]};case U.Get:return M(t[1],t[2]);case U.Concat:return{type:Y.Concat,params:Z(t.slice(1))};case U.HasBlock:return{type:Y.HasBlock,name:t[1]};case U.HasBlockParams:return{type:Y.HasBlockParams,name:t[1]};default:if(X(t))return ee(t);throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return D(t);case"boolean":case"number":return{type:Y.Literal,value:t};default:throw e(t)}}}function X(e){return"string"==typeof e[0]&&"("===e[0][0]}function Z(e){return e.map(K)}function Q(e){return null===e?null:z(e,K)}function ee(e){switch(e.length){case 1:return{type:Y.Call,head:G(e[0]),params:null,hash:null};case 2:return Array.isArray(e[1])?{type:Y.Call,head:G(e[0]),params:Z(e[1]),hash:null}:{type:Y.Call,head:G(e[0]),params:null,hash:Q(e[1])};case 3:return{type:Y.Call,head:G(e[0]),params:Z(e[1]),hash:Q(e[2])}}}class te{_freeVariables=[];_symbols=["this"];top=this;toSymbols(){return this._symbols.slice(1)}toUpvars(){return this._freeVariables}freeVar(e){return ne(this._freeVariables,e)}block(e){return this.symbol(e)}arg(e){return ne(this._symbols,e)}local(e){throw new Error(`No local ${e} was found. Maybe you meant ^${e} for upvar, or !${e} for keyword?`)}this(){return 0}hasLocal(e){return!1}symbol(e){return ne(this._symbols,e)}child(e){return new re(this,e)}}class re{locals=t();constructor(e,t){this.parent=e;for(let r of t)this.locals[r]=e.top.symbol(r)}get paramSymbols(){return s(this.locals)}get top(){return this.parent.top}freeVar(e){return this.parent.freeVar(e)}arg(e){return this.parent.arg(e)}block(e){return this.parent.block(e)}local(e){return e in this.locals?this.locals[e]:this.parent.local(e)}this(){return this.parent.this()}hasLocal(e){return e in this.locals||this.parent.hasLocal(e)}child(e){return new re(this,e)}}function ne(e,t){let r=e.indexOf(t);return-1===r?(r=e.length,e.push(t),r):r}function se(e){return new Error(`unimplemented ${e}`)}function ae(e,t){let r=[];return e.forEach((e=>r.push(...oe(L(e),t)))),r}function le(e,t){let r=[];return e.forEach((e=>r.push(...oe(e,t)))),r}function oe(t,r=new te){switch(t.kind){case T.AppendPath:return[[t.trusted?k.TrustingAppend:k.Append,Ae(t.path,r)]];case T.AppendExpr:return[[t.trusted?k.TrustingAppend:k.Append,ye(t.expr,t.trusted?"TrustedAppend":"Append",r)]];case T.Call:{let{head:e,params:n,hash:s,trusted:a}=t,l=n?we(n,r):null,o=s?be(s,r):null,i=ge(e,a?f.ResolveAsHelperHead:f.ResolveAsComponentOrHelperHead,r);return[[a?k.TrustingAppend:k.Append,[k.Call,i,l,o]]]}case T.Literal:return[[k.Append,t.value]];case T.Comment:return[[k.Comment,t.value]];case T.Block:{let e=function(e,t,r){let n=[],s=[];for(const[a,l]of Object.entries(e))if(n.push(a),"default"===a){let e=r.child(t||[]);s.push(Ee(l,e,e.paramSymbols))}else s.push(Ee(l,r,[]));return[n,s]}(t.blocks,t.blockParams,r),n=be(t.hash,r),s=we(t.params,r),a=ge(t.head,f.ResolveAsComponentHead,r);return[[k.Block,a,s,n,e]]}case T.Keyword:return[me(t,r)];case T.Element:return function({name:t,attrs:r,block:s},l){let o=[de(r)?[k.OpenElementWithSplat,t]:[k.OpenElement,t]];if(r){let{params:e,args:t}=function(e,t){let r=[],s=[],a=[];for(const[n,l]of Object.entries(e))l===T.Splat?r.push([k.AttrSplat,t.block("&attrs")]):"@"===n[0]?(s.push(n),a.push(ye(l,"Strict",t))):r.push(...fe(n,l,he(n),t));return{params:r,args:n(s)&&n(a)?[s,a]:null}}(r,l);o.push(...e),a(null===t,"Can't pass args to a simple element")}if(o.push([k.FlushElement]),Array.isArray(s))s.forEach((e=>o.push(...oe(e,l))));else if(null!==s)throw e(s);return o.push([k.CloseElement]),o}(t,r);case T.Modifier:throw se("modifier");case T.DynamicComponent:throw se("dynamic component");default:throw e(t)}}function ie(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[U.Literal,r]}function ce(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[U.Comment,r]}function ue(e){return String.fromCharCode(parseInt(e,16))}const pe="\n";function me(e,t){let{name:n}=e,s=we(e.params,t),a=t.child(e.blockParams||[]),l=Ee(e.blocks.default,a,a.paramSymbols),o=e.blocks.else?Ee(e.blocks.else,t,[]):null;switch(n){case"let":return[k.Let,r(s,"let requires params"),l];case"if":return[k.If,r(s,"if requires params")[0],l,o];case"each":{let n=e.hash?e.hash.key:null,a=n?ye(n,"Strict",t):null;return[k.Each,r(s,"if requires params")[0],a,l,o]}default:throw new Error("unimplemented keyword")}}function de(e){return null!==e&&Object.keys(e).some((t=>e[t]===T.Splat))}function he(e){if("xmlns"===e)return l;let t=/^([^:]*):([^:]*)$/u.exec(e);if(null===t)return null;switch(t[1]){case"xlink":return i;case"xml":return o;case"xmlns":return l}return null}function fe(e,t,r,n){if(t.type===Y.Literal){let n=t.value;if(!1===n)return[];if(!0===n)return[[k.StaticAttr,e,"",r??void 0]];if("string"==typeof n)return[[k.StaticAttr,e,n,r??void 0]];throw new Error(`Unexpected/unimplemented literal attribute ${JSON.stringify(n)}`)}return[[k.DynamicAttr,e,ye(t,"AttrValue",n),r??void 0]]}function ke(e,t){switch(e){case"Append":return t?"AppendBare":"AppendInvoke";case"TrustedAppend":return t?"TrustedAppendBare":"TrustedAppendInvoke";case"AttrValue":return t?"AttrValueBare":"AttrValueInvoke";default:return e}}function ye(t,r,n){switch(t.type){case Y.GetPath:return Ae(t,n);case Y.GetVar:return ve(t.variable,ke(r,!0),n);case Y.Concat:return[k.Concat,xe(t.params,n)];case Y.Call:{let e=we(t.params,n),s=be(t.hash,n),a=ge(t.head,"Strict"===r?"SubExpression":ke(r,!1),n);return[k.Call,a,e,s]}case Y.HasBlock:return[k.HasBlock,ve({kind:N.Block,name:t.name,mode:"loose"},f.Strict,n)];case Y.HasBlockParams:return[k.HasBlockParams,ve({kind:N.Block,name:t.name,mode:"loose"},f.Strict,n)];case Y.Literal:return void 0===t.value?[k.Undefined]:t.value;default:e(t)}}function ge(e,t,r){return e.type===Y.GetVar?ve(e.variable,t,r):Ae(e,r)}function Ae(e,t){return ve(e.path.head,f.Strict,t,e.path.tail)}function ve(e,t,r,n){let s,a=k.GetSymbol;if(e.kind===N.Free)a="Strict"===t?k.GetStrictKeyword:"AppendBare"===t||"AppendInvoke"===t?k.GetFreeAsComponentOrHelperHead:"TrustedAppendBare"===t||"TrustedAppendInvoke"===t||"AttrValueBare"===t||"AttrValueInvoke"===t||"SubExpression"===t?k.GetFreeAsHelperHead:function(e){switch(e){case f.Strict:return k.GetStrictKeyword;case f.ResolveAsComponentOrHelperHead:return k.GetFreeAsComponentOrHelperHead;case f.ResolveAsHelperHead:return k.GetFreeAsHelperHead;case f.ResolveAsModifierHead:return k.GetFreeAsModifierHead;case f.ResolveAsComponentHead:return k.GetFreeAsComponentHead;default:return c(e)}}(t),s=r.freeVar(e.name);else a=k.GetSymbol,s=function(e,t,r){switch(e){case N.Arg:return t.arg(r);case N.Block:return t.block(r);case N.Local:return t.local(r);case N.This:return t.this();default:return c(e)}}(e.kind,r,e.name);return void 0===n||0===n.length?[a,s]:[a,s,n]}function we(e,t){return null!==e&&n(e)?e.map((e=>ye(e,"Strict",t))):null}function xe(e,t){return e.map((e=>ye(e,"AttrValue",t)))}function be(e,t){if(null===e)return null;let r=[[],[]];for(const[n,s]of Object.entries(e))r[0].push(n),r[1].push(ye(s,"Strict",t));return r}function Ee(e,t,r=[]){return[le(e,t),r]}const Ce=!("undefined"==typeof window||!window.location||!/[&?]enable_local_should_log/u.test(window.location.search));class Be extends(A("Template").fields()){}class Se extends(A("InElement").fields()){}class Oe extends(A("Not").fields()){}class He extends(A("If").fields()){}class Pe extends(A("IfInline").fields()){}class Te extends(A("Each").fields()){}class Ne extends(A("Let").fields()){}class Le extends(A("WithDynamicVars").fields()){}class Ie extends(A("GetDynamicVar").fields()){}class $e extends(A("Log").fields()){}class Ge extends(A("InvokeComponent").fields()){}class Me extends(A("NamedBlocks").fields()){}class De extends(A("NamedBlock").fields()){}class Ve extends(A("AppendTrustedHTML").fields()){}class Fe extends(A("AppendTextNode").fields()){}class _e extends(A("AppendComment").fields()){}class je extends(A("Component").fields()){}class qe extends(A("StaticAttr").fields()){}class Re extends(A("DynamicAttr").fields()){}class ze extends(A("SimpleElement").fields()){}class We extends(A("ElementParameters").fields()){}class Ue extends(A("Yield").fields()){}class Ye extends(A("Debugger").fields()){}class Je extends(A("CallExpression").fields()){}class Ke extends(A("Modifier").fields()){}class Xe extends(A("InvokeBlock").fields()){}class Ze extends(A("SplatAttr").fields()){}class Qe extends(A("PathExpression").fields()){}class et extends(A("Missing").fields()){}class tt extends(A("InterpolateExpression").fields()){}class rt extends(A("HasBlock").fields()){}class nt extends(A("HasBlockParams").fields()){}class st extends(A("Curry").fields()){}class at extends(A("Positional").fields()){}class lt extends(A("NamedArguments").fields()){}class ot extends(A("NamedArgument").fields()){}class it extends(A("Args").fields()){}class ct extends(A("Tail").fields()){}class ut{constructor(e){this.list=e}toArray(){return this.list}map(e){let t=u(this.list,e);return new ut(t)}filter(e){let t=[];for(let r of this.list)e(r)&&t.push(r);return mt(t)}toPresentArray(){return this.list}into({ifPresent:e}){return e(this)}}class pt{list=[];map(e){return new pt}filter(e){return new pt}toArray(){return this.list}toPresentArray(){return null}into({ifEmpty:e}){return e()}}function mt(e){return n(e)?new ut(e):new pt}class dt{static all(...e){let t=[];for(let r of e){if(r.isErr)return r.cast();t.push(r.value)}return yt(t)}}const ht=dt;class ft extends dt{isOk=!0;isErr=!1;constructor(e){super(),this.value=e}expect(e){return this.value}ifOk(e){return e(this.value),this}andThen(e){return e(this.value)}mapOk(e){return yt(e(this.value))}ifErr(e){return this}mapErr(e){return this}}class kt extends dt{isOk=!1;isErr=!0;constructor(e){super(),this.reason=e}expect(e){throw new Error(e||"expected an Ok, got Err")}andThen(e){return this.cast()}mapOk(e){return this.cast()}ifOk(e){return this}mapErr(e){return gt(e(this.reason))}ifErr(e){return e(this.reason),this}cast(){return this}}function yt(e){return new ft(e)}function gt(e){return new kt(e)}class At{constructor(e=[]){this.items=e}add(e){this.items.push(e)}toArray(){let e=this.items.filter((e=>e instanceof kt))[0];return void 0!==e?e.cast():yt(this.items.map((e=>e.value)))}toOptionalList(){return this.toArray().mapOk((e=>mt(e)))}}function vt(e){return"Path"===e.callee.type}function wt(e){var t;if("Path"===(t=e).callee.type&&"Free"===t.callee.ref.type&&!w.isStrictResolution(t.callee.ref.resolution)&&!function(e){if("Path"===e.type){let{ref:t,tail:r}=e;return"Free"===t.type&&!w.isStrictResolution(t.resolution)&&0===r.length}return!1}(e.callee))throw v(`\`${xt(e.callee)}\` is not a valid name for a modifier`,e.loc)}function xt(e){switch(e.type){case"Literal":return JSON.stringify(e.value);case"Path":{let t=[bt(e.ref)];return t.push(...e.tail.map((e=>e.chars))),t.join(".")}case"Call":return`(${xt(e.callee)} ...)`;case"Interpolate":throw p("a concat statement cannot appear as the head of an expression")}}function bt(e){switch(e.type){case"Arg":return e.name.chars;case"Free":case"Local":return e.name;case"This":return"this"}}function Et(e){return"Path"===e.type&&"Free"===e.ref.type&&e.ref.name in x?new w.CallExpression({callee:e,args:w.Args.empty(e.loc),loc:e.loc}):e}const Ct=new class{visit(e,t){switch(e.type){case"Literal":return yt(this.Literal(e));case"Interpolate":return this.Interpolate(e,t);case"Path":return this.PathExpression(e);case"Call":{let r=Ut.translate(e,t);return null!==r?r:this.CallExpression(e,t)}}}visitList(e,t){return new At(e.map((e=>Ct.visit(e,t)))).toOptionalList()}PathExpression(e){let t=this.VariableReference(e.ref),{tail:r}=e;if(n(r)){let n=r[0].loc.extend(m(r).loc);return yt(new Qe({loc:e.loc,head:t,tail:new ct({loc:n,members:r})}))}return yt(t)}VariableReference(e){return e}Literal(e){return e}Interpolate(e,t){let r=e.parts.map(Et);return Ct.visitList(r,t).mapOk((t=>new tt({loc:e.loc,parts:t})))}CallExpression(e,t){if(vt(e))return ht.all(Ct.visit(e.callee,t),Ct.Args(e.args,t)).mapOk((([t,r])=>new Je({loc:e.loc,callee:t,args:r})));throw new Error("unimplemented subexpression at the head of a subexpression")}Args({positional:e,named:t,loc:r},n){return ht.all(this.Positional(e,n),this.NamedArguments(t,n)).mapOk((([e,t])=>new it({loc:r,positional:e,named:t})))}Positional(e,t){return Ct.visitList(e.exprs,t).mapOk((t=>new at({loc:e.loc,list:t})))}NamedArguments(e,t){let r=e.entries.map((e=>{let r=Et(e.value);return Ct.visit(r,t).mapOk((t=>new ot({loc:e.loc,key:e.name,value:t})))}));return new At(r).toOptionalList().mapOk((t=>new lt({loc:e.loc,entries:t})))}};class Bt{types;constructor(e,t,r){this.keyword=e,this.delegate=r;let n=new Set;for(let e of St[t])n.add(e);this.types=n}match(e){if(!this.types.has(e.type))return!1;let t=Ot(e);return null!==t&&"Path"===t.type&&"Free"===t.ref.type&&t.ref.name===this.keyword}translate(e,t){if(this.match(e)){let r=Ot(e);return null!==r&&"Path"===r.type&&r.tail.length>0?gt(v(`The \`${this.keyword}\` keyword was used incorrectly. It was used as \`${r.loc.asString()}\`, but it cannot be used with additional path segments. \n\nError caused by`,e.loc)):this.delegate.assert(e,t).andThen((r=>this.delegate.translate({node:e,state:t},r)))}return null}}const St={Call:["Call"],Block:["InvokeBlock"],Append:["AppendContent"],Modifier:["ElementModifier"]};function Ot(e){switch(e.type){case"Path":return e;case"AppendContent":return Ot(e.value);case"Call":case"InvokeBlock":case"ElementModifier":return e.callee;default:return null}}class Ht{_keywords=[];_type;constructor(e){this._type=e}kw(e,t){return this._keywords.push(function(e,t,r){return new Bt(e,t,r)}(e,this._type,t)),this}translate(e,t){for(let r of this._keywords){let n=r.translate(e,t);if(null!==n)return n}let r=Ot(e);if(r&&"Path"===r.type&&"Free"===r.ref.type&&b(r.ref.name)){let{name:t}=r.ref,n=this._type,s=x[t];if(!s.includes(n))return gt(v(`The \`${t}\` keyword was used incorrectly. It was used as ${Pt[n]}, but its valid usages are:\n\n${function(e,t){return t.map((t=>{switch(t){case"Append":return`- As an append statement, as in: {{${e}}}`;case"Block":return`- As a block statement, as in: {{#${e}}}{{/${e}}}`;case"Call":return`- As an expression, as in: (${e})`;case"Modifier":return`- As a modifier, as in: <div {{${e}}}></div>`;default:return c(t)}})).join("\n\n")}(t,s)}\n\nError caused by`,e.loc))}return null}}const Pt={Append:"an append statement",Block:"a block statement",Call:"a call expression",Modifier:"a modifier"};function Tt(e){return new Ht(e)}function Nt({assert:e,translate:t}){return{assert:e,translate:({node:e,state:r},n)=>t({node:e,state:r},n).mapOk((t=>new Fe({text:t,loc:e.loc})))}}const Lt={[H.Component]:"component",[H.Helper]:"helper",[H.Modifier]:"modifier"};function It(e){return(t,r)=>{let n=Lt[e],s=e===H.Component,{args:a}=t,l=a.nth(0);if(null===l)return gt(v(`(${n}) requires a ${n} definition or identifier as its first positional parameter, did not receive any parameters.`,a.loc));if("Literal"===l.type){if(s&&r.isStrict)return gt(v(`(${n}) cannot resolve string values in strict mode templates`,t.loc));if(!s)return gt(v(`(${n}) cannot resolve string values, you must pass a ${n} definition directly`,t.loc))}return a=new w.Args({positional:new w.PositionalArguments({exprs:a.positional.exprs.slice(1),loc:a.positional.loc}),named:a.named,loc:a.loc}),yt({definition:l,args:a})}}function $t(e){return({node:t,state:r},{definition:n,args:s})=>{let a=Ct.visit(n,r),l=Ct.Args(s,r);return ht.all(a,l).mapOk((([r,n])=>new st({loc:t.loc,curriedType:e,definition:r,args:n})))}}function Gt(e){return{assert:It(e),translate:$t(e)}}const Mt={assert:function(e){let t="AppendContent"===e.type?e.value:e,r="Call"===t.type?t.args.named:null,n="Call"===t.type?t.args.positional:null;if(r&&!r.isEmpty())return gt(v("(-get-dynamic-vars) does not take any named arguments",e.loc));let s=n?.nth(0);return s?n&&n.size>1?gt(v("(-get-dynamic-vars) only receives one positional arg",e.loc)):yt(s):gt(v("(-get-dynamic-vars) requires a var name to get",e.loc))},translate:function({node:e,state:t},r){return Ct.visit(r,t).mapOk((t=>new Ie({name:t,loc:e.loc})))}};function Dt(e){return t=>{let r="AppendContent"===t.type?t.value:t,n="Call"===r.type?r.args.named:null,s="Call"===r.type?r.args.positional:null;if(n&&!n.isEmpty())return gt(v(`(${e}) does not take any named arguments`,r.loc));if(!s||s.isEmpty())return yt(E.synthetic("default"));if(1===s.exprs.length){let t=s.exprs[0];return w.isLiteral(t,"string")?yt(t.toSlice()):gt(v(`(${e}) can only receive a string literal as its first argument`,r.loc))}return gt(v(`(${e}) only takes a single positional argument`,r.loc))}}function Vt(e){return({node:t,state:{scope:r}},n)=>yt("has-block"===e?new rt({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}):new nt({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}))}function Ft(e){return{assert:Dt(e),translate:Vt(e)}}function _t(e){return t=>{let r="unless"===e,n="AppendContent"===t.type?t.value:t,s="Call"===n.type?n.args.named:null,a="Call"===n.type?n.args.positional:null;if(s&&!s.isEmpty())return gt(v(`(${e}) cannot receive named parameters, received ${s.entries.map((e=>e.name.chars)).join(", ")}`,t.loc));let l=a?.nth(0);if(!a||!l)return gt(v(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Did not receive any parameters`,t.loc));let o=a.nth(1),i=a.nth(2);return null===o?gt(v(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Received only one parameter, the condition`,t.loc)):a.size>3?gt(v(`When used inline, (${e}) can receive a maximum of three positional parameters 1. the condition that determines the state of the (${e}), 2. the value to return if the condition is ${r?"false":"true"}, and 3. the value to return if the condition is ${r?"true":"false"}. Received ${a?.size??0} parameters`,t.loc)):yt({condition:l,truthy:o,falsy:i})}}function jt(e){let t="unless"===e;return({node:e,state:r},{condition:n,truthy:s,falsy:a})=>{let l=Ct.visit(n,r),o=Ct.visit(s,r),i=a?Ct.visit(a,r):yt(null);return ht.all(l,o,i).mapOk((([r,n,s])=>(t&&(r=new Oe({value:r,loc:e.loc})),new Pe({loc:e.loc,condition:r,truthy:n,falsy:s}))))}}function qt(e){return{assert:_t(e),translate:jt(e)}}const Rt={assert:function(e){let{args:{named:t,positional:r}}=e;return t&&!t.isEmpty()?gt(v("(log) does not take any named arguments",e.loc)):yt(r)},translate:function({node:e,state:t},r){return Ct.Positional(r,t).mapOk((t=>new $e({positional:t,loc:e.loc})))}},zt=Tt("Append").kw("has-block",Nt(Ft("has-block"))).kw("has-block-params",Nt(Ft("has-block-params"))).kw("-get-dynamic-var",Nt(Mt)).kw("log",Nt(Rt)).kw("if",Nt(qt("if"))).kw("unless",Nt(qt("unless"))).kw("yield",{assert(e){let{args:t}=e;if(t.named.isEmpty())return yt({target:C.SourceSpan.synthetic("default").toSlice(),positional:t.positional});{let e=t.named.get("to");return t.named.size>1||null===e?gt(v("yield only takes a single named argument: 'to'",t.named.loc)):w.isLiteral(e,"string")?yt({target:e.toSlice(),positional:t.positional}):gt(v("you can only yield to a literal string value",e.loc))}},translate:({node:e,state:t},{target:r,positional:n})=>Ct.Positional(n,t).mapOk((n=>new Ue({loc:e.loc,target:r,to:t.scope.allocateBlock(r.chars),positional:n})))}).kw("debugger",{assert(e){let{args:t}=e,{positional:r}=t;return t.isEmpty()?yt(void 0):r.isEmpty()?gt(v("debugger does not take any named arguments",e.loc)):gt(v("debugger does not take any positional arguments",e.loc))},translate:({node:e,state:{scope:t}})=>(t.setHasDebugger(),yt(new Ye({loc:e.loc,scope:t})))}).kw("component",{assert:It(H.Component),translate({node:e,state:t},{definition:r,args:n}){let s=Ct.visit(r,t),a=Ct.Args(n,t);return ht.all(s,a).mapOk((([t,r])=>new Ge({loc:e.loc,definition:t,args:r,blocks:null})))}}).kw("helper",{assert:It(H.Helper),translate({node:e,state:t},{definition:r,args:n}){let s=Ct.visit(r,t),a=Ct.Args(n,t);return ht.all(s,a).mapOk((([t,r])=>{let n=new Je({callee:t,args:r,loc:e.loc});return new Fe({loc:e.loc,text:n})}))}}),Wt=Tt("Block").kw("in-element",{assert(e){let{args:t}=e,r=t.get("guid");if(r)return gt(v("Cannot pass `guid` to `{{#in-element}}`",r.loc));let n=t.get("insertBefore"),s=t.nth(0);return null===s?gt(v("{{#in-element}} requires a target element as its first positional parameter",t.loc)):yt({insertBefore:n,destination:s})},translate({node:e,state:t},{insertBefore:r,destination:n}){let s=e.blocks.get("default"),a=cr.NamedBlock(s,t),l=Ct.visit(n,t);return ht.all(a,l).andThen((([n,s])=>r?Ct.visit(r,t).mapOk((e=>({body:n,destination:s,insertBefore:e}))):yt({body:n,destination:s,insertBefore:new et({loc:e.callee.loc.collapse("end")})}))).mapOk((({body:r,destination:n,insertBefore:s})=>new Se({loc:e.loc,block:r,insertBefore:s,guid:t.generateUniqueCursor(),destination:n})))}}).kw("if",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return gt(v(`{{#if}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return gt(v(`{{#if}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?gt(v("{{#if}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):yt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=Ct.visit(r,t),l=cr.NamedBlock(n,t),o=s?cr.NamedBlock(s,t):yt(null);return ht.all(a,l,o).mapOk((([t,r,n])=>new He({loc:e.loc,condition:t,block:r,inverse:n})))}}).kw("unless",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return gt(v(`{{#unless}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return gt(v(`{{#unless}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?gt(v("{{#unless}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):yt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=Ct.visit(r,t),l=cr.NamedBlock(n,t),o=s?cr.NamedBlock(s,t):yt(null);return ht.all(a,l,o).mapOk((([t,r,n])=>new He({loc:e.loc,condition:new Oe({value:t,loc:e.loc}),block:r,inverse:n})))}}).kw("each",{assert(e){let{args:t}=e;if(!t.named.entries.every((e=>"key"===e.name.chars)))return gt(v(`{{#each}} can only receive the 'key' named parameter, received ${t.named.entries.filter((e=>"key"!==e.name.chars)).map((e=>e.name.chars)).join(", ")}`,t.named.loc));if(t.positional.size>1)return gt(v(`{{#each}} can only receive one positional parameter, the collection being iterated. Received ${t.positional.size} parameters`,t.positional.loc));let r=t.nth(0),n=t.get("key");return null===r?gt(v("{{#each}} requires an iterable value to be passed as its first positional parameter, did not receive any parameters",t.loc)):yt({value:r,key:n})},translate({node:e,state:t},{value:r,key:n}){let s=e.blocks.get("default"),a=e.blocks.get("else"),l=Ct.visit(r,t),o=n?Ct.visit(n,t):yt(null),i=cr.NamedBlock(s,t),c=a?cr.NamedBlock(a,t):yt(null);return ht.all(l,o,i,c).mapOk((([t,r,n,s])=>new Te({loc:e.loc,value:t,key:r,block:n,inverse:s})))}}).kw("let",{assert(e){let{args:t}=e;return t.named.isEmpty()?0===t.positional.size?gt(v("{{#let}} requires at least one value as its first positional parameter, did not receive any parameters",t.positional.loc)):e.blocks.get("else")?gt(v("{{#let}} cannot receive an {{else}} block",t.positional.loc)):yt({positional:t.positional}):gt(v(`{{#let}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,t.named.loc))},translate({node:e,state:t},{positional:r}){let n=e.blocks.get("default"),s=Ct.Positional(r,t),a=cr.NamedBlock(n,t);return ht.all(s,a).mapOk((([t,r])=>new Ne({loc:e.loc,positional:t,block:r})))}}).kw("-with-dynamic-vars",{assert:e=>yt({named:e.args.named}),translate({node:e,state:t},{named:r}){let n=e.blocks.get("default"),s=Ct.NamedArguments(r,t),a=cr.NamedBlock(n,t);return ht.all(s,a).mapOk((([t,r])=>new Le({loc:e.loc,named:t,block:r})))}}).kw("component",{assert:It(H.Component),translate({node:e,state:t},{definition:r,args:n}){let s=Ct.visit(r,t),a=Ct.Args(n,t),l=cr.NamedBlocks(e.blocks,t);return ht.all(s,a,l).mapOk((([t,r,n])=>new Ge({loc:e.loc,definition:t,args:r,blocks:n})))}}),Ut=Tt("Call").kw("has-block",Ft("has-block")).kw("has-block-params",Ft("has-block-params")).kw("-get-dynamic-var",Mt).kw("log",Rt).kw("if",qt("if")).kw("unless",qt("unless")).kw("component",Gt(H.Component)).kw("helper",Gt(H.Helper)).kw("modifier",Gt(H.Modifier)),Yt=Tt("Modifier"),Jt="http://www.w3.org/1999/xlink",Kt="http://www.w3.org/XML/1998/namespace",Xt="http://www.w3.org/2000/xmlns/",Zt={"xlink:actuate":Jt,"xlink:arcrole":Jt,"xlink:href":Jt,"xlink:role":Jt,"xlink:show":Jt,"xlink:title":Jt,"xlink:type":Jt,"xml:base":Kt,"xml:lang":Kt,"xml:space":Kt,xmlns:Xt,"xmlns:xlink":Xt};const Qt={div:y.div,span:y.span,p:y.p,a:y.a},er=["div","span","p","a"];function tr(e){return"string"==typeof e?e:er[e]}const rr={class:g.class,id:g.id,value:g.value,name:g.name,type:g.type,style:g.style,href:g.href},nr=["class","id","value","name","type","style","href"];function sr(e){return rr[e]??e}function ar(e){return"string"==typeof e?e:nr[e]}class lr{delegate;constructor(e,t,r){this.element=e,this.state=r,this.delegate=t}toStatement(){return this.prepare().andThen((e=>this.delegate.toStatement(this,e)))}attr(e){let t=e.name,r=e.value,n=(s=t.chars,Zt[s]||void 0);var s;return w.isLiteral(r,"string")?yt(new qe({loc:e.loc,name:t,value:r.toSlice(),namespace:n,kind:{component:this.delegate.dynamicFeatures}})):Ct.visit(Et(r),this.state).mapOk((r=>{let s=e.trusting;return new Re({loc:e.loc,name:t,value:r,namespace:n,kind:{trusting:s,component:this.delegate.dynamicFeatures}})}))}modifier(e){(function(e){return!!vt(e)&&!e.args.isEmpty()})(e)&&wt(e);let t=Yt.translate(e,this.state);if(null!==t)return t;let r=Ct.visit(e.callee,this.state),n=Ct.Args(e.args,this.state);return ht.all(r,n).mapOk((([t,r])=>new Ke({loc:e.loc,callee:t,args:r})))}attrs(){let e=new At,t=new At,r=null,n=0===this.element.attrs.filter((e=>"SplatAttr"===e.type)).length;for(let t of this.element.attrs)"SplatAttr"===t.type?e.add(yt(new Ze({loc:t.loc,symbol:this.state.scope.allocateBlock("attrs")}))):"type"===t.name.chars&&n?r=t:e.add(this.attr(t));for(let e of this.element.componentArgs)t.add(this.delegate.arg(e,this));return r&&e.add(this.attr(r)),ht.all(t.toArray(),e.toArray()).mapOk((([e,t])=>({attrs:t,args:new lt({loc:B(e,C.SourceSpan.NON_EXISTENT),entries:mt(e)})})))}prepare(){let e=this.attrs(),t=new At(this.element.modifiers.map((e=>this.modifier(e)))).toArray();return ht.all(e,t).mapOk((([e,t])=>{let{attrs:r,args:n}=e,s=[...r,...t];return{args:n,params:new We({loc:B(s,C.SourceSpan.NON_EXISTENT),body:mt(s)})}}))}}class or{dynamicFeatures=!0;constructor(e,t){this.tag=e,this.element=t}arg(e,{state:t}){let r=e.name;return Ct.visit(Et(e.value),t).mapOk((t=>new ot({loc:e.loc,key:r,value:t})))}toStatement(e,{args:t,params:r}){let{element:n,state:s}=e;return this.blocks(s).mapOk((e=>new je({loc:n.loc,tag:this.tag,params:r,args:t,blocks:e})))}blocks(e){return cr.NamedBlocks(this.element.blocks,e)}}class ir{constructor(e,t,r){this.tag=e,this.element=t,this.dynamicFeatures=r}isComponent=!1;arg(e){return gt(v(`${e.name.chars} is not a valid attribute name. @arguments are only allowed on components, but the tag for this element (\`${this.tag.chars}\`) is a regular, non-component HTML element.`,e.loc))}toStatement(e,{params:t}){let{state:r,element:n}=e;return cr.visitList(this.element.body,r).mapOk((e=>new ze({loc:n.loc,tag:this.tag,params:t,body:e.toArray(),dynamicFeatures:this.dynamicFeatures})))}}const cr=new class{visitList(e,t){return new At(e.map((e=>cr.visit(e,t)))).toOptionalList().mapOk((e=>e.filter((e=>null!==e))))}visit(e,t){switch(e.type){case"GlimmerComment":return yt(null);case"AppendContent":return this.AppendContent(e,t);case"HtmlText":return yt(this.TextNode(e));case"HtmlComment":return yt(this.HtmlComment(e));case"InvokeBlock":return this.InvokeBlock(e,t);case"InvokeComponent":return this.Component(e,t);case"SimpleElement":return this.SimpleElement(e,t)}}InvokeBlock(e,t){let r=Wt.translate(e,t);if(null!==r)return r;let n=Ct.visit(e.callee,t),s=Ct.Args(e.args,t);return ht.all(n,s).andThen((([r,n])=>this.NamedBlocks(e.blocks,t).mapOk((t=>new Xe({loc:e.loc,head:r,args:n,blocks:t})))))}NamedBlocks(e,t){return new At(e.blocks.map((e=>this.NamedBlock(e,t)))).toArray().mapOk((t=>new Me({loc:e.loc,blocks:mt(t)})))}NamedBlock(e,t){return t.visitBlock(e.block).mapOk((t=>new De({loc:e.loc,name:e.name,body:t.toArray(),scope:e.block.scope})))}SimpleElement(e,t){return new lr(e,new ir(e.tag,e,function({attrs:e,modifiers:t}){return t.length>0||!!e.filter((e=>"SplatAttr"===e.type))[0]}(e)),t).toStatement()}Component(e,t){return Ct.visit(e.callee,t).andThen((r=>new lr(e,new or(r,e),t).toStatement()))}AppendContent(e,t){let r=zt.translate(e,t);return null!==r?r:Ct.visit(e.value,t).mapOk((t=>e.trusting?new Ve({loc:e.loc,html:t}):new Fe({loc:e.loc,text:t})))}TextNode(e){return new Fe({loc:e.loc,text:new w.LiteralExpression({loc:e.loc,value:e.chars})})}HtmlComment(e){return new _e({loc:e.loc,value:e.text})}};class ur{_currentScope;_cursorCount=0;constructor(e,t){this.isStrict=t,this._currentScope=e}generateUniqueCursor(){return`%cursor:${this._cursorCount++}%`}get scope(){return this._currentScope}visitBlock(e){let t=this._currentScope;this._currentScope=e.scope;try{return cr.visitList(e.body,this)}finally{this._currentScope=t}}}var pr=function(e){return e.Value="value",e.Component="component",e.Helper="helper",e.Modifier="modifier",e.ComponentOrHelper="component or helper",e}(pr||{});class mr{static validate(e){return new this(e).validate()}constructor(e){this.template=e}validate(){return this.Statements(this.template.body).mapOk((()=>this.template))}Statements(e){let t=yt(null);for(let r of e)t=t.andThen((()=>this.Statement(r)));return t}NamedBlocks({blocks:e}){let t=yt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedBlock(r)));return t}NamedBlock(e){return this.Statements(e.body)}Statement(e){switch(e.type){case"InElement":return this.InElement(e);case"Debugger":case"AppendComment":return yt(null);case"Yield":return this.Yield(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"AppendTextNode":return this.AppendTextNode(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e)}}Expressions(e){let t=yt(null);for(let r of e)t=t.andThen((()=>this.Expression(r)));return t}Expression(e,t=e,r){switch(e.type){case"Literal":case"Missing":case"This":case"Arg":case"Local":case"HasBlock":case"HasBlockParams":case"GetDynamicVar":return yt(null);case"PathExpression":return this.Expression(e.head,t,r);case"Free":return this.errorFor(e.name,t,r);case"InterpolateExpression":return this.InterpolateExpression(e,t,r);case"CallExpression":return this.CallExpression(e,t,r??pr.Helper);case"Not":return this.Expression(e.value,t,r);case"IfInline":return this.IfInline(e);case"Curry":return this.Curry(e);case"Log":return this.Log(e)}}Args(e){return this.Positional(e.positional).andThen((()=>this.NamedArguments(e.named)))}Positional(e,t){let r=yt(null),n=e.list.toArray();return r=1===n.length?this.Expression(n[0],t):this.Expressions(n),r}NamedArguments({entries:e}){let t=yt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedArgument(r)));return t}NamedArgument(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,pr.Helper):this.Expression(e.value,e)}ElementParameters({body:e}){let t=yt(null);for(let r of e.toArray())t=t.andThen((()=>this.ElementParameter(r)));return t}ElementParameter(e){switch(e.type){case"StaticAttr":case"SplatAttr":return yt(null);case"DynamicAttr":return this.DynamicAttr(e);case"Modifier":return this.Modifier(e)}}DynamicAttr(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,pr.Helper):this.Expression(e.value,e)}Modifier(e){return this.Expression(e.callee,e,pr.Modifier).andThen((()=>this.Args(e.args)))}InElement(e){return this.Expression(e.destination).andThen((()=>this.Expression(e.insertBefore))).andThen((()=>this.NamedBlock(e.block)))}Yield(e){return this.Positional(e.positional,e)}AppendTrustedHTML(e){return this.Expression(e.html,e)}AppendTextNode(e){return"CallExpression"===e.text.type?this.Expression(e.text,e,pr.ComponentOrHelper):this.Expression(e.text,e)}Component(e){return this.Expression(e.tag,e,pr.Component).andThen((()=>this.ElementParameters(e.params))).andThen((()=>this.NamedArguments(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}SimpleElement(e){return this.ElementParameters(e.params).andThen((()=>this.Statements(e.body)))}InvokeBlock(e){return this.Expression(e.head,e.head,pr.Component).andThen((()=>this.Args(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}If(e){return this.Expression(e.condition,e).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):yt(null)))}Each(e){return this.Expression(e.value,e).andThen((()=>e.key?this.Expression(e.key,e):yt(null))).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):yt(null)))}Let(e){return this.Positional(e.positional).andThen((()=>this.NamedBlock(e.block)))}WithDynamicVars(e){return this.NamedArguments(e.named).andThen((()=>this.NamedBlock(e.block)))}InvokeComponent(e){return this.Expression(e.definition,e,pr.Component).andThen((()=>this.Args(e.args))).andThen((()=>e.blocks?this.NamedBlocks(e.blocks):yt(null)))}InterpolateExpression(e,t,r){let n=e.parts.toArray();return 1===n.length?this.Expression(n[0],t,r):this.Expressions(n)}CallExpression(e,t,r){return this.Expression(e.callee,t,r).andThen((()=>this.Args(e.args)))}IfInline(e){return this.Expression(e.condition).andThen((()=>this.Expression(e.truthy))).andThen((()=>e.falsy?this.Expression(e.falsy):yt(null)))}Curry(e){let t;return t=e.curriedType===P.Component?pr.Component:e.curriedType===P.Helper?pr.Helper:pr.Modifier,this.Expression(e.definition,e,t).andThen((()=>this.Args(e.args)))}Log(e){return this.Positional(e.positional,e)}errorFor(e,t,r=pr.Value){return gt(v(`Attempted to resolve a ${r} in a strict mode template, but that value was not in scope: ${e}`,S(t)))}}class dr{upvars;symbols;constructor([e,t,r,n]){this.upvars=n,this.symbols=t}format(e){let t=[];for(let r of e[0])t.push(this.formatOpcode(r));return t}formatOpcode(e){if(!Array.isArray(e))return e;switch(e[0]){case k.Append:return["append",this.formatOpcode(e[1])];case k.TrustingAppend:return["trusting-append",this.formatOpcode(e[1])];case k.Block:return["block",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case k.InElement:return["in-element",e[1],this.formatOpcode(e[2]),e[3]?this.formatOpcode(e[3]):void 0];case k.OpenElement:return["open-element",tr(e[1])];case k.OpenElementWithSplat:return["open-element-with-splat",tr(e[1])];case k.CloseElement:return["close-element"];case k.FlushElement:return["flush-element"];case k.StaticAttr:return["static-attr",ar(e[1]),e[2],e[3]];case k.StaticComponentAttr:return["static-component-attr",ar(e[1]),e[2],e[3]];case k.DynamicAttr:return["dynamic-attr",ar(e[1]),this.formatOpcode(e[2]),e[3]];case k.ComponentAttr:return["component-attr",ar(e[1]),this.formatOpcode(e[2]),e[3]];case k.AttrSplat:return["attr-splat"];case k.Yield:return["yield",e[1],this.formatParams(e[2])];case k.DynamicArg:return["dynamic-arg",e[1],this.formatOpcode(e[2])];case k.StaticArg:return["static-arg",e[1],this.formatOpcode(e[2])];case k.TrustingDynamicAttr:return["trusting-dynamic-attr",ar(e[1]),this.formatOpcode(e[2]),e[3]];case k.TrustingComponentAttr:return["trusting-component-attr",ar(e[1]),this.formatOpcode(e[2]),e[3]];case k.Debugger:return["debugger",e[1]];case k.Comment:return["comment",e[1]];case k.Modifier:return["modifier",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case k.Component:return["component",this.formatOpcode(e[1]),this.formatElementParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case k.HasBlock:return["has-block",this.formatOpcode(e[1])];case k.HasBlockParams:return["has-block-params",this.formatOpcode(e[1])];case k.Curry:return["curry",this.formatOpcode(e[1]),this.formatCurryType(e[2]),this.formatParams(e[3]),this.formatHash(e[4])];case k.Undefined:return["undefined"];case k.Call:return["call",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case k.Concat:return["concat",this.formatParams(e[1])];case k.GetStrictKeyword:return["get-strict-free",this.upvars[e[1]],e[2]];case k.GetFreeAsComponentOrHelperHead:return["GetFreeAsComponentOrHelperHead",this.upvars[e[1]],e[2]];case k.GetFreeAsHelperHead:return["GetFreeAsHelperHead",this.upvars[e[1]],e[2]];case k.GetFreeAsComponentHead:return["GetFreeAsComponentHead",this.upvars[e[1]],e[2]];case k.GetFreeAsModifierHead:return["GetFreeAsModifierHead",this.upvars[e[1]],e[2]];case k.GetSymbol:return 0===e[1]?["get-symbol","this",e[2]]:["get-symbol",this.symbols[e[1]-1],e[2]];case k.GetLexicalSymbol:return["get-template-symbol",e[1],e[2]];case k.If:return["if",this.formatOpcode(e[1]),this.formatBlock(e[2]),e[3]?this.formatBlock(e[3]):null];case k.IfInline:return["if-inline"];case k.Not:return["not"];case k.Each:return["each",this.formatOpcode(e[1]),e[2]?this.formatOpcode(e[2]):null,this.formatBlock(e[3]),e[4]?this.formatBlock(e[4]):null];case k.Let:return["let",this.formatParams(e[1]),this.formatBlock(e[2])];case k.Log:return["log",this.formatParams(e[1])];case k.WithDynamicVars:return["-with-dynamic-vars",this.formatHash(e[1]),this.formatBlock(e[2])];case k.GetDynamicVar:return["-get-dynamic-vars",this.formatOpcode(e[1])];case k.InvokeComponent:return["component",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])]}}formatCurryType(e){switch(e){case H.Component:return"component";case H.Helper:return"helper";case H.Modifier:return"modifier";default:throw c(e)}}formatElementParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatHash(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatOpcode(e[1][n]),t)),t())}formatBlocks(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatBlock(e[1][n]),t)),t())}formatBlock(e){return{statements:e[0].map((e=>this.formatOpcode(e))),parameters:e[1]}}}const hr=new class{expr(e){switch(e.type){case"Missing":return;case"Literal":return this.Literal(e);case"CallExpression":return this.CallExpression(e);case"PathExpression":return this.PathExpression(e);case"Arg":return[k.GetSymbol,e.symbol];case"Local":return this.Local(e);case"This":return[k.GetSymbol,0];case"Free":return[e.resolution.resolution(),e.symbol];case"HasBlock":return this.HasBlock(e);case"HasBlockParams":return this.HasBlockParams(e);case"Curry":return this.Curry(e);case"Not":return this.Not(e);case"IfInline":return this.IfInline(e);case"InterpolateExpression":return this.InterpolateExpression(e);case"GetDynamicVar":return this.GetDynamicVar(e);case"Log":return this.Log(e)}}Literal({value:e}){return void 0===e?[k.Undefined]:e}Missing(){}HasBlock({symbol:e}){return[k.HasBlock,[k.GetSymbol,e]]}HasBlockParams({symbol:e}){return[k.HasBlockParams,[k.GetSymbol,e]]}Curry({definition:e,curriedType:t,args:r}){return[k.Curry,hr.expr(e),t,hr.Positional(r.positional),hr.NamedArguments(r.named)]}Local({isTemplateLocal:e,symbol:t}){return[e?k.GetLexicalSymbol:k.GetSymbol,t]}PathExpression({head:e,tail:t}){return[...hr.expr(e),hr.Tail(t)]}InterpolateExpression({parts:e}){return[k.Concat,e.map((e=>hr.expr(e))).toArray()]}CallExpression({callee:e,args:t}){return[k.Call,hr.expr(e),...hr.Args(t)]}Tail({members:e}){return u(e,(e=>e.chars))}Args({positional:e,named:t}){return[this.Positional(e),this.NamedArguments(t)]}Positional({list:e}){return e.map((e=>hr.expr(e))).toPresentArray()}NamedArgument({key:e,value:t}){return[e.chars,hr.expr(t)]}NamedArguments({entries:e}){let t=e.toArray();if(n(t)){let e=[],r=[];for(let n of t){let[t,s]=hr.NamedArgument(n);e.push(t),r.push(s)}return h(e),h(r),[e,r]}return null}Not({value:e}){return[k.Not,hr.expr(e)]}IfInline({condition:e,truthy:t,falsy:r}){let n=[k.IfInline,hr.expr(e),hr.expr(t)];return r&&n.push(hr.expr(r)),n}GetDynamicVar({name:e}){return[k.GetDynamicVar,hr.expr(e)]}Log({positional:e}){return[k.Log,this.Positional(e)]}};class fr{constructor(e){this.statements=e}toArray(){return this.statements}}const kr=new class{list(e){let t=[];for(let r of e){let e=kr.content(r);e&&e instanceof fr?t.push(...e.toArray()):t.push(e)}return t}content(e){return Ce&&d.log("encoding",e),this.visitContent(e)}visitContent(e){switch(e.type){case"Debugger":return[k.Debugger,e.scope.getDebugInfo()];case"AppendComment":return this.AppendComment(e);case"AppendTextNode":return this.AppendTextNode(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"Yield":return this.Yield(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InElement":return this.InElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e);default:return c(e)}}Yield({to:e,positional:t}){return[k.Yield,e,hr.Positional(t)]}InElement({guid:e,insertBefore:t,destination:r,block:n}){let s=kr.NamedBlock(n)[1],a=hr.expr(r),l=hr.expr(t);return void 0===l?[k.InElement,s,e,a]:[k.InElement,s,e,a,l]}InvokeBlock({head:e,args:t,blocks:r}){return[k.Block,hr.expr(e),...hr.Args(t),kr.NamedBlocks(r)]}AppendTrustedHTML({html:e}){return[k.TrustingAppend,hr.expr(e)]}AppendTextNode({text:e}){return[k.Append,hr.expr(e)]}AppendComment({value:e}){return[k.Comment,e.chars]}SimpleElement({tag:e,params:t,body:r,dynamicFeatures:n}){let s=n?k.OpenElementWithSplat:k.OpenElement;return new fr([[s,(a=e.chars,Qt[a]??a)],...kr.ElementParameters(t).toArray(),[k.FlushElement],...kr.list(r),[k.CloseElement]]);var a}Component({tag:e,params:t,args:r,blocks:n}){let s=hr.expr(e),a=kr.ElementParameters(t),l=hr.NamedArguments(r),o=kr.NamedBlocks(n);return[k.Component,s,a.toPresentArray(),l,o]}ElementParameters({body:e}){return e.map((e=>kr.ElementParameter(e)))}ElementParameter(e){switch(e.type){case"SplatAttr":return[k.AttrSplat,e.symbol];case"DynamicAttr":return[vr(e.kind),...gr(e)];case"StaticAttr":return[Ar(e.kind),...yr(e)];case"Modifier":return[k.Modifier,hr.expr(e.callee),...hr.Args(e.args)]}}NamedBlocks({blocks:e}){let t=[],r=[];for(let n of e.toArray()){let[e,s]=kr.NamedBlock(n);t.push(e),r.push(s)}return t.length>0?[t,r]:null}NamedBlock({name:e,body:t,scope:r}){let n=e.chars;return"inverse"===n&&(n="else"),[n,[kr.list(t),r.slots]]}If({condition:e,block:t,inverse:r}){return[k.If,hr.expr(e),kr.NamedBlock(t)[1],r?kr.NamedBlock(r)[1]:null]}Each({value:e,key:t,block:r,inverse:n}){return[k.Each,hr.expr(e),t?hr.expr(t):null,kr.NamedBlock(r)[1],n?kr.NamedBlock(n)[1]:null]}Let({positional:e,block:t}){return[k.Let,hr.Positional(e),kr.NamedBlock(t)[1]]}WithDynamicVars({named:e,block:t}){return[k.WithDynamicVars,hr.NamedArguments(e),kr.NamedBlock(t)[1]]}InvokeComponent({definition:e,args:t,blocks:r}){return[k.InvokeComponent,hr.expr(e),hr.Positional(t.positional),hr.NamedArguments(t.named),r?kr.NamedBlocks(r):null]}};function yr({name:e,value:t,namespace:r}){let n=[sr(e.chars),t.chars];return r&&n.push(r),n}function gr({name:e,value:t,namespace:r}){let n=[sr(e.chars),hr.expr(t)];return r&&n.push(r),n}function Ar(e){return e.component?k.StaticComponentAttr:k.StaticAttr}function vr(e){return e.component?e.trusting?k.TrustingComponentAttr:k.ComponentAttr:e.trusting?k.TrustingDynamicAttr:k.DynamicAttr}const wr=(()=>{const e="object"==typeof module&&"function"==typeof module.require?module.require:globalThis.require;if(e)try{const t=e("crypto"),r=e=>{const r=t.createHash("sha1");return r.update(e,"utf8"),r.digest("base64").substring(0,8)};return r("test"),r}catch{}return function(){return null}})(),xr={id:wr};function br(e,t=xr){const r=new C.Source(e??"",t.meta?.moduleName),[n,s]=O(r,{lexicalScope:()=>!1,...t}),a=function(e,t,r){let n=new ur(t.table,r);Ce&&(d.groupCollapsed("pass0: visiting"),d.log("symbols",t.table),d.log("source",e),d.groupEnd());let s=cr.visitList(t.body,n);Ce&&(s.isOk?d.log("-> pass0: out",s.value):d.log("-> pass0: error",s.reason));let a=s.mapOk((e=>new Be({loc:t.loc,scope:t.table,body:e.toArray()})));return r&&(a=a.andThen((e=>mr.validate(e)))),a}(r,n,t.strictMode??!1).mapOk((e=>function(e){let t=kr.list(e.body),r=e.scope,n=[t,r.symbols,r.hasEval,r.upvars];if(Ce){let e=new dr(n);d.log("-> ",t.map((t=>e.formatOpcode(t))))}return n}(e)));if(Ce&&d.log("Template ->",a),a.isOk)return[a.value,s];throw a.reason}const Er="796d24e6-2450-4fb0-8cdf-b65638b5ef70";function Cr(e,t=xr){const[r,n]=br(e,t),s=t.meta?.moduleName,a=t.id||wr,l=JSON.stringify(r),o={id:a(JSON.stringify(t.meta)+l),block:l,moduleName:s??"(unknown template module)",scope:Er,isStrictMode:t.strictMode??!1};0===n.length&&delete o.scope;let i=JSON.stringify(o);if(n.length>0){const e=`()=>[${n.join(",")}]`;i=i.replace(`"${Er}"`,e)}return i}export{U as Builder,pe as NEWLINE,te as ProgramSymbols,dr as WireFormatDebugger,oe as buildStatement,ae as buildStatements,ce as c,wr as defaultId,Cr as precompile,br as precompileJSON,ie as s,ue as unicode};
import{assertNever as e,dict as t,expect as r,isPresentArray as n,values as s,assert as a,NS_XMLNS as l,NS_XML as o,NS_XLINK as i,exhausted as c,mapPresentArray as u,unreachable as p,getLast as m,LOCAL_LOGGER as d,assertPresentArray as h}from"@glimmer/util";import{VariableResolutionContext as f,SexpOpcodes as k,WellKnownTagNames as y,WellKnownAttrNames as g}from"@glimmer/wire-format";import{node as A,generateSyntaxError as v,ASTv2 as w,KEYWORDS_TYPES as x,isKeyword as b,SourceSlice as E,src as C,maybeLoc as B,loc as S,normalize as O}from"@glimmer/syntax";import{CurriedTypes as H}from"@glimmer/vm";let P=function(e){return e.Block="Block",e.Call="Call",e.Element="Element",e.AppendPath="AppendPath",e.AppendExpr="AppendExpr",e.Literal="Literal",e.Modifier="Modifier",e.DynamicComponent="DynamicComponent",e.Comment="Comment",e.Splat="Splat",e.Keyword="Keyword",e}({}),T=function(e){return e.Local="Local",e.Free="Free",e.Arg="Arg",e.Block="Block",e.This="This",e}({});function N(n){if(Array.isArray(n))return function(e){if(!Array.isArray(e))return!1;const t=e[0];if("number"==typeof t)switch(t){case W.Literal:case W.Get:case W.Concat:case W.HasBlock:case W.HasBlockParams:return!0;default:return!1}if("("===t[0])return!0;return!1}(n)?Y(n):function(e){if(Array.isArray(e)&&"string"==typeof e[0])switch(e[0][0]){case"(":case"#":case"<":case"!":return!0;default:return!1}return!1}(n)?function(e){const n=e[0];switch(n[0]){case"(":{let t=null,r=null;return 3===e.length?(t=X(e[1]),r=Z(e[2])):2===e.length&&(Array.isArray(e[1])?t=X(e[1]):r=Z(e[1])),{kind:P.Call,head:$(n),params:t,hash:r,trusted:!1}}case"#":{const{head:t,params:r,hash:n,blocks:s,blockParams:a}=V(e);return{kind:P.Block,head:t,params:r,hash:n,blocks:s,blockParams:a}}case"!":{const t=e[0].slice(1),{params:r,hash:n,blocks:s,blockParams:a}=V(e);return{kind:P.Keyword,name:t,params:r,hash:n,blocks:s,blockParams:a}}case"<":{let s=t(),a=[];return 3===e.length?(s=q(e[1]),a=j(e[2])):2===e.length&&(Array.isArray(e[1])?a=j(e[1]):s=q(e[1])),{kind:P.Element,name:r(z(n),`BUG: expected ${n} to look like a tag name`),attrs:s,block:a}}default:throw new Error(`Unreachable ${JSON.stringify(e)} in normalizeSugaryArrayStatement`)}}(n):function(e){switch(e[0]){case W.Literal:return{kind:P.Literal,value:e[1]};case W.Append:return Y(e[1],e[2]);case W.Modifier:return{kind:P.Modifier,params:X(e[1]),hash:Z(e[2])};case W.DynamicComponent:return{kind:P.DynamicComponent,expr:J(e[1]),hash:Z(e[2]),block:j(e[3])};case W.Comment:return{kind:P.Comment,value:e[1]}}}(n);if("string"==typeof n)return L(M(n),!1);throw e(n)}function L(e,t){return e.type===U.GetPath?{kind:P.AppendPath,path:e,trusted:t}:{kind:P.AppendExpr,expr:e,trusted:t}}function I(e){const t=/^(#|!)(.*)$/u.exec(e);if(null===t)throw new Error("Unexpected missing # in block head");return M(t[2])}function $(e){const t=/^\((.*)\)$/u.exec(e);if(null===t)throw new Error("Unexpected missing () in call head");return M(t[1])}function G(e,t=[]){const r=D(e);return n(t)?{type:U.GetPath,path:{head:r,tail:t}}:{type:U.GetVar,variable:r}}function M(e){const{kind:t,name:r}=D(e),[s,...a]=r.split("."),l={kind:t,name:s,mode:"loose"};return n(a)?{type:U.GetPath,path:{head:l,tail:a}}:{type:U.GetVar,variable:l}}function D(e){let t,r;if(/^this(?:\.|$)/u.test(e))return{kind:T.This,name:e,mode:"loose"};switch(e[0]){case"^":t=T.Free,r=e.slice(1);break;case"@":t=T.Arg,r=e.slice(1);break;case"&":t=T.Block,r=e.slice(1);break;default:t=T.Local,r=e}return{kind:t,name:r,mode:"loose"}}function V(e){const r=e[0];let n=t(),s=null,a=null,l=null;return 2===e.length?n=_(e[1]):3===e.length?(Array.isArray(e[1])?s=X(e[1]):({hash:a,blockParams:l}=F(e[1])),n=_(e[2])):4===e.length&&(s=X(e[1]),({hash:a,blockParams:l}=F(e[2])),n=_(e[3])),{head:I(r),params:s,hash:a,blockParams:l,blocks:n}}function F(e){if(null===e)return{hash:null,blockParams:null};let r=null,n=null;return function(e,t){Object.keys(e).forEach((r=>{const n=e[r];t(r,n)}))}(e,((e,s)=>{"as"===e?n=Array.isArray(s)?s:[s]:(r=r||t(),r[e]=J(s))})),{hash:r,blockParams:n}}function _(e){return Array.isArray(e)?{default:j(e)}:R(e,j)}function j(e){return e.map((e=>N(e)))}function q(e){return R(e,(e=>function(e){if("splat"===e)return{expr:P.Splat,trusted:!1};return{expr:J(e),trusted:!1}}(e).expr))}function R(e,r){const n=t();return Object.keys(e).forEach((t=>{n[t]=r(e[t],t)})),n}function z(e){const t=/^<([\d\-a-z][\d\-A-Za-z]*)>$/u.exec(e);return t?.[1]??null}let W=function(e){return e[e.Literal=0]="Literal",e[e.Comment=1]="Comment",e[e.Append=2]="Append",e[e.Modifier=3]="Modifier",e[e.DynamicComponent=4]="DynamicComponent",e[e.Get=5]="Get",e[e.Concat=6]="Concat",e[e.HasBlock=7]="HasBlock",e[e.HasBlockParams=8]="HasBlockParams",e}({}),U=function(e){return e.Literal="Literal",e.Call="Call",e.GetPath="GetPath",e.GetVar="GetVar",e.Concat="Concat",e.HasBlock="HasBlock",e.HasBlockParams="HasBlockParams",e}({});function Y(t,r=!1){if(null==t)return{expr:{type:U.Literal,value:t},kind:P.AppendExpr,trusted:!1};if(Array.isArray(t))switch(t[0]){case W.Literal:return{expr:{type:U.Literal,value:t[1]},kind:P.AppendExpr,trusted:!1};case W.Get:return L(G(t[1],t[2]),r);case W.Concat:return{expr:{type:U.Concat,params:X(t.slice(1))},kind:P.AppendExpr,trusted:r};case W.HasBlock:return{expr:{type:U.HasBlock,name:t[1]},kind:P.AppendExpr,trusted:r};case W.HasBlockParams:return{expr:{type:U.HasBlockParams,name:t[1]},kind:P.AppendExpr,trusted:r};default:if(K(t))return{expr:Q(t),kind:P.AppendExpr,trusted:r};throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return L(M(t),r);case"boolean":case"number":return{expr:{type:U.Literal,value:t},kind:P.AppendExpr,trusted:!0};default:throw e(t)}}}function J(t){if(null==t)return{type:U.Literal,value:t};if(Array.isArray(t))switch(t[0]){case W.Literal:return{type:U.Literal,value:t[1]};case W.Get:return G(t[1],t[2]);case W.Concat:return{type:U.Concat,params:X(t.slice(1))};case W.HasBlock:return{type:U.HasBlock,name:t[1]};case W.HasBlockParams:return{type:U.HasBlockParams,name:t[1]};default:if(K(t))return Q(t);throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return M(t);case"boolean":case"number":return{type:U.Literal,value:t};default:throw e(t)}}}function K(e){return"string"==typeof e[0]&&"("===e[0][0]}function X(e){return e.map(J)}function Z(e){return null===e?null:R(e,J)}function Q(e){switch(e.length){case 1:return{type:U.Call,head:$(e[0]),params:null,hash:null};case 2:return Array.isArray(e[1])?{type:U.Call,head:$(e[0]),params:X(e[1]),hash:null}:{type:U.Call,head:$(e[0]),params:null,hash:Z(e[1])};case 3:return{type:U.Call,head:$(e[0]),params:X(e[1]),hash:Z(e[2])}}}class ee{_freeVariables=[];_symbols=["this"];top=this;toSymbols(){return this._symbols.slice(1)}toUpvars(){return this._freeVariables}freeVar(e){return re(this._freeVariables,e)}block(e){return this.symbol(e)}arg(e){return re(this._symbols,e)}local(e){throw new Error(`No local ${e} was found. Maybe you meant ^${e} for upvar, or !${e} for keyword?`)}this(){return 0}hasLocal(e){return!1}symbol(e){return re(this._symbols,e)}child(e){return new te(this,e)}}class te{locals=t();constructor(e,t){this.parent=e;for(let r of t)this.locals[r]=e.top.symbol(r)}get paramSymbols(){return s(this.locals)}get top(){return this.parent.top}freeVar(e){return this.parent.freeVar(e)}arg(e){return this.parent.arg(e)}block(e){return this.parent.block(e)}local(e){return e in this.locals?this.locals[e]:this.parent.local(e)}this(){return this.parent.this()}hasLocal(e){return e in this.locals||this.parent.hasLocal(e)}child(e){return new te(this,e)}}function re(e,t){let r=e.indexOf(t);return-1===r?(r=e.length,e.push(t),r):r}function ne(e){return new Error(`unimplemented ${e}`)}function se(e,t){let r=[];return e.forEach((e=>r.push(...le(N(e),t)))),r}function ae(e,t){let r=[];return e.forEach((e=>r.push(...le(e,t)))),r}function le(t,r=new ee){switch(t.kind){case P.AppendPath:return[[t.trusted?k.TrustingAppend:k.Append,ge(t.path,r)]];case P.AppendExpr:return[[t.trusted?k.TrustingAppend:k.Append,ke(t.expr,t.trusted?"TrustedAppend":"Append",r)]];case P.Call:{let{head:e,params:n,hash:s,trusted:a}=t,l=n?ve(n,r):null,o=s?xe(s,r):null,i=ye(e,a?f.ResolveAsHelperHead:f.ResolveAsComponentOrHelperHead,r);return[[a?k.TrustingAppend:k.Append,[k.Call,i,l,o]]]}case P.Literal:return[[k.Append,t.value]];case P.Comment:return[[k.Comment,t.value]];case P.Block:{let e=function(e,t,r){let n=[],s=[];for(const[a,l]of Object.entries(e))if(n.push(a),"default"===a){let e=r.child(t||[]);s.push(be(l,e,e.paramSymbols))}else s.push(be(l,r,[]));return[n,s]}(t.blocks,t.blockParams,r),n=xe(t.hash,r),s=ve(t.params,r),a=ye(t.head,f.ResolveAsComponentHead,r);return[[k.Block,a,s,n,e]]}case P.Keyword:return[pe(t,r)];case P.Element:return function({name:t,attrs:r,block:s},l){let o=[me(r)?[k.OpenElementWithSplat,t]:[k.OpenElement,t]];if(r){let{params:e,args:t}=function(e,t){let r=[],s=[],a=[];for(const[n,l]of Object.entries(e))l===P.Splat?r.push([k.AttrSplat,t.block("&attrs")]):"@"===n[0]?(s.push(n),a.push(ke(l,"Strict",t))):r.push(...he(n,l,de(n),t));return{params:r,args:n(s)&&n(a)?[s,a]:null}}(r,l);o.push(...e),a(null===t,"Can't pass args to a simple element")}if(o.push([k.FlushElement]),Array.isArray(s))s.forEach((e=>o.push(...le(e,l))));else if(null!==s)throw e(s);return o.push([k.CloseElement]),o}(t,r);case P.Modifier:throw ne("modifier");case P.DynamicComponent:throw ne("dynamic component");default:throw e(t)}}function oe(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[W.Literal,r]}function ie(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[W.Comment,r]}function ce(e){return String.fromCharCode(parseInt(e,16))}const ue="\n";function pe(e,t){let{name:n}=e,s=ve(e.params,t),a=t.child(e.blockParams||[]),l=be(e.blocks.default,a,a.paramSymbols),o=e.blocks.else?be(e.blocks.else,t,[]):null;switch(n){case"let":return[k.Let,r(s,"let requires params"),l];case"if":return[k.If,r(s,"if requires params")[0],l,o];case"each":{let n=e.hash?e.hash.key:null,a=n?ke(n,"Strict",t):null;return[k.Each,r(s,"if requires params")[0],a,l,o]}default:throw new Error("unimplemented keyword")}}function me(e){return null!==e&&Object.keys(e).some((t=>e[t]===P.Splat))}function de(e){if("xmlns"===e)return l;let t=/^([^:]*):([^:]*)$/u.exec(e);if(null===t)return null;switch(t[1]){case"xlink":return i;case"xml":return o;case"xmlns":return l}return null}function he(e,t,r,n){if(t.type===U.Literal){let n=t.value;if(!1===n)return[];if(!0===n)return[[k.StaticAttr,e,"",r??void 0]];if("string"==typeof n)return[[k.StaticAttr,e,n,r??void 0]];throw new Error(`Unexpected/unimplemented literal attribute ${JSON.stringify(n)}`)}return[[k.DynamicAttr,e,ke(t,"AttrValue",n),r??void 0]]}function fe(e,t){switch(e){case"Append":return t?"AppendBare":"AppendInvoke";case"TrustedAppend":return t?"TrustedAppendBare":"TrustedAppendInvoke";case"AttrValue":return t?"AttrValueBare":"AttrValueInvoke";default:return e}}function ke(t,r,n){switch(t.type){case U.GetPath:return ge(t,n);case U.GetVar:return Ae(t.variable,fe(r,!0),n);case U.Concat:return[k.Concat,we(t.params,n)];case U.Call:{let e=ve(t.params,n),s=xe(t.hash,n),a=ye(t.head,"Strict"===r?"SubExpression":fe(r,!1),n);return[k.Call,a,e,s]}case U.HasBlock:return[k.HasBlock,Ae({kind:T.Block,name:t.name,mode:"loose"},f.Strict,n)];case U.HasBlockParams:return[k.HasBlockParams,Ae({kind:T.Block,name:t.name,mode:"loose"},f.Strict,n)];case U.Literal:return void 0===t.value?[k.Undefined]:t.value;default:e(t)}}function ye(e,t,r){return e.type===U.GetVar?Ae(e.variable,t,r):ge(e,r)}function ge(e,t){return Ae(e.path.head,f.Strict,t,e.path.tail)}function Ae(e,t,r,n){let s,a=k.GetSymbol;if(e.kind===T.Free)a="Strict"===t?k.GetStrictKeyword:"AppendBare"===t||"AppendInvoke"===t?k.GetFreeAsComponentOrHelperHead:"TrustedAppendBare"===t||"TrustedAppendInvoke"===t||"AttrValueBare"===t||"AttrValueInvoke"===t||"SubExpression"===t?k.GetFreeAsHelperHead:function(e){switch(e){case f.Strict:return k.GetStrictKeyword;case f.ResolveAsComponentOrHelperHead:return k.GetFreeAsComponentOrHelperHead;case f.ResolveAsHelperHead:return k.GetFreeAsHelperHead;case f.ResolveAsModifierHead:return k.GetFreeAsModifierHead;case f.ResolveAsComponentHead:return k.GetFreeAsComponentHead;default:return c(e)}}(t),s=r.freeVar(e.name);else a=k.GetSymbol,s=function(e,t,r){switch(e){case T.Arg:return t.arg(r);case T.Block:return t.block(r);case T.Local:return t.local(r);case T.This:return t.this();default:return c(e)}}(e.kind,r,e.name);return void 0===n||0===n.length?[a,s]:[a,s,n]}function ve(e,t){return null!==e&&n(e)?e.map((e=>ke(e,"Strict",t))):null}function we(e,t){return e.map((e=>ke(e,"AttrValue",t)))}function xe(e,t){if(null===e)return null;let r=[[],[]];for(const[n,s]of Object.entries(e))r[0].push(n),r[1].push(ke(s,"Strict",t));return r}function be(e,t,r=[]){return[ae(e,t),r]}const Ee=!("undefined"==typeof window||!window.location||!/[&?]enable_local_should_log/u.test(window.location.search));class Ce extends(A("Template").fields()){}class Be extends(A("InElement").fields()){}class Se extends(A("Not").fields()){}class Oe extends(A("If").fields()){}class He extends(A("IfInline").fields()){}class Pe extends(A("Each").fields()){}class Te extends(A("Let").fields()){}class Ne extends(A("WithDynamicVars").fields()){}class Le extends(A("GetDynamicVar").fields()){}class Ie extends(A("Log").fields()){}class $e extends(A("InvokeComponent").fields()){}class Ge extends(A("NamedBlocks").fields()){}class Me extends(A("NamedBlock").fields()){}class De extends(A("AppendTrustedHTML").fields()){}class Ve extends(A("AppendTextNode").fields()){}class Fe extends(A("AppendComment").fields()){}class _e extends(A("Component").fields()){}class je extends(A("StaticAttr").fields()){}class qe extends(A("DynamicAttr").fields()){}class Re extends(A("SimpleElement").fields()){}class ze extends(A("ElementParameters").fields()){}class We extends(A("Yield").fields()){}class Ue extends(A("Debugger").fields()){}class Ye extends(A("CallExpression").fields()){}class Je extends(A("Modifier").fields()){}class Ke extends(A("InvokeBlock").fields()){}class Xe extends(A("SplatAttr").fields()){}class Ze extends(A("PathExpression").fields()){}class Qe extends(A("Missing").fields()){}class et extends(A("InterpolateExpression").fields()){}class tt extends(A("HasBlock").fields()){}class rt extends(A("HasBlockParams").fields()){}class nt extends(A("Curry").fields()){}class st extends(A("Positional").fields()){}class at extends(A("NamedArguments").fields()){}class lt extends(A("NamedArgument").fields()){}class ot extends(A("Args").fields()){}class it extends(A("Tail").fields()){}class ct{constructor(e){this.list=e}toArray(){return this.list}map(e){let t=u(this.list,e);return new ct(t)}filter(e){let t=[];for(let r of this.list)e(r)&&t.push(r);return pt(t)}toPresentArray(){return this.list}into({ifPresent:e}){return e(this)}}class ut{list=[];map(e){return new ut}filter(e){return new ut}toArray(){return this.list}toPresentArray(){return null}into({ifEmpty:e}){return e()}}function pt(e){return n(e)?new ct(e):new ut}class mt{static all(...e){let t=[];for(let r of e){if(r.isErr)return r.cast();t.push(r.value)}return kt(t)}}const dt=mt;class ht extends mt{isOk=!0;isErr=!1;constructor(e){super(),this.value=e}expect(e){return this.value}ifOk(e){return e(this.value),this}andThen(e){return e(this.value)}mapOk(e){return kt(e(this.value))}ifErr(e){return this}mapErr(e){return this}}class ft extends mt{isOk=!1;isErr=!0;constructor(e){super(),this.reason=e}expect(e){throw new Error(e||"expected an Ok, got Err")}andThen(e){return this.cast()}mapOk(e){return this.cast()}ifOk(e){return this}mapErr(e){return yt(e(this.reason))}ifErr(e){return e(this.reason),this}cast(){return this}}function kt(e){return new ht(e)}function yt(e){return new ft(e)}class gt{constructor(e=[]){this.items=e}add(e){this.items.push(e)}toArray(){let e=this.items.filter((e=>e instanceof ft))[0];return void 0!==e?e.cast():kt(this.items.map((e=>e.value)))}toOptionalList(){return this.toArray().mapOk((e=>pt(e)))}}function At(e){return"Path"===e.callee.type}function vt(e){var t;if("Path"===(t=e).callee.type&&"Free"===t.callee.ref.type&&!w.isStrictResolution(t.callee.ref.resolution)&&!function(e){if("Path"===e.type){let{ref:t,tail:r}=e;return"Free"===t.type&&!w.isStrictResolution(t.resolution)&&0===r.length}return!1}(e.callee))throw v(`\`${wt(e.callee)}\` is not a valid name for a modifier`,e.loc)}function wt(e){switch(e.type){case"Literal":return JSON.stringify(e.value);case"Path":{let t=[xt(e.ref)];return t.push(...e.tail.map((e=>e.chars))),t.join(".")}case"Call":return`(${wt(e.callee)} ...)`;case"Interpolate":throw p("a concat statement cannot appear as the head of an expression")}}function xt(e){switch(e.type){case"Arg":return e.name.chars;case"Free":case"Local":return e.name;case"This":return"this"}}function bt(e){return"Path"===e.type&&"Free"===e.ref.type&&e.ref.name in x?new w.CallExpression({callee:e,args:w.Args.empty(e.loc),loc:e.loc}):e}const Et=new class{visit(e,t){switch(e.type){case"Literal":return kt(this.Literal(e));case"Interpolate":return this.Interpolate(e,t);case"Path":return this.PathExpression(e);case"Call":{let r=Wt.translate(e,t);return null!==r?r:this.CallExpression(e,t)}}}visitList(e,t){return new gt(e.map((e=>Et.visit(e,t)))).toOptionalList()}PathExpression(e){let t=this.VariableReference(e.ref),{tail:r}=e;if(n(r)){let n=r[0].loc.extend(m(r).loc);return kt(new Ze({loc:e.loc,head:t,tail:new it({loc:n,members:r})}))}return kt(t)}VariableReference(e){return e}Literal(e){return e}Interpolate(e,t){let r=e.parts.map(bt);return Et.visitList(r,t).mapOk((t=>new et({loc:e.loc,parts:t})))}CallExpression(e,t){if(At(e))return dt.all(Et.visit(e.callee,t),Et.Args(e.args,t)).mapOk((([t,r])=>new Ye({loc:e.loc,callee:t,args:r})));throw new Error("unimplemented subexpression at the head of a subexpression")}Args({positional:e,named:t,loc:r},n){return dt.all(this.Positional(e,n),this.NamedArguments(t,n)).mapOk((([e,t])=>new ot({loc:r,positional:e,named:t})))}Positional(e,t){return Et.visitList(e.exprs,t).mapOk((t=>new st({loc:e.loc,list:t})))}NamedArguments(e,t){let r=e.entries.map((e=>{let r=bt(e.value);return Et.visit(r,t).mapOk((t=>new lt({loc:e.loc,key:e.name,value:t})))}));return new gt(r).toOptionalList().mapOk((t=>new at({loc:e.loc,entries:t})))}};class Ct{types;constructor(e,t,r){this.keyword=e,this.delegate=r;let n=new Set;for(let e of Bt[t])n.add(e);this.types=n}match(e){if(!this.types.has(e.type))return!1;let t=St(e);return null!==t&&"Path"===t.type&&"Free"===t.ref.type&&t.ref.name===this.keyword}translate(e,t){if(this.match(e)){let r=St(e);return null!==r&&"Path"===r.type&&r.tail.length>0?yt(v(`The \`${this.keyword}\` keyword was used incorrectly. It was used as \`${r.loc.asString()}\`, but it cannot be used with additional path segments. \n\nError caused by`,e.loc)):this.delegate.assert(e,t).andThen((r=>this.delegate.translate({node:e,state:t},r)))}return null}}const Bt={Call:["Call"],Block:["InvokeBlock"],Append:["AppendContent"],Modifier:["ElementModifier"]};function St(e){switch(e.type){case"Path":return e;case"AppendContent":return St(e.value);case"Call":case"InvokeBlock":case"ElementModifier":return e.callee;default:return null}}class Ot{_keywords=[];_type;constructor(e){this._type=e}kw(e,t){return this._keywords.push(function(e,t,r){return new Ct(e,t,r)}(e,this._type,t)),this}translate(e,t){for(let r of this._keywords){let n=r.translate(e,t);if(null!==n)return n}let r=St(e);if(r&&"Path"===r.type&&"Free"===r.ref.type&&b(r.ref.name)){let{name:t}=r.ref,n=this._type,s=x[t];if(!s.includes(n))return yt(v(`The \`${t}\` keyword was used incorrectly. It was used as ${Ht[n]}, but its valid usages are:\n\n${function(e,t){return t.map((t=>{switch(t){case"Append":return`- As an append statement, as in: {{${e}}}`;case"Block":return`- As a block statement, as in: {{#${e}}}{{/${e}}}`;case"Call":return`- As an expression, as in: (${e})`;case"Modifier":return`- As a modifier, as in: <div {{${e}}}></div>`;default:return c(t)}})).join("\n\n")}(t,s)}\n\nError caused by`,e.loc))}return null}}const Ht={Append:"an append statement",Block:"a block statement",Call:"a call expression",Modifier:"a modifier"};function Pt(e){return new Ot(e)}function Tt({assert:e,translate:t}){return{assert:e,translate:({node:e,state:r},n)=>t({node:e,state:r},n).mapOk((t=>new Ve({text:t,loc:e.loc})))}}const Nt={[H.Component]:"component",[H.Helper]:"helper",[H.Modifier]:"modifier"};function Lt(e){return(t,r)=>{let n=Nt[e],s=e===H.Component,{args:a}=t,l=a.nth(0);if(null===l)return yt(v(`(${n}) requires a ${n} definition or identifier as its first positional parameter, did not receive any parameters.`,a.loc));if("Literal"===l.type){if(s&&r.isStrict)return yt(v(`(${n}) cannot resolve string values in strict mode templates`,t.loc));if(!s)return yt(v(`(${n}) cannot resolve string values, you must pass a ${n} definition directly`,t.loc))}return a=new w.Args({positional:new w.PositionalArguments({exprs:a.positional.exprs.slice(1),loc:a.positional.loc}),named:a.named,loc:a.loc}),kt({definition:l,args:a})}}function It(e){return({node:t,state:r},{definition:n,args:s})=>{let a=Et.visit(n,r),l=Et.Args(s,r);return dt.all(a,l).mapOk((([r,n])=>new nt({loc:t.loc,curriedType:e,definition:r,args:n})))}}function $t(e){return{assert:Lt(e),translate:It(e)}}const Gt={assert:function(e){let t="AppendContent"===e.type?e.value:e,r="Call"===t.type?t.args.named:null,n="Call"===t.type?t.args.positional:null;if(r&&!r.isEmpty())return yt(v("(-get-dynamic-vars) does not take any named arguments",e.loc));let s=n?.nth(0);return s?n&&n.size>1?yt(v("(-get-dynamic-vars) only receives one positional arg",e.loc)):kt(s):yt(v("(-get-dynamic-vars) requires a var name to get",e.loc))},translate:function({node:e,state:t},r){return Et.visit(r,t).mapOk((t=>new Le({name:t,loc:e.loc})))}};function Mt(e){return t=>{let r="AppendContent"===t.type?t.value:t,n="Call"===r.type?r.args.named:null,s="Call"===r.type?r.args.positional:null;if(n&&!n.isEmpty())return yt(v(`(${e}) does not take any named arguments`,r.loc));if(!s||s.isEmpty())return kt(E.synthetic("default"));if(1===s.exprs.length){let t=s.exprs[0];return w.isLiteral(t,"string")?kt(t.toSlice()):yt(v(`(${e}) can only receive a string literal as its first argument`,r.loc))}return yt(v(`(${e}) only takes a single positional argument`,r.loc))}}function Dt(e){return({node:t,state:{scope:r}},n)=>kt("has-block"===e?new tt({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}):new rt({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}))}function Vt(e){return{assert:Mt(e),translate:Dt(e)}}function Ft(e){return t=>{let r="unless"===e,n="AppendContent"===t.type?t.value:t,s="Call"===n.type?n.args.named:null,a="Call"===n.type?n.args.positional:null;if(s&&!s.isEmpty())return yt(v(`(${e}) cannot receive named parameters, received ${s.entries.map((e=>e.name.chars)).join(", ")}`,t.loc));let l=a?.nth(0);if(!a||!l)return yt(v(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Did not receive any parameters`,t.loc));let o=a.nth(1),i=a.nth(2);return null===o?yt(v(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Received only one parameter, the condition`,t.loc)):a.size>3?yt(v(`When used inline, (${e}) can receive a maximum of three positional parameters 1. the condition that determines the state of the (${e}), 2. the value to return if the condition is ${r?"false":"true"}, and 3. the value to return if the condition is ${r?"true":"false"}. Received ${a?.size??0} parameters`,t.loc)):kt({condition:l,truthy:o,falsy:i})}}function _t(e){let t="unless"===e;return({node:e,state:r},{condition:n,truthy:s,falsy:a})=>{let l=Et.visit(n,r),o=Et.visit(s,r),i=a?Et.visit(a,r):kt(null);return dt.all(l,o,i).mapOk((([r,n,s])=>(t&&(r=new Se({value:r,loc:e.loc})),new He({loc:e.loc,condition:r,truthy:n,falsy:s}))))}}function jt(e){return{assert:Ft(e),translate:_t(e)}}const qt={assert:function(e){let{args:{named:t,positional:r}}=e;return t&&!t.isEmpty()?yt(v("(log) does not take any named arguments",e.loc)):kt(r)},translate:function({node:e,state:t},r){return Et.Positional(r,t).mapOk((t=>new Ie({positional:t,loc:e.loc})))}},Rt=Pt("Append").kw("has-block",Tt(Vt("has-block"))).kw("has-block-params",Tt(Vt("has-block-params"))).kw("-get-dynamic-var",Tt(Gt)).kw("log",Tt(qt)).kw("if",Tt(jt("if"))).kw("unless",Tt(jt("unless"))).kw("yield",{assert(e){let{args:t}=e;if(t.named.isEmpty())return kt({target:C.SourceSpan.synthetic("default").toSlice(),positional:t.positional});{let e=t.named.get("to");return t.named.size>1||null===e?yt(v("yield only takes a single named argument: 'to'",t.named.loc)):w.isLiteral(e,"string")?kt({target:e.toSlice(),positional:t.positional}):yt(v("you can only yield to a literal string value",e.loc))}},translate:({node:e,state:t},{target:r,positional:n})=>Et.Positional(n,t).mapOk((n=>new We({loc:e.loc,target:r,to:t.scope.allocateBlock(r.chars),positional:n})))}).kw("debugger",{assert(e){let{args:t}=e,{positional:r}=t;return t.isEmpty()?kt(void 0):r.isEmpty()?yt(v("debugger does not take any named arguments",e.loc)):yt(v("debugger does not take any positional arguments",e.loc))},translate:({node:e,state:{scope:t}})=>(t.setHasDebugger(),kt(new Ue({loc:e.loc,scope:t})))}).kw("component",{assert:Lt(H.Component),translate({node:e,state:t},{definition:r,args:n}){let s=Et.visit(r,t),a=Et.Args(n,t);return dt.all(s,a).mapOk((([t,r])=>new $e({loc:e.loc,definition:t,args:r,blocks:null})))}}).kw("helper",{assert:Lt(H.Helper),translate({node:e,state:t},{definition:r,args:n}){let s=Et.visit(r,t),a=Et.Args(n,t);return dt.all(s,a).mapOk((([t,r])=>{let n=new Ye({callee:t,args:r,loc:e.loc});return new Ve({loc:e.loc,text:n})}))}}),zt=Pt("Block").kw("in-element",{assert(e){let{args:t}=e,r=t.get("guid");if(r)return yt(v("Cannot pass `guid` to `{{#in-element}}`",r.loc));let n=t.get("insertBefore"),s=t.nth(0);return null===s?yt(v("{{#in-element}} requires a target element as its first positional parameter",t.loc)):kt({insertBefore:n,destination:s})},translate({node:e,state:t},{insertBefore:r,destination:n}){let s=e.blocks.get("default"),a=ir.NamedBlock(s,t),l=Et.visit(n,t);return dt.all(a,l).andThen((([n,s])=>r?Et.visit(r,t).mapOk((e=>({body:n,destination:s,insertBefore:e}))):kt({body:n,destination:s,insertBefore:new Qe({loc:e.callee.loc.collapse("end")})}))).mapOk((({body:r,destination:n,insertBefore:s})=>new Be({loc:e.loc,block:r,insertBefore:s,guid:t.generateUniqueCursor(),destination:n})))}}).kw("if",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return yt(v(`{{#if}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return yt(v(`{{#if}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?yt(v("{{#if}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):kt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=Et.visit(r,t),l=ir.NamedBlock(n,t),o=s?ir.NamedBlock(s,t):kt(null);return dt.all(a,l,o).mapOk((([t,r,n])=>new Oe({loc:e.loc,condition:t,block:r,inverse:n})))}}).kw("unless",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return yt(v(`{{#unless}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return yt(v(`{{#unless}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?yt(v("{{#unless}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):kt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=Et.visit(r,t),l=ir.NamedBlock(n,t),o=s?ir.NamedBlock(s,t):kt(null);return dt.all(a,l,o).mapOk((([t,r,n])=>new Oe({loc:e.loc,condition:new Se({value:t,loc:e.loc}),block:r,inverse:n})))}}).kw("each",{assert(e){let{args:t}=e;if(!t.named.entries.every((e=>"key"===e.name.chars)))return yt(v(`{{#each}} can only receive the 'key' named parameter, received ${t.named.entries.filter((e=>"key"!==e.name.chars)).map((e=>e.name.chars)).join(", ")}`,t.named.loc));if(t.positional.size>1)return yt(v(`{{#each}} can only receive one positional parameter, the collection being iterated. Received ${t.positional.size} parameters`,t.positional.loc));let r=t.nth(0),n=t.get("key");return null===r?yt(v("{{#each}} requires an iterable value to be passed as its first positional parameter, did not receive any parameters",t.loc)):kt({value:r,key:n})},translate({node:e,state:t},{value:r,key:n}){let s=e.blocks.get("default"),a=e.blocks.get("else"),l=Et.visit(r,t),o=n?Et.visit(n,t):kt(null),i=ir.NamedBlock(s,t),c=a?ir.NamedBlock(a,t):kt(null);return dt.all(l,o,i,c).mapOk((([t,r,n,s])=>new Pe({loc:e.loc,value:t,key:r,block:n,inverse:s})))}}).kw("let",{assert(e){let{args:t}=e;return t.named.isEmpty()?0===t.positional.size?yt(v("{{#let}} requires at least one value as its first positional parameter, did not receive any parameters",t.positional.loc)):e.blocks.get("else")?yt(v("{{#let}} cannot receive an {{else}} block",t.positional.loc)):kt({positional:t.positional}):yt(v(`{{#let}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,t.named.loc))},translate({node:e,state:t},{positional:r}){let n=e.blocks.get("default"),s=Et.Positional(r,t),a=ir.NamedBlock(n,t);return dt.all(s,a).mapOk((([t,r])=>new Te({loc:e.loc,positional:t,block:r})))}}).kw("-with-dynamic-vars",{assert:e=>kt({named:e.args.named}),translate({node:e,state:t},{named:r}){let n=e.blocks.get("default"),s=Et.NamedArguments(r,t),a=ir.NamedBlock(n,t);return dt.all(s,a).mapOk((([t,r])=>new Ne({loc:e.loc,named:t,block:r})))}}).kw("component",{assert:Lt(H.Component),translate({node:e,state:t},{definition:r,args:n}){let s=Et.visit(r,t),a=Et.Args(n,t),l=ir.NamedBlocks(e.blocks,t);return dt.all(s,a,l).mapOk((([t,r,n])=>new $e({loc:e.loc,definition:t,args:r,blocks:n})))}}),Wt=Pt("Call").kw("has-block",Vt("has-block")).kw("has-block-params",Vt("has-block-params")).kw("-get-dynamic-var",Gt).kw("log",qt).kw("if",jt("if")).kw("unless",jt("unless")).kw("component",$t(H.Component)).kw("helper",$t(H.Helper)).kw("modifier",$t(H.Modifier)),Ut=Pt("Modifier"),Yt="http://www.w3.org/1999/xlink",Jt="http://www.w3.org/XML/1998/namespace",Kt="http://www.w3.org/2000/xmlns/",Xt={"xlink:actuate":Yt,"xlink:arcrole":Yt,"xlink:href":Yt,"xlink:role":Yt,"xlink:show":Yt,"xlink:title":Yt,"xlink:type":Yt,"xml:base":Jt,"xml:lang":Jt,"xml:space":Jt,xmlns:Kt,"xmlns:xlink":Kt};const Zt={div:y.div,span:y.span,p:y.p,a:y.a},Qt=["div","span","p","a"];function er(e){return"string"==typeof e?e:Qt[e]}const tr={class:g.class,id:g.id,value:g.value,name:g.name,type:g.type,style:g.style,href:g.href},rr=["class","id","value","name","type","style","href"];function nr(e){return tr[e]??e}function sr(e){return"string"==typeof e?e:rr[e]}class ar{delegate;constructor(e,t,r){this.element=e,this.state=r,this.delegate=t}toStatement(){return this.prepare().andThen((e=>this.delegate.toStatement(this,e)))}attr(e){let t=e.name,r=e.value,n=(s=t.chars,Xt[s]||void 0);var s;return w.isLiteral(r,"string")?kt(new je({loc:e.loc,name:t,value:r.toSlice(),namespace:n,kind:{component:this.delegate.dynamicFeatures}})):Et.visit(bt(r),this.state).mapOk((r=>{let s=e.trusting;return new qe({loc:e.loc,name:t,value:r,namespace:n,kind:{trusting:s,component:this.delegate.dynamicFeatures}})}))}modifier(e){(function(e){return!!At(e)&&!e.args.isEmpty()})(e)&&vt(e);let t=Ut.translate(e,this.state);if(null!==t)return t;let r=Et.visit(e.callee,this.state),n=Et.Args(e.args,this.state);return dt.all(r,n).mapOk((([t,r])=>new Je({loc:e.loc,callee:t,args:r})))}attrs(){let e=new gt,t=new gt,r=null,n=0===this.element.attrs.filter((e=>"SplatAttr"===e.type)).length;for(let t of this.element.attrs)"SplatAttr"===t.type?e.add(kt(new Xe({loc:t.loc,symbol:this.state.scope.allocateBlock("attrs")}))):"type"===t.name.chars&&n?r=t:e.add(this.attr(t));for(let e of this.element.componentArgs)t.add(this.delegate.arg(e,this));return r&&e.add(this.attr(r)),dt.all(t.toArray(),e.toArray()).mapOk((([e,t])=>({attrs:t,args:new at({loc:B(e,C.SourceSpan.NON_EXISTENT),entries:pt(e)})})))}prepare(){let e=this.attrs(),t=new gt(this.element.modifiers.map((e=>this.modifier(e)))).toArray();return dt.all(e,t).mapOk((([e,t])=>{let{attrs:r,args:n}=e,s=[...r,...t];return{args:n,params:new ze({loc:B(s,C.SourceSpan.NON_EXISTENT),body:pt(s)})}}))}}class lr{dynamicFeatures=!0;constructor(e,t){this.tag=e,this.element=t}arg(e,{state:t}){let r=e.name;return Et.visit(bt(e.value),t).mapOk((t=>new lt({loc:e.loc,key:r,value:t})))}toStatement(e,{args:t,params:r}){let{element:n,state:s}=e;return this.blocks(s).mapOk((e=>new _e({loc:n.loc,tag:this.tag,params:r,args:t,blocks:e})))}blocks(e){return ir.NamedBlocks(this.element.blocks,e)}}class or{constructor(e,t,r){this.tag=e,this.element=t,this.dynamicFeatures=r}isComponent=!1;arg(e){return yt(v(`${e.name.chars} is not a valid attribute name. @arguments are only allowed on components, but the tag for this element (\`${this.tag.chars}\`) is a regular, non-component HTML element.`,e.loc))}toStatement(e,{params:t}){let{state:r,element:n}=e;return ir.visitList(this.element.body,r).mapOk((e=>new Re({loc:n.loc,tag:this.tag,params:t,body:e.toArray(),dynamicFeatures:this.dynamicFeatures})))}}const ir=new class{visitList(e,t){return new gt(e.map((e=>ir.visit(e,t)))).toOptionalList().mapOk((e=>e.filter((e=>null!==e))))}visit(e,t){switch(e.type){case"GlimmerComment":return kt(null);case"AppendContent":return this.AppendContent(e,t);case"HtmlText":return kt(this.TextNode(e));case"HtmlComment":return kt(this.HtmlComment(e));case"InvokeBlock":return this.InvokeBlock(e,t);case"InvokeComponent":return this.Component(e,t);case"SimpleElement":return this.SimpleElement(e,t)}}InvokeBlock(e,t){let r=zt.translate(e,t);if(null!==r)return r;let n=Et.visit(e.callee,t),s=Et.Args(e.args,t);return dt.all(n,s).andThen((([r,n])=>this.NamedBlocks(e.blocks,t).mapOk((t=>new Ke({loc:e.loc,head:r,args:n,blocks:t})))))}NamedBlocks(e,t){return new gt(e.blocks.map((e=>this.NamedBlock(e,t)))).toArray().mapOk((t=>new Ge({loc:e.loc,blocks:pt(t)})))}NamedBlock(e,t){return t.visitBlock(e.block).mapOk((t=>new Me({loc:e.loc,name:e.name,body:t.toArray(),scope:e.block.scope})))}SimpleElement(e,t){return new ar(e,new or(e.tag,e,function({attrs:e,modifiers:t}){return t.length>0||!!e.filter((e=>"SplatAttr"===e.type))[0]}(e)),t).toStatement()}Component(e,t){return Et.visit(e.callee,t).andThen((r=>new ar(e,new lr(r,e),t).toStatement()))}AppendContent(e,t){let r=Rt.translate(e,t);return null!==r?r:Et.visit(e.value,t).mapOk((t=>e.trusting?new De({loc:e.loc,html:t}):new Ve({loc:e.loc,text:t})))}TextNode(e){return new Ve({loc:e.loc,text:new w.LiteralExpression({loc:e.loc,value:e.chars})})}HtmlComment(e){return new Fe({loc:e.loc,value:e.text})}};class cr{_currentScope;_cursorCount=0;constructor(e,t){this.isStrict=t,this._currentScope=e}generateUniqueCursor(){return`%cursor:${this._cursorCount++}%`}get scope(){return this._currentScope}visitBlock(e){let t=this._currentScope;this._currentScope=e.scope;try{return ir.visitList(e.body,this)}finally{this._currentScope=t}}}var ur=function(e){return e.Value="value",e.Component="component",e.Helper="helper",e.Modifier="modifier",e.ComponentOrHelper="component or helper",e}(ur||{});class pr{static validate(e){return new this(e).validate()}constructor(e){this.template=e}validate(){return this.Statements(this.template.body).mapOk((()=>this.template))}Statements(e){let t=kt(null);for(let r of e)t=t.andThen((()=>this.Statement(r)));return t}NamedBlocks({blocks:e}){let t=kt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedBlock(r)));return t}NamedBlock(e){return this.Statements(e.body)}Statement(e){switch(e.type){case"InElement":return this.InElement(e);case"Debugger":case"AppendComment":return kt(null);case"Yield":return this.Yield(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"AppendTextNode":return this.AppendTextNode(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e)}}Expressions(e){let t=kt(null);for(let r of e)t=t.andThen((()=>this.Expression(r)));return t}Expression(e,t=e,r){switch(e.type){case"Literal":case"Missing":case"This":case"Arg":case"Local":case"HasBlock":case"HasBlockParams":case"GetDynamicVar":return kt(null);case"PathExpression":return this.Expression(e.head,t,r);case"Free":return this.errorFor(e.name,t,r);case"InterpolateExpression":return this.InterpolateExpression(e,t,r);case"CallExpression":return this.CallExpression(e,t,r??ur.Helper);case"Not":return this.Expression(e.value,t,r);case"IfInline":return this.IfInline(e);case"Curry":return this.Curry(e);case"Log":return this.Log(e)}}Args(e){return this.Positional(e.positional).andThen((()=>this.NamedArguments(e.named)))}Positional(e,t){let r=kt(null),n=e.list.toArray();return r=1===n.length?this.Expression(n[0],t):this.Expressions(n),r}NamedArguments({entries:e}){let t=kt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedArgument(r)));return t}NamedArgument(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,ur.Helper):this.Expression(e.value,e)}ElementParameters({body:e}){let t=kt(null);for(let r of e.toArray())t=t.andThen((()=>this.ElementParameter(r)));return t}ElementParameter(e){switch(e.type){case"StaticAttr":case"SplatAttr":return kt(null);case"DynamicAttr":return this.DynamicAttr(e);case"Modifier":return this.Modifier(e)}}DynamicAttr(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,ur.Helper):this.Expression(e.value,e)}Modifier(e){return this.Expression(e.callee,e,ur.Modifier).andThen((()=>this.Args(e.args)))}InElement(e){return this.Expression(e.destination).andThen((()=>this.Expression(e.insertBefore))).andThen((()=>this.NamedBlock(e.block)))}Yield(e){return this.Positional(e.positional,e)}AppendTrustedHTML(e){return this.Expression(e.html,e)}AppendTextNode(e){return"CallExpression"===e.text.type?this.Expression(e.text,e,ur.ComponentOrHelper):this.Expression(e.text,e)}Component(e){return this.Expression(e.tag,e,ur.Component).andThen((()=>this.ElementParameters(e.params))).andThen((()=>this.NamedArguments(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}SimpleElement(e){return this.ElementParameters(e.params).andThen((()=>this.Statements(e.body)))}InvokeBlock(e){return this.Expression(e.head,e.head,ur.Component).andThen((()=>this.Args(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}If(e){return this.Expression(e.condition,e).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):kt(null)))}Each(e){return this.Expression(e.value,e).andThen((()=>e.key?this.Expression(e.key,e):kt(null))).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):kt(null)))}Let(e){return this.Positional(e.positional).andThen((()=>this.NamedBlock(e.block)))}WithDynamicVars(e){return this.NamedArguments(e.named).andThen((()=>this.NamedBlock(e.block)))}InvokeComponent(e){return this.Expression(e.definition,e,ur.Component).andThen((()=>this.Args(e.args))).andThen((()=>e.blocks?this.NamedBlocks(e.blocks):kt(null)))}InterpolateExpression(e,t,r){let n=e.parts.toArray();return 1===n.length?this.Expression(n[0],t,r):this.Expressions(n)}CallExpression(e,t,r){return this.Expression(e.callee,t,r).andThen((()=>this.Args(e.args)))}IfInline(e){return this.Expression(e.condition).andThen((()=>this.Expression(e.truthy))).andThen((()=>e.falsy?this.Expression(e.falsy):kt(null)))}Curry(e){let t;return t=e.curriedType===H.Component?ur.Component:e.curriedType===H.Helper?ur.Helper:ur.Modifier,this.Expression(e.definition,e,t).andThen((()=>this.Args(e.args)))}Log(e){return this.Positional(e.positional,e)}errorFor(e,t,r=ur.Value){return yt(v(`Attempted to resolve a ${r} in a strict mode template, but that value was not in scope: ${e}`,S(t)))}}class mr{upvars;symbols;constructor([e,t,r,n]){this.upvars=n,this.symbols=t}format(e){let t=[];for(let r of e[0])t.push(this.formatOpcode(r));return t}formatOpcode(e){if(!Array.isArray(e))return e;switch(e[0]){case k.Append:return["append",this.formatOpcode(e[1])];case k.TrustingAppend:return["trusting-append",this.formatOpcode(e[1])];case k.Block:return["block",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case k.InElement:return["in-element",e[1],this.formatOpcode(e[2]),e[3]?this.formatOpcode(e[3]):void 0];case k.OpenElement:return["open-element",er(e[1])];case k.OpenElementWithSplat:return["open-element-with-splat",er(e[1])];case k.CloseElement:return["close-element"];case k.FlushElement:return["flush-element"];case k.StaticAttr:return["static-attr",sr(e[1]),e[2],e[3]];case k.StaticComponentAttr:return["static-component-attr",sr(e[1]),e[2],e[3]];case k.DynamicAttr:return["dynamic-attr",sr(e[1]),this.formatOpcode(e[2]),e[3]];case k.ComponentAttr:return["component-attr",sr(e[1]),this.formatOpcode(e[2]),e[3]];case k.AttrSplat:return["attr-splat"];case k.Yield:return["yield",e[1],this.formatParams(e[2])];case k.DynamicArg:return["dynamic-arg",e[1],this.formatOpcode(e[2])];case k.StaticArg:return["static-arg",e[1],this.formatOpcode(e[2])];case k.TrustingDynamicAttr:return["trusting-dynamic-attr",sr(e[1]),this.formatOpcode(e[2]),e[3]];case k.TrustingComponentAttr:return["trusting-component-attr",sr(e[1]),this.formatOpcode(e[2]),e[3]];case k.Debugger:return["debugger",e[1]];case k.Comment:return["comment",e[1]];case k.Modifier:return["modifier",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case k.Component:return["component",this.formatOpcode(e[1]),this.formatElementParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case k.HasBlock:return["has-block",this.formatOpcode(e[1])];case k.HasBlockParams:return["has-block-params",this.formatOpcode(e[1])];case k.Curry:return["curry",this.formatOpcode(e[1]),this.formatCurryType(e[2]),this.formatParams(e[3]),this.formatHash(e[4])];case k.Undefined:return["undefined"];case k.Call:return["call",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case k.Concat:return["concat",this.formatParams(e[1])];case k.GetStrictKeyword:return["get-strict-free",this.upvars[e[1]],e[2]];case k.GetFreeAsComponentOrHelperHead:return["GetFreeAsComponentOrHelperHead",this.upvars[e[1]],e[2]];case k.GetFreeAsHelperHead:return["GetFreeAsHelperHead",this.upvars[e[1]],e[2]];case k.GetFreeAsComponentHead:return["GetFreeAsComponentHead",this.upvars[e[1]],e[2]];case k.GetFreeAsModifierHead:return["GetFreeAsModifierHead",this.upvars[e[1]],e[2]];case k.GetSymbol:return 0===e[1]?["get-symbol","this",e[2]]:["get-symbol",this.symbols[e[1]-1],e[2]];case k.GetLexicalSymbol:return["get-template-symbol",e[1],e[2]];case k.If:return["if",this.formatOpcode(e[1]),this.formatBlock(e[2]),e[3]?this.formatBlock(e[3]):null];case k.IfInline:return["if-inline"];case k.Not:return["not"];case k.Each:return["each",this.formatOpcode(e[1]),e[2]?this.formatOpcode(e[2]):null,this.formatBlock(e[3]),e[4]?this.formatBlock(e[4]):null];case k.Let:return["let",this.formatParams(e[1]),this.formatBlock(e[2])];case k.Log:return["log",this.formatParams(e[1])];case k.WithDynamicVars:return["-with-dynamic-vars",this.formatHash(e[1]),this.formatBlock(e[2])];case k.GetDynamicVar:return["-get-dynamic-vars",this.formatOpcode(e[1])];case k.InvokeComponent:return["component",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])]}}formatCurryType(e){switch(e){case H.Component:return"component";case H.Helper:return"helper";case H.Modifier:return"modifier";default:throw c(e)}}formatElementParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatHash(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatOpcode(e[1][n]),t)),t())}formatBlocks(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatBlock(e[1][n]),t)),t())}formatBlock(e){return{statements:e[0].map((e=>this.formatOpcode(e))),parameters:e[1]}}}const dr=new class{expr(e){switch(e.type){case"Missing":return;case"Literal":return this.Literal(e);case"CallExpression":return this.CallExpression(e);case"PathExpression":return this.PathExpression(e);case"Arg":return[k.GetSymbol,e.symbol];case"Local":return this.Local(e);case"This":return[k.GetSymbol,0];case"Free":return[e.resolution.resolution(),e.symbol];case"HasBlock":return this.HasBlock(e);case"HasBlockParams":return this.HasBlockParams(e);case"Curry":return this.Curry(e);case"Not":return this.Not(e);case"IfInline":return this.IfInline(e);case"InterpolateExpression":return this.InterpolateExpression(e);case"GetDynamicVar":return this.GetDynamicVar(e);case"Log":return this.Log(e)}}Literal({value:e}){return void 0===e?[k.Undefined]:e}Missing(){}HasBlock({symbol:e}){return[k.HasBlock,[k.GetSymbol,e]]}HasBlockParams({symbol:e}){return[k.HasBlockParams,[k.GetSymbol,e]]}Curry({definition:e,curriedType:t,args:r}){return[k.Curry,dr.expr(e),t,dr.Positional(r.positional),dr.NamedArguments(r.named)]}Local({isTemplateLocal:e,symbol:t}){return[e?k.GetLexicalSymbol:k.GetSymbol,t]}PathExpression({head:e,tail:t}){return[...dr.expr(e),dr.Tail(t)]}InterpolateExpression({parts:e}){return[k.Concat,e.map((e=>dr.expr(e))).toArray()]}CallExpression({callee:e,args:t}){return[k.Call,dr.expr(e),...dr.Args(t)]}Tail({members:e}){return u(e,(e=>e.chars))}Args({positional:e,named:t}){return[this.Positional(e),this.NamedArguments(t)]}Positional({list:e}){return e.map((e=>dr.expr(e))).toPresentArray()}NamedArgument({key:e,value:t}){return[e.chars,dr.expr(t)]}NamedArguments({entries:e}){let t=e.toArray();if(n(t)){let e=[],r=[];for(let n of t){let[t,s]=dr.NamedArgument(n);e.push(t),r.push(s)}return h(e),h(r),[e,r]}return null}Not({value:e}){return[k.Not,dr.expr(e)]}IfInline({condition:e,truthy:t,falsy:r}){let n=[k.IfInline,dr.expr(e),dr.expr(t)];return r&&n.push(dr.expr(r)),n}GetDynamicVar({name:e}){return[k.GetDynamicVar,dr.expr(e)]}Log({positional:e}){return[k.Log,this.Positional(e)]}};class hr{constructor(e){this.statements=e}toArray(){return this.statements}}const fr=new class{list(e){let t=[];for(let r of e){let e=fr.content(r);e&&e instanceof hr?t.push(...e.toArray()):t.push(e)}return t}content(e){return Ee&&d.log("encoding",e),this.visitContent(e)}visitContent(e){switch(e.type){case"Debugger":return[k.Debugger,e.scope.getDebugInfo()];case"AppendComment":return this.AppendComment(e);case"AppendTextNode":return this.AppendTextNode(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"Yield":return this.Yield(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InElement":return this.InElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e);default:return c(e)}}Yield({to:e,positional:t}){return[k.Yield,e,dr.Positional(t)]}InElement({guid:e,insertBefore:t,destination:r,block:n}){let s=fr.NamedBlock(n)[1],a=dr.expr(r),l=dr.expr(t);return void 0===l?[k.InElement,s,e,a]:[k.InElement,s,e,a,l]}InvokeBlock({head:e,args:t,blocks:r}){return[k.Block,dr.expr(e),...dr.Args(t),fr.NamedBlocks(r)]}AppendTrustedHTML({html:e}){return[k.TrustingAppend,dr.expr(e)]}AppendTextNode({text:e}){return[k.Append,dr.expr(e)]}AppendComment({value:e}){return[k.Comment,e.chars]}SimpleElement({tag:e,params:t,body:r,dynamicFeatures:n}){let s=n?k.OpenElementWithSplat:k.OpenElement;return new hr([[s,(a=e.chars,Zt[a]??a)],...fr.ElementParameters(t).toArray(),[k.FlushElement],...fr.list(r),[k.CloseElement]]);var a}Component({tag:e,params:t,args:r,blocks:n}){let s=dr.expr(e),a=fr.ElementParameters(t),l=dr.NamedArguments(r),o=fr.NamedBlocks(n);return[k.Component,s,a.toPresentArray(),l,o]}ElementParameters({body:e}){return e.map((e=>fr.ElementParameter(e)))}ElementParameter(e){switch(e.type){case"SplatAttr":return[k.AttrSplat,e.symbol];case"DynamicAttr":return[Ar(e.kind),...yr(e)];case"StaticAttr":return[gr(e.kind),...kr(e)];case"Modifier":return[k.Modifier,dr.expr(e.callee),...dr.Args(e.args)]}}NamedBlocks({blocks:e}){let t=[],r=[];for(let n of e.toArray()){let[e,s]=fr.NamedBlock(n);t.push(e),r.push(s)}return t.length>0?[t,r]:null}NamedBlock({name:e,body:t,scope:r}){let n=e.chars;return"inverse"===n&&(n="else"),[n,[fr.list(t),r.slots]]}If({condition:e,block:t,inverse:r}){return[k.If,dr.expr(e),fr.NamedBlock(t)[1],r?fr.NamedBlock(r)[1]:null]}Each({value:e,key:t,block:r,inverse:n}){return[k.Each,dr.expr(e),t?dr.expr(t):null,fr.NamedBlock(r)[1],n?fr.NamedBlock(n)[1]:null]}Let({positional:e,block:t}){return[k.Let,dr.Positional(e),fr.NamedBlock(t)[1]]}WithDynamicVars({named:e,block:t}){return[k.WithDynamicVars,dr.NamedArguments(e),fr.NamedBlock(t)[1]]}InvokeComponent({definition:e,args:t,blocks:r}){return[k.InvokeComponent,dr.expr(e),dr.Positional(t.positional),dr.NamedArguments(t.named),r?fr.NamedBlocks(r):null]}};function kr({name:e,value:t,namespace:r}){let n=[nr(e.chars),t.chars];return r&&n.push(r),n}function yr({name:e,value:t,namespace:r}){let n=[nr(e.chars),dr.expr(t)];return r&&n.push(r),n}function gr(e){return e.component?k.StaticComponentAttr:k.StaticAttr}function Ar(e){return e.component?e.trusting?k.TrustingComponentAttr:k.ComponentAttr:e.trusting?k.TrustingDynamicAttr:k.DynamicAttr}const vr=(()=>{const e="object"==typeof module&&"function"==typeof module.require?module.require:globalThis.require;if(e)try{const t=e("crypto"),r=e=>{const r=t.createHash("sha1");return r.update(e,"utf8"),r.digest("base64").substring(0,8)};return r("test"),r}catch{}return function(){return null}})(),wr={id:vr};function xr(e,t=wr){const r=new C.Source(e??"",t.meta?.moduleName),[n,s]=O(r,{lexicalScope:()=>!1,...t}),a=function(e,t,r){let n=new cr(t.table,r);Ee&&(d.groupCollapsed("pass0: visiting"),d.log("symbols",t.table),d.log("source",e),d.groupEnd());let s=ir.visitList(t.body,n);Ee&&(s.isOk?d.log("-> pass0: out",s.value):d.log("-> pass0: error",s.reason));let a=s.mapOk((e=>new Ce({loc:t.loc,scope:t.table,body:e.toArray()})));return r&&(a=a.andThen((e=>pr.validate(e)))),a}(r,n,t.strictMode??!1).mapOk((e=>function(e){let t=fr.list(e.body),r=e.scope,n=[t,r.symbols,r.hasEval,r.upvars];if(Ee){let e=new mr(n);d.log("-> ",t.map((t=>e.formatOpcode(t))))}return n}(e)));if(Ee&&d.log("Template ->",a),a.isOk)return[a.value,s];throw a.reason}const br="796d24e6-2450-4fb0-8cdf-b65638b5ef70";function Er(e,t=wr){const[r,n]=xr(e,t),s=t.meta?.moduleName,a=t.id||vr,l=JSON.stringify(r),o={id:a(JSON.stringify(t.meta)+l),block:l,moduleName:s??"(unknown template module)",scope:br,isStrictMode:t.strictMode??!1};0===n.length&&delete o.scope;let i=JSON.stringify(o);if(n.length>0){const e=`()=>[${n.join(",")}]`;i=i.replace(`"${br}"`,e)}return i}export{W as Builder,ue as NEWLINE,ee as ProgramSymbols,mr as WireFormatDebugger,le as buildStatement,se as buildStatements,ie as c,vr as defaultId,Er as precompile,xr as precompileJSON,oe as s,ce as unicode};
//# sourceMappingURL=index.js.map
{
"name": "@glimmer/compiler",
"version": "0.90.0",
"version": "0.90.1",
"license": "MIT",

@@ -27,7 +27,7 @@ "repository": "https://github.com/glimmerjs/glimmer-vm/tree/main/packages/@glimmer/compiler",

"dependencies": {
"@glimmer/interfaces": "^0.90.0",
"@glimmer/syntax": "^0.90.0",
"@glimmer/util": "^0.90.0",
"@glimmer/vm": "^0.90.0",
"@glimmer/wire-format": "^0.90.0"
"@glimmer/interfaces": "^0.90.1",
"@glimmer/syntax": "^0.90.1",
"@glimmer/util": "^0.90.1",
"@glimmer/vm": "^0.90.1",
"@glimmer/wire-format": "^0.90.1"
},

@@ -41,3 +41,3 @@ "devDependencies": {

"@glimmer-workspace/build-support": "^1.0.0",
"@glimmer/local-debug-flags": "^0.90.0"
"@glimmer/local-debug-flags": "^0.90.1"
},

@@ -44,0 +44,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc