@optionfactory/fml 9.0.0-rc28 → 9.0.0-rc29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-errors.iife.js +21 -16
- package/dist/client-errors.iife.js.map +1 -1
- package/dist/client-errors.iife.min.js +1 -1
- package/dist/client-errors.iife.min.js.map +1 -1
- package/dist/custom-elements.json +16 -16
- package/dist/fml.css +13 -13
- package/dist/fml.css.map +1 -1
- package/dist/fml.iife.js +871 -883
- package/dist/fml.iife.js.map +1 -1
- package/dist/fml.iife.min.js +1 -1
- package/dist/fml.iife.min.js.map +1 -1
- package/dist/ftl.d.mts +3 -3
- package/dist/ftl.iife.js +275 -679
- package/dist/ftl.iife.js.map +1 -1
- package/dist/ftl.iife.min.js +1 -1
- package/dist/ftl.iife.min.js.map +1 -1
- package/dist/ftl.min.mjs +1 -1
- package/dist/ftl.min.mjs.map +1 -1
- package/dist/ftl.mjs +275 -679
- package/dist/ftl.mjs.map +1 -1
- package/dist/ful.css +13 -13
- package/dist/ful.css.map +1 -1
- package/dist/ful.d.mts +195 -71
- package/dist/ful.iife.js +564 -189
- package/dist/ful.iife.js.map +1 -1
- package/dist/ful.iife.min.js +1 -1
- package/dist/ful.iife.min.js.map +1 -1
- package/dist/ful.min.mjs +1 -1
- package/dist/ful.min.mjs.map +1 -1
- package/dist/ful.mjs +564 -189
- package/dist/ful.mjs.map +1 -1
- package/dist/httpc.d.mts +9 -7
- package/dist/httpc.iife.js +32 -15
- package/dist/httpc.iife.js.map +1 -1
- package/dist/httpc.iife.min.js +1 -1
- package/dist/httpc.iife.min.js.map +1 -1
- package/dist/httpc.min.mjs +1 -1
- package/dist/httpc.min.mjs.map +1 -1
- package/dist/httpc.mjs +32 -15
- package/dist/httpc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +13 -13
- package/dist/web-types.json +17 -17
- package/package.json +2 -2
package/dist/ftl.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class t{#t;#e=new Map;constructor(t){this.#t=t}getOrCompute(t,e){if(this.#e.has(t))return this.#e.get(t);const r=e(t);return this.#e.size>=this.#t&&this.#e.delete(this.#e.keys().next().value),this.#e.set(t,r),r}get size(){return this.#e.size}}const e={ter:Symbol("ternary"),elv:Symbol("elvis"),nullc:Symbol("null-coalescence"),or:Symbol("or"),and:Symbol("and"),eq:Symbol("eq"),cmp:Symbol("cmp"),not:Symbol("not"),access:Symbol("access"),member:Symbol("access-member"),subscript:Symbol("access-subscript"),method:Symbol("access-method-call"),call:Symbol("module-function-call"),tstring:Symbol("tstring"),literal:Symbol("literal"),array:Symbol("array-literal"),dict:Symbol("dict-literal"),function:Symbol("module-function"),symbol:Symbol("symbol"),templated:{ten:Symbol("templated-node"),teh:Symbol("templated-html"),tet:Symbol("templated-text"),tel:Symbol("templated-literal")},dom:{t:Symbol("text"),h:Symbol("html"),n:Symbol("node")}},r=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0]]);class n extends SyntaxError{constructor(t,e,r,n){super(t),this.expected=e,this.found=r,this.location=n,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let r=null;const n=t.find(t=>t.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const s=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(s):s,a=this.location.source+":"+o.line+":"+o.column;if(r){const t=this.location.end,n="".padEnd(o.line.toString().length," "),i=r[s.line-1],l=(s.line===t.line?t.column:i.length+1)-s.column||1;e+="\n --\x3e "+a+"\n"+n+" |\n"+o.line+" | "+i+"\n"+n+" | "+"".padEnd(s.column-1," ")+"".padEnd(l,"^")}else e+="\n at "+a}return e}static buildMessage(t,e){function r(t){return t.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function s(t){return n?t.replace(n,t=>"\\u{"+r(t)+"}"):t}function o(t){return s(t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+r(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+r(t)))}function a(t){return s(t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+r(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+r(t)))}const i={literal:t=>'"'+o(t.text)+'"',class(t){const e=t.parts.map(t=>Array.isArray(t)?a(t[0])+"-"+a(t[1]):a(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function l(t){return i[t.type](t)}return"Expected "+function(t){const e=t.map(l);if(e.sort(),e.length>0){let t=1;for(let r=1;r<e.length;r++)e[r-1]!==e[r]&&(e[t]=e[r],t++);e.length=t}switch(e.length){case 1:return e[0];case 2:return e[0]+" or "+e[1];default:return e.slice(0,-1).join(", ")+", or "+e[e.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."}}const s=(t,e)=>{if("self"===e)return t[t.length-1];for(let r=t.length-1;r>=0;r--){const n=t[r];if(null!=n&&("object"==typeof n||"function"==typeof n)&&e in n)return n[e]}};class o{#r;#n;constructor(t,e){this.#r=t,this.#n=e}#s(t){return s(this.#n,t)}#o(t,r){const n=0===r?t.lhs:t.rhs[r-1];return n.type===e.symbol?n.value:n.type===e.member?n.rhs:null}#a;#i(){return this.#a||(this.#a=new Proxy(this.#n,{get:(t,e)=>this.#s(e)})),this.#a}[e.and](t){return this.visit(t.lhs)&&this.visit(t.rhs)}[e.or](t){return this.visit(t.lhs)||this.visit(t.rhs)}[e.nullc](t){return this.visit(t.lhs)??this.visit(t.rhs)}[e.not](t){return!this.visit(t.expr)}[e.eq](t){const e=this.visit(t.lhs)===this.visit(t.rhs);return"=="===t.op?e:!e}[e.cmp](t){const e=this.visit(t.lhs),r=this.visit(t.rhs);switch(t.op){case">":return e>r;case"<":return e<r;case">=":return e>=r;case"<=":return e<=r;default:throw new Error(`unknown cmp op ${t.op}`)}}[e.call](t){const e=t.value,r=null===e.module?this.#r:this.#r?.[e.module];if(!r)throw new Error(`Module "${e.module}" not found`);const n=r[e.value];if(!n)throw new Error(`Function "#${null===e.module?"":`${e.module}:`}${e.value}" not found`);const s=t.args.map(t=>this.visit(t));return n.apply(this.#i(),s)}[e.literal](t){return t.value}[e.tstring](t){let e="";const r=t.parts;for(let t=0,n=r.length;t<n;t++){const n=this.visit(r[t]);null!=n&&(e+=n)}return e}[e.symbol](t){return this.#s(t.value)}[e.dict](t){return Object.fromEntries(t.value.map(t=>[this.visit(t[0]),this.visit(t[1])]))}[e.array](t){return t.value.map(t=>this.visit(t))}[e.ter](t){return this.visit(t.cond)?this.visit(t.ifTrue):this.visit(t.ifFalse)}[e.elv](t){return this.visit(t.cond)||this.visit(t.ifFalse)}[e.access](t){let r,n=this.visit(t.lhs);for(let s=0;s!==t.rhs.length;++s){const o=t.rhs[s];if(o.ns&&null==n)return;let a;switch(o.type){case e.member:a=n[o.rhs];break;case e.subscript:a=n[this.visit(o.rhs)];break;case e.method:{if(!n){const e=this.#o(t,s);throw new Error(null===e?"Method missing":`Method missing "${e}"`)}const e=o.args.map(t=>this.visit(t));a=n.apply(r,e);break}}r=n,n=a}return n}visit(t,...e){return this[t.type](t,...e)}visitRoot(t,r){return r?t.map(t=>{switch(t.type){case e.templated.tel:return{type:e.dom.t,value:t.value};case e.templated.tet:return{type:e.dom.t,value:this.visit(t.value)};case e.templated.teh:return{type:e.dom.h,value:this.visit(t.value)};case e.templated.ten:return{type:e.dom.n,value:this.visit(t.value)};default:throw new Error(`unknown node type ${t.type.toString()}`)}}):this.visit(t)}}class a{static MODE_EXPRESSION=Symbol("MODE_EXPRESSION");static MODE_TEMPLATED=Symbol("MODE_TEMPLATED");static#l=new t(1e3);static parse(t,s){const o=s?.toString()+t;return this.#l.getOrCompute(o,()=>function(t,s){const o={},a=(s=void 0!==s?s:{}).grammarSource,i={TemplatedRoot:me,ExpressionRoot:ve};let l=me;const u="{{{{",c="}}}}",h="{{{",d="}}}",p="{{",f="}}",m="\\",g="{",v="?",y=":",b="?:",E="??",A="||",x="&&",w="!",P="?.",T=".",C="[",S="]",O="(",N=",",R=")",D="-",M="'",$='"',_="`",F="}",L="#",j="==",k="!=",I=">=",V=">",q="<=",H="<",z=/^[^\\{]/,B=/^[0-9]/,W=/^[^']/,X=/^[^"]/,Q=/^[^\\`{]/,U=/^[a-zA-Z$_]/,G=/^[a-zA-Z$_0-9]/,Z=/^[ \t\n\r]/,J=ue("{{{{",!1),Y=ue("}}}}",!1),K=ue("{{{",!1),tt=ue("}}}",!1),et=ue("{{",!1),rt=ue("}}",!1),nt=ce(["\\","{"],!0,!1,!1),st=ue("\\",!1),ot={type:"any"},at=ue("{",!1),it=ue("?",!1),lt=ue(":",!1),ut=ue("?:",!1),ct=ue("??",!1),ht=ue("||",!1),dt=ue("&&",!1),pt=ue("!",!1),ft=he("member"),mt=ue("?.",!1),gt=ue(".",!1),vt=he("subscript"),yt=ue("[",!1),bt=ue("]",!1),Et=he("method-call"),At=ue("(",!1),xt=ue(",",!1),wt=ue(")",!1),Pt=he("module-function-call"),Tt=he("number-literal"),Ct=ue("-",!1),St=ce([["0","9"]],!1,!1,!1),Ot=he("string-literal"),Nt=ue("'",!1),Rt=ce(["'"],!0,!1,!1),Dt=ue('"',!1),Mt=ce(['"'],!0,!1,!1),$t=ue("`",!1),_t=he("tstring-expression"),Ft=ue("}",!1),Lt=he("tstring-literal"),jt=ce(["\\","`","{"],!0,!1,!1),kt=he("array-literal"),It=he("dict-literal"),Vt=he("module-function"),qt=ue("#",!1),Ht=ce([["a","z"],["A","Z"],"$","_"],!1,!1,!1),zt=ce([["a","z"],["A","Z"],"$","_",["0","9"]],!1,!1,!1),Bt=he("identifier-or-keyword"),Wt=ue("==",!1),Xt=ue("!=",!1),Qt=ue(">=",!1),Ut=ue(">",!1),Gt=ue("<=",!1),Zt=ue("<",!1),Jt=ce([" ","\t","\n","\r"],!1,!1,!1);function Yt(t){return t}function Kt(t,e,r){return{op:e,rhs:r}}function te(t,e,r){return{op:e,rhs:r}}function ee(t){return t}let re=0|s.peg$currPos;const ne=[{line:1,column:1}];let se,oe=re,ae=s.peg$maxFailExpected||[],ie=0|s.peg$silentFails,le={};if(s.startRule){if(!(s.startRule in i))throw new Error("Can't start parsing from rule \""+s.startRule+'".');l=i[s.startRule]}function ue(t,e){return{type:"literal",text:t,ignoreCase:e}}function ce(t,e,r,n){return{type:"class",parts:t,inverted:e,ignoreCase:r,unicode:n}}function he(t){return{type:"other",description:t}}function de(e){let r,n=ne[e];if(n)return n;if(e>=ne.length)r=ne.length-1;else for(r=e;!ne[--r];);for(n=ne[r],n={line:n.line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return ne[e]=n,n}function pe(t,e,r){const n=de(t),s=de(e);return{source:a,start:{offset:t,line:n.line,column:n.column},end:{offset:e,line:s.line,column:s.column}}}function fe(t){re<oe||(re>oe&&(oe=re,ae=[]),ae.push(t))}function me(){let t,e;const r=38*re+0,n=le[r];if(n)return re=n.nextPos,n.result;for(t=[],e=ge();e!==o;)t.push(e),e=ge();return le[r]={nextPos:re,result:t},t}function ge(){let r,n,s,a,i;const l=38*re+1,v=le[l];return v?(re=v.nextPos,v.result):(r=re,n=re,s=function(){let e;const r=38*re+2,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,4)===u?(e=u,re+=4):(e=o,0===ie&&fe(J)),le[r]={nextPos:re,result:e},e)}(),s!==o?(a=ve(),a!==o?(i=function(){let e;const r=38*re+3,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,4)===c?(e=c,re+=4):(e=o,0===ie&&fe(Y)),le[r]={nextPos:re,result:e},e)}(),i!==o?n=a:(re=n,n=o)):(re=n,n=o)):(re=n,n=o),n!==o&&(y=n,n={type:e.templated.ten,value:y}),r=n,r===o&&(r=re,n=re,s=function(){let e;const r=38*re+4,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,3)===h?(e=h,re+=3):(e=o,0===ie&&fe(K)),le[r]={nextPos:re,result:e},e)}(),s!==o?(a=ve(),a!==o?(i=function(){let e;const r=38*re+5,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,3)===d?(e=d,re+=3):(e=o,0===ie&&fe(tt)),le[r]={nextPos:re,result:e},e)}(),i!==o?n=a:(re=n,n=o)):(re=n,n=o)):(re=n,n=o),n!==o&&(n=function(t){return{type:e.templated.teh,value:t}}(n)),r=n,r===o&&(r=re,n=re,s=function(){let e;const r=38*re+6,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,2)===p?(e=p,re+=2):(e=o,0===ie&&fe(et)),le[r]={nextPos:re,result:e},e)}(),s!==o?(a=ve(),a!==o?(i=function(){let e;const r=38*re+7,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,2)===f?(e=f,re+=2):(e=o,0===ie&&fe(rt)),le[r]={nextPos:re,result:e},e)}(),i!==o?n=a:(re=n,n=o)):(re=n,n=o)):(re=n,n=o),n!==o&&(n=function(t){return{type:e.templated.tet,value:t}}(n)),r=n,r===o&&(r=re,n=function(){let e,r,n,s,a,i,l;const u=38*re+8,c=le[u];if(c)return re=c.nextPos,c.result;if(e=re,r=[],n=re,s=[],a=t.charAt(re),z.test(a)?re++:(a=o,0===ie&&fe(nt)),a!==o)for(;a!==o;)s.push(a),a=t.charAt(re),z.test(a)?re++:(a=o,0===ie&&fe(nt));else s=o;if(n=s!==o?t.substring(n,re):s,n===o&&(n=re,92===t.charCodeAt(re)?(s=m,re++):(s=o,0===ie&&fe(st)),s!==o?(t.length>re?(a=t.charAt(re),re++):(a=o,0===ie&&fe(ot)),a!==o?n=a:(re=n,n=o)):(re=n,n=o),n===o&&(n=re,s=re,123===t.charCodeAt(re)?(a=g,re++):(a=o,0===ie&&fe(at)),a!==o?(i=re,ie++,123===t.charCodeAt(re)?(l=g,re++):(l=o,0===ie&&fe(at)),ie--,l===o?i=void 0:(re=i,i=o),i!==o?(a=[a,i],s=a):(re=s,s=o)):(re=s,s=o),n=s!==o?t.substring(n,re):s)),n!==o)for(;n!==o;){if(r.push(n),n=re,s=[],a=t.charAt(re),z.test(a)?re++:(a=o,0===ie&&fe(nt)),a!==o)for(;a!==o;)s.push(a),a=t.charAt(re),z.test(a)?re++:(a=o,0===ie&&fe(nt));else s=o;n=s!==o?t.substring(n,re):s,n===o&&(n=re,92===t.charCodeAt(re)?(s=m,re++):(s=o,0===ie&&fe(st)),s!==o?(t.length>re?(a=t.charAt(re),re++):(a=o,0===ie&&fe(ot)),a!==o?n=Yt(a):(re=n,n=o)):(re=n,n=o),n===o&&(n=re,s=re,123===t.charCodeAt(re)?(a=g,re++):(a=o,0===ie&&fe(at)),a!==o?(i=re,ie++,123===t.charCodeAt(re)?(l=g,re++):(l=o,0===ie&&fe(at)),ie--,l===o?i=void 0:(re=i,i=o),i!==o?(a=[a,i],s=a):(re=s,s=o)):(re=s,s=o),n=s!==o?t.substring(n,re):s))}else r=o;return r!==o&&(r=r.join("")),e=r,le[u]={nextPos:re,result:e},e}(),n!==o&&(n=function(t){return{type:e.templated.tel,value:t}}(n)),r=n))),le[l]={nextPos:re,result:r},r);var y}function ve(){let t,e;const r=38*re+9,n=le[r];return n?(re=n.nextPos,n.result):(t=re,_e(),e=ye(),e!==o?(_e(),t=e):(re=t,t=o),le[r]={nextPos:re,result:t},t)}function ye(){let r,n,s,a,i,l;const u=38*re+10,c=le[u];return c?(re=c.nextPos,c.result):(r=re,n=be(),n!==o?(_e(),63===t.charCodeAt(re)?(s=v,re++):(s=o,0===ie&&fe(it)),s!==o?(_e(),a=ye(),a!==o?(_e(),58===t.charCodeAt(re)?(i=y,re++):(i=o,0===ie&&fe(lt)),i!==o?(_e(),l=ye(),l!==o?r={type:e.ter,cond:n,ifTrue:a,ifFalse:l}:(re=r,r=o)):(re=r,r=o)):(re=r,r=o)):(re=r,r=o)):(re=r,r=o),r===o&&(r=be()),le[u]={nextPos:re,result:r},r)}function be(){let r,n,s,a;const i=38*re+11,l=le[i];return l?(re=l.nextPos,l.result):(r=re,n=Ee(),n!==o?(_e(),t.substr(re,2)===b?(s=b,re+=2):(s=o,0===ie&&fe(ut)),s!==o?(_e(),a=be(),a!==o?r={type:e.elv,cond:n,ifFalse:a}:(re=r,r=o)):(re=r,r=o)):(re=r,r=o),r===o&&(r=Ee()),le[i]={nextPos:re,result:r},r)}function Ee(){let r,n,s,a;const i=38*re+12,l=le[i];return l?(re=l.nextPos,l.result):(r=re,n=Ae(),n!==o?(_e(),t.substr(re,2)===E?(s=E,re+=2):(s=o,0===ie&&fe(ct)),s!==o?(_e(),a=Ee(),a!==o?r={type:e.nullc,lhs:n,rhs:a}:(re=r,r=o)):(re=r,r=o)):(re=r,r=o),r===o&&(r=Ae()),le[i]={nextPos:re,result:r},r)}function Ae(){let r,n,s,a,i,l;const u=38*re+13,c=le[u];if(c)return re=c.nextPos,c.result;if(r=re,n=xe(),n!==o){for(s=[],a=re,_e(),t.substr(re,2)===A?(i=A,re+=2):(i=o,0===ie&&fe(ht)),i!==o?(_e(),l=xe(),l!==o?a=l:(re=a,a=o)):(re=a,a=o);a!==o;)s.push(a),a=re,_e(),t.substr(re,2)===A?(i=A,re+=2):(i=o,0===ie&&fe(ht)),i!==o?(_e(),l=xe(),l!==o?a=l:(re=a,a=o)):(re=a,a=o);r=function(t,r){let n=t;for(const t of r)n={type:e.or,lhs:n,rhs:t};return n}(n,s)}else re=r,r=o;return le[u]={nextPos:re,result:r},r}function xe(){let r,n,s,a,i,l;const u=38*re+14,c=le[u];if(c)return re=c.nextPos,c.result;if(r=re,n=we(),n!==o){for(s=[],a=re,_e(),t.substr(re,2)===x?(i=x,re+=2):(i=o,0===ie&&fe(dt)),i!==o?(_e(),l=we(),l!==o?a=l:(re=a,a=o)):(re=a,a=o);a!==o;)s.push(a),a=re,_e(),t.substr(re,2)===x?(i=x,re+=2):(i=o,0===ie&&fe(dt)),i!==o?(_e(),l=we(),l!==o?a=l:(re=a,a=o)):(re=a,a=o);r=function(t,r){let n=t;for(const t of r)n={type:e.and,lhs:n,rhs:t};return n}(n,s)}else re=r,r=o;return le[u]={nextPos:re,result:r},r}function we(){let t,r,n,s,a,i;const l=38*re+15,u=le[l];if(u)return re=u.nextPos,u.result;if(t=re,r=Pe(),r!==o){for(n=[],s=re,_e(),a=Me(),a!==o?(_e(),i=Pe(),i!==o?s=Kt(0,a,i):(re=s,s=o)):(re=s,s=o);s!==o;)n.push(s),s=re,_e(),a=Me(),a!==o?(_e(),i=Pe(),i!==o?s=Kt(0,a,i):(re=s,s=o)):(re=s,s=o);t=function(t,r){let n=t;for(const t of r)n={type:e.eq,op:t.op,lhs:n,rhs:t.rhs};return n}(r,n)}else re=t,t=o;return le[l]={nextPos:re,result:t},t}function Pe(){let t,r,n,s,a,i;const l=38*re+16,u=le[l];if(u)return re=u.nextPos,u.result;if(t=re,r=Te(),r!==o){for(n=[],s=re,_e(),a=$e(),a!==o?(_e(),i=Te(),i!==o?s=te(0,a,i):(re=s,s=o)):(re=s,s=o);s!==o;)n.push(s),s=re,_e(),a=$e(),a!==o?(_e(),i=Te(),i!==o?s=te(0,a,i):(re=s,s=o)):(re=s,s=o);t=function(t,r){let n=t;for(const t of r)n={type:e.cmp,op:t.op,lhs:n,rhs:t.rhs};return n}(r,n)}else re=t,t=o;return le[l]={nextPos:re,result:t},t}function Te(){let r,n,s;const a=38*re+17,i=le[a];return i?(re=i.nextPos,i.result):(r=re,33===t.charCodeAt(re)?(n=w,re++):(n=o,0===ie&&fe(pt)),n!==o?(_e(),s=Te(),s!==o?r={type:e.not,expr:s}:(re=r,r=o)):(re=r,r=o),r===o&&(r=function(){let t,r,n,s,a;const i=38*re+18,l=le[i];if(l)return re=l.nextPos,l.result;if(t=re,r=Se(),r!==o){if(_e(),n=[],s=re,a=Ce(),a!==o?(_e(),s=a):(re=s,s=o),s!==o)for(;s!==o;)n.push(s),s=re,a=Ce(),a!==o?(_e(),s=a):(re=s,s=o);else n=o;n!==o?t={type:e.access,lhs:r,rhs:n}:(re=t,t=o)}else re=t,t=o;return t===o&&(t=Se()),le[i]={nextPos:re,result:t},t}()),le[a]={nextPos:re,result:r},r)}function Ce(){let r;const n=38*re+19,s=le[n];return s?(re=s.nextPos,s.result):(r=function(){let r,n,s;const a=38*re+20,i=le[a];return i?(re=i.nextPos,i.result):(ie++,r=re,t.substr(re,2)===P?(n=P,re+=2):(n=o,0===ie&&fe(mt)),n===o&&(46===t.charCodeAt(re)?(n=T,re++):(n=o,0===ie&&fe(gt))),n!==o?(_e(),s=De(),s!==o?r={type:e.member,ns:"?."===n,rhs:s}:(re=r,r=o)):(re=r,r=o),ie--,r===o&&(n=o,0===ie&&fe(ft)),le[a]={nextPos:re,result:r},r)}(),r===o&&(r=function(){let r,n,s,a,i;const l=38*re+21,u=le[l];return u?(re=u.nextPos,u.result):(ie++,r=re,t.substr(re,2)===P?(n=P,re+=2):(n=o,0===ie&&fe(mt)),n===o&&(n=null),91===t.charCodeAt(re)?(s=C,re++):(s=o,0===ie&&fe(yt)),s!==o?(_e(),a=ye(),a!==o?(_e(),93===t.charCodeAt(re)?(i=S,re++):(i=o,0===ie&&fe(bt)),i!==o?r={type:e.subscript,ns:null!==n,rhs:a}:(re=r,r=o)):(re=r,r=o)):(re=r,r=o),ie--,r===o&&(n=o,0===ie&&fe(vt)),le[l]={nextPos:re,result:r},r)}(),r===o&&(r=function(){let r,n,s,a,i,l,u,c;const h=38*re+22,d=le[h];if(d)return re=d.nextPos,d.result;if(ie++,r=re,t.substr(re,2)===P?(n=P,re+=2):(n=o,0===ie&&fe(mt)),n===o&&(n=null),40===t.charCodeAt(re)?(s=O,re++):(s=o,0===ie&&fe(At)),s!==o){for(_e(),a=re,i=ye(),i!==o?(l=_e(),a=i):(re=a,a=o),a===o&&(a=null),i=[],l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(_e(),c=ye(),c!==o?(_e(),l=c):(re=l,l=o)):(re=l,l=o);l!==o;)i.push(l),l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(_e(),c=ye(),c!==o?(_e(),l=c):(re=l,l=o)):(re=l,l=o);41===t.charCodeAt(re)?(l=R,re++):(l=o,0===ie&&fe(wt)),l!==o?(f=i,r={type:e.method,ns:null!==n,args:null===(p=a)?[]:[p,...f]}):(re=r,r=o)}else re=r,r=o;var p,f;return ie--,r===o&&(n=o,0===ie&&fe(Et)),le[h]={nextPos:re,result:r},r}())),le[n]={nextPos:re,result:r},r)}function Se(){let n,s,a,i;const l=38*re+23,u=le[l];return u?(re=u.nextPos,u.result):(n=re,40===t.charCodeAt(re)?(s=O,re++):(s=o,0===ie&&fe(At)),s!==o?(_e(),a=ye(),a!==o?(_e(),41===t.charCodeAt(re)?(i=R,re++):(i=o,0===ie&&fe(wt)),i!==o?n=a:(re=n,n=o)):(re=n,n=o)):(re=n,n=o),n===o&&(n=function(){let r,n,s,a,i,l,u,c;const h=38*re+24,d=le[h];if(d)return re=d.nextPos,d.result;if(ie++,r=re,n=function(){let r,n,s,a,i;const l=38*re+32,u=le[l];return u?(re=u.nextPos,u.result):(ie++,r=re,35===t.charCodeAt(re)?(n=L,re++):(n=o,0===ie&&fe(qt)),n!==o?(s=re,a=De(),a!==o?(58===t.charCodeAt(re)?(i=y,re++):(i=o,0===ie&&fe(lt)),i!==o?s=a:(re=s,s=o)):(re=s,s=o),s===o&&(s=null),a=De(),a!==o?r={type:e.function,module:s,value:a}:(re=r,r=o)):(re=r,r=o),ie--,r===o&&(n=o,0===ie&&fe(Vt)),le[l]={nextPos:re,result:r},r)}(),n!==o)if(40===t.charCodeAt(re)?(s=O,re++):(s=o,0===ie&&fe(At)),s!==o){for(_e(),a=re,i=ye(),i!==o?(l=_e(),a=i):(re=a,a=o),a===o&&(a=null),i=[],l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(_e(),c=ye(),c!==o?(_e(),l=c):(re=l,l=o)):(re=l,l=o);l!==o;)i.push(l),l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(_e(),c=ye(),c!==o?(_e(),l=c):(re=l,l=o)):(re=l,l=o);41===t.charCodeAt(re)?(l=R,re++):(l=o,0===ie&&fe(wt)),l!==o?r=function(t,r,n){const s=null===r?[]:[r,...n];return{type:e.call,value:t,args:s}}(n,a,i):(re=r,r=o)}else re=r,r=o;else re=r,r=o;return ie--,r===o&&(n=o,0===ie&&fe(Pt)),le[h]={nextPos:re,result:r},r}(),n===o&&(n=function(){let r;const n=38*re+25,s=le[n];return s?(re=s.nextPos,s.result):(r=function(){let r,n,s,a,i,l,u,c,h,d;const p=38*re+26,f=le[p];if(f)return re=f.nextPos,f.result;if(ie++,r=re,n=re,s=re,45===t.charCodeAt(re)?(a=D,re++):(a=o,0===ie&&fe(Ct)),a===o&&(a=null),i=re,l=[],u=t.charAt(re),B.test(u)?re++:(u=o,0===ie&&fe(St)),u!==o)for(;u!==o;)l.push(u),u=t.charAt(re),B.test(u)?re++:(u=o,0===ie&&fe(St));else l=o;if(l!==o){if(u=re,46===t.charCodeAt(re)?(c=T,re++):(c=o,0===ie&&fe(gt)),c!==o){for(h=[],d=t.charAt(re),B.test(d)?re++:(d=o,0===ie&&fe(St));d!==o;)h.push(d),d=t.charAt(re),B.test(d)?re++:(d=o,0===ie&&fe(St));c=[c,h],u=c}else re=u,u=o;u===o&&(u=null),l=[l,u],i=l}else re=i,i=o;if(i===o)if(i=re,46===t.charCodeAt(re)?(l=T,re++):(l=o,0===ie&&fe(gt)),l!==o){if(u=[],c=t.charAt(re),B.test(c)?re++:(c=o,0===ie&&fe(St)),c!==o)for(;c!==o;)u.push(c),c=t.charAt(re),B.test(c)?re++:(c=o,0===ie&&fe(St));else u=o;u!==o?(l=[l,u],i=l):(re=i,i=o)}else re=i,i=o;return i!==o?(a=[a,i],s=a):(re=s,s=o),n=s!==o?t.substring(n,re):s,n!==o&&(n={type:e.literal,value:parseFloat(n)}),r=n,ie--,r===o&&(n=o,0===ie&&fe(Tt)),le[p]={nextPos:re,result:r},r}(),r===o&&(r=Oe(),r===o&&(r=function(){let r,n,s,a,i,l,u;const c=38*re+30,h=le[c];if(h)return re=h.nextPos,h.result;if(ie++,r=re,91===t.charCodeAt(re)?(n=C,re++):(n=o,0===ie&&fe(yt)),n!==o){for(_e(),s=ye(),s===o&&(s=null),_e(),a=[],i=re,44===t.charCodeAt(re)?(l=N,re++):(l=o,0===ie&&fe(xt)),l!==o?(_e(),u=ye(),u!==o?(_e(),i=u):(re=i,i=o)):(re=i,i=o);i!==o;)a.push(i),i=re,44===t.charCodeAt(re)?(l=N,re++):(l=o,0===ie&&fe(xt)),l!==o?(_e(),u=ye(),u!==o?(_e(),i=u):(re=i,i=o)):(re=i,i=o);93===t.charCodeAt(re)?(i=S,re++):(i=o,0===ie&&fe(bt)),i!==o?r=function(t,r){const n=null===t?[]:[t,...r];return{type:e.array,value:n}}(s,a):(re=r,r=o)}else re=r,r=o;return ie--,r===o&&(n=o,0===ie&&fe(kt)),le[c]={nextPos:re,result:r},r}(),r===o&&(r=function(){let r,n,s,a,i,l,u,c,h,d,p;const f=38*re+31,m=le[f];if(m)return re=m.nextPos,m.result;if(ie++,r=re,123===t.charCodeAt(re)?(n=g,re++):(n=o,0===ie&&fe(at)),n!==o){for(_e(),s=re,a=Oe(),a!==o?(i=_e(),58===t.charCodeAt(re)?(l=y,re++):(l=o,0===ie&&fe(lt)),l!==o?(u=_e(),c=ye(),c!==o?s=[a,c]:(re=s,s=o)):(re=s,s=o)):(re=s,s=o),s===o&&(s=null),a=_e(),i=[],l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(c=_e(),h=Oe(),h!==o?(_e(),58===t.charCodeAt(re)?(d=y,re++):(d=o,0===ie&&fe(lt)),d!==o?(_e(),p=ye(),p!==o?(_e(),l=[h,p]):(re=l,l=o)):(re=l,l=o)):(re=l,l=o)):(re=l,l=o);l!==o;)i.push(l),l=re,44===t.charCodeAt(re)?(u=N,re++):(u=o,0===ie&&fe(xt)),u!==o?(c=_e(),h=Oe(),h!==o?(_e(),58===t.charCodeAt(re)?(d=y,re++):(d=o,0===ie&&fe(lt)),d!==o?(_e(),p=ye(),p!==o?(_e(),l=[h,p]):(re=l,l=o)):(re=l,l=o)):(re=l,l=o)):(re=l,l=o);125===t.charCodeAt(re)?(l=F,re++):(l=o,0===ie&&fe(Ft)),l!==o?(b=i,E=[],null!==(v=s)&&E.push(v),E.push.apply(E,b),r={type:e.dict,value:E}):(re=r,r=o)}else re=r,r=o;var v,b,E;return ie--,r===o&&(n=o,0===ie&&fe(It)),le[f]={nextPos:re,result:r},r}()))),le[n]={nextPos:re,result:r},r)}(),n===o&&(n=function(){let t,n;const s=38*re+34,a=le[s];return a?(re=a.nextPos,a.result):(ie++,t=re,n=De(),n!==o&&(i=n,n=r.has(i)?{type:e.literal,value:r.get(i)}:{type:e.symbol,value:i}),t=n,ie--,t===o&&(n=o,0===ie&&fe(Bt)),le[s]={nextPos:re,result:t},t);var i}()))),le[l]={nextPos:re,result:n},n)}function Oe(){let r,n,s,a,i;const l=38*re+27,u=le[l];if(u)return re=u.nextPos,u.result;if(ie++,r=re,39===t.charCodeAt(re)?(n=M,re++):(n=o,0===ie&&fe(Nt)),n!==o){for(s=re,a=[],i=t.charAt(re),W.test(i)?re++:(i=o,0===ie&&fe(Rt));i!==o;)a.push(i),i=t.charAt(re),W.test(i)?re++:(i=o,0===ie&&fe(Rt));s=t.substring(s,re),39===t.charCodeAt(re)?(a=M,re++):(a=o,0===ie&&fe(Nt)),a!==o?r={type:e.literal,value:s}:(re=r,r=o)}else re=r,r=o;if(r===o){if(r=re,34===t.charCodeAt(re)?(n=$,re++):(n=o,0===ie&&fe(Dt)),n!==o){for(s=re,a=[],i=t.charAt(re),X.test(i)?re++:(i=o,0===ie&&fe(Mt));i!==o;)a.push(i),i=t.charAt(re),X.test(i)?re++:(i=o,0===ie&&fe(Mt));s=t.substring(s,re),34===t.charCodeAt(re)?(a=$,re++):(a=o,0===ie&&fe(Dt)),a!==o?r={type:e.literal,value:s}:(re=r,r=o)}else re=r,r=o;if(r===o)if(r=re,96===t.charCodeAt(re)?(n=_,re++):(n=o,0===ie&&fe($t)),n!==o){for(s=[],a=Ne(),a===o&&(a=Re());a!==o;)s.push(a),a=Ne(),a===o&&(a=Re());96===t.charCodeAt(re)?(a=_,re++):(a=o,0===ie&&fe($t)),a!==o?r={type:e.tstring,parts:s}:(re=r,r=o)}else re=r,r=o}return ie--,r===o&&(n=o,0===ie&&fe(Ot)),le[l]={nextPos:re,result:r},r}function Ne(){let e,r,n,s;const a=38*re+28,i=le[a];return i?(re=i.nextPos,i.result):(ie++,e=re,123===t.charCodeAt(re)?(r=g,re++):(r=o,0===ie&&fe(at)),r!==o?(_e(),n=ye(),n!==o?(_e(),125===t.charCodeAt(re)?(s=F,re++):(s=o,0===ie&&fe(Ft)),s!==o?e=n:(re=e,e=o)):(re=e,e=o)):(re=e,e=o),ie--,e===o&&(r=o,0===ie&&fe(_t)),le[a]={nextPos:re,result:e},e)}function Re(){let r,n,s,a,i;const l=38*re+29,u=le[l];if(u)return re=u.nextPos,u.result;if(ie++,r=re,n=[],s=re,a=[],i=t.charAt(re),Q.test(i)?re++:(i=o,0===ie&&fe(jt)),i!==o)for(;i!==o;)a.push(i),i=t.charAt(re),Q.test(i)?re++:(i=o,0===ie&&fe(jt));else a=o;if(s=a!==o?t.substring(s,re):a,s===o&&(s=re,92===t.charCodeAt(re)?(a=m,re++):(a=o,0===ie&&fe(st)),a!==o?(t.length>re?(i=t.charAt(re),re++):(i=o,0===ie&&fe(ot)),i!==o?s=i:(re=s,s=o)):(re=s,s=o)),s!==o)for(;s!==o;){if(n.push(s),s=re,a=[],i=t.charAt(re),Q.test(i)?re++:(i=o,0===ie&&fe(jt)),i!==o)for(;i!==o;)a.push(i),i=t.charAt(re),Q.test(i)?re++:(i=o,0===ie&&fe(jt));else a=o;s=a!==o?t.substring(s,re):a,s===o&&(s=re,92===t.charCodeAt(re)?(a=m,re++):(a=o,0===ie&&fe(st)),a!==o?(t.length>re?(i=t.charAt(re),re++):(i=o,0===ie&&fe(ot)),i!==o?s=ee(i):(re=s,s=o)):(re=s,s=o))}else n=o;return n!==o&&(n={type:e.literal,value:n.join("")}),r=n,r===o&&(r=re,123===t.charCodeAt(re)?(n=g,re++):(n=o,0===ie&&fe(at)),n!==o&&(n={type:e.literal,value:n}),r=n),ie--,r===o&&(n=o,0===ie&&fe(Lt)),le[l]={nextPos:re,result:r},r}function De(){let e,r,n,s,a;const i=38*re+33,l=le[i];if(l)return re=l.nextPos,l.result;if(e=re,r=re,n=t.charAt(re),U.test(n)?re++:(n=o,0===ie&&fe(Ht)),n!==o){for(s=[],a=t.charAt(re),G.test(a)?re++:(a=o,0===ie&&fe(zt));a!==o;)s.push(a),a=t.charAt(re),G.test(a)?re++:(a=o,0===ie&&fe(zt));n=[n,s],r=n}else re=r,r=o;return e=r!==o?t.substring(e,re):r,le[i]={nextPos:re,result:e},e}function Me(){let e;const r=38*re+35,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,2)===j?(e=j,re+=2):(e=o,0===ie&&fe(Wt)),e===o&&(t.substr(re,2)===k?(e=k,re+=2):(e=o,0===ie&&fe(Xt))),le[r]={nextPos:re,result:e},e)}function $e(){let e;const r=38*re+36,n=le[r];return n?(re=n.nextPos,n.result):(t.substr(re,2)===I?(e=I,re+=2):(e=o,0===ie&&fe(Qt)),e===o&&(62===t.charCodeAt(re)?(e=V,re++):(e=o,0===ie&&fe(Ut)),e===o&&(t.substr(re,2)===q?(e=q,re+=2):(e=o,0===ie&&fe(Gt)),e===o&&(60===t.charCodeAt(re)?(e=H,re++):(e=o,0===ie&&fe(Zt))))),le[r]={nextPos:re,result:e},e)}function _e(){let e,r;const n=38*re+37,s=le[n];if(s)return re=s.nextPos,s.result;for(ie++,e=[],r=t.charAt(re),Z.test(r)?re++:(r=o,0===ie&&fe(Jt));r!==o;)e.push(r),r=t.charAt(re),Z.test(r)?re++:(r=o,0===ie&&fe(Jt));return ie--,le[n]={nextPos:re,result:e},e}se=l();const Fe=se!==o&&re===t.length;function Le(){throw se!==o&&re<t.length&&fe({type:"end"}),e=ae,r=oe<t.length?function(e=re){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(oe):null,s=oe<t.length?pe(oe,oe+1):pe(oe,oe),new n(n.buildMessage(e,r),e,r,s);var e,r,s}return s.peg$library?{peg$result:se,peg$currPos:re,peg$FAILED:o,peg$maxFailExpected:ae,peg$maxFailPos:oe,peg$success:Fe,peg$throw:Fe?void 0:Le}:Fe?se:void Le()}(t,{startRule:s===a.MODE_TEMPLATED?"TemplatedRoot":"ExpressionRoot"}))}static evaluate(t,e,r,n){return new o(t,e).visitRoot(r,n===a.MODE_TEMPLATED)}static interpret(t,e,r,n){return a.evaluate(t,e,a.parse(r,n),n)}}class i{#r;#n;constructor(t,e){this.#r=t,this.#n=e}withModule(t,e){const r=t?{[t]:e}:e;return new i({...this.#r,...r},this.#n)}withOverlay(...t){return new i(this.#r,0===t.length?this.#n:[...this.#n,...t])}resolve(t){return s(this.#n,t)}evaluateExpression(t){return a.interpret(this.#r,this.#n,t,a.MODE_EXPRESSION)}evaluateTemplated(t){return a.interpret(this.#r,this.#n,t,a.MODE_TEMPLATED)}}class l{static fromHtml(...t){const e=document.createElement("template");return e.innerHTML=t.map(t=>t.trim()).join(""),document.adoptNode(e.content)}static toHtml(t){var e=document.createElement("template");return e.content.appendChild(t),e.innerHTML}static isBlank(t){return 0===t.childElementCount&&""===t.textContent.trim()}static from(...t){const e=new DocumentFragment;for(const r of t)e.appendChild(r);return e}static fromChildNodes(t){const e=new DocumentFragment;for(;t.firstChild;)e.appendChild(t.firstChild);return e}}class u{static id=0;static uid(t){return`${t}-${++u.id}`}static defaultValue(t,e,r){return t.hasAttribute(e)||t.setAttribute(e,r),t.getAttribute(e)}static forward(t,e,r){e.getAttributeNames().filter(e=>e.startsWith(t)).forEach(n=>{const s=n.substring(t.length);if("class"===s){const n=e.getAttribute(`${t}class`)?.split(/\s+/).filter(t=>t.length)??[];return void r.classList.add(...n)}r.setAttribute(s,e.getAttribute(n))})}static set(t,e,r){null==r?t.removeAttribute(e):t.setAttribute(e,r)}}class c{static from(t){for(const e of t.children)e.matches('[slot=""]')&&e.removeAttribute("slot");const e=Array.from(t.children).filter(t=>t.matches("[slot]")).map(t=>{t.remove();const e=t.getAttribute("slot");return t.removeAttribute("slot"),[e,c.slotFromNode(t)]}),r={};r.default=new DocumentFragment,r.default.append(...t.childNodes);for(const[t,n]of e)t in r||(r[t]=new DocumentFragment),r[t].append(n);return r}static slotFromNode(t){return t instanceof HTMLTemplateElement?document.adoptNode(t.content):t instanceof HTMLScriptElement&&"text/html"===t.type?l.fromHtml(t.innerHTML):t}}class h{static isParsed(t){for(let e=t;e;e=e.parentNode)if(e.nextSibling)return!0;return!1}static waitDomContentLoaded(t){if("loading"===t.readyState)return new Promise(e=>{t.addEventListener("DOMContentLoaded",()=>e(void 0),{once:!0})});if("complete"===t.readyState)return Promise.resolve();const e=t.defaultView;return null===e?Promise.resolve():new Promise(t=>{const r=()=>{e.removeEventListener("DOMContentLoaded",r),e.removeEventListener("load",r),t(void 0)};e.addEventListener("DOMContentLoaded",r),e.addEventListener("load",r)})}static waitParsed(t){return h.isParsed(t)?Promise.resolve(t):new Promise(e=>{const r=new MutationObserver(()=>{h.isParsed(t)&&(r.disconnect(),e(t))});for(let e=t.parentNode;e;e=e.parentNode)r.observe(e,{childList:!0});h.waitDomContentLoaded(t.ownerDocument).then(()=>{r.disconnect(),e(t)})})}static queryChildren(t,e){for(const r of t.children)if(r.matches(e))return r;return null}static queryChildrenAll(t,e){const r=[];for(const n of t.children)n.matches(e)&&r.push(n);return r}}class d{#u=new Set;removed(t){return this.#u.has(t)}remove(t){t.replaceChildren?.(),Object.keys(t.dataset||{}).filter(t=>t.startsWith("tpl")).forEach(e=>{delete t.dataset[e]}),this.#u.add(t)}popData(t,e){const r=t.dataset[e];return delete t.dataset[e],r}prepend(t,e){t.parentNode.insertBefore(e,t)}append(t,e){t.parentNode.insertBefore(e,t.nextSibling)}replace(t,e){this.prepend(t,e),this.remove(t)}cleanup(){for(const t of this.#u)t.remove();this.#u.clear()}}class p{static ORDERED_COMMANDS=["tplIf","tplWith","tplEach","tplWhen","tplClassAppend","tplAttrAppend","tplRemove","tplVerbatim"];static tplIf(t,e,r,n){n.evaluateExpression(e)||r.remove(t)}static tplWith(t,e,r,n){const s=n.evaluateExpression(e),o=r.popData(t,"tplVar"),a=new g(t,n).withOverlay(o?{[o]:s}:s).render();r.replace(t,a)}static tplEach(t,e,r,n){const s=r.popData(t,"tplVar"),o=r.popData(t,"tplStat"),a=new g(t,n),i=n.evaluateExpression(e),l=null===i||"object"!=typeof i?void 0:Object.getPrototypeOf(i),u=i?.[Symbol.iterator]||l!==Object.prototype&&null!==l?null:Object.entries(i),c=i instanceof Map?[...i]:u,h=null===c?i:c.map(([t,e])=>({key:t,value:e}));if(!h?.[Symbol.iterator])throw new Error(`Expected an iterable got '${i}'`);const d=o?h:null,p="number"==typeof d?.length?d.length:d?.size,f="number"==typeof p?p:null;let m=0;for(const e of h){const n=s?{[s]:e}:e,i={index:m,count:m+1,size:f,first:0===m,last:null===f?null:m===f-1,even:m%2==0,odd:m%2==1},l=o?[{[o]:i},n]:[n];r.prepend(t,a.withOverlay(...l).render()),++m}r.remove(t)}static tplWhen(t,e,r,n){n.evaluateExpression(e)||r.remove(t)}static tplVerbatim(t,e,r,n){const s=t.cloneNode(!0);r.replace(t,s)}static tplRemove(t,e,r,n){switch(e.toLowerCase()){case"tag":{const e=l.fromChildNodes(t);"tplVerbatim"in t.dataset?(r.popData(t,"tplVerbatim"),r.replace(t,e)):(r.append(t,e),r.remove(t));break}case"body":t.replaceChildren();break;case"all":r.remove(t)}}static tplClassAppend(t,e,r,n){const s=n.evaluateExpression(e);if(!s)return;const o=(Array.isArray(s)?s:[s]).flatMap(t=>"string"==typeof t?t.split(" "):t).filter(Boolean);0!==o.length&&t.classList.add(...o)}static tplAttrAppend(t,e,r,n){const s=n.evaluateExpression(e);s&&0!==s.length&&(Array.isArray(s[0])?s:[s]).forEach(([e,r])=>{t.setAttribute(e,r)})}static textNode(t,r,n,s){for(const o of s.evaluateTemplated(r))if(null!=o.value)switch(o.type){case e.dom.t:n.prepend(t,document.createTextNode(o.value));break;case e.dom.h:n.prepend(t,l.fromHtml("string"==typeof o.value?o.value:String(o.value)));break;case e.dom.n:if(!(o.value instanceof Node))throw new TypeError(`Expected a Node, got '${typeof o.value}'`);n.prepend(t,o.value)}n.remove(t)}}const f=new t(1e3);function m(t){return f.getOrCompute(t,t=>t.substring(3).split(/(?=[A-Z])/).join("-").toLowerCase())}class g{static fromHtml(t,e,...r){return new g(l.fromHtml(t),new i(e,r))}static fromSelector(t,e,...r){const n=document.querySelector(t);if(!(n instanceof HTMLTemplateElement))throw new Error("template selector does not match any template tag");return g.fromTemplate(n,e,...r)}static fromTemplate(t,e,...r){const n=document.adoptNode(t.content);return new g(n,new i(e,r))}static fromFragment(t,e,...r){return new g(t,new i(e,r))}#c;#h;constructor(t,e){this.#c=t,this.#h=e}withEvaluator(t){return new g(this.#c,t)}withFragment(t){return new g(t,this.#h)}withModule(t,e){return new g(this.#c,this.#h.withModule(t,e))}withOverlay(...t){return new g(this.#c,this.#h.withOverlay(...t))}evaluateExpression(t,...e){return this.#h.withOverlay(...e).evaluateExpression(t)}evaluateTemplated(t,...e){return this.#h.withOverlay(...e).evaluateTemplated(t)}evaluator(){return this.#h}render(){try{const t=new d,e=document.importNode(this.#c,!0),r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?e:l.from(e),n=document.createNodeIterator(r,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,g.#d);let s;for(;null!==(s=n.nextNode());){if(t.cleanup(),s.nodeType===Node.TEXT_NODE){try{p.textNode(s,s.nodeValue,t,this.#h)}catch(t){throw v.wrap("Error evaluating text node",s,t)}continue}const e=s;for(const r of p.ORDERED_COMMANDS){if(!(r in e.dataset))continue;const n=t.popData(e,r);try{p[r](e,n,t,this.#h)}catch(t){throw v.wrap(`Error evaluating data-tpl-${m(r)}="${n}"`,e,t)}if(t.removed(e))break}for(const r of Object.keys(e.dataset||{})){if(!r.startsWith("tpl"))continue;const n=m(r),s=t.popData(e,r);try{const t=this.#h.evaluateExpression(s);if("boolean"==typeof t){e.toggleAttribute(n,t);continue}null!=t&&e.setAttribute(n,t)}catch(t){throw v.wrap(`Error evaluating data-tpl-${n}="${s}"`,e,t)}}}return t.cleanup(),r}catch(t){if(t instanceof v)throw t;throw new v("Error rendering template",this.#c,t)}}renderTo(t){t.replaceChildren(this.render())}appendTo(t){t.appendChild(this.render())}renderToSelector(t){const e=document.querySelector(t);e&&this.renderTo(e)}appendToSelector(t){const e=document.querySelector(t);e&&this.appendTo(e)}static#d(t){if(t.nodeType===Node.TEXT_NODE)return t.nodeValue.includes("{{")&&t.nodeValue.includes("}}")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT;for(const e of t.attributes)if(e.name.startsWith("data-tpl-"))return NodeFilter.FILTER_ACCEPT;return NodeFilter.FILTER_SKIP}}class v extends Error{static FRAMES=3;#p;#f;truncated=!1;static wrap(t,e,r){return r instanceof v&&r.depth>=v.FRAMES?(r.truncated=!0,r):new v(t,e,r)}constructor(t,e,r){super(`${t} in \`${v.describe(e)}\``,{cause:r}),this.name="RenderError",this.#p=e,this.#f=(r instanceof v?r.depth:0)+1}get depth(){return this.#f}get node(){return this.#p}get html(){return v.stringify(this.#p)}static describe(t){if(t.nodeType===Node.TEXT_NODE)return v.#m(String(t.nodeValue).trim());if(t.nodeType===Node.ELEMENT_NODE){const e=t,r=Array.from(e.attributes,t=>` ${t.name}="${t.value}"`).join("");return v.#m(`<${e.localName}${r}>`)}const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||String(t.nodeValue??"").trim().length>0).map(t=>v.describe(t));return v.#m(e.join(""))}static#m(t){return t.length>120?`${t.slice(0,120)}…`:t}static stringify(t){return l.toHtml(v.#g(t.cloneNode(!0)))}static#g(t){t.nodeType===Node.TEXT_NODE&&(t.nodeValue=t.nodeValue.trim());for(let e=0;e<t.childNodes.length;e++){const r=t.childNodes[e];r.nodeType===Node.TEXT_NODE?(r.nodeValue=r.nodeValue.trim(),0===r.nodeValue.length&&(t.removeChild(r),e--)):r.nodeType===Node.ELEMENT_NODE&&v.#g(r)}return t}}class y{#v=new Map;#y;#b=new Promise(t=>{this.#y=t});constructor(){h.waitDomContentLoaded(document).then(()=>{this.#E()})}ready(){return this.#b}async#E(){await this.settled(),document.dispatchEvent(new CustomEvent("ftl:ready",{bubbles:!1,cancelable:!1})),this.#y()}enqueue(t){if(this.#v.has(t))return;const{promise:e,resolve:r}=Promise.withResolvers(),n=h.waitParsed(t).then(()=>t.upgrade()).finally(()=>{this.#v.delete(t),r()});this.#v.set(t,{upgrade:n,finished:e})}async#A(t,e){for(;;){const r=Array.from(this.#v).filter(([e])=>t(e)).map(([,t])=>e(t));if(0===r.length)return;await Promise.all(r)}}settled(){return this.#A(()=>!0,t=>t.finished)}upgraded(t){return this.#A(t,t=>t.upgrade)}whenUpgraded(t){return this.#v.get(t)?.upgrade}pending(){return Array.from(this.#v.keys())}}class b{#x={};#w=!1;#P={string:{unmarshal:(t,e,r)=>t,marshal:(t,e,r)=>null==t?null:String(t)},number:{unmarshal:(t,e,r)=>null===t?null:Number(t),marshal:(t,e,r)=>null==t?null:String(t)},presence:{unmarshal:(t,e,r)=>null!==t,marshal:(t,e,r)=>t?"":null},bool:{unmarshal:(t,e,r)=>"true"===t,marshal:(t,e,r)=>null==t?null:String(!0===t)},json:{unmarshal:(t,e,r)=>null===t?null:JSON.parse(t),marshal:(t,e,r)=>null==t?null:JSON.stringify(t)},csv:{unmarshal:(t,e,r)=>null===t?[]:t.split(",").map(t=>t.trim()).filter(t=>t),marshal:(t,e,r)=>null==t?null:t.join(",")}};#T={};#r;#C=[];#h=new i(void 0,[]);#S=new y;defineElement(t,e){return this.#w?(this.#O(t,e),this):(this.#x[t]=e,this)}static declarationsOf(t){const e=[];for(let r=t;null!==r&&r!==HTMLElement;r=Object.getPrototypeOf(r))e.unshift(r);const r=t=>e.flatMap(e=>Object.getOwnPropertyDescriptor(e,t)?.value??[]);return{observed:r("observed"),attributes:r("attributes")}}static propertyOf(t){return t.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}#O(t,e){const{observed:r,attributes:n}=b.declarationsOf(e),{template:s,templates:o,slots:a,mappers:i,config:l}=e,u=r.map(t=>t.split(":")[0]),c=[...new Set(u.reverse())].reverse(),h=[...n,...r].reduce((t,e)=>{const[r,n]=e.split(":"),s=n??"string";if(!(s in this.#P)&&!(s in(i??{})))throw new Error(`unsupported attribute type: ${s}`);return t[r]=i?.[s]??this.#P[s],t},{}),d=Object.entries(Object.assign({},o,s?{default:s}:{})).map(([t,e])=>[t,g.fromHtml(e)]),p=Object.fromEntries(d);e.BITS={registry:this,enqueue:t=>this.#S.enqueue(t),SLOTS:a,CONFIG:l,OBSERVED:c,DECLARED:[...new Set([...c,...n.map(t=>t.split(":")[0])])],ATTR_TO_MAPPER:h,ATTR_TO_PROPERTY:Object.fromEntries(c.map(t=>[t,b.propertyOf(t)])),TEMPLATES:p},customElements.define(t,e)}defineModule(t,e){const r=t?{[t]:e}:e;return this.#r={...this.#r,...r},this.#N(),this}defineModules(t){return this.#r=t,this.#N(),this}defineComponent(t,e){return this.#T[t]=e,this}defineData(...t){return this.#C=t,this.#N(),this}defineOverlay(...t){return this.#C=[...this.#C,...t],this.#N(),this}defineMapper(t,e){return this.#P[t]=e,this}plugin(t){return t.configure(this),this}configure(){for(const[t,e]of Object.entries(this.#x))this.#O(t,e),delete this.#x[t];return this.#w=!0,this}settle(t){return this.#S.upgraded(t)}whenUpgraded(t){return this.#S.whenUpgraded(t)}pending(){return this.#S.pending()}ready(){return this.#S.ready()}#N(){this.#h=new i(this.#r,this.#C)}evaluator(){return this.#h}component(t){return this.#T[t]}}const E=new b;class A{static fromHtml(t){return g.fromHtml(t).withEvaluator(E.evaluator())}static fromSelector(t){return g.fromSelector(t).withEvaluator(E.evaluator())}static fromTemplate(t){return g.fromTemplate(t).withEvaluator(E.evaluator())}static fromFragment(t){return g.fromFragment(t).withEvaluator(E.evaluator())}}class x{static waitFor(t){return E.settle(e=>t.contains(e))}static waitForChildren(t){return E.settle(e=>t!==e&&t.contains(e))}}class w extends HTMLElement{static BITS={registry:E,enqueue:t=>{},SLOTS:!1,CONFIG:void 0,OBSERVED:[],DECLARED:[],ATTR_TO_MAPPER:{},ATTR_TO_PROPERTY:{},TEMPLATES:{}};static get observedAttributes(){return this.BITS.OBSERVED}constructor(){super(),this.internals=this.attachInternals()}internals;#R=!1;#D=!1;#M=new Set;#$=null;#_={};#F(){return this.constructor.BITS}#L(t){const e=this.#F().ATTR_TO_MAPPER[t];if(!e)throw new Error(`${this.constructor.name} declares no attribute '${t}': declare it in static observed or static attributes, or read it with getAttribute`);return e}unmarshal(t,e){return this.#L(t).unmarshal(e,t,this)}marshal(t,e){return this.#L(t).marshal(e,t,this)}get _registry(){return this.#F().registry}component(t){return this.#F().registry.component(t)}template(t){const e=this.#F().TEMPLATES[t??"default"];if(!e)throw new Error(`no template named '${t??"default"}' on ${this.constructor.name}`);const r=e.withEvaluator(this.#F().registry.evaluator()),n=this.#F().CONFIG;return n?r.withOverlay({config:n}):r}connectedCallback(){this.#D||this.#F().enqueue(this)}attributeChangedCallback(t,e,r){e!==r&&(this.#M.has(t)||(this.#R?this[this.#F().ATTR_TO_PROPERTY[t]]=this.unmarshal(t,r):null!==this.#$&&t in this.#$&&(this.#$[t]=this.unmarshal(t,r))))}async upgrade(){if(this.#D)return;this.#D=!0;const t=this.#F().SLOTS?c.from(this):void 0,e=Object.fromEntries(this.#F().DECLARED.map(t=>[t,this.unmarshal(t,this.getAttribute(t))])),r=new Set(this.#F().OBSERVED);this.#_=Object.fromEntries(Object.entries(e).filter(([t])=>!r.has(t))),this.#$=e;try{await this.render({slots:t});const r=this.#F().ATTR_TO_PROPERTY;for(const t of this.#F().OBSERVED)this[r[t]]=e[t];this.#R=!0,this.internals.states.add("rendered")}finally{this.#$=null}}render(t){}declared(t){return t in this.#_?this.#_[t]:null!==this.#$&&t in this.#$?this.#$[t]:this.unmarshal(t,this.getAttribute(t))}get rendered(){return this.#R}reflectTo(t,e){const r=this.marshal(t,e);if(r!==this.getAttribute(t)){this.#M.add(t);try{u.set(this,t,r)}finally{this.#M.delete(t)}}}}const P=/\{(\w+)\}/g,T=/\{(\d+)\}/g,C=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),S=new Set,O=t=>{S.has(t)||(S.add(t),console.warn(`l10n: ${t}`))},N=new t(100),R=(t,e,r)=>{const n=`${t.name}|${e??""}|${void 0===r?"":JSON.stringify(r)}`;return N.getOrCompute(n,()=>new t(e,r))};class D{static t(t,...e){const r=this.l10n??{};let n=Object.hasOwn(r,t)?r[t]:void 0;if(void 0===n)return O(`missing message "${t}"`),t;const s=1===e.length&&C(e[0])?e[0]:null;if(C(n))if("number"!=typeof s?.count)O(`plural message "${t}" needs a numeric {count}`),n=n.other;else{const t=this.locale??navigator?.language??"en";n=n[R(Intl.PluralRules,t).select(s.count)]??n.other}return void 0===n||"object"==typeof n?(O(`plural message "${t}" has no "other" form`),t):s?n.replace(P,(e,r)=>Object.hasOwn(s,r)?String(s[r]):(O(`message "${t}" wants {${r}}`),e)):e.length>0?n.replace(T,(r,n)=>{const s=Number(n);return s>=e.length?(O(`message "${t}" wants {${n}}`),r):String(e[s])}):n}static date(t,e){return R(Intl.DateTimeFormat,this.locale,e).format(t)}static number(t,e){return R(Intl.NumberFormat,this.locale,e).format(t)}static bytes(t){const e=R(Intl.NumberFormat,this.locale,{maximumFractionDigits:2}).format;return t>=1073741824?`${e(t/1024/1024/1024)}GiB`:t>=1048576?`${e(t/1024/1024)}MiB`:t>=1024?`${e(t/1024)}KiB`:`${e(t)}B`}static failure(t){return Array.isArray(t?.problems)&&t.problems.length>0?t.problems.map(t=>{return e=t,("string"==typeof e?.reason&&""!==e.reason.trim()?e.reason:void 0)??D.t.call(this,"failure.no-reason");var e}).join("\n"):void 0!==t?.message?String(t.message):null==t?"":String(t)}static of(t={}){const e=t=>E.evaluator().resolve(t),r=r=>(...n)=>r.apply({l10n:e("l10n"),locale:t.locale??e("locale")},n);return{t:r(D.t),date:r(D.date),number:r(D.number),bytes:r(D.bytes),failure:r(D.failure)}}}export{u as Attributes,t as BoundedCache,i as ExpressionEvaluator,a as Expressions,l as Fragments,c as LightSlots,D as Localization,h as Nodes,w as ParsedElement,b as Registry,v as RenderError,x as Rendering,g as Template,A as Templates,E as registry};
|
|
1
|
+
class t{#t;#e=new Map;constructor(t){this.#t=t}getOrCompute(t,e){if(this.#e.has(t))return this.#e.get(t);const r=e(t);return this.#e.size>=this.#t&&this.#e.delete(this.#e.keys().next().value),this.#e.set(t,r),r}get size(){return this.#e.size}}const e={ter:Symbol("ternary"),elv:Symbol("elvis"),nullc:Symbol("null-coalescence"),or:Symbol("or"),and:Symbol("and"),eq:Symbol("eq"),cmp:Symbol("cmp"),not:Symbol("not"),access:Symbol("access"),member:Symbol("access-member"),subscript:Symbol("access-subscript"),method:Symbol("access-method-call"),call:Symbol("module-function-call"),tstring:Symbol("tstring"),literal:Symbol("literal"),array:Symbol("array-literal"),dict:Symbol("dict-literal"),function:Symbol("module-function"),symbol:Symbol("symbol"),templated:{ten:Symbol("templated-node"),teh:Symbol("templated-html"),tet:Symbol("templated-text"),tel:Symbol("templated-literal")},dom:{t:Symbol("text"),h:Symbol("html"),n:Symbol("node")}},r=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0]]);class n extends SyntaxError{constructor(t,e,r,n){super(t),this.expected=e,this.found=r,this.location=n,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let r=null;const n=t.find(t=>t.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const s=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(s):s,i=this.location.source+":"+o.line+":"+o.column;if(r){const t=this.location.end,n="".padEnd(o.line.toString().length," "),l=r[s.line-1],a=(s.line===t.line?t.column:l.length+1)-s.column||1;e+="\n --\x3e "+i+"\n"+n+" |\n"+o.line+" | "+l+"\n"+n+" | "+"".padEnd(s.column-1," ")+"".padEnd(a,"^")}else e+="\n at "+i}return e}static buildMessage(t,e){function r(t){return t.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function s(t,e){return function(t){return n?t.replace(n,t=>"\\u{"+r(t)+"}"):t}(t.replace(e,"\\$&").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+r(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+r(t)))}function o(t){return s(t,/[\\"]/g)}function i(t){return s(t,/[\\\]^-]/g)}const l={literal:t=>'"'+o(t.text)+'"',class(t){const e=t.parts.map(t=>Array.isArray(t)?i(t[0])+"-"+i(t[1]):i(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function a(t){return l[t.type](t)}return"Expected "+function(t){const e=t.map(a);if(e.sort(),e.length>0){let t=1;for(let r=1;r<e.length;r++)e[r-1]!==e[r]&&(e[t]=e[r],t++);e.length=t}switch(e.length){case 1:return e[0];case 2:return e[0]+" or "+e[1];default:return e.slice(0,-1).join(", ")+", or "+e[e.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."}}const s=(t,e)=>{if("self"===e)return t[t.length-1];for(let r=t.length-1;r>=0;r--){const n=t[r];if(null!=n&&("object"==typeof n||"function"==typeof n)&&e in n)return n[e]}};class o{#r;#n;constructor(t,e){this.#r=t,this.#n=e}#s(t){return s(this.#n,t)}#o(t,r){const n=0===r?t.lhs:t.rhs[r-1];return n.type===e.symbol?n.value:n.type===e.member?n.rhs:null}#i;#l(){return this.#i||(this.#i=new Proxy(this.#n,{get:(t,e)=>this.#s(e)})),this.#i}[e.and](t){return this.visit(t.lhs)&&this.visit(t.rhs)}[e.or](t){return this.visit(t.lhs)||this.visit(t.rhs)}[e.nullc](t){return this.visit(t.lhs)??this.visit(t.rhs)}[e.not](t){return!this.visit(t.expr)}[e.eq](t){const e=this.visit(t.lhs)===this.visit(t.rhs);return"=="===t.op?e:!e}[e.cmp](t){const e=this.visit(t.lhs),r=this.visit(t.rhs);switch(t.op){case">":return e>r;case"<":return e<r;case">=":return e>=r;case"<=":return e<=r;default:throw new Error(`unknown cmp op ${t.op}`)}}[e.call](t){const e=t.value,r=null===e.module?this.#r:this.#r?.[e.module];if(!r)throw new Error(`Module "${e.module}" not found`);const n=r[e.value];if(!n)throw new Error(`Function "#${null===e.module?"":`${e.module}:`}${e.value}" not found`);const s=t.args.map(t=>this.visit(t));return n.apply(this.#l(),s)}[e.literal](t){return t.value}[e.tstring](t){let e="";const r=t.parts;for(let t=0,n=r.length;t<n;t++){const n=this.visit(r[t]);null!=n&&(e+=n)}return e}[e.symbol](t){return this.#s(t.value)}[e.dict](t){return Object.fromEntries(t.value.map(t=>[this.visit(t[0]),this.visit(t[1])]))}[e.array](t){return t.value.map(t=>this.visit(t))}[e.ter](t){return this.visit(t.cond)?this.visit(t.ifTrue):this.visit(t.ifFalse)}[e.elv](t){return this.visit(t.cond)||this.visit(t.ifFalse)}[e.access](t){let r,n=this.visit(t.lhs);for(let s=0;s!==t.rhs.length;++s){const o=t.rhs[s];if(o.ns&&null==n)return;let i;switch(o.type){case e.member:i=n[o.rhs];break;case e.subscript:i=n[this.visit(o.rhs)];break;case e.method:{if(!n){const e=this.#o(t,s);throw new Error(null===e?"Method missing":`Method missing "${e}"`)}const e=o.args.map(t=>this.visit(t));i=n.apply(r,e);break}}r=n,n=i}return n}visit(t,...e){return this[t.type](t,...e)}visitRoot(t,r){return r?t.map(t=>{switch(t.type){case e.templated.tel:return{type:e.dom.t,value:t.value};case e.templated.tet:return{type:e.dom.t,value:this.visit(t.value)};case e.templated.teh:return{type:e.dom.h,value:this.visit(t.value)};case e.templated.ten:return{type:e.dom.n,value:this.visit(t.value)};default:throw new Error(`unknown node type ${t.type.toString()}`)}}):this.visit(t)}}class i{static MODE_EXPRESSION=Symbol("MODE_EXPRESSION");static MODE_TEMPLATED=Symbol("MODE_TEMPLATED");static#a=new t(1e3);static parse(t,s){const o=s?.toString()+t;return this.#a.getOrCompute(o,()=>function(t,s){const o={},i=(s=void 0!==s?s:{}).grammarSource,l={TemplatedRoot:ae,ExpressionRoot:ce};let a=ae;const u="{{{{",c="}}}}",h="{{{",d="}}}",p="{{",m="}}",f="\\",g="{",v="?",y=":",b="?:",E="??",x="||",A="&&",w="!",P="?.",T=".",C="[",S="]",O="(",N=",",D=")",R="-",M="'",$='"',_="`",L="}",F="#",j="==",k="!=",I=">=",V=">",q="<=",H="<",B=re("{{{{",!1),z=re("}}}}",!1),W=re("{{{",!1),X=re("}}}",!1),Q=re("{{",!1),U=re("}}",!1),G=ne(["\\","{"],!0,!1,!1),J=re("\\",!1),Y={type:"any"},Z=re("{",!1),K=re("?",!1),tt=re(":",!1),et=re("?:",!1),rt=re("??",!1),nt=re("||",!1),st=re("&&",!1),ot=re("!",!1),it=se("member"),lt=re("?.",!1),at=re(".",!1),ut=se("subscript"),ct=re("[",!1),ht=re("]",!1),dt=se("method-call"),pt=re("(",!1),mt=re(",",!1),ft=re(")",!1),gt=se("module-function-call"),vt=se("number-literal"),yt=re("-",!1),bt=ne([["0","9"]],!1,!1,!1),Et=se("string-literal"),xt=re("'",!1),At=ne(["'"],!0,!1,!1),wt=re('"',!1),Pt=ne(['"'],!0,!1,!1),Tt=re("`",!1),Ct=se("tstring-expression"),St=re("}",!1),Ot=se("tstring-literal"),Nt=ne(["\\","`","{"],!0,!1,!1),Dt=se("array-literal"),Rt=se("dict-literal"),Mt=se("module-function"),$t=re("#",!1),_t=ne([["a","z"],["A","Z"],"$","_"],!1,!1,!1),Lt=ne([["a","z"],["A","Z"],"$","_",["0","9"]],!1,!1,!1),Ft=se("identifier-or-keyword"),jt=re("==",!1),kt=re("!=",!1),It=re(">=",!1),Vt=re(">",!1),qt=re("<=",!1),Ht=re("<",!1),Bt=ne([" ","\t","\n","\r"],!1,!1,!1);function zt(t){return t}function Wt(t,e,r){return{op:e,rhs:r}}function Xt(t,e,r){return{op:e,rhs:r}}function Qt(t){return t}let Ut=0|s.peg$currPos;const Gt=[{line:1,column:1}];let Jt,Yt,Zt=Ut,Kt=s.peg$maxFailExpected||[],te=0|s.peg$silentFails,ee=new Map;if(s.startRule){if(!(s.startRule in l))throw new Error("Can't start parsing from rule \""+s.startRule+'".');a=l[s.startRule]}function re(t,e){return{type:"literal",text:t,ignoreCase:e}}function ne(t,e,r,n){return{type:"class",parts:t,inverted:e,ignoreCase:r,unicode:n}}function se(t){return{type:"other",description:t}}function oe(e){let r,n=Gt[e];if(n)return n;if(e>=Gt.length)r=Gt.length-1;else for(r=e;!Gt[--r];);for(n=Gt[r],n={line:n.line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Gt[e]=n,n}function ie(t,e,r){const n=oe(t),s=oe(e);return{source:i,start:{offset:t,line:n.line,column:n.column},end:{offset:e,line:s.line,column:s.column}}}function le(t){Ut<Zt||(Ut>Zt&&(Zt=Ut,Kt=[]),Kt.push(t))}function ae(){let t,e;const r=38*Ut+0,n=ee.get(r);if(n)return Ut=n.nextPos,n.result;for(t=[];e=ue(),e!==o;)t.push(e);return ee.set(r,{nextPos:Ut,result:t}),t}function ue(){let r,n,s,i,l;const a=38*Ut+1,v=ee.get(a);return v?(Ut=v.nextPos,v.result):(r=Ut,n=Ut,s=function(){let e;const r=38*Ut+2,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,4)===u?(e=u,Ut+=4):(e=o,0===te&&le(B)),ee.set(r,{nextPos:Ut,result:e}),e)}(),s!==o?(i=ce(),i!==o?(l=function(){let e;const r=38*Ut+3,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,4)===c?(e=c,Ut+=4):(e=o,0===te&&le(z)),ee.set(r,{nextPos:Ut,result:e}),e)}(),l!==o?n=i:(Ut=n,n=o)):(Ut=n,n=o)):(Ut=n,n=o),n!==o&&(y=n,n={type:e.templated.ten,value:y}),r=n,r===o&&(r=Ut,n=Ut,s=function(){let e;const r=38*Ut+4,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,3)===h?(e=h,Ut+=3):(e=o,0===te&&le(W)),ee.set(r,{nextPos:Ut,result:e}),e)}(),s!==o?(i=ce(),i!==o?(l=function(){let e;const r=38*Ut+5,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,3)===d?(e=d,Ut+=3):(e=o,0===te&&le(X)),ee.set(r,{nextPos:Ut,result:e}),e)}(),l!==o?n=i:(Ut=n,n=o)):(Ut=n,n=o)):(Ut=n,n=o),n!==o&&(n=function(t){return{type:e.templated.teh,value:t}}(n)),r=n,r===o&&(r=Ut,n=Ut,s=function(){let e;const r=38*Ut+6,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,2)===p?(e=p,Ut+=2):(e=o,0===te&&le(Q)),ee.set(r,{nextPos:Ut,result:e}),e)}(),s!==o?(i=ce(),i!==o?(l=function(){let e;const r=38*Ut+7,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,2)===m?(e=m,Ut+=2):(e=o,0===te&&le(U)),ee.set(r,{nextPos:Ut,result:e}),e)}(),l!==o?n=i:(Ut=n,n=o)):(Ut=n,n=o)):(Ut=n,n=o),n!==o&&(n=function(t){return{type:e.templated.tet,value:t}}(n)),r=n,r===o&&(r=Ut,n=function(){let e,r,n,s,i,l,a;const u=38*Ut+8,c=ee.get(u);if(c)return Ut=c.nextPos,c.result;for(e=Ut,r=[];;){for(n=Ut,s=[];i=t.charAt(Ut),""!==i&&(Yt=i.charCodeAt(0),92!==Yt&&123!==Yt)?Ut++:(i=o,0===te&&le(G)),i!==o;)s.push(i);if(s.length<1&&(s=o),n=s!==o?t.substring(n,Ut):s,n===o&&(n=Ut,92===t.charCodeAt(Ut)?(s=f,Ut++):(s=o,0===te&&le(J)),s!==o?(t.length>Ut?(i=t.charAt(Ut),Ut++):(i=o,0===te&&le(Y)),i!==o?n=zt(i):(Ut=n,n=o)):(Ut=n,n=o),n===o&&(n=Ut,s=Ut,123===t.charCodeAt(Ut)?(i=g,Ut++):(i=o,0===te&&le(Z)),i!==o?(l=Ut,te++,123===t.charCodeAt(Ut)?(a=g,Ut++):(a=o,0===te&&le(Z)),te--,a===o?l=void 0:(Ut=l,l=o),l!==o?(i=[i,l],s=i):(Ut=s,s=o)):(Ut=s,s=o),n=s!==o?t.substring(n,Ut):s)),n===o)break;r.push(n)}return r.length<1&&(r=o),r!==o&&(r=r.join("")),e=r,ee.set(u,{nextPos:Ut,result:e}),e}(),n!==o&&(n=function(t){return{type:e.templated.tel,value:t}}(n)),r=n))),ee.set(a,{nextPos:Ut,result:r}),r);var y}function ce(){let t,e;const r=38*Ut+9,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t=Ut,Se(),e=he(),e!==o?(Se(),t=e):(Ut=t,t=o),ee.set(r,{nextPos:Ut,result:t}),t)}function he(){let r,n,s,i,l,a;const u=38*Ut+10,c=ee.get(u);return c?(Ut=c.nextPos,c.result):(r=Ut,n=de(),n!==o?(Se(),63===t.charCodeAt(Ut)?(s=v,Ut++):(s=o,0===te&&le(K)),s!==o?(Se(),i=he(),i!==o?(Se(),58===t.charCodeAt(Ut)?(l=y,Ut++):(l=o,0===te&&le(tt)),l!==o?(Se(),a=he(),a!==o?r={type:e.ter,cond:n,ifTrue:i,ifFalse:a}:(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o),r===o&&(r=de()),ee.set(u,{nextPos:Ut,result:r}),r)}function de(){let r,n,s,i;const l=38*Ut+11,a=ee.get(l);return a?(Ut=a.nextPos,a.result):(r=Ut,n=pe(),n!==o?(Se(),t.substr(Ut,2)===b?(s=b,Ut+=2):(s=o,0===te&&le(et)),s!==o?(Se(),i=de(),i!==o?r={type:e.elv,cond:n,ifFalse:i}:(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o),r===o&&(r=pe()),ee.set(l,{nextPos:Ut,result:r}),r)}function pe(){let r,n,s,i;const l=38*Ut+12,a=ee.get(l);return a?(Ut=a.nextPos,a.result):(r=Ut,n=me(),n!==o?(Se(),t.substr(Ut,2)===E?(s=E,Ut+=2):(s=o,0===te&&le(rt)),s!==o?(Se(),i=pe(),i!==o?r={type:e.nullc,lhs:n,rhs:i}:(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o),r===o&&(r=me()),ee.set(l,{nextPos:Ut,result:r}),r)}function me(){let r,n,s,i,l,a;const u=38*Ut+13,c=ee.get(u);if(c)return Ut=c.nextPos,c.result;if(r=Ut,n=fe(),n!==o){for(s=[];i=Ut,Se(),t.substr(Ut,2)===x?(l=x,Ut+=2):(l=o,0===te&&le(nt)),l!==o?(Se(),a=fe(),a!==o?i=a:(Ut=i,i=o)):(Ut=i,i=o),i!==o;)s.push(i);r=function(t,r){let n=t;for(const t of r)n={type:e.or,lhs:n,rhs:t};return n}(n,s)}else Ut=r,r=o;return ee.set(u,{nextPos:Ut,result:r}),r}function fe(){let r,n,s,i,l,a;const u=38*Ut+14,c=ee.get(u);if(c)return Ut=c.nextPos,c.result;if(r=Ut,n=ge(),n!==o){for(s=[];i=Ut,Se(),t.substr(Ut,2)===A?(l=A,Ut+=2):(l=o,0===te&&le(st)),l!==o?(Se(),a=ge(),a!==o?i=a:(Ut=i,i=o)):(Ut=i,i=o),i!==o;)s.push(i);r=function(t,r){let n=t;for(const t of r)n={type:e.and,lhs:n,rhs:t};return n}(n,s)}else Ut=r,r=o;return ee.set(u,{nextPos:Ut,result:r}),r}function ge(){let t,r,n,s,i,l;const a=38*Ut+15,u=ee.get(a);if(u)return Ut=u.nextPos,u.result;if(t=Ut,r=ve(),r!==o){for(n=[];s=Ut,Se(),i=Te(),i!==o?(Se(),l=ve(),l!==o?s=Wt(0,i,l):(Ut=s,s=o)):(Ut=s,s=o),s!==o;)n.push(s);t=function(t,r){let n=t;for(const t of r)n={type:e.eq,op:t.op,lhs:n,rhs:t.rhs};return n}(r,n)}else Ut=t,t=o;return ee.set(a,{nextPos:Ut,result:t}),t}function ve(){let t,r,n,s,i,l;const a=38*Ut+16,u=ee.get(a);if(u)return Ut=u.nextPos,u.result;if(t=Ut,r=ye(),r!==o){for(n=[];s=Ut,Se(),i=Ce(),i!==o?(Se(),l=ye(),l!==o?s=Xt(0,i,l):(Ut=s,s=o)):(Ut=s,s=o),s!==o;)n.push(s);t=function(t,r){let n=t;for(const t of r)n={type:e.cmp,op:t.op,lhs:n,rhs:t.rhs};return n}(r,n)}else Ut=t,t=o;return ee.set(a,{nextPos:Ut,result:t}),t}function ye(){let r,n,s;const i=38*Ut+17,l=ee.get(i);return l?(Ut=l.nextPos,l.result):(r=Ut,33===t.charCodeAt(Ut)?(n=w,Ut++):(n=o,0===te&&le(ot)),n!==o?(Se(),s=ye(),s!==o?r={type:e.not,expr:s}:(Ut=r,r=o)):(Ut=r,r=o),r===o&&(r=function(){let t,r,n,s,i;const l=38*Ut+18,a=ee.get(l);if(a)return Ut=a.nextPos,a.result;if(t=Ut,r=Ee(),r!==o){for(Se(),n=[];s=Ut,i=be(),i!==o?(Se(),s=i):(Ut=s,s=o),s!==o;)n.push(s);n.length<1&&(n=o),n!==o?t={type:e.access,lhs:r,rhs:n}:(Ut=t,t=o)}else Ut=t,t=o;return t===o&&(t=Ee()),ee.set(l,{nextPos:Ut,result:t}),t}()),ee.set(i,{nextPos:Ut,result:r}),r)}function be(){let r;const n=38*Ut+19,s=ee.get(n);return s?(Ut=s.nextPos,s.result):(r=function(){let r,n,s;const i=38*Ut+20,l=ee.get(i);return l?(Ut=l.nextPos,l.result):(te++,r=Ut,t.substr(Ut,2)===P?(n=P,Ut+=2):(n=o,0===te&&le(lt)),n===o&&(46===t.charCodeAt(Ut)?(n=T,Ut++):(n=o,0===te&&le(at))),n!==o?(Se(),s=Pe(),s!==o?r={type:e.member,ns:"?."===n,rhs:s}:(Ut=r,r=o)):(Ut=r,r=o),te--,r===o&&(n=o,0===te&&le(it)),ee.set(i,{nextPos:Ut,result:r}),r)}(),r===o&&(r=function(){let r,n,s,i,l;const a=38*Ut+21,u=ee.get(a);return u?(Ut=u.nextPos,u.result):(te++,r=Ut,t.substr(Ut,2)===P?(n=P,Ut+=2):(n=o,0===te&&le(lt)),n===o&&(n=null),91===t.charCodeAt(Ut)?(s=C,Ut++):(s=o,0===te&&le(ct)),s!==o?(Se(),i=he(),i!==o?(Se(),93===t.charCodeAt(Ut)?(l=S,Ut++):(l=o,0===te&&le(ht)),l!==o?r={type:e.subscript,ns:null!==n,rhs:i}:(Ut=r,r=o)):(Ut=r,r=o)):(Ut=r,r=o),te--,r===o&&(n=o,0===te&&le(ut)),ee.set(a,{nextPos:Ut,result:r}),r)}(),r===o&&(r=function(){let r,n,s,i,l,a,u,c;const h=38*Ut+22,d=ee.get(h);if(d)return Ut=d.nextPos,d.result;if(te++,r=Ut,t.substr(Ut,2)===P?(n=P,Ut+=2):(n=o,0===te&&le(lt)),n===o&&(n=null),40===t.charCodeAt(Ut)?(s=O,Ut++):(s=o,0===te&&le(pt)),s!==o){for(Se(),i=Ut,l=he(),l!==o?(a=Se(),i=l):(Ut=i,i=o),i===o&&(i=null),l=[];a=Ut,44===t.charCodeAt(Ut)?(u=N,Ut++):(u=o,0===te&&le(mt)),u!==o?(Se(),c=he(),c!==o?(Se(),a=c):(Ut=a,a=o)):(Ut=a,a=o),a!==o;)l.push(a);41===t.charCodeAt(Ut)?(a=D,Ut++):(a=o,0===te&&le(ft)),a!==o?(m=l,r={type:e.method,ns:null!==n,args:null===(p=i)?[]:[p,...m]}):(Ut=r,r=o)}else Ut=r,r=o;var p,m;return te--,r===o&&(n=o,0===te&&le(dt)),ee.set(h,{nextPos:Ut,result:r}),r}())),ee.set(n,{nextPos:Ut,result:r}),r)}function Ee(){let n,s,i,l;const a=38*Ut+23,u=ee.get(a);return u?(Ut=u.nextPos,u.result):(n=Ut,40===t.charCodeAt(Ut)?(s=O,Ut++):(s=o,0===te&&le(pt)),s!==o?(Se(),i=he(),i!==o?(Se(),41===t.charCodeAt(Ut)?(l=D,Ut++):(l=o,0===te&&le(ft)),l!==o?n=i:(Ut=n,n=o)):(Ut=n,n=o)):(Ut=n,n=o),n===o&&(n=function(){let r,n,s,i,l,a,u,c;const h=38*Ut+24,d=ee.get(h);if(d)return Ut=d.nextPos,d.result;if(te++,r=Ut,n=function(){let r,n,s,i,l;const a=38*Ut+32,u=ee.get(a);return u?(Ut=u.nextPos,u.result):(te++,r=Ut,35===t.charCodeAt(Ut)?(n=F,Ut++):(n=o,0===te&&le($t)),n!==o?(s=Ut,i=Pe(),i!==o?(58===t.charCodeAt(Ut)?(l=y,Ut++):(l=o,0===te&&le(tt)),l!==o?s=i:(Ut=s,s=o)):(Ut=s,s=o),s===o&&(s=null),i=Pe(),i!==o?r={type:e.function,module:s,value:i}:(Ut=r,r=o)):(Ut=r,r=o),te--,r===o&&(n=o,0===te&&le(Mt)),ee.set(a,{nextPos:Ut,result:r}),r)}(),n!==o)if(40===t.charCodeAt(Ut)?(s=O,Ut++):(s=o,0===te&&le(pt)),s!==o){for(Se(),i=Ut,l=he(),l!==o?(a=Se(),i=l):(Ut=i,i=o),i===o&&(i=null),l=[];a=Ut,44===t.charCodeAt(Ut)?(u=N,Ut++):(u=o,0===te&&le(mt)),u!==o?(Se(),c=he(),c!==o?(Se(),a=c):(Ut=a,a=o)):(Ut=a,a=o),a!==o;)l.push(a);41===t.charCodeAt(Ut)?(a=D,Ut++):(a=o,0===te&&le(ft)),a!==o?r=function(t,r,n){const s=null===r?[]:[r,...n];return{type:e.call,value:t,args:s}}(n,i,l):(Ut=r,r=o)}else Ut=r,r=o;else Ut=r,r=o;return te--,r===o&&(n=o,0===te&&le(gt)),ee.set(h,{nextPos:Ut,result:r}),r}(),n===o&&(n=function(){let r;const n=38*Ut+25,s=ee.get(n);return s?(Ut=s.nextPos,s.result):(r=function(){let r,n,s,i,l,a,u,c,h,d;const p=38*Ut+26,m=ee.get(p);if(m)return Ut=m.nextPos,m.result;for(te++,r=Ut,n=Ut,s=Ut,45===t.charCodeAt(Ut)?(i=R,Ut++):(i=o,0===te&&le(yt)),i===o&&(i=null),l=Ut,a=[];u=t.charAt(Ut),Yt=u.charCodeAt(0),Yt>=48&&Yt<=57?Ut++:(u=o,0===te&&le(bt)),u!==o;)a.push(u);if(a.length<1&&(a=o),a!==o){if(u=Ut,46===t.charCodeAt(Ut)?(c=T,Ut++):(c=o,0===te&&le(at)),c!==o){for(h=[];d=t.charAt(Ut),Yt=d.charCodeAt(0),Yt>=48&&Yt<=57?Ut++:(d=o,0===te&&le(bt)),d!==o;)h.push(d);c=[c,h],u=c}else Ut=u,u=o;u===o&&(u=null),a=[a,u],l=a}else Ut=l,l=o;if(l===o)if(l=Ut,46===t.charCodeAt(Ut)?(a=T,Ut++):(a=o,0===te&&le(at)),a!==o){for(u=[];c=t.charAt(Ut),Yt=c.charCodeAt(0),Yt>=48&&Yt<=57?Ut++:(c=o,0===te&&le(bt)),c!==o;)u.push(c);u.length<1&&(u=o),u!==o?(a=[a,u],l=a):(Ut=l,l=o)}else Ut=l,l=o;return l!==o?(i=[i,l],s=i):(Ut=s,s=o),n=s!==o?t.substring(n,Ut):s,n!==o&&(n={type:e.literal,value:parseFloat(n)}),r=n,te--,r===o&&(n=o,0===te&&le(vt)),ee.set(p,{nextPos:Ut,result:r}),r}(),r===o&&(r=xe(),r===o&&(r=function(){let r,n,s,i,l,a,u;const c=38*Ut+30,h=ee.get(c);if(h)return Ut=h.nextPos,h.result;if(te++,r=Ut,91===t.charCodeAt(Ut)?(n=C,Ut++):(n=o,0===te&&le(ct)),n!==o){for(Se(),s=he(),s===o&&(s=null),Se(),i=[];l=Ut,44===t.charCodeAt(Ut)?(a=N,Ut++):(a=o,0===te&&le(mt)),a!==o?(Se(),u=he(),u!==o?(Se(),l=u):(Ut=l,l=o)):(Ut=l,l=o),l!==o;)i.push(l);93===t.charCodeAt(Ut)?(l=S,Ut++):(l=o,0===te&&le(ht)),l!==o?r=function(t,r){const n=null===t?[]:[t,...r];return{type:e.array,value:n}}(s,i):(Ut=r,r=o)}else Ut=r,r=o;return te--,r===o&&(n=o,0===te&&le(Dt)),ee.set(c,{nextPos:Ut,result:r}),r}(),r===o&&(r=function(){let r,n,s,i,l,a,u,c,h,d,p;const m=38*Ut+31,f=ee.get(m);if(f)return Ut=f.nextPos,f.result;if(te++,r=Ut,123===t.charCodeAt(Ut)?(n=g,Ut++):(n=o,0===te&&le(Z)),n!==o){for(Se(),s=Ut,i=xe(),i!==o?(l=Se(),58===t.charCodeAt(Ut)?(a=y,Ut++):(a=o,0===te&&le(tt)),a!==o?(u=Se(),c=he(),c!==o?s=[i,c]:(Ut=s,s=o)):(Ut=s,s=o)):(Ut=s,s=o),s===o&&(s=null),i=Se(),l=[];a=Ut,44===t.charCodeAt(Ut)?(u=N,Ut++):(u=o,0===te&&le(mt)),u!==o?(c=Se(),h=xe(),h!==o?(Se(),58===t.charCodeAt(Ut)?(d=y,Ut++):(d=o,0===te&&le(tt)),d!==o?(Se(),p=he(),p!==o?(Se(),a=[h,p]):(Ut=a,a=o)):(Ut=a,a=o)):(Ut=a,a=o)):(Ut=a,a=o),a!==o;)l.push(a);125===t.charCodeAt(Ut)?(a=L,Ut++):(a=o,0===te&&le(St)),a!==o?(b=l,E=[],null!==(v=s)&&E.push(v),E.push.apply(E,b),r={type:e.dict,value:E}):(Ut=r,r=o)}else Ut=r,r=o;var v,b,E;return te--,r===o&&(n=o,0===te&&le(Rt)),ee.set(m,{nextPos:Ut,result:r}),r}()))),ee.set(n,{nextPos:Ut,result:r}),r)}(),n===o&&(n=function(){let t,n;const s=38*Ut+34,i=ee.get(s);return i?(Ut=i.nextPos,i.result):(te++,t=Ut,n=Pe(),n!==o&&(l=n,n=r.has(l)?{type:e.literal,value:r.get(l)}:{type:e.symbol,value:l}),t=n,te--,t===o&&(n=o,0===te&&le(Ft)),ee.set(s,{nextPos:Ut,result:t}),t);var l}()))),ee.set(a,{nextPos:Ut,result:n}),n)}function xe(){let r,n,s,i,l;const a=38*Ut+27,u=ee.get(a);if(u)return Ut=u.nextPos,u.result;if(te++,r=Ut,39===t.charCodeAt(Ut)?(n=M,Ut++):(n=o,0===te&&le(xt)),n!==o){for(s=Ut,i=[];l=t.charAt(Ut),""!==l&&(Yt=l.charCodeAt(0),39!==Yt)?Ut++:(l=o,0===te&&le(At)),l!==o;)i.push(l);s=t.substring(s,Ut),39===t.charCodeAt(Ut)?(i=M,Ut++):(i=o,0===te&&le(xt)),i!==o?r={type:e.literal,value:s}:(Ut=r,r=o)}else Ut=r,r=o;if(r===o){if(r=Ut,34===t.charCodeAt(Ut)?(n=$,Ut++):(n=o,0===te&&le(wt)),n!==o){for(s=Ut,i=[];l=t.charAt(Ut),""!==l&&(Yt=l.charCodeAt(0),34!==Yt)?Ut++:(l=o,0===te&&le(Pt)),l!==o;)i.push(l);s=t.substring(s,Ut),34===t.charCodeAt(Ut)?(i=$,Ut++):(i=o,0===te&&le(wt)),i!==o?r={type:e.literal,value:s}:(Ut=r,r=o)}else Ut=r,r=o;if(r===o)if(r=Ut,96===t.charCodeAt(Ut)?(n=_,Ut++):(n=o,0===te&&le(Tt)),n!==o){for(s=[];i=Ae(),i===o&&(i=we()),i!==o;)s.push(i);96===t.charCodeAt(Ut)?(i=_,Ut++):(i=o,0===te&&le(Tt)),i!==o?r={type:e.tstring,parts:s}:(Ut=r,r=o)}else Ut=r,r=o}return te--,r===o&&(n=o,0===te&&le(Et)),ee.set(a,{nextPos:Ut,result:r}),r}function Ae(){let e,r,n,s;const i=38*Ut+28,l=ee.get(i);return l?(Ut=l.nextPos,l.result):(te++,e=Ut,123===t.charCodeAt(Ut)?(r=g,Ut++):(r=o,0===te&&le(Z)),r!==o?(Se(),n=he(),n!==o?(Se(),125===t.charCodeAt(Ut)?(s=L,Ut++):(s=o,0===te&&le(St)),s!==o?e=n:(Ut=e,e=o)):(Ut=e,e=o)):(Ut=e,e=o),te--,e===o&&(r=o,0===te&&le(Ct)),ee.set(i,{nextPos:Ut,result:e}),e)}function we(){let r,n,s,i,l;const a=38*Ut+29,u=ee.get(a);if(u)return Ut=u.nextPos,u.result;for(te++,r=Ut,n=[];;){for(s=Ut,i=[];l=t.charAt(Ut),""!==l&&(Yt=l.charCodeAt(0),92!==Yt&&96!==Yt&&123!==Yt)?Ut++:(l=o,0===te&&le(Nt)),l!==o;)i.push(l);if(i.length<1&&(i=o),s=i!==o?t.substring(s,Ut):i,s===o&&(s=Ut,92===t.charCodeAt(Ut)?(i=f,Ut++):(i=o,0===te&&le(J)),i!==o?(t.length>Ut?(l=t.charAt(Ut),Ut++):(l=o,0===te&&le(Y)),l!==o?s=Qt(l):(Ut=s,s=o)):(Ut=s,s=o)),s===o)break;n.push(s)}return n.length<1&&(n=o),n!==o&&(n={type:e.literal,value:n.join("")}),r=n,r===o&&(r=Ut,123===t.charCodeAt(Ut)?(n=g,Ut++):(n=o,0===te&&le(Z)),n!==o&&(n={type:e.literal,value:n}),r=n),te--,r===o&&(n=o,0===te&&le(Ot)),ee.set(a,{nextPos:Ut,result:r}),r}function Pe(){let e,r,n,s,i;const l=38*Ut+33,a=ee.get(l);if(a)return Ut=a.nextPos,a.result;if(e=Ut,r=Ut,n=t.charAt(Ut),Yt=n.charCodeAt(0),Yt>=97&&Yt<=122||Yt>=65&&Yt<=90||36===Yt||95===Yt?Ut++:(n=o,0===te&&le(_t)),n!==o){for(s=[];i=t.charAt(Ut),Yt=i.charCodeAt(0),Yt>=97&&Yt<=122||Yt>=65&&Yt<=90||36===Yt||95===Yt||Yt>=48&&Yt<=57?Ut++:(i=o,0===te&&le(Lt)),i!==o;)s.push(i);n=[n,s],r=n}else Ut=r,r=o;return e=r!==o?t.substring(e,Ut):r,ee.set(l,{nextPos:Ut,result:e}),e}function Te(){let e;const r=38*Ut+35,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,2)===j?(e=j,Ut+=2):(e=o,0===te&&le(jt)),e===o&&(t.substr(Ut,2)===k?(e=k,Ut+=2):(e=o,0===te&&le(kt))),ee.set(r,{nextPos:Ut,result:e}),e)}function Ce(){let e;const r=38*Ut+36,n=ee.get(r);return n?(Ut=n.nextPos,n.result):(t.substr(Ut,2)===I?(e=I,Ut+=2):(e=o,0===te&&le(It)),e===o&&(62===t.charCodeAt(Ut)?(e=V,Ut++):(e=o,0===te&&le(Vt)),e===o&&(t.substr(Ut,2)===q?(e=q,Ut+=2):(e=o,0===te&&le(qt)),e===o&&(60===t.charCodeAt(Ut)?(e=H,Ut++):(e=o,0===te&&le(Ht))))),ee.set(r,{nextPos:Ut,result:e}),e)}function Se(){let e,r;const n=38*Ut+37,s=ee.get(n);if(s)return Ut=s.nextPos,s.result;for(te++,e=[];r=t.charAt(Ut),Yt=r.charCodeAt(0),32===Yt||9===Yt||10===Yt||13===Yt?Ut++:(r=o,0===te&&le(Bt)),r!==o;)e.push(r);return te--,ee.set(n,{nextPos:Ut,result:e}),e}Jt=a();const Oe=Jt!==o&&Ut===t.length;function Ne(){throw Jt!==o&&Ut<t.length&&le({type:"end"}),e=Kt,r=Zt<t.length?function(e=Ut){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(Zt):null,s=Zt<t.length?ie(Zt,Zt+1):ie(Zt,Zt),new n(n.buildMessage(e,r),e,r,s);var e,r,s}return s.peg$library?{peg$result:Jt,peg$currPos:Ut,peg$FAILED:o,peg$maxFailExpected:Kt,peg$maxFailPos:Zt,peg$success:Oe,peg$throw:Oe?void 0:Ne}:Oe?Jt:void Ne()}(t,{startRule:s===i.MODE_TEMPLATED?"TemplatedRoot":"ExpressionRoot"}))}static evaluate(t,e,r,n){return new o(t,e).visitRoot(r,n===i.MODE_TEMPLATED)}static interpret(t,e,r,n){return i.evaluate(t,e,i.parse(r,n),n)}}class l{#r;#n;constructor(t,e){this.#r=t,this.#n=e}withModule(t,e){const r=t?{[t]:e}:e;return new l({...this.#r,...r},this.#n)}withOverlay(...t){return new l(this.#r,0===t.length?this.#n:[...this.#n,...t])}resolve(t){return s(this.#n,t)}evaluateExpression(t){return i.interpret(this.#r,this.#n,t,i.MODE_EXPRESSION)}evaluateTemplated(t){return i.interpret(this.#r,this.#n,t,i.MODE_TEMPLATED)}}class a{static fromHtml(...t){const e=document.createElement("template");return e.innerHTML=t.map(t=>t.trim()).join(""),document.adoptNode(e.content)}static toHtml(t){var e=document.createElement("template");return e.content.appendChild(t),e.innerHTML}static isBlank(t){return 0===t.childElementCount&&""===t.textContent.trim()}static from(...t){const e=new DocumentFragment;for(const r of t)e.appendChild(r);return e}static fromChildNodes(t){const e=new DocumentFragment;for(;t.firstChild;)e.appendChild(t.firstChild);return e}}class u{static id=0;static uid(t){return`${t}-${++u.id}`}static defaultValue(t,e,r){return t.hasAttribute(e)||t.setAttribute(e,r),t.getAttribute(e)}static forward(t,e,r){e.getAttributeNames().filter(e=>e.startsWith(t)).forEach(n=>{const s=n.substring(t.length);if("class"===s){const n=e.getAttribute(`${t}class`)?.split(/\s+/).filter(t=>t.length)??[];return void r.classList.add(...n)}r.setAttribute(s,e.getAttribute(n))})}static set(t,e,r){null==r?t.removeAttribute(e):t.setAttribute(e,r)}}class c{static from(t){for(const e of t.children)e.matches('[slot=""]')&&e.removeAttribute("slot");const e=Array.from(t.children).filter(t=>t.matches("[slot]")).map(t=>{t.remove();const e=t.getAttribute("slot");return t.removeAttribute("slot"),[e,c.slotFromNode(t)]}),r=Object.create(null);r.default=new DocumentFragment,r.default.append(...t.childNodes);for(const[t,n]of e)t in r||(r[t]=new DocumentFragment),r[t].append(n);return r}static slotFromNode(t){return t instanceof HTMLTemplateElement?document.adoptNode(t.content):t instanceof HTMLScriptElement&&"text/html"===t.type?a.fromHtml(t.innerHTML):t}}class h{static isParsed(t){for(let e=t;e;e=e.parentNode)if(e.nextSibling)return!0;return!1}static waitDomContentLoaded(t){if("loading"===t.readyState)return new Promise(e=>{t.addEventListener("DOMContentLoaded",()=>e(void 0),{once:!0})});if("complete"===t.readyState)return Promise.resolve();const e=t.defaultView;if(null===e)return Promise.resolve();const[r]=e.performance?.getEntriesByType("navigation")??[];return r?.domContentLoadedEventStart>0?Promise.resolve():new Promise(t=>{const r=()=>{e.removeEventListener("DOMContentLoaded",r),e.removeEventListener("load",r),t(void 0)};e.addEventListener("DOMContentLoaded",r),e.addEventListener("load",r)})}static waitParsed(t){return h.isParsed(t)||"loading"!==t.ownerDocument.readyState?Promise.resolve(t):new Promise(e=>{const r=new MutationObserver(()=>{h.isParsed(t)&&(r.disconnect(),e(t))});for(let e=t.parentNode;e;e=e.parentNode)r.observe(e,{childList:!0});h.waitDomContentLoaded(t.ownerDocument).then(()=>{r.disconnect(),e(t)})})}static queryChildren(t,e){for(const r of t.children)if(r.matches(e))return r;return null}static queryChildrenAll(t,e){const r=[];for(const n of t.children)n.matches(e)&&r.push(n);return r}}class d{#u=new Set;removed(t){return this.#u.has(t)}remove(t){t.replaceChildren?.(),Object.keys(t.dataset||{}).filter(t=>t.startsWith("tpl")).forEach(e=>{delete t.dataset[e]}),this.#u.add(t)}popData(t,e){const r=t.dataset[e];return delete t.dataset[e],r}prepend(t,e){t.parentNode.insertBefore(e,t)}append(t,e){t.parentNode.insertBefore(e,t.nextSibling)}replace(t,e){this.prepend(t,e),this.remove(t)}cleanup(){for(const t of this.#u)t.remove();this.#u.clear()}}class p{static ORDERED_COMMANDS=["tplIf","tplWith","tplEach","tplWhen","tplClassAppend","tplAttrAppend","tplRemove","tplVerbatim"];static tplIf(t,e,r,n){n.evaluateExpression(e)||r.remove(t)}static tplWith(t,e,r,n){const s=n.evaluateExpression(e),o=r.popData(t,"tplVar"),i=new g(t,n).withOverlay(o?{[o]:s}:s).render();r.replace(t,i)}static tplEach(t,e,r,n){const s=r.popData(t,"tplVar"),o=r.popData(t,"tplStat"),i=new g(t,n),l=n.evaluateExpression(e),a=null===l||"object"!=typeof l?void 0:Object.getPrototypeOf(l),u=l?.[Symbol.iterator]||a!==Object.prototype&&null!==a?null:Object.entries(l),c=l instanceof Map?[...l]:u,h=null===c?l:c.map(([t,e])=>({key:t,value:e}));if(!h?.[Symbol.iterator])throw new Error(`Expected an iterable got '${l}'`);const d=o?h:null,p="number"==typeof d?.length?d.length:d?.size,m="number"==typeof p?p:null;let f=0;for(const e of h){const n=s?{[s]:e}:e,l={index:f,count:f+1,size:m,first:0===f,last:null===m?null:f===m-1,even:f%2==0,odd:f%2==1},a=o?[{[o]:l},n]:[n];r.prepend(t,i.withOverlay(...a).render()),++f}r.remove(t)}static tplWhen(t,e,r,n){n.evaluateExpression(e)||r.remove(t)}static tplVerbatim(t,e,r,n){const s=t.cloneNode(!0);r.replace(t,s)}static tplRemove(t,e,r,n){switch(e.toLowerCase()){case"tag":{const e=a.fromChildNodes(t);"tplVerbatim"in t.dataset?(r.popData(t,"tplVerbatim"),r.replace(t,e)):(r.append(t,e),r.remove(t));break}case"body":t.replaceChildren();break;case"all":r.remove(t)}}static tplClassAppend(t,e,r,n){const s=n.evaluateExpression(e);if(!s)return;const o=(Array.isArray(s)?s:[s]).flatMap(t=>"string"==typeof t?t.split(" "):t).filter(Boolean);0!==o.length&&t.classList.add(...o)}static tplAttrAppend(t,e,r,n){const s=n.evaluateExpression(e);s&&0!==s.length&&(Array.isArray(s[0])?s:[s]).forEach(([e,r])=>{null!=r&&t.setAttribute(e,r)})}static textNode(t,r,n,s){for(const o of s.evaluateTemplated(r))if(null!=o.value)switch(o.type){case e.dom.t:n.prepend(t,document.createTextNode(o.value));break;case e.dom.h:n.prepend(t,a.fromHtml("string"==typeof o.value?o.value:String(o.value)));break;case e.dom.n:if(!(o.value instanceof Node))throw new TypeError(`Expected a Node, got '${typeof o.value}'`);n.prepend(t,o.value)}n.remove(t)}}const m=new t(1e3);function f(t){return m.getOrCompute(t,t=>t.substring(3).split(/(?=[A-Z])/).join("-").toLowerCase())}class g{static fromHtml(t,e,...r){return new g(a.fromHtml(t),new l(e,r))}static fromSelector(t,e,...r){const n=document.querySelector(t);if(!(n instanceof HTMLTemplateElement))throw new Error("template selector does not match any template tag");return g.fromTemplate(n,e,...r)}static fromTemplate(t,e,...r){const n=document.adoptNode(t.content);return new g(n,new l(e,r))}static fromFragment(t,e,...r){return new g(t,new l(e,r))}#c;#h;constructor(t,e){this.#c=t,this.#h=e}withEvaluator(t){return new g(this.#c,t)}withFragment(t){return new g(t,this.#h)}withModule(t,e){return new g(this.#c,this.#h.withModule(t,e))}withOverlay(...t){return new g(this.#c,this.#h.withOverlay(...t))}evaluateExpression(t,...e){return this.#h.withOverlay(...e).evaluateExpression(t)}evaluateTemplated(t,...e){return this.#h.withOverlay(...e).evaluateTemplated(t)}evaluator(){return this.#h}render(){try{const t=new d,e=document.importNode(this.#c,!0),r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?e:a.from(e),n=document.createNodeIterator(r,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,g.#d);let s;for(;null!==(s=n.nextNode());){if(t.cleanup(),s.nodeType===Node.TEXT_NODE){try{p.textNode(s,s.nodeValue,t,this.#h)}catch(t){throw v.wrap("Error evaluating text node",s,t)}continue}const e=s;for(const r of p.ORDERED_COMMANDS){if(!(r in e.dataset))continue;const n=t.popData(e,r);try{p[r](e,n,t,this.#h)}catch(t){throw v.wrap(`Error evaluating data-tpl-${f(r)}="${n}"`,e,t)}if(t.removed(e))break}for(const r of Object.keys(e.dataset||{})){if(!r.startsWith("tpl"))continue;const n=f(r),s=t.popData(e,r);try{const t=this.#h.evaluateExpression(s);if("boolean"==typeof t){e.toggleAttribute(n,t);continue}null!=t&&e.setAttribute(n,t)}catch(t){throw v.wrap(`Error evaluating data-tpl-${n}="${s}"`,e,t)}}}return t.cleanup(),r}catch(t){if(t instanceof v)throw t;throw new v("Error rendering template",this.#c,t)}}renderTo(t){t.replaceChildren(this.render())}appendTo(t){t.appendChild(this.render())}renderToSelector(t){const e=document.querySelector(t);e&&this.renderTo(e)}appendToSelector(t){const e=document.querySelector(t);e&&this.appendTo(e)}static#d(t){if(t.nodeType===Node.TEXT_NODE)return t.nodeValue.includes("{{")&&t.nodeValue.includes("}}")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT;for(const e of t.attributes)if(e.name.startsWith("data-tpl-"))return NodeFilter.FILTER_ACCEPT;return NodeFilter.FILTER_SKIP}}class v extends Error{static FRAMES=3;#p;#m;truncated=!1;static wrap(t,e,r){return r instanceof v&&r.depth>=v.FRAMES?(r.truncated=!0,r):new v(t,e,r)}constructor(t,e,r){super(`${t} in \`${v.describe(e)}\``,{cause:r}),this.name="RenderError",this.#p=e,this.#m=(r instanceof v?r.depth:0)+1}get depth(){return this.#m}get node(){return this.#p}get html(){return v.stringify(this.#p)}static describe(t){if(t.nodeType===Node.TEXT_NODE)return v.#f(String(t.nodeValue).trim());if(t.nodeType===Node.ELEMENT_NODE){const e=t,r=Array.from(e.attributes,t=>` ${t.name}="${t.value}"`).join("");return v.#f(`<${e.localName}${r}>`)}const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||String(t.nodeValue??"").trim().length>0).map(t=>v.describe(t));return v.#f(e.join(""))}static#f(t){return t.length>120?`${t.slice(0,120)}…`:t}static stringify(t){return a.toHtml(v.#g(t.cloneNode(!0)))}static#g(t){t.nodeType===Node.TEXT_NODE&&(t.nodeValue=t.nodeValue.trim());for(let e=0;e<t.childNodes.length;e++){const r=t.childNodes[e];r.nodeType===Node.TEXT_NODE?(r.nodeValue=r.nodeValue.trim(),0===r.nodeValue.length&&(t.removeChild(r),e--)):r.nodeType===Node.ELEMENT_NODE&&v.#g(r)}return t}}class y{#v=new Map;#y;#b=new Promise(t=>{this.#y=t});constructor(){h.waitDomContentLoaded(document).then(()=>{this.#E()})}ready(){return this.#b}async#E(){await this.settled(),document.dispatchEvent(new CustomEvent("ftl:ready",{bubbles:!1,cancelable:!1})),this.#y()}enqueue(t){if(this.#v.has(t))return;const{promise:e,resolve:r}=Promise.withResolvers(),n=h.waitParsed(t).then(()=>t.upgrade()).finally(()=>{this.#v.delete(t),r()});this.#v.set(t,{upgrade:n,finished:e})}async#x(t,e){for(;;){const r=Array.from(this.#v).filter(([e])=>t(e)).map(([,t])=>e(t));if(0===r.length)return;await Promise.all(r)}}settled(){return this.#x(()=>!0,t=>t.finished)}upgraded(t){return this.#x(t,t=>t.upgrade)}whenUpgraded(t){return this.#v.get(t)?.upgrade}pending(){return Array.from(this.#v.keys())}}class b{#A={};#w=!1;#P={string:{unmarshal:(t,e,r)=>t,marshal:(t,e,r)=>null==t?null:String(t)},number:{unmarshal:(t,e,r)=>null===t?null:Number(t),marshal:(t,e,r)=>null==t?null:String(t)},presence:{unmarshal:(t,e,r)=>null!==t,marshal:(t,e,r)=>t?"":null},bool:{unmarshal:(t,e,r)=>"true"===t,marshal:(t,e,r)=>null==t?null:String(!0===t)},json:{unmarshal:(t,e,r)=>null===t?null:JSON.parse(t),marshal:(t,e,r)=>null==t?null:JSON.stringify(t)},csv:{unmarshal:(t,e,r)=>null===t?[]:t.split(",").map(t=>t.trim()).filter(t=>t),marshal:(t,e,r)=>null==t?null:t.join(",")}};#T={};#r;#C=[];#h=new l(void 0,[]);#S=new y;defineElement(t,e){return this.#w?(this.#O(t,e),this):(this.#A[t]=e,this)}static declarationsOf(t){const e=[];for(let r=t;null!==r&&r!==HTMLElement;r=Object.getPrototypeOf(r))e.unshift(r);const r=t=>e.flatMap(e=>Object.getOwnPropertyDescriptor(e,t)?.value??[]);return{observed:r("observed"),attributes:r("attributes")}}static propertyOf(t){return t.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}#O(t,e){const{observed:r,attributes:n}=b.declarationsOf(e),{template:s,templates:o,slots:i,mappers:l,config:a}=e,u=r.map(t=>t.split(":")[0]),c=[...new Set(u.reverse())].reverse(),h=[...n,...r].reduce((t,e)=>{const[r,n]=e.split(":"),s=n??"string";if(!(s in this.#P)&&!(s in(l??{})))throw new Error(`unsupported attribute type: ${s}`);return t[r]=l?.[s]??this.#P[s],t},{}),d=Object.entries(Object.assign({},o,s?{default:s}:{})).map(([t,e])=>[t,g.fromHtml(e)]),p=Object.fromEntries(d);e.BITS={registry:this,enqueue:t=>this.#S.enqueue(t),SLOTS:i,CONFIG:a,OBSERVED:c,DECLARED:[...new Set([...c,...n.map(t=>t.split(":")[0])])],ATTR_TO_MAPPER:h,ATTR_TO_PROPERTY:Object.fromEntries(c.map(t=>[t,b.propertyOf(t)])),TEMPLATES:p},customElements.define(t,e)}defineModule(t,e){const r=t?{[t]:e}:e;return this.#r={...this.#r,...r},this.#N(),this}defineModules(t){return this.#r=t,this.#N(),this}defineComponent(t,e){return this.#T[t]=e,this}defineData(...t){return this.#C=t,this.#N(),this}defineOverlay(...t){return this.#C=[...this.#C,...t],this.#N(),this}defineMapper(t,e){return this.#P[t]=e,this}plugin(t){return t.configure(this),this}configure(){for(const[t,e]of Object.entries(this.#A))this.#O(t,e),delete this.#A[t];return this.#w=!0,this}settle(t){return this.#S.upgraded(t)}whenUpgraded(t){return this.#S.whenUpgraded(t)}pending(){return this.#S.pending()}ready(){return this.#S.ready()}#N(){this.#h=new l(this.#r,this.#C)}evaluator(){return this.#h}component(t){return this.#T[t]}}const E=new b;class x{static fromHtml(t){return g.fromHtml(t).withEvaluator(E.evaluator())}static fromSelector(t){return g.fromSelector(t).withEvaluator(E.evaluator())}static fromTemplate(t){return g.fromTemplate(t).withEvaluator(E.evaluator())}static fromFragment(t){return g.fromFragment(t).withEvaluator(E.evaluator())}}class A{static waitFor(t){return E.settle(e=>t.contains(e))}static waitForChildren(t){return E.settle(e=>t!==e&&t.contains(e))}}class w extends HTMLElement{static BITS={registry:E,enqueue:t=>{},SLOTS:!1,CONFIG:void 0,OBSERVED:[],DECLARED:[],ATTR_TO_MAPPER:{},ATTR_TO_PROPERTY:{},TEMPLATES:{}};static get observedAttributes(){return this.BITS.OBSERVED}constructor(){super(),this.internals=this.attachInternals()}internals;#D=!1;#R=!1;#M=new Set;#$=null;#_={};#L(){return this.constructor.BITS}#F(t){const e=this.#L().ATTR_TO_MAPPER[t];if(!e)throw new Error(`${this.constructor.name} declares no attribute '${t}': declare it in static observed or static attributes, or read it with getAttribute`);return e}unmarshal(t,e){return this.#F(t).unmarshal(e,t,this)}marshal(t,e){return this.#F(t).marshal(e,t,this)}get _registry(){return this.#L().registry}component(t){return this.#L().registry.component(t)}template(t){const e=this.#L().TEMPLATES[t??"default"];if(!e)throw new Error(`no template named '${t??"default"}' on ${this.constructor.name}`);const r=e.withEvaluator(this.#L().registry.evaluator()),n=this.#L().CONFIG;return n?r.withOverlay({config:n}):r}connectedCallback(){this.#R||this.#L().enqueue(this)}attributeChangedCallback(t,e,r){e!==r&&(this.#M.has(t)||(this.#D?this[this.#L().ATTR_TO_PROPERTY[t]]=this.unmarshal(t,r):null!==this.#$&&t in this.#$&&(this.#$[t]=this.unmarshal(t,r))))}async upgrade(){if(this.#R)return;this.#R=!0;const t=this.#L().SLOTS?c.from(this):void 0,e=Object.fromEntries(this.#L().DECLARED.map(t=>[t,this.unmarshal(t,this.getAttribute(t))])),r=new Set(this.#L().OBSERVED);this.#_=Object.fromEntries(Object.entries(e).filter(([t])=>!r.has(t))),this.#$=e;try{await this.render({slots:t});const r=this.#L().ATTR_TO_PROPERTY;for(const t of this.#L().OBSERVED)this[r[t]]=e[t];this.#D=!0,this.internals.states.add("rendered")}finally{this.#$=null}}render(t){}declared(t){return t in this.#_?this.#_[t]:null!==this.#$&&t in this.#$?this.#$[t]:this.unmarshal(t,this.getAttribute(t))}get rendered(){return this.#D}reflectTo(t,e){const r=this.marshal(t,e);if(r!==this.getAttribute(t)){this.#M.add(t);try{u.set(this,t,r)}finally{this.#M.delete(t)}}}}const P=/\{(\w+)\}/g,T=/\{(\d+)\}/g,C=t=>"object"==typeof t&&null!==t&&[Object.prototype,null].includes(Object.getPrototypeOf(t)),S=new Set,O=t=>{S.has(t)||(S.add(t),console.warn(`l10n: ${t}`))},N=new t(100),D=(t,e,r)=>{const n=`${t.name}|${e??""}|${void 0===r?"":JSON.stringify(r)}`;return N.getOrCompute(n,()=>new t(e,r))};class R{static t(t,...e){const r=this.l10n??{};let n=Object.hasOwn(r,t)?r[t]:void 0;if(void 0===n)return O(`missing message "${t}"`),t;const s=1===e.length&&C(e[0])?e[0]:null;if(C(n))if("number"!=typeof s?.count)O(`plural message "${t}" needs a numeric {count}`),n=n.other;else{const t=this.locale??navigator?.language??"en";n=n[D(Intl.PluralRules,t).select(s.count)]??n.other}return void 0===n||"object"==typeof n?(O(`plural message "${t}" has no "other" form`),t):s?n.replace(P,(e,r)=>Object.hasOwn(s,r)?String(s[r]):(O(`message "${t}" wants {${r}}`),e)):e.length>0?n.replace(T,(r,n)=>{const s=Number(n);return s>=e.length?(O(`message "${t}" wants {${n}}`),r):String(e[s])}):n}static date(t,e){return D(Intl.DateTimeFormat,this.locale,e).format(t)}static number(t,e){return D(Intl.NumberFormat,this.locale,e).format(t)}static bytes(t){const e=D(Intl.NumberFormat,this.locale,{maximumFractionDigits:2}).format;return t>=1073741824?`${e(t/1024/1024/1024)}GiB`:t>=1048576?`${e(t/1024/1024)}MiB`:t>=1024?`${e(t/1024)}KiB`:`${e(t)}B`}static failure(t){return Array.isArray(t?.problems)&&t.problems.length>0?t.problems.map(t=>{return e=t,("string"==typeof e?.reason&&""!==e.reason.trim()?e.reason:void 0)??R.t.call(this,"failure.no-reason");var e}).join("\n"):void 0!==t?.message?String(t.message):null==t?"":String(t)}static of(t={}){const e=t=>E.evaluator().resolve(t),r=r=>(...n)=>r.apply({l10n:e("l10n"),locale:t.locale??e("locale")},n);return{t:r(R.t),date:r(R.date),number:r(R.number),bytes:r(R.bytes),failure:r(R.failure)}}}export{u as Attributes,t as BoundedCache,l as ExpressionEvaluator,i as Expressions,a as Fragments,c as LightSlots,R as Localization,h as Nodes,w as ParsedElement,b as Registry,v as RenderError,A as Rendering,g as Template,x as Templates,E as registry};
|
|
2
2
|
//# sourceMappingURL=ftl.min.mjs.map
|