@hyperfixi/engine 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  `,r:"\r",t:" ",v:"\v"},oe=t=>t>="a"&&t<="z"||t>="A"&&t<="Z",se=t=>t>="0"&&t<="9",Nt=t=>t===" "||t===" "||t==="\r"||t===`
3
3
  `,Tt=t=>oe(t)||se(t)||t==="-"||t==="_"||t===":",Ct=t=>oe(t)||se(t)||t==="_"||t==="$";function de(t,e=!1){let n=[],r=0,o=0,s=1,i="<START>",c=0,a=()=>t.charAt(r),u=b=>t.charAt(r+b),l=()=>(i=t.charAt(r++),i===`
4
4
  `?(s++,o=0):o++,i),m=b=>({type:b,value:"",start:r,end:r+1,line:s,column:o}),f=(b,k)=>(b.value=k,b.end=r,b),p=b=>{let k="";for(;a()&&b(a());)k+=l();return k},d=()=>e&&c===0,y=()=>oe(i)||se(i)||")\"'`}]".includes(i),g=(b,k)=>{let L=m(b),G=l();if(a()==="{"){if(L.template=!0,G+=l(),G+=p(pe=>pe!=="}"),a()!=="}")throw new Error("Unterminated "+(k?"class":"id")+" reference");let X=l();k&&(G+=X)}else if(k)for(;Tt(a())||a()==="\\";)a()==="\\"&&l(),G+=l();else G+=p(Tt);return f(L,G)},v=()=>{let b=m("STRING"),k=l();b.template=k==="`";let L="";for(;a()&&a()!==k;)if(a()==="\\"){l();let G=l();if(G in sn)L+=sn[G];else if(b.template&&G==="$")L+="\\$";else if(G==="x"){let X=a()&&u(1)?parseInt(l()+l(),16):NaN;if(Number.isNaN(X))throw new Error(`Invalid hexadecimal escape at [Line: ${b.line}, Column: ${b.column}]`);L+=String.fromCharCode(X)}else L+=G}else L+=l();if(a()!==k)throw new Error(`Unterminated string at [Line: ${b.line}, Column: ${b.column}]`);return l(),f(b,L)},C=()=>{let b=m("IDENTIFIER"),k=l()+p(Ct);return a()==="!"&&k==="beep"&&(k+=l()),f(b,k)},S=()=>{let b=m("IDENTIFIER"),k=l(),L=k==="\\";for(L&&(k="");(Ct(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!L);)a()==="\\"?(L=!0,l()):(L=!1,k+=l());return f(b,k)},R=()=>{let b=m("NUMBER"),k=l()+p(se);return a()==="."&&se(u(1))&&(k+=l()),k+=p(se),(a()==="e"||a()==="E")&&(se(u(1))?k+=l():u(1)==="-"&&(k+=l()+l())),f(b,k+p(se))},I=()=>{let b=m("OP");b.op=!0;let k=l();for(;a()&&on.has(k+a());)k+=l();return f(b,k)},A=()=>{let b=m("ATTRIBUTE_REF"),k=l();return k==="["?(k+=p(L=>L!=="]"),a()==="]"&&(k+=l())):(k+=p(Tt),a()==="="&&(k+=l(),a()==='"'||a()==="'"?k+=v().value:Ct(a())&&(k+=C().value))),f(b,k)},M=()=>{let b=n.at(-1);return b?b.type==="IDENTIFIER"||b.type==="CLASS_REF"||b.type==="ID_REF"?!1:!(b.op&&(b.value===">"||b.value===")")):!0},q=()=>{let b=a(),k=u(2);return(b==="-"||b==="/")&&u(1)===b&&(Nt(k)||k===""||k===b)};for(;r<t.length;){let b=a(),k=u(1);if(q())p(L=>L!=="\r"&&L!==`
5
- `),l();else if(Nt(b))n.push(f(m("WHITESPACE"),p(Nt)));else if(!y()&&b==="."&&(oe(k)||k==="{"||k==="-"))n.push(g("CLASS_REF",!0));else if(!y()&&b==="#"&&(oe(k)||k==="{"))n.push(g("ID_REF",!1));else if(b==="@"||b==="["&&k==="@")n.push(A());else if(b==="*"&&oe(k)){let L=m("STYLE_REF");n.push(f(L,l()+p(G=>oe(G)||G==="-")))}else if(d()&&(oe(b)||b==="\\"))n.push(S());else if(!d()&&(oe(b)||b==="_"||b==="$"))n.push(C());else if(se(b))n.push(R());else if(!d()&&(b==='"'||b==="`"))n.push(v());else if(!d()&&b==="'")n.push(M()?v():I());else if(on.has(b))i==="$"&&b==="{"&&c++,b==="}"&&c--,n.push(I());else if(d()||b==="`"){let L=m("RESERVED");n.push(f(L,l()))}else throw new Error("Unknown token: "+b+" ")}return n}function h(t){return t.match("the"),po(t)}function po(t){let e=cn(t),n,r=()=>t.match("and")??t.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&t.err("You must parenthesize logical operations with different operators"),e=ho(o.value,e,cn(t));return e}function ho(t,e,n){let r=t==="or";return{type:"logicalOperator",operator:t,left:e,right:n,start:e.start,end:n.end,ev:o=>E(e.ev(o),s=>!!s===r?s:n.ev(o))}}var yo={"+":(t,e)=>Array.isArray(t)?t.concat(e):T(t)+T(e),"-":(t,e)=>T(t)-T(e),"*":(t,e)=>T(t)*T(e),"/":(t,e)=>T(t)/T(e),mod:(t,e)=>T(t)%T(e)};function St(t){let e=Rt(t),n,r=()=>t.matchAnyOp("+","-","*","/")??t.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&t.err("You must parenthesize math operations with different operators");let s=e,i=Rt(t),c=yo[o.value];e={type:"mathOperator",operator:o.value,left:s,right:i,start:s.start,end:i.end,ev:u=>N([s.ev(u),i.ev(u)],([l,m])=>c(l,m))}}return e}function Rt(t){let e=$(t);for(let n=!0;n;){n=!1;for(let r of t.g.collections){let o=r(t,e);if(o){e=o,n=!0;break}}}return e}function $(t){t.match("the");let e=t.pos();if(t.match("not"))return Ce(t,"logicalNot",e,$(t),n=>!n);if(t.match("no"))return Ce(t,"noExpression",e,Rt(t),_e);for(let n of t.g.unaries){let r=n(t);if(r)return ee(t,r)}return wo(t)}function Ce(t,e,n,r,o,s=e!=="negativeNumber"){let i={type:e,root:r,start:n,end:t.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return s?ee(t,i):i}var go="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function wo(t){let e=dn(t),n=t.matchAny(...go)??t.matchOp("%");if(n)return an(t,"stringPostfixExpression",e,n.value);let r=t.matchAny("s","seconds")?1e3:t.matchAny("ms","milliseconds")?1:0;if(r)return an(t,"timeExpression",e,r);for(let o of t.g.postfixes){let s=o(t,e);if(s)return s}return e}function an(t,e,n,r){let o=i=>typeof r=="number"?T(i)*r:`${i}${r}`,s={type:e,root:n,suffix:r,start:n.start,end:t.endPos(),ev:i=>E(n.ev(i),o)};return n.stat&&(s.stat=()=>o(De(n))),s}function dn(t){let e=t.pos();return t.matchOp("-")?Ce(t,"negativeNumber",e,dn(t),n=>-T(n)):ut(t)}function ut(t){let e=At(t);return e?ee(t,e):t.err("Unexpected value: "+t.cur().value)}function ie(t){return t.match("the"),Ot(t,ut(t))}function Ot(t,e){let n=je(e);return n.put||t.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function je(t){let e=t;for(;e.type==="parenthesized"&&"expr"in e&&vo(e.expr);)e=e.expr;return e}var vo=t=>H(w(t,"ev"));function De(t){if(t.stat)return t.stat();throw new Error("This expression cannot be evaluated statically: "+t.type)}function Eo(t){let e=t.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(e)return{operator:e.value,right:!0,isType:!1};let n=(a,u=!0,l=!1)=>({operator:a,right:u,isType:l}),r=()=>t.match("equal")&&t.match("to"),o=(a,u)=>(t.req("than"),t.match("or")?(t.req("equal"),t.req("to"),n(u)):n(a));if(t.match("is")||t.match("am")){let a=!!t.match("not"),u=a?"not ":"";return t.match("in")?n(u+"in"):t.match("a")||t.match("an")?n(u+"a",!1,!0):t.match("empty")?n(u+"empty",!1):t.match("between")?n(u+"between"):!a&&t.match("less")?o("<","<="):!a&&t.match("greater")?o(">",">="):t.match("really")?(r(),n(a?"!==":"===")):t.match("equal")?(t.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(t.match("equals"))return n("==");if(t.match("really"))return t.req("equals"),n("===");if(t.matchAny("exist","exists"))return n("exist",!1);let s=!!t.matchAny("do","does");s&&t.req("not");let i=s?"not ":"",c=(a,u)=>t.match(a)??(s&&a!=="match"&&a!=="contain"?void 0:t.match(u));if(c("match","matches"))return n(i+"match");if(c("contain","contains"))return n(i+"contain");if(s&&t.match("exist"))return n("not exist",!1);if(c("include","includes"))return n(i+"include");if(t.match(s?"start":"starts"))return t.req("with"),n(i+"start with");if(t.match(s?"end":"ends"))return t.req("with"),n(i+"end with");if(c("precede","precedes"))return n(i+"precede");if(c("follow","follows"))return n(i+"follow");s&&t.expected("matches","contains","starts with","ends with","precede","follow")}function cn(t){let e=St(t),n=Eo(t);if(!n)return e;let{operator:r}=n,o,s=!0,i,c;n.isType?(o=t.reqType("IDENTIFIER").value,s=!t.matchOp("!")):n.right&&(i=St(t),r.endsWith("match")&&(c=i.css));let a;r.endsWith("between")&&(t.req("and"),a=St(t));let u=!1;t.match("ignoring")&&(t.req("case"),u=!0);let l=p=>u&&typeof p=="string"?p.toLowerCase():p,m=i?.type==="symbol"&&"scope"in i&&i.scope==="local"&&i.name!=="undefined"&&i.name!=="null"?i.name:void 0;return{type:"comparisonOperator",operator:r,left:e,right:i,right2:a,typeName:o,ignoringCase:u,start:e.start,end:t.endPos(),ev:p=>N([e.ev(p),c??i?.ev(p),a?.ev(p)],([d,y,g])=>{if(o){let v=rt(d,o,s);return r==="a"?v:!v}if(m&&y===void 0&&(r==="is"||r==="is not")){let v=!!ue(d,m);return r==="is"?v:!v}return fn(r,l(d),l(y),g)})}}function un(t,e){let n=w(t,"contains")??w(t,"includes");if(!H(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,t,[e])}function bo(t,e){let n=w(t,"match")??w(t,"matches");if(!H(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,t,[e])}var ln=(t,e,n)=>t instanceof Node&&e instanceof Node&&(t.compareDocumentPosition(e)&n)!==0;function fn(t,e,n,r){if(t==="not between")return T(e)<T(n)||T(e)>T(r);if(t.startsWith("not "))return!fn(t.slice(4),e,n,r);switch(t){case"is":case"==":return e==n;case"is not":case"!=":return e!=n;case"===":return e===n;case"!==":return e!==n;case"<":return T(e)<T(n);case">":return T(e)>T(n);case"<=":return T(e)<=T(n);case">=":return T(e)>=T(n);case"match":return e!=null&&bo(e,n);case"in":return n!=null&&un(n,e);case"contain":case"include":return e!=null&&un(e,n);case"start with":return e!=null&&String(e).startsWith(String(n));case"end with":return e!=null&&String(e).endsWith(String(n));case"between":return T(e)>=T(n)&&T(e)<=T(r);case"precede":return ln(e,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return ln(e,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return _e(e);case"exist":return nn(e)}throw new Error("Unknown comparison : "+t)}function At(t){let e=t.cur();switch(e.type){case"NUMBER":return t.consume(),Pt("number",parseFloat(e.value),e);case"STRING":return No(t);case"ID_REF":return Co(t);case"CLASS_REF":return te(t);case"ATTRIBUTE_REF":return Y(t);case"STYLE_REF":return hn(t)}if(e.op){if(e.value==="(")return xo(t);if(e.value==="[")return To(t);if(e.value==="{")return Ge(t);if(e.value==="<")return So(t)}let n=t.match("true")??t.match("false");if(n)return Pt("boolean",n.value==="true",n);let r=t.match("null");if(r)return Pt("null",null,r);for(let o of t.g.leaves){let s=o(t);if(s)return s}return Ft(t)}function Pt(t,e,n){return{type:t,value:e,start:n.start,end:n.end,ev:()=>e,stat:()=>e}}function xo(t){let e=t.pos();t.consume();let n=t.withoutFollows(()=>h(t));return t.reqOp(")"),{type:"parenthesized",expr:n,start:e,end:t.endPos(),ev:r=>n.ev(r)}}var ko=(t,e)=>N(t.map(n=>typeof n=="string"?n:n.ev(e)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function mn(t,e){let n=t.child(de(e,!0),e),r=[],o="";do{o+=n.lastWs();let s=n.cur();if(s.value==="$"){n.consume();let i=n.matchOp("{");r.push(o,h(n)),o="",i&&n.reqOp("}")}else s.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function No(t){let e=t.consume(),n=e.value,r={type:"string",value:n,start:e.start,end:e.end,ev:()=>n};if(e.template){let o=r.parts=mn(t,n);r.ev=s=>ko(o,s)}else r.stat=()=>n;return r}function To(t){let e=t.pos();t.consume();let n=[];if(!t.matchOp("]")){do n.push(h(t));while(t.matchOp(","));t.reqOp("]")}return{type:"arrayLiteral",values:n,start:e,end:t.endPos(),ev:r=>N(n.map(o=>o.ev(r)),o=>o)}}function Ge(t){let e=t.pos();t.consume();let n=[],r=[],o=()=>t.cur().op&&t.cur().value==="}";if(!t.matchOp("}")){do{let s=t.matchType("STRING");if(s)n.push(s.value);else if(t.matchOp("["))n.push(h(t)),t.reqOp("]");else{let i="";for(let c=t.matchType("IDENTIFIER")??t.matchOp("-");c;c=t.matchType("IDENTIFIER")??t.matchOp("-"))i+=c.value;n.push(i)}t.reqOp(":"),r.push(h(t))}while(t.matchOp(",")&&!o());t.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:e,end:t.endPos(),ev:s=>N([...n.map(i=>typeof i=="string"?i:i.ev(s)),...r.map(i=>i.ev(s))],i=>Object.fromEntries(n.map((c,a)=>[String(i[a]),i[n.length+a]])))}}function lt(t){if(!t.matchOp("("))return;let e=t.last.start,n=He(t,e);return t.reqOp(")"),n.end=t.endPos(),n}function He(t,e=t.pos()){let n=[],r=[];if(t.cur().type==="IDENTIFIER")do n.push(t.reqType("IDENTIFIER").value),t.reqOp(":"),r.push(h(t));while(t.matchOp(","));return{type:"namedArgumentList",names:n,values:r,start:e,end:t.endPos(),ev:o=>N(r.map(s=>s.ev(o)),s=>Object.fromEntries([["_namedArgList_",!0],...n.map((i,c)=>[i,s[c]])]))}}function $e(t){return t.matchType("STRING")?.value??t.consumeUntil(void 0,"WHITESPACE").map(e=>e.value).join("")}function Lt(t){let e=t.cur();if(!(e.op&&e.value==="/"||e.type==="IDENTIFIER"&&["http","https","ws","wss"].includes(e.value)))return h(t);let r=$e(t);return{type:"string",value:r,start:e.start,end:t.endPos(),ev:()=>r,stat:()=>r}}function Ft(t){let e=t.pos(),n;t.match("global")?n="global":t.match("element")?(n="element",t.matchOp("'")&&t.req("s")):t.match("dom")?n="inherited":t.match("local")&&(n="local");let r=t.matchOp(":"),o=!r&&t.matchOp("^"),s=t.matchType("IDENTIFIER");if(!s?.value)return;let i=(r?":":o?"^":"")+s.value,a=n??{$:"global",":":"element","^":"inherited"}[i[0]]??"local",u;return a==="inherited"&&t.match("on")&&(u=t.withFollow(["to","into","before","after","then"],()=>h(t))),{type:"symbol",name:i,scope:a,start:e,end:t.endPos(),ev:l=>le(i,l,a,u?.ev(l)),lhs:()=>{},put:(l,m,f)=>st(i,l,a,f,u?.ev(l))}}var pn=(t,e)=>{let n=e.value.substring(2);return h(t.child(de(n),n))};function Co(t){let e=t.consume(),n=(o,s)=>Et(o.me).getElementById(String(s)),r={type:"idRef",start:e.start,end:e.end,ev:()=>null,lhs:()=>{},put:(o,s,i)=>E(r.ev(o),c=>c&&Ee(c,i))};if(e.template){let o=r.expr=pn(t,e);r.ev=s=>E(o.ev(s),i=>n(s,i))}else{let o=r.value=e.value.substring(1);r.css=e.value,r.ev=s=>n(s,o)}return r}function te(t){let e=t.matchType("CLASS_REF");if(!e)return;let n={type:"classRef",start:e.start,end:e.end,ev:()=>null,lhs:()=>{},put:(r,o,s)=>E(n.ev(r),i=>Ee(Array.from(i instanceof ne?i:[]),s))};if(e.template){let r=n.expr=pn(t,e);n.ev=o=>E(r.ev(o),s=>new ne("."+s,o.me,!0))}else{let r=n.css=e.value;n.className=r.slice(1),n.ev=o=>new ne(r,o.me,!0)}return n}var It=class extends ne{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>x(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(x);n.forEach((o,s)=>o.setAttribute("data-hs-query-id",String(s)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function So(t){let e=t.pos();t.consume();let n=t.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");t.reqOp("/"),t.reqOp(">");let r={type:"queryRef",css:n,start:e,end:t.endPos(),ev:o=>new ne(n,o.me),lhs:()=>{},put:(o,s,i)=>E(r.ev(o),c=>Ee(Array.from(c instanceof ne?c:[]),i))};if(/\$[^=]/.test(n)){let o=r.parts=mn(t,n);r.ev=s=>N(o.map(i=>typeof i=="string"?i:i.ev(s)),i=>new It(s.me,i))}return r}function Y(t){let e=t.matchType("ATTRIBUTE_REF");if(!e)return;let n=e.value.startsWith("[")?e.value.slice(2,-1):e.value.slice(1),[r,o]=n.split("="),s=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:s,css:`[${n}]`,start:e.start,end:e.end,ev:i=>we(i.you||i.me,r),lhs:()=>{},put:(i,c,a)=>qe(i.you||i.me,r,a)}}function hn(t){let e=t.matchType("STYLE_REF");if(!e)return;let n=e.value.startsWith("*computed-"),r=e.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:e.start,end:e.end,ev:o=>(n?et:Ze)(o.you||o.me,r),lhs:()=>{},put:(o,s,i)=>tt(o.you||o.me,r,i)}}function yn(t){let e=t.pos();if(!t.matchOp("{"))return;let n=[""],r=[];for(;t.hasMore();){if(t.matchOp("\\"))t.consume();else{if(t.matchOp("}"))break;if(t.match("$")){let o=t.matchOp("{");r.push(h(t)),o&&t.reqOp("}"),n.push("")}else n[n.length-1]+=t.text(t.consume())}n[n.length-1]+=t.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:e,end:t.endPos(),ev:o=>N(r.map(s=>s.ev(o)),s=>n.map((i,c)=>i+(c in s?`${s[c]}`:"")).join(""))}}function U(t){let e=t.endPos();return{type:"implicitMeTarget",start:e,end:e,ev:n=>n.you||n.me}}function Se(t){let e=t.matchType("IDENTIFIER");if(!e)return;let n=[e.value],r=t.matchOp(".")??t.matchOp(":");if(r)do n.push(t.reqType("IDENTIFIER","NUMBER").value);while(t.matchOp(r.value));return n.join(r?.value??"")}function ae(t,e="Expected event name"){return t.matchType("STRING")?.value??Se(t)??t.err(e)}function ee(t,e){return Ro(t,e)??Io(t,e)??Mo(t,e)??Oo(t,e)??Ao(t,e)??Lo(t,e)??Fo(t,e)??qo(t,e)??Po(t,e)??e}function Po(t,e){for(let n of t.g.indirects){let r=n(t,e);if(r)return r}}function Ro(t,e){if(!t.matchOp("."))return;let n=t.reqType("IDENTIFIER").value,r=t.text(e),o={type:"propertyAccess",root:e,prop:n,start:e.start,end:t.endPos(),ev:s=>E(o.root.ev(s),i=>ue(i,n)),lhs:s=>o.root.ev(s),put:(s,i,c)=>{F(i,r),nt(i,n,c)},del:(s,i)=>{F(i,r),O(i,c=>{W(c)&&delete c[n],P.wroteProperty(c)})}};return ee(t,o)}function Io(t,e){if(!t.match("of"))return;let n=$(t),r,o=e;for(;o.root;)r=o,o=o.root;let i={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!i||c===void 0)return t.err("Cannot take a property of a non-symbol: "+o.type);let a=t.text(n),u={property:ue,attribute:we,style:Ze,computed:et}[i],l={type:"ofExpression",root:n,name:c,kind:i,start:e.start,end:t.endPos(),ev:m=>E(l.root.ev(m),f=>u(f,c)),lhs:m=>l.root.ev(m),put:(m,f,p)=>{F(f,a),i==="attribute"?qe(f,c,p):i==="property"?nt(f,c,p):tt(f,c,p)},del:(m,f)=>{F(f,a),O(f,p=>{i==="attribute"?x(p)&&p.removeAttribute(c):i==="property"?(W(p)&&delete p[c],P.wroteProperty(p)):p instanceof HTMLElement&&p.style.removeProperty(c)})}};return r?(r.root=l,ee(t,e)):ee(t,l)}function Oo(t,e){let n=t.matchOp("'"),r=e.type==="symbol"&&["my","its","your"].includes(e.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(t.cur().type);if(!n&&!r)return;n&&t.req("s");let o=Y(t)??hn(t),s=o?void 0:t.reqType("IDENTIFIER").value,i=t.text(e),c=u=>s!==void 0?ue(u,s):o?.type==="attributeRef"?we(u,o.name):o?.type==="computedStyleRef"?et(u,o.name):o&&Ze(u,o.name),a={type:"possessive",root:e,prop:s,attribute:o,start:e.start,end:t.endPos(),ev:u=>E(a.root.ev(u),c),lhs:u=>a.root.ev(u),put:(u,l,m)=>{F(l,i),s!==void 0?nt(l,s,m):o?.type==="attributeRef"?qe(l,o.name,m):o&&tt(l,o.name,m)}};return ee(t,a)}function Ao(t,e){if(!t.match("in"))return;let n=$(t),r=(i,c)=>{if(i==null)return[];let a=[],u=w(i,"css");if(typeof u=="string")O(c,l=>x(l)&&a.push(...bt(l,u)));else if(x(i)){let l=!1;if(O(c,m=>{m instanceof Node&&m.contains(i)&&(l=!0)}),l)return i}else O(i,l=>O(c,m=>l===m&&a.push(l)));return a},o={type:"inExpression",root:e,target:n,start:e.start,end:t.endPos(),ev:i=>N([o.root.ev(i),n.ev(i)],([c,a])=>r(c,a)),lhs:i=>o.ev(i),put:(i,c,a)=>Ee(c,a)},s;if(t.peek("where"))for(let i of t.g.collections)s??=i(t,o);return ee(t,s??o)}function Lo(t,e){if(!t.match("as"))return;t.match("a")||t.match("an");let n=o=>{let s=Se(t)??t.err("Expected dotOrColonPath"),i={type:"asExpression",root:o,conversion:s,start:o.start,end:t.endPos(),ev:c=>E(i.root.ev(c),a=>ot(a,s))};return i},r=n(e);for(;t.matchOp("|");)r=n(r);return ee(t,r)}function Fo(t,e){if(!t.matchOp("("))return;let n=[];if(!t.matchOp(")")){do n.push(h(t));while(t.matchOp(","));t.reqOp(")")}let r=t.text(e),o=e.root?t.text(e.root):"",s={type:"functionCall",root:e,args:n,start:e.start,end:t.endPos(),ev:i=>{let c=s.root,a=c.prop,u=a===void 0?void 0:c.root;return N([(u??c).ev(i),...n.map(l=>l.ev(i))],([l,...m])=>{if(!u||a===void 0)return ct(l,void 0,m,i,r);F(l,o);let f=ct(w(l,a),l,m,i,r);return Ye(l,a),f})}};return ee(t,s)}function ct(t,e,n,r,o){if(!H(t))throw F(t,o),new Error(`'${o}' is not a function`);return w(t,"hyperfunc")&&n.push(r),Reflect.apply(t,e,n)}function Mo(t,e){let n=Y(t);return n&&Mt(t,e,n)}function Mt(t,e,n){let r=t.text(e),o={type:"attributeRefAccess",root:e,attribute:n,start:e.start,end:t.endPos(),ev:s=>E(o.root.ev(s),i=>we(i,n.name)),lhs:s=>o.root.ev(s),put:(s,i,c)=>{F(i,r),qe(i,n.name,c)}};return o}function qo(t,e){if(!t.matchOp("["))return;let n=!!t.matchOp(".."),r=h(t),o=!1,s;!n&&t.matchOp("..")&&(o=!0,t.cur().op&&t.cur().value==="]"||(s=h(t))),t.reqOp("]");let i=t.text(e),c=(l,m)=>T(m)<0?T(w(l,"length"))+T(m):T(m),a=(l,m,f)=>{let p=w(l,"slice");return H(p)?Reflect.apply(p,l,[m,f]):void 0},u={type:"arrayIndex",root:e,first:r,second:s,andBefore:n,andAfter:o,start:e.start,end:t.endPos(),ev:l=>N([u.root.ev(l),r.ev(l),s?.ev(l)],([m,f,p])=>m==null?null:n?a(m,0,c(m,f)+1):o?p==null?a(m,T(f)):a(m,T(f),c(m,p)+1):w(m,String(f))),lhs:l=>N([u.root.ev(l),r.ev(l)],m=>m),put:(l,m,f)=>{let[p,d]=Array.isArray(m)?m:[];F(p,i),W(p)&&(p[String(d)]=f)},del:(l,m)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[f,p]=Array.isArray(m)?m:[];F(f,i),Array.isArray(f)?f.splice(c(f,p),1):W(f)&&delete f[String(p)],P.wroteProperty(f)}};return ee(t,u)}var be=class extends Error{constructor(n,r,o,s){super(n);this.token=r;this.source=o;this.expected=s}written},gn=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Pe=class t{constructor(e,n,r){this.g=e;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(e,n){return new t(this.g,e,n)}tok(e=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(e--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(e){return this.src.substring(e.start,e.end)}match(e,n="IDENTIFIER"){if(this.follows.includes(e))return;let r=this.cur();if(r.value===e&&r.type===n)return this.consume()}matchOp(e){let n=this.cur();if(n.op&&n.value===e)return this.consume()}matchType(...e){if(e.includes(this.cur().type))return this.consume()}matchAny(...e){for(let n of e){let r=this.match(n);if(r)return r}}matchAnyOp(...e){for(let n of e){let r=this.matchOp(n);if(r)return r}}req(e){return this.match(e)??this.expected(e)}reqOp(e){return this.matchOp(e)??this.expected(e)}reqType(...e){return this.matchType(...e)??this.expected(...e)}peek(e,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===e&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(e,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(e==null||o.value!==e)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let e=this.tokens[this.i-1];return e?.type==="WHITESPACE"?e.value:""}pushFollow(...e){return this.follows.push(...e),e.length}popFollow(e=1){this.follows.length-=e}withFollow(e,n){let r=this.pushFollow(...e);try{return n()}finally{this.popFollow(r)}}withoutFollows(e){let n=this.follows;this.follows=[];try{return e()}finally{this.follows=n}}err(e,n){let r=this.cur();throw new be(e??"Unexpected Token : "+r.value,r,this.src,n)}expected(...e){this.err(e.length===1?`Expected '${e[0]}' but found '${this.cur().value}'`:"Expected one of: "+e.map(n=>`'${n}'`).join(", "),e)}commandStart(e){return e.value in this.g.commands}featureStart(e){return e.value in this.g.features}commandBoundary(e){return["end","then","else","otherwise",")"].includes(e.value)||this.commandStart(e)||this.featureStart(e)||e.type==="EOF"}};function qt(t){let e=t.source.split(`
5
+ `),l();else if(Nt(b))n.push(f(m("WHITESPACE"),p(Nt)));else if(!y()&&b==="."&&(oe(k)||k==="{"||k==="-"))n.push(g("CLASS_REF",!0));else if(!y()&&b==="#"&&(oe(k)||k==="{"))n.push(g("ID_REF",!1));else if(b==="@"||b==="["&&k==="@")n.push(A());else if(b==="*"&&oe(k)){let L=m("STYLE_REF");n.push(f(L,l()+p(G=>oe(G)||G==="-")))}else if(d()&&(oe(b)||b==="\\"))n.push(S());else if(!d()&&(oe(b)||b==="_"||b==="$"))n.push(C());else if(se(b))n.push(R());else if(!d()&&(b==='"'||b==="`"))n.push(v());else if(!d()&&b==="'")n.push(M()?v():I());else if(on.has(b))i==="$"&&b==="{"&&c++,b==="}"&&c--,n.push(I());else if(d()||b==="`"){let L=m("RESERVED");n.push(f(L,l()))}else throw new Error("Unknown token: "+b+" ")}return n}function h(t){return t.match("the"),po(t)}function po(t){let e=cn(t),n,r=()=>t.match("and")??t.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&t.err("You must parenthesize logical operations with different operators"),e=ho(o.value,e,cn(t));return e}function ho(t,e,n){let r=t==="or";return{type:"logicalOperator",operator:t,left:e,right:n,start:e.start,end:n.end,ev:o=>E(e.ev(o),s=>!!s===r?s:n.ev(o))}}var yo={"+":(t,e)=>Array.isArray(t)?t.concat(e):T(t)+T(e),"-":(t,e)=>T(t)-T(e),"*":(t,e)=>T(t)*T(e),"/":(t,e)=>T(t)/T(e),mod:(t,e)=>T(t)%T(e)};function St(t){let e=Rt(t),n,r=()=>t.matchAnyOp("+","-","*","/")??t.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&t.err("You must parenthesize math operations with different operators");let s=e,i=Rt(t),c=yo[o.value];e={type:"mathOperator",operator:o.value,left:s,right:i,start:s.start,end:i.end,ev:u=>N([s.ev(u),i.ev(u)],([l,m])=>c(l,m))}}return e}function Rt(t){let e=$(t);for(let n=!0;n;){n=!1;for(let r of t.g.collections){let o=r(t,e);if(o){e=o,n=!0;break}}}return e}function $(t){t.match("the");let e=t.pos();if(t.match("not"))return Ce(t,"logicalNot",e,$(t),n=>!n);if(t.match("no"))return Ce(t,"noExpression",e,Rt(t),_e);for(let n of t.g.unaries){let r=n(t);if(r)return ee(t,r)}return wo(t)}function Ce(t,e,n,r,o,s=e!=="negativeNumber"){let i={type:e,root:r,start:n,end:t.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return s?ee(t,i):i}var go="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function wo(t){let e=dn(t),n=t.matchAny(...go)??t.matchOp("%");if(n)return an(t,"stringPostfixExpression",e,n.value);let r=t.matchAny("s","seconds")?1e3:t.matchAny("ms","milliseconds")?1:0;if(r)return an(t,"timeExpression",e,r);for(let o of t.g.postfixes){let s=o(t,e);if(s)return s}return e}function an(t,e,n,r){let o=i=>typeof r=="number"?T(i)*r:`${i}${r}`,s={type:e,root:n,suffix:r,start:n.start,end:t.endPos(),ev:i=>E(n.ev(i),o)};return n.stat&&(s.stat=()=>o(De(n))),s}function dn(t){let e=t.pos();return t.matchOp("-")?Ce(t,"negativeNumber",e,dn(t),n=>-T(n)):ut(t)}function ut(t){let e=At(t);return e?ee(t,e):t.err("Unexpected value: "+t.cur().value)}function ie(t){return t.match("the"),Ot(t,ut(t))}function Ot(t,e){let n=je(e);return n.put||t.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function je(t){let e=t;for(;e.type==="parenthesized"&&"expr"in e&&vo(e.expr);)e=e.expr;return e}var vo=t=>H(w(t,"ev"));function De(t){if(t.stat)return t.stat();throw new Error("This expression cannot be evaluated statically: "+t.type)}function Eo(t){let e=t.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(e)return{operator:e.value,right:!0,isType:!1};let n=(a,u=!0,l=!1)=>({operator:a,right:u,isType:l}),r=()=>t.match("equal")&&t.match("to"),o=(a,u)=>(t.req("than"),t.match("or")?(t.req("equal"),t.req("to"),n(u)):n(a));if(t.match("is")||t.match("am")){let a=!!t.match("not"),u=a?"not ":"";return t.match("in")?n(u+"in"):t.match("a")||t.match("an")?n(u+"a",!1,!0):t.match("empty")?n(u+"empty",!1):t.match("between")?n(u+"between"):!a&&t.match("less")?o("<","<="):!a&&t.match("greater")?o(">",">="):t.match("really")?(r(),n(a?"!==":"===")):t.match("equal")?(t.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(t.match("equals"))return n("==");if(t.match("really"))return t.req("equals"),n("===");if(t.matchAny("exist","exists"))return n("exist",!1);let s=!!t.matchAny("do","does");s&&t.req("not");let i=s?"not ":"",c=(a,u)=>t.match(a)??(s&&a!=="match"&&a!=="contain"?void 0:t.match(u));if(c("match","matches"))return n(i+"match");if(c("contain","contains"))return n(i+"contain");if(s&&t.match("exist"))return n("not exist",!1);if(c("include","includes"))return n(i+"include");if(t.match(s?"start":"starts"))return t.req("with"),n(i+"start with");if(t.match(s?"end":"ends"))return t.req("with"),n(i+"end with");if(c("precede","precedes"))return n(i+"precede");if(c("follow","follows"))return n(i+"follow");s&&t.expected("matches","contains","starts with","ends with","precede","follow")}function cn(t){let e=St(t),n=Eo(t);if(!n)return e;let{operator:r}=n,o,s=!0,i,c;n.isType?(o=t.reqType("IDENTIFIER").value,s=!t.matchOp("!")):n.right&&(i=St(t),r.endsWith("match")&&(c=i.css));let a;r.endsWith("between")&&(t.req("and"),a=St(t));let u=!1;t.match("ignoring")&&(t.req("case"),u=!0);let l=p=>u&&typeof p=="string"?p.toLowerCase():p,m=i?.type==="symbol"&&"scope"in i&&i.scope==="local"&&i.name!=="undefined"&&i.name!=="null"?i.name:void 0;return{type:"comparisonOperator",operator:r,left:e,right:i,right2:a,typeName:o,ignoringCase:u,start:e.start,end:t.endPos(),ev:p=>N([e.ev(p),c??i?.ev(p),a?.ev(p)],([d,y,g])=>{if(o){let v=rt(d,o,s);return r==="a"?v:!v}if(m&&y===void 0&&(r==="is"||r==="is not")){let v=!!ue(d,m);return r==="is"?v:!v}return fn(r,l(d),l(y),g)})}}function un(t,e){let n=w(t,"contains")??w(t,"includes");if(!H(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,t,[e])}function bo(t,e){let n=w(t,"match")??w(t,"matches");if(!H(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,t,[e])}var ln=(t,e,n)=>t instanceof Node&&e instanceof Node&&(t.compareDocumentPosition(e)&n)!==0;function fn(t,e,n,r){if(t==="not between")return T(e)<T(n)||T(e)>T(r);if(t.startsWith("not "))return!fn(t.slice(4),e,n,r);switch(t){case"is":case"==":return e==n;case"is not":case"!=":return e!=n;case"===":return e===n;case"!==":return e!==n;case"<":return T(e)<T(n);case">":return T(e)>T(n);case"<=":return T(e)<=T(n);case">=":return T(e)>=T(n);case"match":return e!=null&&bo(e,n);case"in":return n!=null&&un(n,e);case"contain":case"include":return e!=null&&un(e,n);case"start with":return e!=null&&String(e).startsWith(String(n));case"end with":return e!=null&&String(e).endsWith(String(n));case"between":return T(e)>=T(n)&&T(e)<=T(r);case"precede":return ln(e,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return ln(e,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return _e(e);case"exist":return nn(e)}throw new Error("Unknown comparison : "+t)}function At(t){let e=t.cur();switch(e.type){case"NUMBER":return t.consume(),Pt("number",parseFloat(e.value),e);case"STRING":return No(t);case"ID_REF":return Co(t);case"CLASS_REF":return te(t);case"ATTRIBUTE_REF":return Y(t);case"STYLE_REF":return hn(t)}if(e.op){if(e.value==="(")return xo(t);if(e.value==="[")return To(t);if(e.value==="{")return Ge(t);if(e.value==="<")return So(t)}let n=t.match("true")??t.match("false");if(n)return Pt("boolean",n.value==="true",n);let r=t.match("null");if(r)return Pt("null",null,r);for(let o of t.g.leaves){let s=o(t);if(s)return s}return Ft(t)}function Pt(t,e,n){return{type:t,value:e,start:n.start,end:n.end,ev:()=>e,stat:()=>e}}function xo(t){let e=t.pos();t.consume();let n=t.withoutFollows(()=>h(t));return t.reqOp(")"),{type:"parenthesized",expr:n,start:e,end:t.endPos(),ev:r=>n.ev(r)}}var ko=(t,e)=>N(t.map(n=>typeof n=="string"?n:n.ev(e)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function mn(t,e){let n=t.child(de(e,!0),e),r=[],o="";do{o+=n.lastWs();let s=n.cur();if(s.value==="$"){n.consume();let i=n.matchOp("{");r.push(o,h(n)),o="",i&&n.reqOp("}")}else s.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function No(t){let e=t.consume(),n=e.value,r={type:"string",value:n,start:e.start,end:e.end,ev:()=>n};if(e.template){let o=r.parts=mn(t,n);r.ev=s=>ko(o,s)}else r.stat=()=>n;return r}function To(t){let e=t.pos();t.consume();let n=[];if(!t.matchOp("]")){do n.push(h(t));while(t.matchOp(","));t.reqOp("]")}return{type:"arrayLiteral",values:n,start:e,end:t.endPos(),ev:r=>N(n.map(o=>o.ev(r)),o=>o)}}function Ge(t){let e=t.pos();t.consume();let n=[],r=[],o=()=>t.cur().op&&t.cur().value==="}";if(!t.matchOp("}")){do{let s=t.matchType("STRING");if(s)n.push(s.value);else if(t.matchOp("["))n.push(h(t)),t.reqOp("]");else{let i="";for(let c=t.matchType("IDENTIFIER")??t.matchOp("-");c;c=t.matchType("IDENTIFIER")??t.matchOp("-"))i+=c.value;n.push(i)}t.reqOp(":"),r.push(h(t))}while(t.matchOp(",")&&!o());t.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:e,end:t.endPos(),ev:s=>N([...n.map(i=>typeof i=="string"?i:i.ev(s)),...r.map(i=>i.ev(s))],i=>Object.fromEntries(n.map((c,a)=>[String(i[a]),i[n.length+a]])))}}function lt(t){if(!t.matchOp("("))return;let e=t.last.start,n=He(t,e);return t.reqOp(")"),n.end=t.endPos(),n}function He(t,e=t.pos()){let n=[],r=[];if(t.cur().type==="IDENTIFIER")do n.push(t.reqType("IDENTIFIER").value),t.reqOp(":"),r.push(h(t));while(t.matchOp(","));return{type:"namedArgumentList",names:n,values:r,start:e,end:t.endPos(),ev:o=>N(r.map(s=>s.ev(o)),s=>Object.fromEntries([["_namedArgList_",!0],...n.map((i,c)=>[i,s[c]])]))}}function $e(t){return t.matchType("STRING")?.value??t.consumeUntil(void 0,"WHITESPACE").map(e=>e.value).join("")}function Lt(t){let e=t.cur();if(!(e.op&&e.value==="/"||e.type==="IDENTIFIER"&&["http","https","ws","wss"].includes(e.value)))return h(t);let r=$e(t);return{type:"string",value:r,start:e.start,end:t.endPos(),ev:()=>r,stat:()=>r}}function Ft(t){let e=t.pos(),n;t.match("global")?n="global":t.match("element")?(n="element",t.matchOp("'")&&t.req("s")):t.match("dom")?n="inherited":t.match("local")&&(n="local");let r=t.matchOp(":"),o=!r&&t.matchOp("^"),s=t.matchType("IDENTIFIER");if(!s?.value)return;let i=(r?":":o?"^":"")+s.value,a=n??{$:"global",":":"element","^":"inherited"}[i[0]]??"local",u;return a==="inherited"&&t.match("on")&&(u=t.withFollow(["to","into","before","after","then"],()=>h(t))),{type:"symbol",name:i,scope:a,...u?{on:u}:{},start:e,end:t.endPos(),ev:l=>le(i,l,a,u?.ev(l)),lhs:()=>{},put:(l,m,f)=>st(i,l,a,f,u?.ev(l))}}var pn=(t,e)=>{let n=e.value.substring(2);return h(t.child(de(n),n))};function Co(t){let e=t.consume(),n=(o,s)=>Et(o.me).getElementById(String(s)),r={type:"idRef",start:e.start,end:e.end,ev:()=>null,lhs:()=>{},put:(o,s,i)=>E(r.ev(o),c=>c&&Ee(c,i))};if(e.template){let o=r.expr=pn(t,e);r.ev=s=>E(o.ev(s),i=>n(s,i))}else{let o=r.value=e.value.substring(1);r.css=e.value,r.ev=s=>n(s,o)}return r}function te(t){let e=t.matchType("CLASS_REF");if(!e)return;let n={type:"classRef",start:e.start,end:e.end,ev:()=>null,lhs:()=>{},put:(r,o,s)=>E(n.ev(r),i=>Ee(Array.from(i instanceof ne?i:[]),s))};if(e.template){let r=n.expr=pn(t,e);n.ev=o=>E(r.ev(o),s=>new ne("."+s,o.me,!0))}else{let r=n.css=e.value;n.className=r.slice(1),n.ev=o=>new ne(r,o.me,!0)}return n}var It=class extends ne{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>x(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(x);n.forEach((o,s)=>o.setAttribute("data-hs-query-id",String(s)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function So(t){let e=t.pos();t.consume();let n=t.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");t.reqOp("/"),t.reqOp(">");let r={type:"queryRef",css:n,start:e,end:t.endPos(),ev:o=>new ne(n,o.me),lhs:()=>{},put:(o,s,i)=>E(r.ev(o),c=>Ee(Array.from(c instanceof ne?c:[]),i))};if(/\$[^=]/.test(n)){let o=r.parts=mn(t,n);r.ev=s=>N(o.map(i=>typeof i=="string"?i:i.ev(s)),i=>new It(s.me,i))}return r}function Y(t){let e=t.matchType("ATTRIBUTE_REF");if(!e)return;let n=e.value.startsWith("[")?e.value.slice(2,-1):e.value.slice(1),[r,o]=n.split("="),s=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:s,css:`[${n}]`,start:e.start,end:e.end,ev:i=>we(i.you||i.me,r),lhs:()=>{},put:(i,c,a)=>qe(i.you||i.me,r,a)}}function hn(t){let e=t.matchType("STYLE_REF");if(!e)return;let n=e.value.startsWith("*computed-"),r=e.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:e.start,end:e.end,ev:o=>(n?et:Ze)(o.you||o.me,r),lhs:()=>{},put:(o,s,i)=>tt(o.you||o.me,r,i)}}function yn(t){let e=t.pos();if(!t.matchOp("{"))return;let n=[""],r=[];for(;t.hasMore();){if(t.matchOp("\\"))t.consume();else{if(t.matchOp("}"))break;if(t.match("$")){let o=t.matchOp("{");r.push(h(t)),o&&t.reqOp("}"),n.push("")}else n[n.length-1]+=t.text(t.consume())}n[n.length-1]+=t.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:e,end:t.endPos(),ev:o=>N(r.map(s=>s.ev(o)),s=>n.map((i,c)=>i+(c in s?`${s[c]}`:"")).join(""))}}function U(t){let e=t.endPos();return{type:"implicitMeTarget",start:e,end:e,ev:n=>n.you||n.me}}function Se(t){let e=t.matchType("IDENTIFIER");if(!e)return;let n=[e.value],r=t.matchOp(".")??t.matchOp(":");if(r)do n.push(t.reqType("IDENTIFIER","NUMBER").value);while(t.matchOp(r.value));return n.join(r?.value??"")}function ae(t,e="Expected event name"){return t.matchType("STRING")?.value??Se(t)??t.err(e)}function ee(t,e){return Ro(t,e)??Io(t,e)??Mo(t,e)??Oo(t,e)??Ao(t,e)??Lo(t,e)??Fo(t,e)??qo(t,e)??Po(t,e)??e}function Po(t,e){for(let n of t.g.indirects){let r=n(t,e);if(r)return r}}function Ro(t,e){if(!t.matchOp("."))return;let n=t.reqType("IDENTIFIER").value,r=t.text(e),o={type:"propertyAccess",root:e,prop:n,start:e.start,end:t.endPos(),ev:s=>E(o.root.ev(s),i=>ue(i,n)),lhs:s=>o.root.ev(s),put:(s,i,c)=>{F(i,r),nt(i,n,c)},del:(s,i)=>{F(i,r),O(i,c=>{W(c)&&delete c[n],P.wroteProperty(c)})}};return ee(t,o)}function Io(t,e){if(!t.match("of"))return;let n=$(t),r,o=e;for(;o.root;)r=o,o=o.root;let i={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!i||c===void 0)return t.err("Cannot take a property of a non-symbol: "+o.type);let a=t.text(n),u={property:ue,attribute:we,style:Ze,computed:et}[i],l={type:"ofExpression",root:n,name:c,kind:i,start:e.start,end:t.endPos(),ev:m=>E(l.root.ev(m),f=>u(f,c)),lhs:m=>l.root.ev(m),put:(m,f,p)=>{F(f,a),i==="attribute"?qe(f,c,p):i==="property"?nt(f,c,p):tt(f,c,p)},del:(m,f)=>{F(f,a),O(f,p=>{i==="attribute"?x(p)&&p.removeAttribute(c):i==="property"?(W(p)&&delete p[c],P.wroteProperty(p)):p instanceof HTMLElement&&p.style.removeProperty(c)})}};return r?(r.root=l,ee(t,e)):ee(t,l)}function Oo(t,e){let n=t.matchOp("'"),r=e.type==="symbol"&&["my","its","your"].includes(e.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(t.cur().type);if(!n&&!r)return;n&&t.req("s");let o=Y(t)??hn(t),s=o?void 0:t.reqType("IDENTIFIER").value,i=t.text(e),c=u=>s!==void 0?ue(u,s):o?.type==="attributeRef"?we(u,o.name):o?.type==="computedStyleRef"?et(u,o.name):o&&Ze(u,o.name),a={type:"possessive",root:e,prop:s,attribute:o,start:e.start,end:t.endPos(),ev:u=>E(a.root.ev(u),c),lhs:u=>a.root.ev(u),put:(u,l,m)=>{F(l,i),s!==void 0?nt(l,s,m):o?.type==="attributeRef"?qe(l,o.name,m):o&&tt(l,o.name,m)}};return ee(t,a)}function Ao(t,e){if(!t.match("in"))return;let n=$(t),r=(i,c)=>{if(i==null)return[];let a=[],u=w(i,"css");if(typeof u=="string")O(c,l=>x(l)&&a.push(...bt(l,u)));else if(x(i)){let l=!1;if(O(c,m=>{m instanceof Node&&m.contains(i)&&(l=!0)}),l)return i}else O(i,l=>O(c,m=>l===m&&a.push(l)));return a},o={type:"inExpression",root:e,target:n,start:e.start,end:t.endPos(),ev:i=>N([o.root.ev(i),n.ev(i)],([c,a])=>r(c,a)),lhs:i=>o.ev(i),put:(i,c,a)=>Ee(c,a)},s;if(t.peek("where"))for(let i of t.g.collections)s??=i(t,o);return ee(t,s??o)}function Lo(t,e){if(!t.match("as"))return;t.match("a")||t.match("an");let n=o=>{let s=Se(t)??t.err("Expected dotOrColonPath"),i={type:"asExpression",root:o,conversion:s,start:o.start,end:t.endPos(),ev:c=>E(i.root.ev(c),a=>ot(a,s))};return i},r=n(e);for(;t.matchOp("|");)r=n(r);return ee(t,r)}function Fo(t,e){if(!t.matchOp("("))return;let n=[];if(!t.matchOp(")")){do n.push(h(t));while(t.matchOp(","));t.reqOp(")")}let r=t.text(e),o=e.root?t.text(e.root):"",s={type:"functionCall",root:e,args:n,start:e.start,end:t.endPos(),ev:i=>{let c=s.root,a=c.prop,u=a===void 0?void 0:c.root;return N([(u??c).ev(i),...n.map(l=>l.ev(i))],([l,...m])=>{if(!u||a===void 0)return ct(l,void 0,m,i,r);F(l,o);let f=ct(w(l,a),l,m,i,r);return Ye(l,a),f})}};return ee(t,s)}function ct(t,e,n,r,o){if(!H(t))throw F(t,o),new Error(`'${o}' is not a function`);return w(t,"hyperfunc")&&n.push(r),Reflect.apply(t,e,n)}function Mo(t,e){let n=Y(t);return n&&Mt(t,e,n)}function Mt(t,e,n){let r=t.text(e),o={type:"attributeRefAccess",root:e,attribute:n,start:e.start,end:t.endPos(),ev:s=>E(o.root.ev(s),i=>we(i,n.name)),lhs:s=>o.root.ev(s),put:(s,i,c)=>{F(i,r),qe(i,n.name,c)}};return o}function qo(t,e){if(!t.matchOp("["))return;let n=!!t.matchOp(".."),r=h(t),o=!1,s;!n&&t.matchOp("..")&&(o=!0,t.cur().op&&t.cur().value==="]"||(s=h(t))),t.reqOp("]");let i=t.text(e),c=(l,m)=>T(m)<0?T(w(l,"length"))+T(m):T(m),a=(l,m,f)=>{let p=w(l,"slice");return H(p)?Reflect.apply(p,l,[m,f]):void 0},u={type:"arrayIndex",root:e,first:r,second:s,andBefore:n,andAfter:o,start:e.start,end:t.endPos(),ev:l=>N([u.root.ev(l),r.ev(l),s?.ev(l)],([m,f,p])=>m==null?null:n?a(m,0,c(m,f)+1):o?p==null?a(m,T(f)):a(m,T(f),c(m,p)+1):w(m,String(f))),lhs:l=>N([u.root.ev(l),r.ev(l)],m=>m),put:(l,m,f)=>{let[p,d]=Array.isArray(m)?m:[];F(p,i),W(p)&&(p[String(d)]=f)},del:(l,m)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[f,p]=Array.isArray(m)?m:[];F(f,i),Array.isArray(f)?f.splice(c(f,p),1):W(f)&&delete f[String(p)],P.wroteProperty(f)}};return ee(t,u)}var be=class extends Error{constructor(n,r,o,s){super(n);this.token=r;this.source=o;this.expected=s}written},gn=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Pe=class t{constructor(e,n,r){this.g=e;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(e,n){return new t(this.g,e,n)}tok(e=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(e--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(e){return this.src.substring(e.start,e.end)}match(e,n="IDENTIFIER"){if(this.follows.includes(e))return;let r=this.cur();if(r.value===e&&r.type===n)return this.consume()}matchOp(e){let n=this.cur();if(n.op&&n.value===e)return this.consume()}matchType(...e){if(e.includes(this.cur().type))return this.consume()}matchAny(...e){for(let n of e){let r=this.match(n);if(r)return r}}matchAnyOp(...e){for(let n of e){let r=this.matchOp(n);if(r)return r}}req(e){return this.match(e)??this.expected(e)}reqOp(e){return this.matchOp(e)??this.expected(e)}reqType(...e){return this.matchType(...e)??this.expected(...e)}peek(e,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===e&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(e,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(e==null||o.value!==e)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let e=this.tokens[this.i-1];return e?.type==="WHITESPACE"?e.value:""}pushFollow(...e){return this.follows.push(...e),e.length}popFollow(e=1){this.follows.length-=e}withFollow(e,n){let r=this.pushFollow(...e);try{return n()}finally{this.popFollow(r)}}withoutFollows(e){let n=this.follows;this.follows=[];try{return e()}finally{this.follows=n}}err(e,n){let r=this.cur();throw new be(e??"Unexpected Token : "+r.value,r,this.src,n)}expected(...e){this.err(e.length===1?`Expected '${e[0]}' but found '${this.cur().value}'`:"Expected one of: "+e.map(n=>`'${n}'`).join(", "),e)}commandStart(e){return e.value in this.g.commands}featureStart(e){return e.value in this.g.features}commandBoundary(e){return["end","then","else","otherwise",")"].includes(e.value)||this.commandStart(e)||this.featureStart(e)||e.type==="EOF"}};function qt(t){let e=t.source.split(`
6
6
  `),n=t.token.line?t.token.line-1:e.length-1,r=e[n]??"",o=t.token.line?t.token.column:Math.max(0,r.length-1),s=String(n+1).length,i=" ".repeat(s+5+o);return` ${n+1} | ${r}
7
7
  `+i+"^".repeat(Math.max(1,t.token.value.length))+`
8
8
  `+i+t.message+`
@@ -14,6 +14,6 @@
14
14
 
15
15
  `+qt(s)+i)}else _(t,"exception",{error:s}),console.error("hyperscript errors were found on the following element:",t,`
16
16
 
17
- `,s)}}var Pn=[],Rn=[];function fe(t){if(!(t instanceof Element||t instanceof Document||t instanceof DocumentFragment))return;for(let n of Pn)n(t);let e=Tn().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";t instanceof Element&&t.matches(e)&&En(t),t.querySelectorAll(e).forEach(En);for(let n of Rn)n(t)}function xe(t){let e=ce(t);if(e){_(t,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of e.listeners??[])n.removeEventListener(r,o);for(let n of e.observers??[])n.disconnect();for(let n of e.timers??[])clearTimeout(n);P.stop(t),t.querySelectorAll("[data-hyperscript-powered]").forEach(xe),_(t,"hyperscript:after:cleanup"),t.removeAttribute("data-hyperscript-powered"),tn(t)}}z.process=fe;function Go(t){try{let e=Nn(t);return e.kind==="features"?{...e.program,errors:[]}:{...e.kind==="commands"?e.commands[0]:e.expression,errors:[]}}catch(e){if(e instanceof be)return{errors:[e]};throw e}}var Re=Object.assign(vn,{config:Object.assign(Z,{conversions:Object.assign(ge,{dynamicResolvers:Me})}),use(t){t(Re)},addBeforeProcessHook:t=>void Pn.push(t),addAfterProcessHook:t=>void Rn.push(t),addSourceTransform:t=>void Sn.push(t),evaluate:vn,parse:Go,process:fe,processNode:fe,cleanup:xe,internals:{runtime:{cleanup:xe,processNode:fe}},version:"4.0.1"});function In(){if(Object.assign(globalThis,{_hyperscript:Re}),typeof document>"u")return;let t=()=>{fe(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t)}function On(t){t.unaries.push(e=>{let n=1;for(;e.tok(n).type==="IDENTIFIER"&&e.tok(n+1).op&&e.tok(n+1).value===".";)n+=2;let r=e.tok(n+1);if(!e.peek("new")||e.tok(n).type!=="IDENTIFIER"||!r.op||r.value!=="(")return;let o=e.pos();e.consume();let s=[e.consume().value];for(;e.matchOp(".");)s.push(e.consume().value);e.reqOp("(");let i=[];if(!e.matchOp(")")){do i.push(h(e));while(e.matchOp(","));e.reqOp(")")}return{type:"newExpression",path:s,args:i,start:o,end:e.endPos(),ev:a=>N(i.map(u=>u.ev(a)),u=>{let l=s.slice(1).reduce((m,f)=>w(m,f),le(s[0],a));if(!H(l))throw new Error(`'${s.join(".")}' is not a constructor`);return Reflect.construct(l,u)})}})}function Ho(t,e){let n=t instanceof HTMLElement&&t.tagName==="SUMMARY"?t.parentElement:t;if(n instanceof HTMLDialogElement)n.open?n.close():e?n.showModal():n.show();else if(n instanceof HTMLDetailsElement)n.open=!n.open;else if(n instanceof HTMLSelectElement){if(document.activeElement===n)return n.blur();n.focus();try{n.showPicker()}catch{}}else if(n instanceof HTMLElement&&n.hasAttribute("popover"))n.togglePopover();else throw new Error("toggle needs a dialog, details, select or popover element")}function An(t){t.toggleElement=(e,n,r)=>{let o=e.match("as")?!!e.req("modal"):!!e.match("modal"),s=e.text(n);return{type:"toggleElementCommand",target:n,modal:o,start:r,end:e.endPos(),run:c=>E(n.ev(c),a=>{F(a,s),O(a,u=>Ho(u,o))})}}}var Ln=(t,e,n)=>new Promise(r=>{let o=!1;t.addEventListener("transitionstart",()=>o=!0,{once:!0}),t.addEventListener("transitionend",()=>r(),{once:!0}),setTimeout(()=>o||r(),e),n?.()});function Fn(t){t.commands.settle=(e,n,r)=>{let o=e.commandBoundary(e.cur())?U(e):h(e),s=e.text(o);return{type:"settleCommand",target:o,start:r,end:e.endPos(),run:c=>E(o.ev(c),a=>{F(a,s);let u=x(a)?[a]:K(a)?Array.from(a).filter(x):[];return Promise.all(u.map(l=>Ln(l,500))).then(()=>{})})}}}function Mn(t){t.commands.transition=(e,n,r)=>{let o=[],s=[],i=[];do o.push(e.withFollow(["from","to"],()=>h(e))),s.push(e.match("from")?h(e):void 0),e.req("to"),i.push(e.match("initial")?"initial":h(e));while(!e.commandBoundary(e.cur())&&e.cur().value!=="over"&&e.cur().value!=="using");let c=e.match("over")?h(e):void 0,a=!c&&e.match("using")?h(e):void 0,u=o[0].root,l=u?e.text(u):"",m=(p,d)=>o.forEach((y,g)=>{d[g]!=null&&E(y.lhs?.(p),v=>y.put?.(p,v,d[g]))});return{type:"transitionCommand",properties:o,from:s,to:i,over:c,using:a,start:r,end:e.endPos(),run:p=>N([u?u.ev(p):p.me,c?.ev(p),a?.ev(p),N(s.map(d=>d?.ev(p)),d=>d),N(i.map(d=>d==="initial"?void 0:d.ev(p)),d=>d)],([d,y,g,v,C])=>{u&&F(d,l);let S=[];return O(d,R=>{if(!(R instanceof HTMLElement))return;let I=R.style.transition;R.style.transition=y?`all ${y}ms ease-in`:g?String(g):Z.defaultTransition;let A=V(R).transitionInitials??={};o.forEach((q,b)=>{b in A||(A[b]=q.ev(p))}),Array.isArray(v)&&m(p,v);let M=i.map((q,b)=>q==="initial"?A[b]:w(C,String(b)));S.push(Ln(R,100,()=>setTimeout(()=>m(p,M),0)).then(()=>{R.style.transition=I}))}),Promise.all(S).then(()=>{})})}}}function qn(t){t.commands.start=(e,n,r)=>{e.match("a"),e.req("view"),e.req("transition"),e.match("using");let o=e.matchType("STRING")?.value,s=D(e);e.hasMore()&&e.req("end");let i=!1;return{type:"viewTransitionCommand",body:s,transitionType:o,start:r,end:e.endPos(),run:a=>{if(!document.startViewTransition)return j(s,a);if(i)throw new Error("A view transition is already in progress");i=!0;let u=()=>{},l=new Promise(d=>u=d),m=()=>l,f=o?document.startViewTransition({update:m,types:[o]}):document.startViewTransition(m),p=d=>(i=!1,u(),d?(console.warn("hyperscript: view transition skipped due to early exit (return, halt, or break)"),f.finished.catch(()=>{}),f.skipTransition(),d):f.finished.then(()=>{}));return new Promise(d=>setTimeout(d,0)).then(()=>j(s,a)).then(d=>p(re(d)))}}}}function _n(t){t.commands.if=(e,n,r)=>{let o=h(e);e.match("then");let s=D(e),i,c=!1,a=e.match("else")??e.match("otherwise");if(a)if(c=e.peek("if")?.line===a.line,c){let l=dt(e);i=l?[l]:[]}else i=D(e);return e.hasMore()&&!c&&e.req("end"),{type:"ifCommand",condition:o,trueBranch:s,falseBranch:i,start:r,end:e.endPos(),run:l=>E(o.ev(l),m=>m?j(s,l):i&&j(i,l))}}}var jn={k:"return",value:null};function Dn(t){t.commands.halt=(e,n,r)=>{let o=!1;e.match("the")&&(e.req("event"),e.matchOp("'")&&e.req("s"),o=!0);let s=!!e.match("bubbling"),i=!s&&!!e.match("default");return{type:"haltCommand",keepExecuting:o,bubbling:s,haltDefault:i,start:r,end:e.endPos(),run:a=>{let u=a.event;if(u instanceof Event&&(i||u.stopPropagation(),s||u.preventDefault()),!o)return jn}}}}function Gn(t){t.commands.return=(e,n,r)=>{let o=e.commandBoundary(e.cur())?void 0:h(e);return{type:"returnCommand",value:o,start:r,end:e.endPos(),run:i=>E(o?o.ev(i):null,c=>(i.meta.returned=!0,i.meta.returnValue=c,{k:"return",value:c}))}},t.commands.exit=(e,n,r)=>({type:"exitCommand",start:r,end:e.endPos(),run:()=>jn})}function Hn(t){t.commands.throw=(e,n,r)=>{let o=h(e);return{type:"throwCommand",value:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{throw c})}}}function Bn(t){let e=te(t);if(!e)return;let n=[e];for(let r=te(t);r;r=te(t))n.push(r);return n}var _t=(t,e)=>(t??[]).map(n=>E(n.ev(e),r=>String(w(r,"className")))),$o=t=>t.split(";").map(e=>e.split(":")[0].trim()).filter(Boolean),jt=t=>t instanceof HTMLElement||t instanceof SVGElement?t.style:void 0,$n=(t,e,n,r,o)=>e?at(t,e,n,s=>x(s)&&r(s),s=>x(s)&&o(s)):O(t,s=>x(s)&&r(s)),Be=(t,{name:e,value:n},r)=>r?t.setAttribute(e,String(n)):t.removeAttribute(e),Un=(t,e,n,r,o,s)=>s?$n(e,n,r,i=>Be(i,s,t),i=>Be(i,s,!t)):N(o.map(i=>$n(e,n,r,c=>c.classList.toggle(String(i),t),c=>c.classList.toggle(String(i),!t))),()=>{});function Vn(t){let e=Bn(t),n=e?void 0:Y(t);return{refs:e,attribute:n,css:e||n?void 0:yn(t)}}function zn(t){t.commands.add=(e,n,r)=>{let{refs:o,attribute:s,css:i}=Vn(e),c;!o&&!s&&!i&&(c=e.withFollow(["to"],()=>h(e)),e.cur().value!=="to"&&e.err("Expected either a class reference or attribute expression"));let a=e.match("to")?h(e):U(e),u=e.match("when")?h(e):void 0,l=o||s?u:void 0,m=e.text(a);return{type:"addCommand",classRefs:o,attributeRef:s,css:i,value:c,to:a,when:l,start:r,end:e.endPos(),run:p=>N([a.ev(p),i?.ev(p),c?.ev(p),..._t(o,p)],([d,y,g,...v])=>{if(F(d,m),c){if(Array.isArray(d))d.push(g);else if(d instanceof Set)d.add(g);else throw d instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof d);P.wroteProperty(d)}else if(i)O(d,C=>{let S=jt(C);S&&(S.cssText+=y)});else return Un(!0,d,l,p,v,s)})}}}var Wo=t=>t instanceof Node||t instanceof NodeList||t instanceof HTMLCollection;function Qn(t){t.commands.remove=(e,n,r)=>{let{refs:o,attribute:s,css:i}=Vn(e),c=o||s||i?void 0:h(e),a=e.match("from")?h(e):c?void 0:U(e),u;e.match("when")&&(c&&e.err("'when' clause is not supported when removing elements"),u=h(e));let l=a?e.text(a):"",m=c?e.text(c):"",f=(d,y,g)=>{if(g==null&&c?.del&&c.lhs&&!Wo(y)){let v=c;return E(c.lhs(d),C=>v.del?.(d,C))}if(F(y,m),Array.isArray(g)){let v=g.indexOf(y);v>-1&&g.splice(v,1),P.wroteProperty(g)}else g instanceof Set||g instanceof Map?(g.delete(y),P.wroteProperty(g)):O(y,v=>{x(v)&&v.parentElement&&(g==null||g instanceof Node&&g.contains(v))&&v.parentElement.removeChild(v)})};return{type:"removeCommand",classRefs:o,attributeRef:s,css:i,element:c,from:a,when:u,start:r,end:e.endPos(),run:d=>N([a?.ev(d),i?.ev(d),c?.ev(d),..._t(o,d)],([y,g,v,...C])=>{if(c)return f(d,v,y);if(F(y,l),i){let S=$o(String(g));O(y,R=>S.forEach(I=>jt(R)?.removeProperty(I)))}else return Un(!1,y,u,d,C,s)})}}}var Wn=(t,e,n)=>(r,o,s)=>{s?o.style[t]=s:r==="toggle"?o.style[t]=getComputedStyle(o)[t]===e?n:e:o.style[t]=r==="hide"?e:n},Jn={display(t,e,n){if(!n&&e instanceof HTMLDialogElement){t==="hide"||t==="toggle"&&e.open?e.close():e.open||e.show();return}let r=V(e);n?e.style.display=n:t==="toggle"?Jn.display(getComputedStyle(e).display==="none"?"show":"hide",e):t==="hide"?(r.originalDisplay??=e.style.display,e.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?e.style.display=r.originalDisplay:e.style.removeProperty("display")},visibility:Wn("visibility","hidden","visible"),opacity:Wn("opacity","0","1"),hidden(t,e){(t==="toggle"?!e.hasAttribute("hidden"):t==="hide")?e.setAttribute("hidden",""):e.removeAttribute("hidden")}};function Dt(t,e){let n=e??Z.defaultHideShowStrategy??"display";return Z.hideShowStrategies[n]??Jn[n]??t.err("Unknown show/hide strategy : "+n)}function Kn(t){t.commands.toggle=(e,n,r)=>{e.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},s;if(e.cur().type==="STYLE_REF"){let y=o.styleProp=e.consume().value.slice(1);s=Dt(e,y),o.on=e.match("of")?e.withFollow(["with","between"],()=>h(e)):U(e)}else if(e.match("between")){let y=te(e);if(y)e.req("and"),o.between=[y,te(e)??e.err("Expected classRef")];else{let g=Y(e)??e.err("Expected either a class reference or attribute expression");e.req("and"),o.between=[g,Y(e)??e.err("Expected attributeRef")]}}else if(!(o.classRefs=Bn(e))&&!(o.attributeRef=Y(e))){let y=e.g.toggleElement;if(!y)o.target=e.withFollow(["between"],()=>ie(e));else{let g=e.withFollow(["between","as"],()=>$(e));if(!e.peek("between"))return y(e,g,r);o.target=Ot(e,g)}}if(!o.styleProp&&!o.target&&(o.on=e.match("on")?h(e):U(e)),e.match("between")){let y=o.betweenValues=e.withFollow(["and"],()=>{let g=[h(e)];for(;e.matchOp(",");)g.push(h(e));return g});e.req("and"),y.push(h(e))}o.target&&!o.betweenValues&&e.err("toggle <expression> requires 'between' with values"),e.peek("for")&&!e.peek("in",2)?(e.match("for"),o.time=h(e)):e.match("until")&&(o.until=ae(e),e.match("from")&&(o.from=h(e))),o.end=e.endPos();let{on:i,target:c,betweenValues:a,between:u,attributeRef:l,styleProp:m}=o,f=i?e.text(i):"",p=(y,g)=>y[(y.findIndex(v=>v==g)+1)%y.length],d=(y,g,v,C)=>{if(a&&c?.lhs&&c.put){let S=c;return N([c.ev(y),c.lhs(y)],([R,I])=>S.put?.(y,I,p(v,R)))}if(a&&m)return O(g,S=>{let R=jt(S);if(!R||!x(S))return;let I=R.getPropertyValue(m)||getComputedStyle(S).getPropertyValue(m);R.setProperty(m,String(p(v,I)))});F(g,f),O(g,S=>{if(x(S))if(s)S instanceof HTMLElement&&s("toggle",S);else if(u){let[R,I]=u;if(R.type==="classRef"&&I.type==="classRef"){let[A,M]=[String(R.className),String(I.className)],q=S.classList.contains(A);S.classList.toggle(A,!q),S.classList.toggle(M,q)}else if(R.type==="attributeRef"&&I.type==="attributeRef"){let A=S.getAttribute(R.name)===String(R.value);Be(S,A?R:I,!1),Be(S,A?I:R,!0)}}else l?Be(S,l,!S.hasAttribute(l.name)):C.forEach(R=>S.classList.toggle(String(R)))})};return o.run=y=>N([i?.ev(y),o.time?.ev(y),o.from?.ev(y),N((a??[]).map(g=>g.ev(y)),g=>g),..._t(o.classRefs,y)],([g,v,C,S,...R])=>{let I=()=>d(y,g,Array.isArray(S)?S:[],R);if(o.time)return new Promise(A=>{I(),setTimeout(()=>{I(),A()},T(v))});if(o.until){let A=o.until,M=C||y.me;return new Promise(q=>{Q(M)&&M.addEventListener(A,()=>{I(),q()},{once:!0}),I()})}return E(I(),()=>{})}),o}}function Zn(t){for(let e of["hide","show"])t.commands[e]=(n,r,o)=>{let s=n.cur(),i=s.value==="when"||s.value==="with"||n.commandBoundary(s)?U(n):h(n),c;n.match("with")&&(c=n.reqType("IDENTIFIER","STYLE_REF").value.replace(/^\*/,""));let a;e==="show"&&n.matchOp(":")&&(a=n.consumeUntil(void 0,"WHITESPACE").map(d=>d.value).join(""));let u=n.match("when")?h(n):void 0,l=Dt(n,c),m=n.text(i),f=d=>y=>{y instanceof HTMLElement&&l(d,y,d==="show"?a:void 0)};return{type:`${e}Command`,target:i,strategy:c,arg:a,when:u,start:o,end:n.endPos(),run:d=>E(i.ev(d),y=>{if(F(y,m),u)return at(y,u,d,f(e),f(e==="hide"?"show":"hide"));O(y,f(e))})}}}function er(t){t.commands.take=(e,n,r)=>{let o=[];for(let v=te(e);v;v=te(e))o.push(v);let s=o.length>0,i=s?void 0:Y(e)??e.err("Expected either a class reference or attribute expression"),c,a,u=v=>(o.length>1&&e.err(`\`${v}\` cannot be combined with multiple class refs`),te(e)??e.err("Expected classRef"));e.match("with")&&(s?c=u("with"):a=h(e));let l;e.match("from")&&(l=h(e),e.match("giving")&&((c||a)&&e.err("`giving` cannot be combined with `with`"),s?c=u("giving"):a=h(e)));let m=e.match("for")?h(e):U(e),f=e.text(m),p=l?e.text(l):"",d=c?.className,y=(v,C)=>O(v,S=>x(S)&&C(S));return{type:"takeCommand",classRefs:o,attributeRef:i,from:l,for:m,replacementClass:c,replacementValue:a,start:r,end:e.endPos(),run:v=>N([l?.ev(v),m.ev(v),a?.ev(v),...o.map(C=>C.ev(v))],([C,S,R,...I])=>{if(F(S,f),i){F(C,p),y(C,A=>R?A.setAttribute(i.name,String(R)):A.removeAttribute(i.name)),y(S,A=>A.setAttribute(i.name,i.value||""));return}o.forEach((A,M)=>{let q=String(A.className);y(l?C:I[M],b=>{b.classList.remove(q),d&&b.classList.add(d)}),y(S,b=>{b.classList.add(q),d&&b.classList.remove(d)})})})}}}var Bo="x y left top right bottom width height bounds scrollLeft scrollTop scrollLeftMax scrollTopMax scrollWidth scrollHeight scroll".split(" ");function tr(t){t.commands.measure=(e,n,r)=>{let o=U(e),s=[];if(!e.commandBoundary(e.cur())){let a=h(e);a.type==="symbol"&&a.name&&Bo.includes(a.name)?s.push(a.name):a.type==="possessive"&&a.prop&&a.root?(o=a.root,s.push(a.prop)):a.type==="ofExpression"&&a.name&&a.root?(o=a.root,s.push(a.name)):o=a}for(;e.matchOp(",");)s.push(e.reqType("IDENTIFIER").value);let i=e.text(o);return{type:"measureCommand",target:o,properties:s,start:r,end:e.endPos(),run:a=>E(o.ev(a),u=>{F(u,i);let l=x(u)?u:K(u)?Array.from(u).find(x):void 0;if(!l)throw new Error(`'${i}' is not an element`);let m=l.getBoundingClientRect(),f={top:l.scrollTop,left:l.scrollLeft,topMax:w(l,"scrollTopMax"),leftMax:w(l,"scrollLeftMax"),height:l.scrollHeight,width:l.scrollWidth},{x:p,y:d,left:y,top:g,right:v,bottom:C,width:S,height:R}=m,I={x:p,y:d,left:y,top:g,right:v,bottom:C,width:S,height:R,bounds:m,scrollLeft:f.left,scrollTop:f.top,scrollLeftMax:f.leftMax,scrollTopMax:f.topMax,scrollWidth:f.width,scrollHeight:f.height,scroll:f};a.result=I;for(let A of s){if(!(A in I))throw new Error("No such measurement as "+A);a.locals[A]=I[A]}})}}}function Ue(t,e,n){for(let r of e)t.commands[r]=(o,s,i)=>{let c=o.commandBoundary(o.cur())?void 0:h(o);return{type:`${e[0]}Command`,target:c,start:i,end:o.endPos(),run:u=>E(c?.ev(u),l=>E(n(l||u.me),()=>{}))}}}var pt=t=>e=>{let n=w(e,t);H(n)&&Reflect.apply(n,e,[])},Yn=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,nr=t=>t instanceof HTMLInputElement&&(t.type==="checkbox"||t.type==="radio"),Xn=(t,e)=>{if(Yn(t))e(t);else if(t instanceof HTMLFormElement)t.querySelectorAll("input, textarea, select").forEach(n=>Yn(n)&&e(n));else return!1;return!0},Uo=t=>{t instanceof HTMLSelectElement?t.selectedIndex=-1:nr(t)?t.checked=!1:t.value=""},Vo=t=>{if(t instanceof HTMLSelectElement)for(let e of t.options)e.selected=e.defaultSelected;else nr(t)?t.checked=t.defaultChecked:t.value=t.defaultValue},zo=t=>e=>O(e,n=>{n instanceof HTMLDialogElement?t?n.open||n.showModal():n.close():n instanceof HTMLDetailsElement?n.open=t:n instanceof HTMLElement&&n.hasAttribute("popover")?n[t?"showPopover":"hidePopover"]():pt(t?"open":"close")(n)});function rr(t){Ue(t,["focus"],pt("focus")),Ue(t,["blur"],pt("blur")),Ue(t,["select"],pt("select")),Ue(t,["empty","clear"],e=>{Array.isArray(e)||e instanceof Set||e instanceof Map?(Array.isArray(e)?e.splice(0):e.clear(),P.wroteProperty(e)):O(e,n=>Xn(n,Uo)||x(n)&&n.replaceChildren())}),Ue(t,["reset"],e=>O(e,n=>n instanceof HTMLFormElement?n.reset():Xn(n,Vo)))}function or(t){for(let e of[!0,!1]){let n=e?"open":"close";t.commands[n]=(r,o,s)=>{let i=!!r.match("fullscreen"),c=r.commandBoundary(r.cur())?void 0:h(r);return{type:`${n}Command`,target:c,start:s,end:r.endPos(),run:u=>E(c?.ev(u),l=>i?e?(x(l)?l:document.documentElement).requestFullscreen():document.exitFullscreen():zo(e)(l||u.me))}}}}function sr(t){t.commands.make=(e,n,r)=>{e.match("a")||e.match("an");let o=h(e),s=[],i=o.type==="queryRef"?o.css:void 0;if(i===void 0&&e.match("from"))do s.push(h(e));while(e.matchOp(","));let c=e.match("called")?Ft(e)??e.err("Expected symbol"):void 0,a=()=>{let l="div",m={classes:[]};for(let[,p,d]of(i??"").matchAll(/(^|#|\.)([^#. ]+)/g))p===""?l=d.trim():p==="#"?m.id=d.trim():m.classes.push(d.trim());let f=document.createElement(l);return m.id!==void 0&&(f.id=m.id),f.classList.add(...m.classes),f};return{type:"makeCommand",value:o,args:s,called:c,start:r,end:e.endPos(),run:l=>N([i===void 0?o.ev(l):void 0,...s.map(m=>m.ev(l))],([m,...f])=>{l.result=i===void 0?Reflect.construct(H(m)?m:Object,f):a(),c?.put?.(l,void 0,l.result)})}}}function ir(t){t.commands.append=(e,n,r)=>{let o=h(e),s=e.match("to")?je(h(e)):void 0;return{type:"appendCommand",value:o,target:s,start:r,end:e.endPos(),run:c=>N([s?s.ev(c):le("result",c),o.ev(c),s?.lhs?.(c)],([a,u,l])=>{if(Array.isArray(a)||a instanceof Set)Array.isArray(a)?a.push(u):a.add(u),P.wroteProperty(a);else if(x(a))x(u)?a.insertAdjacentElement("beforeend",u):a.insertAdjacentHTML("beforeend",String(u)),z.process(a);else{let m=T(a||"")+T(u);if(!s)st("result",c,void 0,m);else if(s.put)s.put(c,l,m);else throw new Error("Unable to append a value!")}})}}}function ar(t){t.commands.swap=(e,n,r)=>{let o=e.withFollow(["with"],()=>ie(e));e.req("with");let s=ie(e);return{type:"swapCommand",first:o,second:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s.ev(c),o.lhs?.(c),s.lhs?.(c)],([a,u,l,m])=>{if(x(a)&&x(u)){let f=document.createComment("");a.replaceWith(f),u.replaceWith(a),f.replaceWith(u)}else o.put?.(c,l,u),s.put?.(c,m,a)})}}}function cr(t){t.commands.send=t.commands.trigger=(e,n,r)=>{let o=ae(e),s=lt(e),i=e.match(n==="trigger"?"on":"to")?h(e):U(e),c=e.text(i);return{type:"sendCommand",event:o,details:s,to:i,start:r,end:e.endPos(),run:u=>N([i.ev(u),s?.ev(u)],([l,m])=>{F(l,c),O(l,f=>_(f,o,W(m)?m:{},u.me))})}}}function ur(t){t.commands.wait=(e,n,r)=>{let o={type:"waitCommand",start:r,end:r,run:()=>{}};if(e.match("for")){e.match("a");let s=o.events=[];do{let a=e.cur();a.type==="NUMBER"||a.op&&a.value==="("?s.push(h(e)):s.push({event:ae(e),args:mt(e)})}while(e.match("or"));let i=o.from=e.match("from")?h(e):void 0,c=i?e.text(i):"me";o.run=a=>E(i?i.ev(a):a.me,u=>{if(!Q(u))throw new Error("Not a valid event target: "+c);return new Promise(l=>{for(let m of s)"event"in m?u.addEventListener(m.event,f=>{a.result=f;for(let p of m.args)a.locals[p]=w(f,p)||w(w(f,"detail"),p)||null;l()},{once:!0}):E(m.ev(a),f=>setTimeout(()=>{a.result=f,l()},T(f)))})})}else{let s;e.match("a")?e.req("tick"):s=o.time=h(e),o.run=i=>E(s?.ev(i),c=>new Promise(a=>setTimeout(a,s?T(c):0)))}return o.end=e.endPos(),o}}function lr(t){let e=t.pos(),n=t.cur(),r=[],o="",s=!1;for(;t.hasMore();){n=t.consume();let i=t.tok(0,!0);if(i.type==="IDENTIFIER"&&i.value==="end")break;s?n.type==="IDENTIFIER"||n.type==="NUMBER"?o+=n.value:(o&&r.push(o),o="",s=!1):n.type==="IDENTIFIER"&&n.value==="function"&&(s=!0)}return{source:t.src.substring(e,n.end+1),functions:r}}function dr(t){t.commands.js=(e,n,r)=>{let o=[];if(e.matchOp("(")&&!e.matchOp(")")){do o.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let{source:s}=lr(e);e.match("end");let i=new Function(...o,s);return{type:"jsCommand",source:s,inputs:o,start:r,end:e.endPos(),run:a=>E(Reflect.apply(i,globalThis,o.map(u=>le(u,a))),u=>{a.result=u})}},t.features.js=(e,n)=>{let{source:r,functions:o}=lr(e),s=new Function(`${r}
18
- return { ${o.map(c=>`${c}:${c}`).join(",")} } `);return{type:"jsFeature",source:r,functions:o,start:n,end:e.endPos(),install:()=>void Object.assign(globalThis,s())}}}function fr(t){for(;;){let e=t();if(J(e))return e.then(n=>n??fr(t));if(e)return e}}var Qo=t=>{if(t){if(W(t)&&Symbol.asyncIterator in Object(t)){let e=Reflect.get(Object(t),Symbol.asyncIterator);return typeof e=="function"?Reflect.apply(e,t,[]):void 0}return(K(t)?t:Object.keys(Object(t)))[Symbol.iterator]()}};function mr(t){t.commands.repeat=t.commands.for=(e,n,r)=>{let o={type:"repeatCommand",until:!1,bottomTested:!1,forever:!1,body:[],start:r,end:r,run:()=>{}};if(n==="for"||e.match("for")){let v=o.identifier=e.reqType("IDENTIFIER").value;e.req("in"),o.expression=h(e);for(let C=o.expression;C;C=C.root)C.type==="collectionExpression"&&(C.varName=v)}else e.match("in")?(o.identifier="it",o.expression=h(e)):e.match("while")?o.condition=h(e):e.match("until")?(o.until=!0,e.match("event")?(o.event=ae(e),e.match("from")&&(o.from=h(e))):o.condition=h(e)):!e.commandBoundary(e.cur())&&e.cur().value!=="forever"?(o.times=h(e),e.req("times")):(e.match("forever"),o.forever=!0);e.match("index")?o.indexIdentifier=e.reqType("IDENTIFIER").value:e.match("indexed")&&(e.req("by"),o.indexIdentifier=e.reqType("IDENTIFIER").value);let s=o.body=D(e);if(o.forever&&e.hasMore()){let v=e.match("until")??e.match("while");v&&(o.forever=!1,o.bottomTested=!0,o.until=v.value==="until",o.condition=h(e))}e.match("else")&&(o.elseBranch=D(e)),e.hasMore()&&e.req("end"),o.end=e.endPos();let{identifier:i,indexIdentifier:c,expression:a,times:u,condition:l,until:m,bottomTested:f,forever:p,event:d,from:y,elseBranch:g}=o;return o.run=v=>N([a?.ev(v),y?.ev(v)],([C,S])=>{let R=Qo(C)??(g?[][Symbol.iterator]():void 0),I=0,A=!1,M=!1;if(d){let L=S||v.me;Q(L)&&L.addEventListener(d,()=>M=!0,{once:!0})}let q=()=>!A&&g?E(j(g,v),L=>({signal:re(L)})):{signal:void 0},b=L=>{let G=I++;A=!0,C&&i?v.result=v.locals[i]=L:v.result=G,c&&(v.locals[c]=G);let X=v.meta.template;if(X&&C){let pe=`${i}_${r}`;X.loops[pe]??={identifier:i,indexIdentifier:c,source:C},X.out.push(`<!--hs-scope:${pe}:${G}-->`)}return E(j(s,v),pe=>{let en=w(pe,"k");if(en==="break")return{signal:void 0};if(en==="return")return{signal:re(pe)};if(d)return new Promise(lo=>setTimeout(lo,0))})};return E(fr(()=>N([l?.ev(v),u?.ev(v)],([L,G])=>f&&I===0||p?b(void 0):m?(d?!M:L!==!0)?b(void 0):q():l?L?b(void 0):q():G?I<T(G)?b(void 0):q():R?E(R.next(),X=>w(X,"done")?q():b(w(X,"value"))):q())),L=>re(w(L,"signal")))}),o}}function pr(t){for(let e of["break","continue"]){let n={k:e};t.commands[e]=(r,o,s)=>({type:`${e}Command`,start:s,end:r.endPos(),run:()=>n})}}function hr(t){t.commands.tell=(e,n,r)=>{let o=h(e),s=D(e);e.hasMore()&&!e.featureStart(e.cur())&&e.req("end");let i=(a,u,l)=>{for(;l<u.length;l++){a.you=u[l];let m=j(s,a);if(J(m))return m.then(f=>re(f)??i(a,u,l+1));if(m)return m}};return{type:"tellCommand",value:o,body:s,start:r,end:e.endPos(),run:a=>E(o.ev(a),u=>{let l=u==null?[]:Array.isArray(u)?u:u instanceof NodeList?Array.from(u):[u],m=a.you;return E(i(a,l,0),f=>(a.you=m,re(f)))})}}}function Ht(t,e){let n;if(typeof e=="string"){let u=document.createElement("template");u.innerHTML=e,n=u.content}else if(e instanceof DocumentFragment)n=e;else if(e instanceof Element)n=document.createDocumentFragment(),n.append(e.cloneNode(!0));else throw new Error("morph requires an HTML string, element, or document fragment");let r=n.firstElementChild;r&&!r.nextElementSibling&&r.tagName===t.tagName&&(br(t,r),n=r);let o=[...t.matches("[id]")?[t]:[],...t.querySelectorAll("[id]")],s=[...n.querySelectorAll("[id]")],i=Yo(o,s),c=new Map;wr(c,i,t.parentElement,o),wr(c,i,n,s);let a=document.createElement("div");a.hidden=!0,(document.body??t.parentElement)?.after(a),vr({target:t,ids:c,persistent:i,pantry:a,futureMatches:new WeakSet},t,n),xe(a),a.remove()}function vr(t,e,n){e instanceof HTMLTemplateElement&&n instanceof HTMLTemplateElement&&(e=e.content,n=n.content);let r=e.firstChild,o=n.firstChild;for(;o;){let s=o,i=r&&Jo(t,s,r);if(i&&i!==r)for(let c=r;c&&c!==i;){let a=c;c=c.nextSibling,a instanceof Element&&(t.ids.has(a)||Er(t,a,s))?Gt(e,a,null):gr(t,a)}if(!i&&s instanceof Element&&t.persistent.has(s.id)){let c=`[id="${CSS.escape(s.id)}"]`,a=t.target.id===s.id?t.target:t.target.querySelector(c)??t.pantry.querySelector(c);if(a){for(let u=a.parentNode;u;u=u.parentNode){let l=t.ids.get(u);l?.delete(a.id),l?.size===0&&t.ids.delete(u)}Gt(e,a,r),i=a}}if(o=s.nextSibling,i&&s instanceof Element)yr(t,i,s),r=i.nextSibling;else if(s instanceof Element&&t.ids.has(s)){let c=document.createElement(s.tagName);e.insertBefore(c,r),yr(t,c,s),r=c.nextSibling}else e.insertBefore(s,r),s instanceof Element&&fe(s),r=s.nextSibling}for(;r;){let s=r;r=r.nextSibling,gr(t,s)}}function yr(t,e,n){e instanceof Element&&(br(e,n),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.defaultValue!==n.defaultValue&&(e.value=n.value),(!e.isEqualNode(n)||n.tagName==="TEMPLATE"||n.querySelector("template"))&&vr(t,e,n),fe(e))}function Jo(t,e,n){if(!(e instanceof Element))return null;let r=t.ids.get(e),o=r?.size??0;if(e.id&&!r)return null;let s=null,i=0,c=10;for(let a=n;a;a=a.nextSibling){let u=t.ids.get(a);if(Ko(a,e)){if(u&&r&&[...u].some(l=>r.has(l)))return a;if(!u){if(c>0&&a.isEqualNode(e))return a;s??=a}}if(i+=u?.size??0,i>o||a.contains(document.activeElement)||--c<1&&o===0)break}return s&&Er(t,s,e)?null:s}function Er(t,e,n){if(t.futureMatches.has(e))return!0;let r=n.nextSibling;for(let o=0;r&&o<10;r=r.nextSibling,o++)if(r instanceof Element&&e.isEqualNode(r))return t.futureMatches.add(e),!0;return!1}function gr(t,e){t.ids.has(e)?Gt(t.pantry,e,null):(e instanceof Element&&xe(e),e.remove())}function Gt(t,e,n){let r=w(t,"moveBefore");if(H(r))try{Reflect.apply(r,t,[e,n]);return}catch{}t.insertBefore(e,n)}function br(t,e){for(let{name:n,value:r}of e.attributes)t.getAttribute(n)!==r&&(t.setAttribute(n,r),n==="value"&&t instanceof HTMLInputElement&&t.type!=="file"&&(t.value=r));for(let{name:n}of[...t.attributes])e.hasAttribute(n)||t.removeAttribute(n)}function Ko(t,e){return!(t instanceof Element)||t.tagName!==e.tagName||t.tagName==="SCRIPT"&&!t.isEqualNode(e)?!1:!t.id||t.id===e.id}function Yo(t,e){let n=new Set,r=new Map;for(let{id:s,tagName:i}of t)r.has(s)?n.add(s):s&&r.set(s,i);let o=new Set;for(let{id:s,tagName:i}of e)o.has(s)?n.add(s):r.get(s)===i&&o.add(s);for(let s of n)o.delete(s);return o}function wr(t,e,n,r){for(let o of r)if(e.has(o.id))for(let s=o;s&&s!==n;s=s.parentElement){let i=t.get(s);i||t.set(s,i=new Set),i.add(o.id)}}function xr(t){t.commands.morph=(e,n,r)=>{let o=h(e);e.req("to");let s=h(e);return{type:"morphCommand",target:o,content:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s.ev(c)],([a,u])=>{O(a,l=>{l instanceof Element&&Ht(l,u)})})}}}function kr(t){t.commands.log=(e,n,r)=>{let o=[h(e)];for(;e.matchOp(",");)o.push(h(e));let s=e.match("with")?h(e):void 0;return{type:"logCommand",values:o,logger:s,start:r,end:e.endPos(),run:c=>N([s?.ev(c),...o.map(a=>a.ev(c))],([a,...u])=>{H(a)?a(...u):console.log(...u)})}}}function Nr(t){t.commands.get=t.commands.call=(e,n,r)=>{let o=h(e);return n==="call"&&o.type!=="functionCall"&&e.err("Must be a function invocation"),{type:"getCommand",value:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{i.result=c})}}}function Tr(t){t.pseudo=(e,n)=>{let r=e.tok(1);if(!(r.op&&(r.value==="."||r.value==="(")))return;let o=ut(e);o.type!=="functionCall"&&e.err("Pseudo-commands must be function calls");let s=o.root,i="args"in o&&Array.isArray(o.args)?o.args:[],c;s&&!s.root&&(e.matchAny("the","to","on","with","into","from","at")?c=h(e):e.match("me")&&(c=U(e)));let a=s?.name??"",u=c?e.text(c):"",l=e.text(o),m=c;return{type:"pseudoCommand",value:o,target:c,start:n,end:e.endPos(),run:p=>m?N([m.ev(p),...i.map(d=>d.ev(p))],([d,...y])=>{F(d,u),p.result=ct(w(d,a),d,y,p,l),Ye(d,a)}):E(o.ev(p),d=>{p.result=d})}}}function Cr(t){t.commands.ask=(e,n,r)=>{let o=h(e);return{type:"askCommand",message:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{i.result=prompt(String(c))})}},t.commands.answer=(e,n,r)=>{let o=h(e),s;if(e.match("with")){let c=e.withFollow(["or"],()=>h(e));e.req("or"),s=[c,h(e)]}return{type:"answerCommand",message:o,choices:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s?.[0].ev(c),s?.[1].ev(c)],([a,u,l])=>{s?c.result=confirm(String(a))?u:l:alert(String(a))})}}}function Sr(t){t.commands.breakpoint=(e,n,r)=>({type:"breakpointCommand",start:r,end:e.endPos(),run:()=>{debugger}})}var $t=(t,e,n)=>{let r=w(t,"slice");return H(r)?Reflect.apply(r,t,[e,n]):void 0},Xo=(t,e,n)=>({*[Symbol.iterator](){let r=new RegExp(t instanceof RegExp?t:String(t),e);for(let o=r.exec(n);o;o=r.exec(n))o[0].length===0&&r.lastIndex++,yield o}});function Pr(t){t.commands.pick=(e,n,r)=>{e.match("the");let o=e.matchAny("first","last","random","match","matches")??e.matchAny("item","items","character","characters");if(!o)return;let s=o.value==="first"||o.value==="last"||o.value==="random"||o.value==="match"||o.value==="matches"?o.value:"range",i={};(s==="match"||s==="matches")&&e.match("of"),e.withFollow(["of","from"],()=>{if(s==="first"||s==="last")i.count=h(e);else if(s==="random")e.cur().type==="NUMBER"&&(i.count=h(e));else if(s==="range")e.match("at")||e.match("from"),e.match("start")||(i.from=h(e)),(e.match("to")||e.matchOp(".."))&&(e.match("end")?i.toEnd=!0:i.to=h(e)),e.match("inclusive")?i.bounds="inclusive":e.match("exclusive")&&(i.bounds="exclusive");else{i.re=h(e);let g=e.matchOp("|")?e.reqType("IDENTIFIER").value:void 0;i.flags=s==="match"?g??"":g===void 0?"gu":"g"+g.replace("g","")}}),e.matchAny("of","from")||e.expected("of","from");let c=h(e),{count:a,from:u,to:l,toEnd:m,bounds:f,re:p,flags:d=""}=i;return{type:"pickCommand",variant:s,root:c,...i,start:r,end:e.endPos(),run:g=>N([c.ev(g),a?.ev(g),u?.ev(g),l?.ev(g),p?.ev(g)],([v,C,S,R,I])=>{if(v==null)g.result=v;else if(s==="first")g.result=$t(v,0,T(C));else if(s==="last")g.result=$t(v,-T(C));else if(s==="random"){let A=K(v)?Array.from(v):[],M=()=>A.splice(Math.floor(Math.random()*A.length),1)[0];g.result=C==null?M():Array.from({length:Math.min(T(C),A.length)},M)}else if(s==="range"){let A=T(S??0)+(f==="exclusive"?1:0),M=m?T(w(v,"length")):R==null?void 0:T(R),q=M===void 0?A+1:M+(f==="inclusive"?1:0);g.result=$t(v,A,q)}else s==="match"?g.result=new RegExp(I instanceof RegExp?I:String(I),d).exec(String(v)):g.result=Xo(I,d,String(v))})}}}var Zo={json:"json",JSON:"json",Object:"json",response:"response",Response:"response",html:"html",HTML:"html",text:"text",Text:"text",String:"text"};function Rr(t){t.commands.fetch=(e,n,r)=>{let o=e.withFollow(["as"],()=>Lt(e)),s=()=>{if(!e.match("as"))return;e.match("a")||e.match("an");let m=Se(e)??e.err("Expected dotOrColonPath");return Zo[m]??":"+m},i=s(),c;e.match("with")&&e.cur().value!=="{"?c=He(e):e.cur().op&&e.cur().value==="{"&&(c=Ge(e)),i??=s()??"text";let a=!1;e.match("do")?(e.req("not"),e.req("throw"),a=!0):e.cur().value==="don"&&e.tok(1,!0).value==="'"&&e.tok(2,!0).value==="t"&&(e.consume(),e.consume(),e.consume(),e.req("throw"),a=!0);let u=i;return{type:"fetchCommand",url:o,options:c,as:u,dontThrow:a,start:r,end:e.endPos(),run:m=>N([o.ev(m),c?.ev(m)],([f,p])=>{let d=m.me,y=W(p)?p:{};y.headers||={},y.conversion=u.startsWith(":")?u.slice(1):u;let g=new AbortController,v=()=>g.abort();Q(d)&&d.addEventListener("fetch:abort",v,{once:!0}),y.signal=g.signal,_(d,"hyperscript:beforeFetch",y,d),_(d,"fetch:beforeRequest",y,d);let C=!1;y.timeout&&setTimeout(()=>C||v(),T(y.timeout));let S=I=>{m.result=I,_(d,"fetch:afterRequest",{result:I}),C=!0},R=Reflect.apply(fetch,globalThis,[f,y]);return Promise.resolve(R).then(I=>{let A={response:I};_(d,"fetch:afterResponse",A);let M=A.response;if(!(M instanceof Response))throw new Error("fetch did not return a Response");if(!a&&u!=="response"&&Z.fetchThrowsOn.some(k=>k.test(String(M.status))))throw Object.assign(new Error(`fetch failed: ${M.status} ${M.statusText} (${f})`),{response:M,status:M.status});if(u==="response")return S(M);if(u==="json")return M.json().then(S);let q=u.startsWith(":")?u.slice(1):void 0,b=q?ge[q]:void 0;return b&&w(b,"_rawResponse")?S(b(M)):M.text().then(k=>S(u==="html"?ve(k):q?ot(k,q):k))}).catch(I=>{throw _(d,"fetch:error",{reason:I}),I}).finally(()=>Q(d)&&d.removeEventListener("fetch:abort",v))})}}}var es={top:"start",middle:"center",bottom:"end"},ts={left:"start",center:"center",right:"end"},Ir=t=>{let e=t.matchAny("smoothly","instantly");return e?e.value==="smoothly"?"smooth":"instant":void 0};function Or(t){t.match("the");let e=t.matchAny("top","middle","bottom"),n=t.matchAny("left","center","right");(e||n)&&t.req("of");let r=$(t),o=t.matchAnyOp("+","-"),s=o?t.withFollow(["px"],()=>h(t)):void 0;t.match("px");let i=t.match("in")?$(t):void 0,c={block:e?es[e.value]:"start",inline:n?ts[n.value]:"nearest"},a=Ir(t);return a&&(c.behavior=a),{target:r,offset:s,sign:o?.value==="-"?-1:o?1:0,options:c,container:i}}function Ar(t,e){return N([t.target.ev(e),t.offset?.ev(e),t.container?.ev(e)],([n,r,o])=>{let s=t.sign*T(r??0);O(n,i=>{let c=i===window?document.body:i;c instanceof HTMLElement&&(o instanceof HTMLElement?o.scrollTo({top:c.offsetTop-o.offsetTop+s,left:c.offsetLeft-o.offsetLeft,behavior:t.options.behavior??"auto"}):(t.sign?ns(c,s,t.options):c).scrollIntoView(t.options))})})}function ns(t,e,n){let r=t.getBoundingClientRect(),o=i=>i==="start"||i==="end"?e:0,s=document.createElement("div");return Object.assign(s.style,{position:"absolute",top:r.top+window.scrollY+o(n.block)+"px",left:r.left+window.scrollX+o(n.inline)+"px",height:r.height+"px",width:r.width+"px",zIndex:String(Number.MIN_SAFE_INTEGER),opacity:"0"}),document.body.appendChild(s),setTimeout(()=>s.remove(),100),s}function Lr(t){t.commands.scroll=(e,n,r)=>{let o={type:"scrollCommand",start:r,end:r,run:()=>{}};if(e.match("to")){let s=o.to=Or(e);o.run=i=>Ar(s,i)}else{let s=["up","down","left","right"],i=e.matchAny(...s),c;!i&&e.cur().value!=="by"&&(c=o.target=$(e),i=e.matchAny(...s)),e.req("by");let a=o.by=e.withFollow(["px"],()=>h(e));e.match("px");let u=o.behavior=Ir(e),l=o.direction=i?.value??"down";o.run=m=>N([c?.ev(m),a.ev(m)],([f,p])=>{let d=T(p)*(l==="up"||l==="left"?-1:1),y=l==="left"||l==="right",g={top:y?0:d,left:y?d:0};u&&(g.behavior=u),(x(f)?f:document.documentElement).scrollBy(g)})}return o.end=e.endPos(),o}}function Fr(t){t.commands.go=(e,n,r)=>{let o={type:"goCommand",back:!1,newWindow:!1,start:r,end:r,run:()=>{}},s=()=>e.match("in")?(e.req("new"),e.req("window"),!0):!1,i=c=>{if(c==null)return;if(x(c))return c.scrollIntoView({block:"start",inline:"nearest"});let a=String(c);a.startsWith("#")?window.location.hash=a:o.newWindow?window.open(a):window.location.href=a};if(e.match("back"))o.back=!0,o.run=()=>window.history.back();else if(e.match("to"),e.match("url")){let c=$e(e);o.newWindow=s(),o.run=()=>i(c)}else if(["the","top","middle","bottom","left","center","right"].includes(e.cur().value)){let c=o.scroll=Or(e);o.run=a=>Ar(c,a)}else{let c=o.target=Lt(e);o.newWindow=s(),o.run=a=>E(c.ev(a),i)}return o.end=e.endPos(),o}}function qr(t){t.commands.set=(e,n,r)=>Wt(e,r)}function Wt(t,e){{if(t.cur().op&&t.cur().value==="{"){let s=Ge(t);t.req("on");let i=h(t);return{type:"setCommand",target:i,object:s,start:e,end:t.endPos(),run:a=>N([s.ev(a),i.ev(a)],([u,l])=>void Object.assign(Object(l),u))}}let n=t.withFollow(["to"],()=>ie(t));t.req("to");let r=h(t);return{type:"setCommand",target:n,value:r,start:e,end:t.endPos(),run:s=>N([n.lhs?.(s),r.ev(s)],([i,c])=>n.put?.(s,i,c))}}}function _r(t){t.commands.default=(e,n,r)=>{let o=e.withFollow(["to"],()=>ie(e));e.req("to");let s=h(e);return{type:"defaultCommand",target:o,value:s,start:r,end:e.endPos(),run:c=>E(o.ev(c),a=>{if(!(a!=null&&a!==""))return N([o.lhs?.(c),s.ev(c)],([u,l])=>o.put?.(c,u,l))})}}}function jr(t){for(let e of["increment","decrement"]){let n=e==="increment"?1:-1;t.commands[e]=(r,o,s)=>{let i=r.withFollow(n<0?["by"]:[],()=>ie(r)),c=r.match("by")?h(r):void 0;return{type:`${e}Command`,target:i,amount:c,start:s,end:r.endPos(),run:u=>N([i.ev(u),c?.ev(u),i.lhs?.(u)],([l,m,f])=>{let p=(l?parseFloat(String(l)):0)+n*(c?parseFloat(String(m)):1);u.result=p,i.put?.(u,f,p)})}}}}function Mr(t,e){t.replaceChildren(ve(e)),z.process(t)}var rs=["arrayIndex","propertyAccess","possessive","ofExpression","attributeRef","styleRef","attributeRefAccess"],os={into:"into",before:"before",after:"after",start:"start",end:"end"},ss={before:"before",after:"after",start:"prepend",end:"append"};function Dr(t){t.commands.put=(e,n,r)=>{let o=h(e),s=e.matchAny("into","before","after");!s&&e.match("at")&&(e.match("the"),s=e.matchAny("start","end"),e.req("of"));let i=os[(s??e.expected("into","before","at start of","at end of","after")).value],c=je(h(e)),a=e.text(c),u=(f,p)=>c.type==="symbol"?E(c.ev(f),d=>{x(d)||d instanceof Document?Mr(d,p):c.put?.(f,void 0,p)}):rs.includes(c.type)?E(c.lhs?.(f),d=>c.put?.(f,d,p)):E(c.ev(f),d=>{F(d,a),O(d,y=>{(x(y)||y instanceof Document)&&Mr(y,p)})}),l=(f,p,d)=>E(c.ev(f),y=>{if(F(y,a),Array.isArray(y)){d==="prepend"?y.unshift(p):y.push(p),P.wroteProperty(y);return}O(y,g=>{x(g)&&(g[d](p instanceof Node?p:ve(p)),z.process(g.parentElement??g))})});return{type:"putCommand",value:o,operation:i,target:c,start:r,end:e.endPos(),run:f=>E(o.ev(f),p=>i==="into"?u(f,p):l(f,p,ss[i]))}}}var Ie=t=>K(t)?Array.from(t):Array.from(Object(t)),Gr=t=>Array.isArray(t)||t instanceof NodeList?Ie(t).map(Gr).join(""):t instanceof HTMLElement?t.outerHTML:t instanceof Node?"":String(t);function is(t){let e={},n=r=>{let o=w(r,"name"),s=w(r,"value"),i=w(r,"type");if(typeof o!="string"||s==null||i==="radio"&&!w(r,"checked")||(i==="checkbox"?s=w(r,"checked")?[s]:void 0:r instanceof HTMLSelectElement&&r.multiple&&(s=Array.from(r.selectedOptions,a=>a.value)),s===void 0))return;let c=e[o];e[o]=c===void 0?s:(Array.isArray(c)?c:[c]).concat(s)};return O(t,r=>{w(r,"name")!=null&&w(r,"value")!=null?n(r):r instanceof Element&&r.querySelectorAll("input,select,textarea").forEach(n)}),e}function Hr(t){Object.assign(ge,{Boolean:e=>!!e,Date:e=>typeof e=="number"||e instanceof Date?new Date(e):new Date(String(e)),Array:Ie,JSON:e=>e instanceof Response?e.json():JSON.parse(String(e)),JSONString:e=>JSON.stringify(e),Object:e=>typeof e=="string"||e instanceof String?JSON.parse(String(e)):{...Object(e)},FormEncoded:e=>new URLSearchParams(Object(e)).toString(),Set:e=>new Set(Ie(e)),Map:e=>new Map(Object.entries(Object(e))),Keys:e=>e instanceof Map?Array.from(e.keys()):Object.keys(Object(e)),Entries:e=>e instanceof Map?Array.from(e.entries()):Object.entries(Object(e)),Reversed:e=>Ie(e).reverse(),Unique:e=>[...new Set(Ie(e))],Flat:e=>Ie(e).flat(),HTML:Gr}),Me.push((e,n)=>{if(e==="Fixed"||e.startsWith("Fixed:"))return Number(n).toFixed(parseInt(e.split(":")[1])||0)},(e,n)=>e==="Values"?is(n):void 0)}var $r="=;expires=Thu, 01 Jan 1970 00:00:00 GMT",Ve=()=>document.cookie?document.cookie.split("; ").map(t=>{let e=t.indexOf("=");return{name:t.slice(0,e),value:decodeURIComponent(t.slice(e+1))}}):[],as=new Proxy({},{get(t,e){if(e===Symbol.iterator){let n=Ve();return n[Symbol.iterator].bind(n)}if(!(typeof e!="string"||e==="then"))return e==="length"?Ve().length:e==="clear"?n=>void(document.cookie=n+$r):e==="clearAll"?()=>Ve().forEach(n=>document.cookie=n.name+$r):e!==""&&!Number.isNaN(Number(e))?Ve()[parseInt(e)]:Ve().find(n=>n.name===e)?.value},set(t,e,n){let r=[];if(typeof n=="string")r.push(encodeURIComponent(n),"samesite=lax");else{r.push(encodeURIComponent(String(w(n,"value"))));let o=(s,i)=>{let c=w(n,s);c&&r.push(`${i}=${c}`)};o("expires","expires"),o("maxAge","max-age"),o("partitioned","partitioned"),o("path","path"),o("samesite","samesite"),w(n,"secure")&&r.push("secure")}return document.cookie=String(e)+"="+r.join(";"),!0}});function Wr(t){xt.cookies=as}var Bt=t=>K(t)?Array.from(t):[];function cs(t){let e=t.pos(),n=t.matchAny("first","last","random");if(!n)return;t.matchAny("in","from","of");let r=$(t),o=n.value;return{type:"positionalExpression",operator:o,root:r,start:e,end:t.endPos(),ev:i=>E(r.ev(i),c=>{if(!c)return;let a=Array.isArray(c)?c:Bt(w(c,"children")??c),u=o==="first"?0:o==="last"?a.length-1:Math.floor(Math.random()*a.length);return a[u]})}}function us(t){let e=t.pos(),n=t.matchAny("next","previous");if(!n)return;let r=n.value==="next",o=At(t)??t.err("Expected leaf"),s=t.match("from")?t.withFollow(["in"],()=>$(t)):U(t),i=t.match("in")?$(t):void 0,c=!i&&t.match("within")?$(t):void 0,a=!!t.match("with");a&&t.req("wrapping");let u=t.text(o),l=(p,d,y)=>{let g=d instanceof Element||d instanceof Document?d:document.body,v=Array.from(g.querySelectorAll(y));if(!(p instanceof Node))return;let C=r?Node.DOCUMENT_POSITION_PRECEDING:Node.DOCUMENT_POSITION_FOLLOWING,S=r?v:v.reverse();return S.find(R=>R.compareDocumentPosition(p)===C)??(a?S[0]:void 0)},m=(p,d,y)=>{let g=Bt(d).filter(R=>R===p||x(R)&&R.matches(y)),v=r?g:g.reverse(),C=v[v.indexOf(p)+1];if(v.includes(p)&&C!==void 0)return C;let S=v[0];return a&&x(S)&&S.matches(y)?S:void 0};return{type:"relativePositionalExpression",operator:n.value,thing:o,from:s,inElt:i,withinElt:c,wrapping:a,start:e,end:t.endPos(),ev:p=>N([o.ev(p),s.ev(p),i?.ev(p),c?.ev(p)],([d,y,g,v])=>{let C=w(d,"css");if(typeof C!="string")throw new Error("Expected a CSS value to be returned by "+u);return i?g&&m(y,g,C):l(y,v,C)})}}function ls(t){let e=t.pos();if(!t.match("closest"))return;let n=!!t.match("parent"),r=t.cur().type==="ATTRIBUTE_REF"?Y(t):void 0,o=r?`[${r.name}]`:$(t).css??t.err("Expected a CSS expression"),s=t.match("to")?h(t):U(t),i={type:"closestExpr",css:o,parentSearch:n,to:s,start:e,end:t.endPos(),ev:c=>E(s.ev(c),a=>{if(a==null)return null;let u=[];return O(a,l=>{let m=n?w(l,"parentElement"):l;u.push(x(m)?m.closest(o):null)}),Ne(a)?u:u[0]}),lhs:c=>i.ev(c),put:(c,a,u)=>{a&&Ee(a,u)}};return r?Mt(t,i,r):i}var Br=["where","sorted","mapped","split","joined"];function ds(t,e){let n=t.matchAny(...Br);if(!n)return;let r=n.value;r==="mapped"?t.req("to"):r!=="where"&&t.req("by");let o=t.withFollow(Br,()=>h(t)),s=r==="sorted"&&!!t.match("descending"),i=(u,l)=>{let m=l.map(f=>(u.beingTested=f,a.varName&&(u.locals[a.varName]=f),o.ev(u)));return u.beingTested=null,m},c=(u,l)=>{if(!l)return l;if(r==="split")return E(o.ev(u),d=>String(l).split(String(d)));let m=Bt(l);if(r==="joined")return E(o.ev(u),d=>m.join(String(d)));let f=i(u,m);if(r==="where")return m.filter((d,y)=>f[y]);if(r==="mapped")return f;let p=s?-1:1;return m.map((d,y)=>y).sort((d,y)=>f[d]==f[y]?0:(T(f[d])<T(f[y])?-1:1)*p).map(d=>m[d])},a={type:"collectionExpression",operator:r==="where"||r==="sorted"||r==="mapped"||r==="split"?r:"joined",root:e,operand:o,descending:s,start:e.start,end:t.endPos(),ev:u=>E(e.ev(u),l=>c(u,l))};return a}function fs(t){let e=t.pos();if(!t.matchOp("\\"))return;let n=[],r=t.matchType("IDENTIFIER");if(r)for(n.push(r.value);t.matchOp(",");)n.push(t.reqType("IDENTIFIER").value);t.reqOp("-"),t.reqOp(">");let o=h(t);return{type:"blockLiteral",params:n,expr:o,start:e,end:t.endPos(),ev:i=>(...c)=>(n.forEach((a,u)=>i.locals[a]=c[u]),o.ev(i))}}function ms(t){let e=t.pos();if(t.match("some"))return Ce(t,"some",e,h(t),n=>!_e(n),!1)}function ps(t,e){if(!t.matchOp(":"))return;let n=t.reqType("IDENTIFIER").value,r=!t.matchOp("!");return{type:"typeCheckExpression",root:e,suffix:n,start:e.start,end:t.endPos(),ev:s=>E(e.ev(s),i=>{if(rt(i,n,r))return i;throw new Error("Typecheck failed! Expected: "+n)})}}function Ur(t,e,n,r){if(_(t.me,"hyperscript:beep",{element:t.me,expression:e,value:r})){let o=r==null?"object (null)":w(w(r,"constructor"),"name")??"unknown",s=typeof r=="string"?`"${r}"`:Ne(r)?Array.from(r):r;console.log(`///_ BEEP! The expression (${n}) evaluates to:`,s,"of type "+o)}}function hs(t){let e=t.pos();if(!t.match("beep!"))return;let n=$(t),r=t.text(n);return Ce(t,"beepExpression",e,n,(o,s)=>(Ur(s,n,r,o),o),!1)}function ys(t,e,n){let r=[h(t)];for(;t.matchOp(",");)r.push(h(t));let o=r.map(s=>t.text(s));return{type:"beepCommand",values:r,start:n,end:t.endPos(),run:s=>N(r.map(i=>i.ev(s)),i=>i.forEach((c,a)=>Ur(s,r[a],o[a],c)))}}function Vr(t){t.leaves.push(ls,ms,fs),t.unaries.push(hs,us,cs),t.commands["beep!"]=ys,t.postfixes.push(ps),t.collections.push(ds)}var Ut=t=>Se(t)??t.err("Expected dotOrColonPath");function zr(t){t.features.def=(e,n)=>{let r=Ut(e),o=r.split("."),s=o.pop()??r,i=[];if(e.matchOp("(")&&!e.matchOp(")")){do i.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let c=D(e),a={type:"defFeature",name:r,displayName:`${s}(${i.join(", ")})`,params:i,body:c,...ft(e),start:n,end:e.endPos(),install:(u,l)=>{kt(u,o,s,Object.assign((...f)=>{let p=B(l,a,u,null);i.forEach((y,g)=>p.locals[y]=f[g]);let d=E(it(p,c,a),y=>w(y,"value"));return J(d)&&a.finallyHandler?d.then(void 0,()=>{}):d},{hyperfunc:!0,hypername:r}))}};return a}}function Qr(t){t.features.init=(e,n)=>{let r=!!e.match("immediately"),o=D(e),s={type:"initFeature",body:o,immediately:r,start:n,end:e.endPos(),install:i=>{let c=()=>void j(o,B(i,s,i,null));r?c():queueMicrotask(c)}};return s}}function Jr(t){t.features.behavior=(e,n)=>{let r=Ut(e),o=r.split("."),s=o.pop()??r,i=[];if(e.matchOp("(")&&!e.matchOp(")")){do i.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let c=We(e).features;for(let u of c)u.behavior=r;return{type:"behaviorFeature",name:r,params:i,features:c,start:n,end:e.endPos(),install:()=>kt(null,o,s,(u,l,m)=>{if(W(u))for(let f of i)Te(u,r+"Scope")[f]=w(m,f);for(let f of c)f.install(u,l)})}}}function Kr(t){t.features.install=(e,n)=>{let r=Ut(e),o=lt(e),s={type:"installFeature",name:r,args:o,start:n,end:e.endPos(),install:(i,c)=>{let a=globalThis;for(let u of r.split("."))if(a=w(a,u),typeof a!="object"&&typeof a!="function")throw new Error("No such behavior defined as "+r);if(!H(a))throw new Error(r+" is not a behavior");a(i,c,o?.ev(B(i,s,i,null)))}};return s}}function Yr(t){t.features.set=(e,n)=>{let r=Wt(e,n);"scope"in r.target&&r.target.scope==="local"&&e.err("variables declared at the feature level cannot be locally scoped (use :foo, ^foo, $foo, or an @attribute target instead).");let o={type:"setFeature",command:r,start:n,end:e.endPos(),install:s=>queueMicrotask(()=>void r.run(B(s,o,s,null)))};return o}}function gs(t,e){if(typeof t!="object"||t===null)return{queue:[],executing:!1};let n=V(t).eventQueues??=new Map,r=n.get(e);return r||n.set(e,r={queue:[],executing:!1}),r}function Vt(t,e){let n=gs(t.me,e);if(n.executing&&!e.every){if(e.queue==="none"||e.queue==="first"&&n.queue.length>0)return;e.queue!=="all"&&(n.queue.length=0),n.queue.push(t);return}n.executing=!0;let r=o=>{n.executing=!1;let s=n.queue.shift();if(s&&setTimeout(()=>Vt(s,e),1),o){let{error:i}=o;console.error(w(i,"message")??i),console.error(w(i,"stack")),_(t.me,"exception",{error:i})}};ye(()=>E(it(t,e.body,e),()=>r()),o=>r({error:o}))}function ws(t,e){if(!Q(e))return;let n=V(e),r=n.listeners??=[],o=n.observers??=[],s=n.timers??=new Set;for(let i of t.events){let c={execCount:0},a=i.elsewhere?[document]:i.from?i.from.ev(B(e,t,e,null)):[e];O(a,u=>{if(!Q(u)){console.warn("'%s' feature ignored because target does not exists:",t.displayName,e);return}let l=i.on;if(i.mutationSpec&&u instanceof Node){l="hyperscript:mutation";let f=new MutationObserver(p=>_(u,l,{mutationList:p,observer:f}));f.observe(u,i.mutationSpec),o.push(f)}if(i.intersectionSpec&&u instanceof Element){l="hyperscript:intersection";let f=new IntersectionObserver(p=>{for(let d of p)_(u,l,{observer:f,entry:d,intersecting:d.isIntersecting,isIntersecting:d.isIntersecting,intersectionRatio:d.intersectionRatio})},i.intersectionSpec);f.observe(u),o.push(f)}if(i.resizeSpec&&u instanceof Element){l="hyperscript:resize";let f=new ResizeObserver(p=>{for(let d of p){let{width:y,height:g}=d.contentRect;_(u,l,{width:y,height:g,contentRect:d.contentRect,entry:d})}});f.observe(u),o.push(f)}let m=f=>{if(e instanceof Node&&u!==e&&!e.isConnected){u.removeEventListener(l,m);return}let p=B(e,t,e,f);if(!(i.elsewhere&&e instanceof Node&&f.target instanceof Node&&e.contains(f.target))){i.from&&(p.result=u);for(let d of i.args){let y=w(f,d);y!==void 0?p.locals[d]=y:p.detail!=null&&(p.locals[d]=w(p.detail,d))}if(i.filter){p.meta.context=f;try{if(!i.filter.ev(p))return}finally{p.meta.context=void 0}}if(i.inExpr?.css){let d=f.target instanceof Element?f.target:null;for(;d&&!d.matches(i.inExpr.css);)d=d.parentElement;if(!d)return;p.result=d}if(c.execCount++,i.startCount){let d=c.execCount;if(i.endCount?d<i.startCount||d>i.endCount:i.unbounded?d<i.startCount:d!==i.startCount)return}if(i.debounceTime){c.debounced&&(clearTimeout(c.debounced),s.delete(c.debounced)),s.add(c.debounced=setTimeout(()=>Vt(p,t),i.debounceTime));return}if(i.throttleTime){if(c.lastExec&&Date.now()<c.lastExec+i.throttleTime)return;c.lastExec=Date.now()}Vt(p,t)}};u.addEventListener(l,m),r.push({target:u,event:l,handler:m})})}}function vs(t){if(!t.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let e={};do if(t.match("anything"))Object.assign(e,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(t.match("childList"))e.childList=!0;else if(t.match("attributes"))e.attributes=!0;else if(t.match("subtree"))e.subtree=!0;else if(t.match("characterData"))e.characterData=!0;else if(t.cur().type==="ATTRIBUTE_REF"){let n=t.consume().value;n.startsWith("@")||t.err("Only shorthand attribute references are allowed here"),(e.attributeFilter??=[]).push(n.substring(1))}else t.err("Unknown mutation config specification");while(t.match("or"));return(e.attributes||e.attributeFilter)&&(e.attributeOldValue=!0),e.characterData&&(e.characterDataOldValue=!0),e}function Es(t){let e={};if(t.match("with")){let n=De(h(t));n instanceof Element&&(e.root=n)}if(t.match("having"))do t.match("margin")?e.rootMargin=$e(t):t.match("threshold")?e.threshold=Number(De(h(t))):t.err("Unknown intersection config specification");while(t.match("and"));return e}function bs(t,e){let n=ae(t),r=mt(t),o;t.matchOp("[")&&(o=h(t),t.reqOp("]"));let s,i,c=!1;e?s=1:t.cur().type==="NUMBER"&&(s=parseInt(t.consume().value),t.match("to")?i=parseInt(t.consume().value):t.match("and")&&(c=!0,t.req("on")));let a={on:n,args:r,filter:o,startCount:s,endCount:i,unbounded:c,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=Es(t):n==="mutation"&&(a.mutationSpec=vs(t)),t.match("from")&&(t.match("elsewhere")?a.elsewhere=!0:a.from=t.withFollow(["or"],()=>h(t))),!a.from&&!a.elsewhere&&t.match("elsewhere")&&(a.elsewhere=!0),t.match("in")&&(a.inExpr=$(t));let u=()=>(t.req("at"),Number(De($(t))));return t.match("debounced")?a.debounceTime=u():t.match("throttled")&&(a.throttleTime=u()),a}function Xr(t){t.features.on=(e,n)=>{let r=!!e.match("every"),o=!r&&!!e.match("first"),s=[];do s.push(bs(e,o));while(e.match("or"));let i="last";!r&&e.match("queue")&&(e.match("all")?i="all":e.match("first")?i="first":e.match("none")?i="none":e.req("last"));let c=D(e),a={type:"onFeature",displayName:"on "+s.map(u=>u.on).join(" or "),events:s,body:c,every:r,queue:i,...ft(e),start:n,end:e.endPos(),install:u=>ws(a,u)};return a}}var Ae=new WeakMap,to=new Map,Jt=new Map,wt=new Map,Kt=new Map,ze=new Set,Qe=new WeakMap,xs=0,me,zt=!1;function ke(t){let e=Ae.get(t);return e||Ae.set(t,e={id:++xs}),e}var ht=t=>typeof t=="object"&&t!==null;function ks(t,e){let n=me;me=t,P.tracking=!0;try{return e()}finally{me=n,P.tracking=n!==void 0}}var Qt=class{constructor(e,n,r){this.expression=e;this.handler=n;this.element=r}dependencies=new Map;stopped=!1;last;triggers=0;evaluate(){try{return this.next=ks(this,this.expression),!0}catch(e){return console.error("Error in reactive expression:",e),!1}}next;handle(e){try{this.handler(e)}catch(n){console.error("Error in reactive handler:",n)}}initialize(){this.evaluate()&&(this.last=this.next),Zr(this),this.last!=null&&this.handle(this.last)}run(){if(++this.triggers>100){console.error("Reactivity loop detected: an effect triggered 100 consecutive times without settling. This usually means an effect is modifying a variable it also depends on.",this.element??this);return}eo(this);let e=this.dependencies;this.dependencies=new Map;let n=this.evaluate();n||(this.dependencies=e),Zr(this),n&&!Object.is(this.next,this.last)&&(this.last=this.next,this.handle(this.next))}settled(){this.triggers=0}stop(){this.stopped||(this.stopped=!0,eo(this),ze.delete(this))}};function Ns(t){t.stopped||(ze.add(t),!zt&&(zt=!0,queueMicrotask(()=>{zt=!1;let e=Array.from(ze);ze.clear();for(let n of e)n.stopped||(n.element&&!n.element.isConnected?n.stop():n.run());if(ze.size===0)for(let n of e)n.settled()})))}var Oe=t=>t?.forEach(Ns);function no(t){for(let[e,n]of Kt)for(let r of t)if(e.contains(r)){Oe(n);break}}var yt;function Ts(){yt??=new MutationObserver(t=>{let e=new Set;for(let n of t){if(n.type==="attributes"){let r=Ae.get(n.target);r&&Oe(Jt.get(`${n.attributeName}:${r.id}`))}e.add(n.target)}no(e)}),yt.observe(document,{attributes:!0,childList:!0,subtree:!0}),document.addEventListener("input",gt,!0),document.addEventListener("change",gt,!0)}function gt(t){let e=t.target;if(!(e instanceof Element))return;let n=Ae.get(e);n&&Oe(wt.get(n.id)),no([e])}function Cs(t,e,n){let r=t.get(e);r||t.set(e,r=new Set),r.add(n)}function Ss(t,e,n){let r=t.get(e);r?.delete(n),r?.size===0&&t.delete(e)}function ro(t,e){let n=!1;for(let r of t.dependencies.values())r.type==="global"?e(to,r.name,t):r.type==="element"?e(ke(r.element).symbols??=new Map,r.name,t):(n=!0,r.type==="query"?e(Kt,r.root,t):r.type==="property"?e(wt,ke(r.object).id,t):e(Jt,`${r.name}:${ke(r.element).id}`,t));return n}function Zr(t){ro(t,Cs)&&Ts()}function eo(t){ro(t,Ss),yt&&!Jt.size&&!wt.size&&!Kt.size&&(yt.disconnect(),document.removeEventListener("input",gt,!0),document.removeEventListener("change",gt,!0))}function Le(t,e,n){let r=new Qt(t,e,n);return r.initialize(),n&&(Qe.has(n)||Qe.set(n,new Set),Qe.get(n)?.add(r)),()=>r.stop()}function Ps(){P.readGlobal=t=>void me?.dependencies.set("symbol:global:"+t,{type:"global",name:t}),P.readElement=(t,e)=>{ht(e)&&me?.dependencies.set(`symbol:element:${t}:${ke(e).id}`,{type:"element",name:t,element:e})},P.readProperty=t=>{ht(t)&&!w(t,"_hsSkipTracking")&&me?.dependencies.set("property:"+ke(t).id,{type:"property",object:t})},P.readAttribute=(t,e)=>{x(t)&&me?.dependencies.set(`attribute:${e}:${ke(t).id}`,{type:"attribute",name:e,element:t})},P.wroteGlobal=t=>Oe(to.get(t)),P.wroteElement=(t,e)=>{ht(e)&&Oe(Ae.get(e)?.symbols?.get(t))},P.readQuery=t=>void me?.dependencies.set("query:"+ke(t).id,{type:"query",root:t}),P.wroteProperty=t=>{let e=ht(t)&&!w(t,"_hsSkipTracking")&&Ae.get(t);e&&Oe(wt.get(e.id))},P.stop=t=>{Qe.get(t)?.forEach(e=>e.stop()),Qe.delete(t)}}var Rs=t=>e=>{console.error(w(e,"message")??e),_(t,"exception",{error:e})};function Is(t){t.features.when=(e,n)=>{let r=[];do r.push(e.withFollow(["or"],()=>h(e)));while(e.match("or"));for(let i of r)i.type==="symbol"&&"scope"in i&&i.scope==="local"&&i.name&&e.err(`Cannot watch local variable '${i.name}'. Local variables are not reactive. Use '$${i.name}' (global) or ':${i.name}' (element-scoped) instead.`);e.req("changes");let o=D(e),s={type:"whenFeature",displayName:"when ... changes",watched:r,body:o,start:n,end:e.endPos(),install:i=>queueMicrotask(()=>{let c=()=>B(i,s,i,null);for(let a of r)Le(()=>a.ev(c()),u=>{let l=c();l.result=u,ye(()=>E(j(o,l),()=>{}),Rs(i))},x(i)?i:void 0)})};return s}}function Os(t){t.features.live=(e,n)=>{let r=D(e),o={type:"liveFeature",displayName:"live",body:r,start:n,end:e.endPos(),install:s=>queueMicrotask(()=>Le(()=>void j(r,B(s,o,s,null)),()=>{},x(s)?s:void 0))};return o}}function As(t){if(t instanceof HTMLInputElement){let n=t.getAttribute("type")??"text";return n==="checkbox"?"checked":n==="number"||n==="range"?"valueAsNumber":"value"}if(t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)return"value";let e=t.getAttribute("contenteditable");if(e!==null&&e!=="false")return"textContent";if(t.tagName.includes("-")&&"value"in t)return"value";throw new Error(`bind cannot auto-detect a property for <${t.tagName.toLowerCase()}>. Use an explicit property (e.g. 'bind $var to #el's value').`)}function Ls(t){if(t instanceof HTMLInputElement&&t.type==="radio")return{element:t,writable:!0,read:()=>ue(t,"checked")?t.value:void 0,write:n=>t.checked=n===t.value};let e=As(t);return{element:t,writable:!0,read:()=>{let n=ue(t,e);return e==="valueAsNumber"&&Number.isNaN(n)?null:n},write:n=>void Reflect.set(t,e,n)}}function Fs(t,e,n){let r=e.you||e.me;if(t.type==="classRef"&&"className"in t&&typeof t.className=="string")x(r)&&r.classList.toggle(t.className,!!n);else if(t.type==="attributeRef"&&typeof n=="boolean"&&t.name){if(!x(r))return;t.name.startsWith("aria-")?r.setAttribute(t.name,String(n)):r.toggleAttribute(t.name,n)}else E(t.lhs?.(e),o=>t.put?.(e,o,n))}function Ms(t,e,n){let r=()=>B(e,n,e,null);if(t.type==="classRef"&&"className"in t&&typeof t.className=="string"){let o=t.className;return{writable:!0,read:()=>(we(e,"class"),x(e)&&e.classList.contains(o)),write:s=>void(x(e)&&e.classList.toggle(o,!!s))}}return{writable:t.type==="attributeRef"||!!t.put,read:()=>t.ev(r()),write:o=>Fs(t,r(),o)}}function qs(t){t.features.bind=(e,n)=>{let r=e.withFollow(["and","with","to"],()=>h(e));e.matchAny("and","with","to")||e.expected("and","with","to");let o=h(e),s={type:"bindFeature",displayName:"bind",left:r,right:o,start:n,end:e.endPos(),install:i=>queueMicrotask(()=>{let c=x(i)?i:void 0,a=u=>{let l=u.ev(B(i,s,i,null));return x(l)?Ls(l):Ms(u,i,s)};try{let u=a(r),l=a(o);if(!u.writable&&!l.writable)throw new Error("bind requires at least one writable side");u.writable&&Le(l.read,u.write,c),l.writable&&Le(u.read,l.write,c);for(let[m,f]of[[u,l],[l,u]]){let p=m.element?.closest("form");if(!p||!c)continue;let d=()=>setTimeout(()=>c.isConnected&&f.write(m.read()),0);p.addEventListener("reset",d),(V(c).listeners??=[]).push({target:p,event:"reset",handler:d})}}catch(u){console.error(w(u,"message")??u)}})};return s}}function oo(t){Ps(),Is(t),Os(t),qs(t)}var so="#text";function _s(t){let e=[],n=0,r=0;for(let o of t.split(/(?<=\n)/)){n++;let s=o.trimStart(),i=r+o.length-s.length;if(r+=o.length,!s||/^(--|\/\/)(\s|$|[-/])/.test(s))continue;let c=i-(r-o.length);if(/^#[a-zA-Z]/.test(s))for(let a of de(s.slice(1)))a.start+=i+1,a.end+=i+1,a.line=n,a.column+=c+1,e.push(a);else{let a=s.replace(/\r?\n$/,`
17
+ `,s)}}var Pn=[],Rn=[];function fe(t){if(!(t instanceof Element||t instanceof Document||t instanceof DocumentFragment))return;for(let n of Pn)n(t);let e=Tn().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";t instanceof Element&&t.matches(e)&&En(t),t.querySelectorAll(e).forEach(En);for(let n of Rn)n(t)}function xe(t){let e=ce(t);if(e){_(t,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of e.listeners??[])n.removeEventListener(r,o);for(let n of e.observers??[])n.disconnect();for(let n of e.timers??[])clearTimeout(n);P.stop(t),t.querySelectorAll("[data-hyperscript-powered]").forEach(xe),_(t,"hyperscript:after:cleanup"),t.removeAttribute("data-hyperscript-powered"),tn(t)}}z.process=fe;function Go(t){try{let e=Nn(t);return e.kind==="features"?{...e.program,errors:[]}:{...e.kind==="commands"?e.commands[0]:e.expression,errors:[]}}catch(e){if(e instanceof be)return{errors:[e]};throw e}}var Re=Object.assign(vn,{config:Object.assign(Z,{conversions:Object.assign(ge,{dynamicResolvers:Me})}),use(t){t(Re)},addBeforeProcessHook:t=>void Pn.push(t),addAfterProcessHook:t=>void Rn.push(t),addSourceTransform:t=>void Sn.push(t),evaluate:vn,parse:Go,process:fe,processNode:fe,cleanup:xe,internals:{runtime:{cleanup:xe,processNode:fe}},version:"4.2.0"});function In(){if(Object.assign(globalThis,{_hyperscript:Re}),typeof document>"u")return;let t=()=>{fe(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t)}function On(t){t.unaries.push(e=>{let n=1;for(;e.tok(n).type==="IDENTIFIER"&&e.tok(n+1).op&&e.tok(n+1).value===".";)n+=2;let r=e.tok(n+1);if(!e.peek("new")||e.tok(n).type!=="IDENTIFIER"||!r.op||r.value!=="(")return;let o=e.pos();e.consume();let s=[e.consume().value];for(;e.matchOp(".");)s.push(e.consume().value);e.reqOp("(");let i=[];if(!e.matchOp(")")){do i.push(h(e));while(e.matchOp(","));e.reqOp(")")}return{type:"newExpression",path:s,args:i,start:o,end:e.endPos(),ev:a=>N(i.map(u=>u.ev(a)),u=>{let l=s.slice(1).reduce((m,f)=>w(m,f),le(s[0],a));if(!H(l))throw new Error(`'${s.join(".")}' is not a constructor`);return Reflect.construct(l,u)})}})}function Ho(t,e){let n=t instanceof HTMLElement&&t.tagName==="SUMMARY"?t.parentElement:t;if(n instanceof HTMLDialogElement)n.open?n.close():e?n.showModal():n.show();else if(n instanceof HTMLDetailsElement)n.open=!n.open;else if(n instanceof HTMLSelectElement){if(document.activeElement===n)return n.blur();n.focus();try{n.showPicker()}catch{}}else if(n instanceof HTMLElement&&n.hasAttribute("popover"))n.togglePopover();else throw new Error("toggle needs a dialog, details, select or popover element")}function An(t){t.toggleElement=(e,n,r)=>{let o=e.match("as")?!!e.req("modal"):!!e.match("modal"),s=e.text(n);return{type:"toggleElementCommand",target:n,modal:o,start:r,end:e.endPos(),run:c=>E(n.ev(c),a=>{F(a,s),O(a,u=>Ho(u,o))})}}}var Ln=(t,e,n)=>new Promise(r=>{let o=!1;t.addEventListener("transitionstart",()=>o=!0,{once:!0}),t.addEventListener("transitionend",()=>r(),{once:!0}),setTimeout(()=>o||r(),e),n?.()});function Fn(t){t.commands.settle=(e,n,r)=>{let o=e.commandBoundary(e.cur())?U(e):h(e),s=e.text(o);return{type:"settleCommand",target:o,start:r,end:e.endPos(),run:c=>E(o.ev(c),a=>{F(a,s);let u=x(a)?[a]:K(a)?Array.from(a).filter(x):[];return Promise.all(u.map(l=>Ln(l,500))).then(()=>{})})}}}function Mn(t){t.commands.transition=(e,n,r)=>{let o=[],s=[],i=[];do o.push(e.withFollow(["from","to"],()=>h(e))),s.push(e.match("from")?h(e):void 0),e.req("to"),i.push(e.match("initial")?"initial":h(e));while(!e.commandBoundary(e.cur())&&e.cur().value!=="over"&&e.cur().value!=="using");let c=e.match("over")?h(e):void 0,a=!c&&e.match("using")?h(e):void 0,u=o[0].root,l=u?e.text(u):"",m=(p,d)=>o.forEach((y,g)=>{d[g]!=null&&E(y.lhs?.(p),v=>y.put?.(p,v,d[g]))});return{type:"transitionCommand",properties:o,from:s,to:i,over:c,using:a,start:r,end:e.endPos(),run:p=>N([u?u.ev(p):p.me,c?.ev(p),a?.ev(p),N(s.map(d=>d?.ev(p)),d=>d),N(i.map(d=>d==="initial"?void 0:d.ev(p)),d=>d)],([d,y,g,v,C])=>{u&&F(d,l);let S=[];return O(d,R=>{if(!(R instanceof HTMLElement))return;let I=R.style.transition;R.style.transition=y?`all ${y}ms ease-in`:g?String(g):Z.defaultTransition;let A=V(R).transitionInitials??={};o.forEach((q,b)=>{b in A||(A[b]=q.ev(p))}),Array.isArray(v)&&m(p,v);let M=i.map((q,b)=>q==="initial"?A[b]:w(C,String(b)));S.push(Ln(R,100,()=>setTimeout(()=>m(p,M),0)).then(()=>{R.style.transition=I}))}),Promise.all(S).then(()=>{})})}}}function qn(t){t.commands.start=(e,n,r)=>{e.match("a"),e.req("view"),e.req("transition"),e.match("using");let o=e.matchType("STRING")?.value,s=D(e);e.hasMore()&&e.req("end");let i=!1;return{type:"viewTransitionCommand",body:s,transitionType:o,start:r,end:e.endPos(),run:a=>{if(!document.startViewTransition)return j(s,a);if(i)throw new Error("A view transition is already in progress");i=!0;let u=()=>{},l=new Promise(d=>u=d),m=()=>l,f=o?document.startViewTransition({update:m,types:[o]}):document.startViewTransition(m),p=d=>(i=!1,u(),d?(console.warn("hyperscript: view transition skipped due to early exit (return, halt, or break)"),f.finished.catch(()=>{}),f.skipTransition(),d):f.finished.then(()=>{}));return new Promise(d=>setTimeout(d,0)).then(()=>j(s,a)).then(d=>p(re(d)))}}}}function _n(t){t.commands.if=(e,n,r)=>{let o=h(e);e.match("then");let s=D(e),i,c=!1,a=e.match("else")??e.match("otherwise");if(a)if(c=e.peek("if")?.line===a.line,c){let l=dt(e);i=l?[l]:[]}else i=D(e);return e.hasMore()&&!c&&e.req("end"),{type:"ifCommand",condition:o,trueBranch:s,falseBranch:i,start:r,end:e.endPos(),run:l=>E(o.ev(l),m=>m?j(s,l):i&&j(i,l))}}}var jn={k:"return",value:null};function Dn(t){t.commands.halt=(e,n,r)=>{let o=!1;e.match("the")&&(e.req("event"),e.matchOp("'")&&e.req("s"),o=!0);let s=!!e.match("bubbling"),i=!s&&!!e.match("default");return{type:"haltCommand",keepExecuting:o,bubbling:s,haltDefault:i,start:r,end:e.endPos(),run:a=>{let u=a.event;if(u instanceof Event&&(i||u.stopPropagation(),s||u.preventDefault()),!o)return jn}}}}function Gn(t){t.commands.return=(e,n,r)=>{let o=e.commandBoundary(e.cur())?void 0:h(e);return{type:"returnCommand",value:o,start:r,end:e.endPos(),run:i=>E(o?o.ev(i):null,c=>(i.meta.returned=!0,i.meta.returnValue=c,{k:"return",value:c}))}},t.commands.exit=(e,n,r)=>({type:"exitCommand",start:r,end:e.endPos(),run:()=>jn})}function Hn(t){t.commands.throw=(e,n,r)=>{let o=h(e);return{type:"throwCommand",value:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{throw c})}}}function Bn(t){let e=te(t);if(!e)return;let n=[e];for(let r=te(t);r;r=te(t))n.push(r);return n}var _t=(t,e)=>(t??[]).map(n=>E(n.ev(e),r=>String(w(r,"className")))),$o=t=>t.split(";").map(e=>e.split(":")[0].trim()).filter(Boolean),jt=t=>t instanceof HTMLElement||t instanceof SVGElement?t.style:void 0,$n=(t,e,n,r,o)=>e?at(t,e,n,s=>x(s)&&r(s),s=>x(s)&&o(s)):O(t,s=>x(s)&&r(s)),Be=(t,{name:e,value:n},r)=>r?t.setAttribute(e,String(n)):t.removeAttribute(e),Un=(t,e,n,r,o,s)=>s?$n(e,n,r,i=>Be(i,s,t),i=>Be(i,s,!t)):N(o.map(i=>$n(e,n,r,c=>c.classList.toggle(String(i),t),c=>c.classList.toggle(String(i),!t))),()=>{});function Vn(t){let e=Bn(t),n=e?void 0:Y(t);return{refs:e,attribute:n,css:e||n?void 0:yn(t)}}function zn(t){t.commands.add=(e,n,r)=>{let{refs:o,attribute:s,css:i}=Vn(e),c;!o&&!s&&!i&&(c=e.withFollow(["to"],()=>h(e)),e.cur().value!=="to"&&e.err("Expected either a class reference or attribute expression"));let a=e.match("to")?h(e):U(e),u=e.match("when")?h(e):void 0,l=o||s?u:void 0,m=e.text(a);return{type:"addCommand",classRefs:o,attributeRef:s,css:i,value:c,to:a,when:l,start:r,end:e.endPos(),run:p=>N([a.ev(p),i?.ev(p),c?.ev(p),..._t(o,p)],([d,y,g,...v])=>{if(F(d,m),c){if(Array.isArray(d))d.push(g);else if(d instanceof Set)d.add(g);else throw d instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof d);P.wroteProperty(d)}else if(i)O(d,C=>{let S=jt(C);S&&(S.cssText+=y)});else return Un(!0,d,l,p,v,s)})}}}var Wo=t=>t instanceof Node||t instanceof NodeList||t instanceof HTMLCollection;function Qn(t){t.commands.remove=(e,n,r)=>{let{refs:o,attribute:s,css:i}=Vn(e),c=o||s||i?void 0:h(e),a=e.match("from")?h(e):c?void 0:U(e),u;e.match("when")&&(c&&e.err("'when' clause is not supported when removing elements"),u=h(e));let l=a?e.text(a):"",m=c?e.text(c):"",f=(d,y,g)=>{if(g==null&&c?.del&&c.lhs&&!Wo(y)){let v=c;return E(c.lhs(d),C=>v.del?.(d,C))}if(F(y,m),Array.isArray(g)){let v=g.indexOf(y);v>-1&&g.splice(v,1),P.wroteProperty(g)}else g instanceof Set||g instanceof Map?(g.delete(y),P.wroteProperty(g)):O(y,v=>{x(v)&&v.parentElement&&(g==null||g instanceof Node&&g.contains(v))&&v.parentElement.removeChild(v)})};return{type:"removeCommand",classRefs:o,attributeRef:s,css:i,element:c,from:a,when:u,start:r,end:e.endPos(),run:d=>N([a?.ev(d),i?.ev(d),c?.ev(d),..._t(o,d)],([y,g,v,...C])=>{if(c)return f(d,v,y);if(F(y,l),i){let S=$o(String(g));O(y,R=>S.forEach(I=>jt(R)?.removeProperty(I)))}else return Un(!1,y,u,d,C,s)})}}}var Wn=(t,e,n)=>(r,o,s)=>{s?o.style[t]=s:r==="toggle"?o.style[t]=getComputedStyle(o)[t]===e?n:e:o.style[t]=r==="hide"?e:n},Jn={display(t,e,n){if(!n&&e instanceof HTMLDialogElement){t==="hide"||t==="toggle"&&e.open?e.close():e.open||e.show();return}let r=V(e);n?e.style.display=n:t==="toggle"?Jn.display(getComputedStyle(e).display==="none"?"show":"hide",e):t==="hide"?(r.originalDisplay??=e.style.display,e.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?e.style.display=r.originalDisplay:e.style.removeProperty("display")},visibility:Wn("visibility","hidden","visible"),opacity:Wn("opacity","0","1"),hidden(t,e){(t==="toggle"?!e.hasAttribute("hidden"):t==="hide")?e.setAttribute("hidden",""):e.removeAttribute("hidden")}};function Dt(t,e){let n=e??Z.defaultHideShowStrategy??"display";return Z.hideShowStrategies[n]??Jn[n]??t.err("Unknown show/hide strategy : "+n)}function Kn(t){t.commands.toggle=(e,n,r)=>{e.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},s;if(e.cur().type==="STYLE_REF"){let y=o.styleProp=e.consume().value.slice(1);s=Dt(e,y),o.on=e.match("of")?e.withFollow(["with","between"],()=>h(e)):U(e)}else if(e.match("between")){let y=te(e);if(y)e.req("and"),o.between=[y,te(e)??e.err("Expected classRef")];else{let g=Y(e)??e.err("Expected either a class reference or attribute expression");e.req("and"),o.between=[g,Y(e)??e.err("Expected attributeRef")]}}else if(!(o.classRefs=Bn(e))&&!(o.attributeRef=Y(e))){let y=e.g.toggleElement;if(!y)o.target=e.withFollow(["between"],()=>ie(e));else{let g=e.withFollow(["between","as"],()=>$(e));if(!e.peek("between"))return y(e,g,r);o.target=Ot(e,g)}}if(!o.styleProp&&!o.target&&(o.on=e.match("on")?h(e):U(e)),e.match("between")){let y=o.betweenValues=e.withFollow(["and"],()=>{let g=[h(e)];for(;e.matchOp(",");)g.push(h(e));return g});e.req("and"),y.push(h(e))}o.target&&!o.betweenValues&&e.err("toggle <expression> requires 'between' with values"),e.peek("for")&&!e.peek("in",2)?(e.match("for"),o.time=h(e)):e.match("until")&&(o.until=ae(e),e.match("from")&&(o.from=h(e))),o.end=e.endPos();let{on:i,target:c,betweenValues:a,between:u,attributeRef:l,styleProp:m}=o,f=i?e.text(i):"",p=(y,g)=>y[(y.findIndex(v=>v==g)+1)%y.length],d=(y,g,v,C)=>{if(a&&c?.lhs&&c.put){let S=c;return N([c.ev(y),c.lhs(y)],([R,I])=>S.put?.(y,I,p(v,R)))}if(a&&m)return O(g,S=>{let R=jt(S);if(!R||!x(S))return;let I=R.getPropertyValue(m)||getComputedStyle(S).getPropertyValue(m);R.setProperty(m,String(p(v,I)))});F(g,f),O(g,S=>{if(x(S))if(s)S instanceof HTMLElement&&s("toggle",S);else if(u){let[R,I]=u;if(R.type==="classRef"&&I.type==="classRef"){let[A,M]=[String(R.className),String(I.className)],q=S.classList.contains(A);S.classList.toggle(A,!q),S.classList.toggle(M,q)}else if(R.type==="attributeRef"&&I.type==="attributeRef"){let A=S.getAttribute(R.name)===String(R.value);Be(S,A?R:I,!1),Be(S,A?I:R,!0)}}else l?Be(S,l,!S.hasAttribute(l.name)):C.forEach(R=>S.classList.toggle(String(R)))})};return o.run=y=>N([i?.ev(y),o.time?.ev(y),o.from?.ev(y),N((a??[]).map(g=>g.ev(y)),g=>g),..._t(o.classRefs,y)],([g,v,C,S,...R])=>{let I=()=>d(y,g,Array.isArray(S)?S:[],R);if(o.time)return new Promise(A=>{I(),setTimeout(()=>{I(),A()},T(v))});if(o.until){let A=o.until,M=C||y.me;return new Promise(q=>{Q(M)&&M.addEventListener(A,()=>{I(),q()},{once:!0}),I()})}return E(I(),()=>{})}),o}}function Zn(t){for(let e of["hide","show"])t.commands[e]=(n,r,o)=>{let s=n.cur(),i=s.value==="when"||s.value==="with"||n.commandBoundary(s)?U(n):h(n),c;n.match("with")&&(c=n.reqType("IDENTIFIER","STYLE_REF").value.replace(/^\*/,""));let a;e==="show"&&n.matchOp(":")&&(a=n.consumeUntil(void 0,"WHITESPACE").map(d=>d.value).join(""));let u=n.match("when")?h(n):void 0,l=Dt(n,c),m=n.text(i),f=d=>y=>{y instanceof HTMLElement&&l(d,y,d==="show"?a:void 0)};return{type:`${e}Command`,target:i,strategy:c,arg:a,when:u,start:o,end:n.endPos(),run:d=>E(i.ev(d),y=>{if(F(y,m),u)return at(y,u,d,f(e),f(e==="hide"?"show":"hide"));O(y,f(e))})}}}function er(t){t.commands.take=(e,n,r)=>{let o=[];for(let v=te(e);v;v=te(e))o.push(v);let s=o.length>0,i=s?void 0:Y(e)??e.err("Expected either a class reference or attribute expression"),c,a,u=v=>(o.length>1&&e.err(`\`${v}\` cannot be combined with multiple class refs`),te(e)??e.err("Expected classRef"));e.match("with")&&(s?c=u("with"):a=h(e));let l;e.match("from")&&(l=h(e),e.match("giving")&&((c||a)&&e.err("`giving` cannot be combined with `with`"),s?c=u("giving"):a=h(e)));let m=e.match("for")?h(e):U(e),f=e.text(m),p=l?e.text(l):"",d=c?.className,y=(v,C)=>O(v,S=>x(S)&&C(S));return{type:"takeCommand",classRefs:o,attributeRef:i,from:l,for:m,replacementClass:c,replacementValue:a,start:r,end:e.endPos(),run:v=>N([l?.ev(v),m.ev(v),a?.ev(v),...o.map(C=>C.ev(v))],([C,S,R,...I])=>{if(F(S,f),i){F(C,p),y(C,A=>R?A.setAttribute(i.name,String(R)):A.removeAttribute(i.name)),y(S,A=>A.setAttribute(i.name,i.value||""));return}o.forEach((A,M)=>{let q=String(A.className);y(l?C:I[M],b=>{b.classList.remove(q),d&&b.classList.add(d)}),y(S,b=>{b.classList.add(q),d&&b.classList.remove(d)})})})}}}var Bo="x y left top right bottom width height bounds scrollLeft scrollTop scrollLeftMax scrollTopMax scrollWidth scrollHeight scroll".split(" ");function tr(t){t.commands.measure=(e,n,r)=>{let o=U(e),s=[];if(!e.commandBoundary(e.cur())){let a=h(e);a.type==="symbol"&&a.name&&Bo.includes(a.name)?s.push(a.name):a.type==="possessive"&&a.prop&&a.root?(o=a.root,s.push(a.prop)):a.type==="ofExpression"&&a.name&&a.root?(o=a.root,s.push(a.name)):o=a}for(;e.matchOp(",");)s.push(e.reqType("IDENTIFIER").value);let i=e.text(o);return{type:"measureCommand",target:o,properties:s,start:r,end:e.endPos(),run:a=>E(o.ev(a),u=>{F(u,i);let l=x(u)?u:K(u)?Array.from(u).find(x):void 0;if(!l)throw new Error(`'${i}' is not an element`);let m=l.getBoundingClientRect(),f={top:l.scrollTop,left:l.scrollLeft,topMax:w(l,"scrollTopMax"),leftMax:w(l,"scrollLeftMax"),height:l.scrollHeight,width:l.scrollWidth},{x:p,y:d,left:y,top:g,right:v,bottom:C,width:S,height:R}=m,I={x:p,y:d,left:y,top:g,right:v,bottom:C,width:S,height:R,bounds:m,scrollLeft:f.left,scrollTop:f.top,scrollLeftMax:f.leftMax,scrollTopMax:f.topMax,scrollWidth:f.width,scrollHeight:f.height,scroll:f};a.result=I;for(let A of s){if(!(A in I))throw new Error("No such measurement as "+A);a.locals[A]=I[A]}})}}}function Ue(t,e,n){for(let r of e)t.commands[r]=(o,s,i)=>{let c=o.commandBoundary(o.cur())?void 0:h(o);return{type:`${e[0]}Command`,target:c,start:i,end:o.endPos(),run:u=>E(c?.ev(u),l=>E(n(l||u.me),()=>{}))}}}var pt=t=>e=>{let n=w(e,t);H(n)&&Reflect.apply(n,e,[])},Yn=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,nr=t=>t instanceof HTMLInputElement&&(t.type==="checkbox"||t.type==="radio"),Xn=(t,e)=>{if(Yn(t))e(t);else if(t instanceof HTMLFormElement)t.querySelectorAll("input, textarea, select").forEach(n=>Yn(n)&&e(n));else return!1;return!0},Uo=t=>{t instanceof HTMLSelectElement?t.selectedIndex=-1:nr(t)?t.checked=!1:t.value=""},Vo=t=>{if(t instanceof HTMLSelectElement)for(let e of t.options)e.selected=e.defaultSelected;else nr(t)?t.checked=t.defaultChecked:t.value=t.defaultValue},zo=t=>e=>O(e,n=>{n instanceof HTMLDialogElement?t?n.open||n.showModal():n.close():n instanceof HTMLDetailsElement?n.open=t:n instanceof HTMLElement&&n.hasAttribute("popover")?n[t?"showPopover":"hidePopover"]():pt(t?"open":"close")(n)});function rr(t){Ue(t,["focus"],pt("focus")),Ue(t,["blur"],pt("blur")),Ue(t,["select"],pt("select")),Ue(t,["empty","clear"],e=>{Array.isArray(e)||e instanceof Set||e instanceof Map?(Array.isArray(e)?e.splice(0):e.clear(),P.wroteProperty(e)):O(e,n=>Xn(n,Uo)||x(n)&&n.replaceChildren())}),Ue(t,["reset"],e=>O(e,n=>n instanceof HTMLFormElement?n.reset():Xn(n,Vo)))}function or(t){for(let e of[!0,!1]){let n=e?"open":"close";t.commands[n]=(r,o,s)=>{let i=!!r.match("fullscreen"),c=r.commandBoundary(r.cur())?void 0:h(r);return{type:`${n}Command`,target:c,start:s,end:r.endPos(),run:u=>E(c?.ev(u),l=>i?e?(x(l)?l:document.documentElement).requestFullscreen():document.exitFullscreen():zo(e)(l||u.me))}}}}function sr(t){t.commands.make=(e,n,r)=>{e.match("a")||e.match("an");let o=h(e),s=[],i=o.type==="queryRef"?o.css:void 0;if(i===void 0&&e.match("from"))do s.push(h(e));while(e.matchOp(","));let c=e.match("called")?Ft(e)??e.err("Expected symbol"):void 0,a=()=>{let l="div",m={classes:[]};for(let[,p,d]of(i??"").matchAll(/(^|#|\.)([^#. ]+)/g))p===""?l=d.trim():p==="#"?m.id=d.trim():m.classes.push(d.trim());let f=document.createElement(l);return m.id!==void 0&&(f.id=m.id),f.classList.add(...m.classes),f};return{type:"makeCommand",value:o,args:s,called:c,start:r,end:e.endPos(),run:l=>N([i===void 0?o.ev(l):void 0,...s.map(m=>m.ev(l))],([m,...f])=>{l.result=i===void 0?Reflect.construct(H(m)?m:Object,f):a(),c?.put?.(l,void 0,l.result)})}}}function ir(t){t.commands.append=(e,n,r)=>{let o=h(e),s=e.match("to")?je(h(e)):void 0;return{type:"appendCommand",value:o,target:s,start:r,end:e.endPos(),run:c=>N([s?s.ev(c):le("result",c),o.ev(c),s?.lhs?.(c)],([a,u,l])=>{if(Array.isArray(a)||a instanceof Set)Array.isArray(a)?a.push(u):a.add(u),P.wroteProperty(a);else if(x(a))x(u)?a.insertAdjacentElement("beforeend",u):a.insertAdjacentHTML("beforeend",String(u)),z.process(a);else{let m=T(a||"")+T(u);if(!s)st("result",c,void 0,m);else if(s.put)s.put(c,l,m);else throw new Error("Unable to append a value!")}})}}}function ar(t){t.commands.swap=(e,n,r)=>{let o=e.withFollow(["with"],()=>ie(e));e.req("with");let s=ie(e);return{type:"swapCommand",first:o,second:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s.ev(c),o.lhs?.(c),s.lhs?.(c)],([a,u,l,m])=>{if(x(a)&&x(u)){let f=document.createComment("");a.replaceWith(f),u.replaceWith(a),f.replaceWith(u)}else o.put?.(c,l,u),s.put?.(c,m,a)})}}}function cr(t){t.commands.send=t.commands.trigger=(e,n,r)=>{let o=ae(e),s=lt(e),i=e.match(n==="trigger"?"on":"to")?h(e):U(e),c=e.text(i);return{type:"sendCommand",event:o,details:s,to:i,start:r,end:e.endPos(),run:u=>N([i.ev(u),s?.ev(u)],([l,m])=>{F(l,c),O(l,f=>_(f,o,W(m)?m:{},u.me))})}}}function ur(t){t.commands.wait=(e,n,r)=>{let o={type:"waitCommand",start:r,end:r,run:()=>{}};if(e.match("for")){e.match("a");let s=o.events=[];do{let a=e.cur();a.type==="NUMBER"||a.op&&a.value==="("?s.push(h(e)):s.push({event:ae(e),args:mt(e)})}while(e.match("or"));let i=o.from=e.match("from")?h(e):void 0,c=i?e.text(i):"me";o.run=a=>E(i?i.ev(a):a.me,u=>{if(!Q(u))throw new Error("Not a valid event target: "+c);return new Promise(l=>{for(let m of s)"event"in m?u.addEventListener(m.event,f=>{a.result=f;for(let p of m.args)a.locals[p]=w(f,p)||w(w(f,"detail"),p)||null;l()},{once:!0}):E(m.ev(a),f=>setTimeout(()=>{a.result=f,l()},T(f)))})})}else{let s;e.match("a")?e.req("tick"):s=o.time=h(e),o.run=i=>E(s?.ev(i),c=>new Promise(a=>setTimeout(a,s?T(c):0)))}return o.end=e.endPos(),o}}function lr(t){let e=t.pos(),n=t.cur(),r=[],o="",s=!1;for(;t.hasMore();){n=t.consume();let i=t.tok(0,!0);if(i.type==="IDENTIFIER"&&i.value==="end")break;s?n.type==="IDENTIFIER"||n.type==="NUMBER"?o+=n.value:(o&&r.push(o),o="",s=!1):n.type==="IDENTIFIER"&&n.value==="function"&&(s=!0)}return{source:t.src.substring(e,n.end+1),functions:r}}function dr(t){t.commands.js=(e,n,r)=>{let o=[];if(e.matchOp("(")&&!e.matchOp(")")){do o.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let{source:s}=lr(e);e.match("end");let i=new Function(...o,s);return{type:"jsCommand",source:s,inputs:o,start:r,end:e.endPos(),run:a=>E(Reflect.apply(i,globalThis,o.map(u=>le(u,a))),u=>{a.result=u})}},t.features.js=(e,n)=>{let{source:r,functions:o}=lr(e),s=new Function(`${r}
18
+ return { ${o.map(c=>`${c}:${c}`).join(",")} } `);return{type:"jsFeature",source:r,functions:o,start:n,end:e.endPos(),install:()=>void Object.assign(globalThis,s())}}}function fr(t){for(;;){let e=t();if(J(e))return e.then(n=>n??fr(t));if(e)return e}}var Qo=t=>{if(t){if(W(t)&&Symbol.asyncIterator in Object(t)){let e=Reflect.get(Object(t),Symbol.asyncIterator);return typeof e=="function"?Reflect.apply(e,t,[]):void 0}return(K(t)?t:Object.keys(Object(t)))[Symbol.iterator]()}};function mr(t){t.commands.repeat=t.commands.for=(e,n,r)=>{let o={type:"repeatCommand",until:!1,bottomTested:!1,forever:!1,body:[],start:r,end:r,run:()=>{}};if(n==="for"||e.match("for")){let v=o.identifier=e.reqType("IDENTIFIER").value;e.req("in"),o.expression=h(e);for(let C=o.expression;C;C=C.root)C.type==="collectionExpression"&&(C.varName=v)}else e.match("in")?(o.identifier="it",o.expression=h(e)):e.match("while")?o.condition=h(e):e.match("until")?(o.until=!0,e.match("event")?(o.event=ae(e),e.match("from")&&(o.from=h(e))):o.condition=h(e)):!e.commandBoundary(e.cur())&&e.cur().value!=="forever"?(o.times=h(e),e.req("times")):(e.match("forever"),o.forever=!0);e.match("index")?o.indexIdentifier=e.reqType("IDENTIFIER").value:e.match("indexed")&&(e.req("by"),o.indexIdentifier=e.reqType("IDENTIFIER").value);let s=o.body=D(e);if(o.forever&&e.hasMore()){let v=e.match("until")??e.match("while");v&&(o.forever=!1,o.bottomTested=!0,o.until=v.value==="until",o.condition=h(e))}e.match("else")&&(o.elseBranch=D(e)),e.hasMore()&&e.req("end"),o.end=e.endPos();let{identifier:i,indexIdentifier:c,expression:a,times:u,condition:l,until:m,bottomTested:f,forever:p,event:d,from:y,elseBranch:g}=o;return o.run=v=>N([a?.ev(v),y?.ev(v)],([C,S])=>{let R=Qo(C)??(g?[][Symbol.iterator]():void 0),I=0,A=!1,M=!1;if(d){let L=S||v.me;Q(L)&&L.addEventListener(d,()=>M=!0,{once:!0})}let q=()=>!A&&g?E(j(g,v),L=>({signal:re(L)})):{signal:void 0},b=L=>{let G=I++;A=!0,C&&i?v.result=v.locals[i]=L:v.result=G,c&&(v.locals[c]=G);let X=v.meta.template;if(X&&C){let pe=`${i}_${r}`;X.loops[pe]??={identifier:i,indexIdentifier:c,source:C},X.out.push(`<!--hs-scope:${pe}:${G}-->`)}return E(j(s,v),pe=>{let en=w(pe,"k");if(en==="break")return{signal:void 0};if(en==="return")return{signal:re(pe)};if(d)return new Promise(lo=>setTimeout(lo,0))})};return E(fr(()=>N([l?.ev(v),u?.ev(v)],([L,G])=>f&&I===0||p?b(void 0):m?(d?!M:L!==!0)?b(void 0):q():l?L?b(void 0):q():G?I<T(G)?b(void 0):q():R?E(R.next(),X=>w(X,"done")?q():b(w(X,"value"))):q())),L=>re(w(L,"signal")))}),o}}function pr(t){for(let e of["break","continue"]){let n={k:e};t.commands[e]=(r,o,s)=>({type:`${e}Command`,start:s,end:r.endPos(),run:()=>n})}}function hr(t){t.commands.tell=(e,n,r)=>{let o=h(e),s=D(e);e.hasMore()&&!e.featureStart(e.cur())&&e.req("end");let i=(a,u,l)=>{for(;l<u.length;l++){a.you=u[l];let m=j(s,a);if(J(m))return m.then(f=>re(f)??i(a,u,l+1));if(m)return m}};return{type:"tellCommand",value:o,body:s,start:r,end:e.endPos(),run:a=>E(o.ev(a),u=>{let l=u==null?[]:Array.isArray(u)?u:u instanceof NodeList?Array.from(u):[u],m=a.you;return E(i(a,l,0),f=>(a.you=m,re(f)))})}}}function Ht(t,e){let n;if(typeof e=="string"){let u=document.createElement("template");u.innerHTML=e,n=u.content}else if(e instanceof DocumentFragment)n=e;else if(e instanceof Element)n=document.createDocumentFragment(),n.append(e.cloneNode(!0));else throw new Error("morph requires an HTML string, element, or document fragment");let r=n.firstElementChild;r&&!r.nextElementSibling&&r.tagName===t.tagName&&(br(t,r),n=r);let o=[...t.matches("[id]")?[t]:[],...t.querySelectorAll("[id]")],s=[...n.querySelectorAll("[id]")],i=Yo(o,s),c=new Map;wr(c,i,t.parentElement,o),wr(c,i,n,s);let a=document.createElement("div");a.hidden=!0,(document.body??t.parentElement)?.after(a),vr({target:t,ids:c,persistent:i,pantry:a,futureMatches:new WeakSet},t,n),xe(a),a.remove()}function vr(t,e,n){e instanceof HTMLTemplateElement&&n instanceof HTMLTemplateElement&&(e=e.content,n=n.content);let r=e.firstChild,o=n.firstChild;for(;o;){let s=o,i=r&&Jo(t,s,r);if(i&&i!==r)for(let c=r;c&&c!==i;){let a=c;c=c.nextSibling,a instanceof Element&&(t.ids.has(a)||Er(t,a,s))?Gt(e,a,null):gr(t,a)}if(!i&&s instanceof Element&&t.persistent.has(s.id)){let c=`[id="${CSS.escape(s.id)}"]`,a=t.target.id===s.id?t.target:t.target.querySelector(c)??t.pantry.querySelector(c);if(a){for(let u=a.parentNode;u;u=u.parentNode){let l=t.ids.get(u);l?.delete(a.id),l?.size===0&&t.ids.delete(u)}Gt(e,a,r),i=a}}if(o=s.nextSibling,i&&s instanceof Element)yr(t,i,s),r=i.nextSibling;else if(s instanceof Element&&t.ids.has(s)){let c=document.createElement(s.tagName);e.insertBefore(c,r),yr(t,c,s),r=c.nextSibling}else e.insertBefore(s,r),s instanceof Element&&fe(s),r=s.nextSibling}for(;r;){let s=r;r=r.nextSibling,gr(t,s)}}function yr(t,e,n){e instanceof Element&&(br(e,n),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.defaultValue!==n.defaultValue&&(e.value=n.value),(!e.isEqualNode(n)||n.tagName==="TEMPLATE"||n.querySelector("template"))&&vr(t,e,n),fe(e))}function Jo(t,e,n){if(!(e instanceof Element))return null;let r=t.ids.get(e),o=r?.size??0;if(e.id&&!r)return null;let s=null,i=0,c=10;for(let a=n;a;a=a.nextSibling){let u=t.ids.get(a);if(Ko(a,e)){if(u&&r&&[...u].some(l=>r.has(l)))return a;if(!u){if(c>0&&a.isEqualNode(e))return a;s??=a}}if(i+=u?.size??0,i>o||a.contains(document.activeElement)||--c<1&&o===0)break}return s&&Er(t,s,e)?null:s}function Er(t,e,n){if(t.futureMatches.has(e))return!0;let r=n.nextSibling;for(let o=0;r&&o<10;r=r.nextSibling,o++)if(r instanceof Element&&e.isEqualNode(r))return t.futureMatches.add(e),!0;return!1}function gr(t,e){t.ids.has(e)?Gt(t.pantry,e,null):(e instanceof Element&&xe(e),e.remove())}function Gt(t,e,n){let r=w(t,"moveBefore");if(H(r))try{Reflect.apply(r,t,[e,n]);return}catch{}t.insertBefore(e,n)}function br(t,e){for(let{name:n,value:r}of e.attributes)t.getAttribute(n)!==r&&(t.setAttribute(n,r),n==="value"&&t instanceof HTMLInputElement&&t.type!=="file"&&(t.value=r));for(let{name:n}of[...t.attributes])e.hasAttribute(n)||t.removeAttribute(n)}function Ko(t,e){return!(t instanceof Element)||t.tagName!==e.tagName||t.tagName==="SCRIPT"&&!t.isEqualNode(e)?!1:!t.id||t.id===e.id}function Yo(t,e){let n=new Set,r=new Map;for(let{id:s,tagName:i}of t)r.has(s)?n.add(s):s&&r.set(s,i);let o=new Set;for(let{id:s,tagName:i}of e)o.has(s)?n.add(s):r.get(s)===i&&o.add(s);for(let s of n)o.delete(s);return o}function wr(t,e,n,r){for(let o of r)if(e.has(o.id))for(let s=o;s&&s!==n;s=s.parentElement){let i=t.get(s);i||t.set(s,i=new Set),i.add(o.id)}}function xr(t){t.commands.morph=(e,n,r)=>{let o=h(e);e.req("to");let s=h(e);return{type:"morphCommand",target:o,content:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s.ev(c)],([a,u])=>{O(a,l=>{l instanceof Element&&Ht(l,u)})})}}}function kr(t){t.commands.log=(e,n,r)=>{let o=[h(e)];for(;e.matchOp(",");)o.push(h(e));let s=e.match("with")?h(e):void 0;return{type:"logCommand",values:o,logger:s,start:r,end:e.endPos(),run:c=>N([s?.ev(c),...o.map(a=>a.ev(c))],([a,...u])=>{H(a)?a(...u):console.log(...u)})}}}function Nr(t){t.commands.get=t.commands.call=(e,n,r)=>{let o=h(e);return n==="call"&&o.type!=="functionCall"&&e.err("Must be a function invocation"),{type:"getCommand",value:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{i.result=c})}}}function Tr(t){t.pseudo=(e,n)=>{let r=e.tok(1);if(!(r.op&&(r.value==="."||r.value==="(")))return;let o=ut(e);o.type!=="functionCall"&&e.err("Pseudo-commands must be function calls");let s=o.root,i="args"in o&&Array.isArray(o.args)?o.args:[],c;s&&!s.root&&(e.matchAny("the","to","on","with","into","from","at")?c=h(e):e.match("me")&&(c=U(e)));let a=s?.name??"",u=c?e.text(c):"",l=e.text(o),m=c;return{type:"pseudoCommand",value:o,target:c,start:n,end:e.endPos(),run:p=>m?N([m.ev(p),...i.map(d=>d.ev(p))],([d,...y])=>{F(d,u),p.result=ct(w(d,a),d,y,p,l),Ye(d,a)}):E(o.ev(p),d=>{p.result=d})}}}function Cr(t){t.commands.ask=(e,n,r)=>{let o=h(e);return{type:"askCommand",message:o,start:r,end:e.endPos(),run:i=>E(o.ev(i),c=>{i.result=prompt(String(c))})}},t.commands.answer=(e,n,r)=>{let o=h(e),s;if(e.match("with")){let c=e.withFollow(["or"],()=>h(e));e.req("or"),s=[c,h(e)]}return{type:"answerCommand",message:o,choices:s,start:r,end:e.endPos(),run:c=>N([o.ev(c),s?.[0].ev(c),s?.[1].ev(c)],([a,u,l])=>{s?c.result=confirm(String(a))?u:l:alert(String(a))})}}}function Sr(t){t.commands.breakpoint=(e,n,r)=>({type:"breakpointCommand",start:r,end:e.endPos(),run:()=>{debugger}})}var $t=(t,e,n)=>{let r=w(t,"slice");return H(r)?Reflect.apply(r,t,[e,n]):void 0},Xo=(t,e,n)=>({*[Symbol.iterator](){let r=new RegExp(t instanceof RegExp?t:String(t),e);for(let o=r.exec(n);o;o=r.exec(n))o[0].length===0&&r.lastIndex++,yield o}});function Pr(t){t.commands.pick=(e,n,r)=>{e.match("the");let o=e.matchAny("first","last","random","match","matches")??e.matchAny("item","items","character","characters");if(!o)return;let s=o.value==="first"||o.value==="last"||o.value==="random"||o.value==="match"||o.value==="matches"?o.value:"range",i={};(s==="match"||s==="matches")&&e.match("of"),e.withFollow(["of","from"],()=>{if(s==="first"||s==="last")i.count=h(e);else if(s==="random")e.cur().type==="NUMBER"&&(i.count=h(e));else if(s==="range")e.match("at")||e.match("from"),e.match("start")||(i.from=h(e)),(e.match("to")||e.matchOp(".."))&&(e.match("end")?i.toEnd=!0:i.to=h(e)),e.match("inclusive")?i.bounds="inclusive":e.match("exclusive")&&(i.bounds="exclusive");else{i.re=h(e);let g=e.matchOp("|")?e.reqType("IDENTIFIER").value:void 0;i.flags=s==="match"?g??"":g===void 0?"gu":"g"+g.replace("g","")}}),e.matchAny("of","from")||e.expected("of","from");let c=h(e),{count:a,from:u,to:l,toEnd:m,bounds:f,re:p,flags:d=""}=i;return{type:"pickCommand",variant:s,root:c,...i,start:r,end:e.endPos(),run:g=>N([c.ev(g),a?.ev(g),u?.ev(g),l?.ev(g),p?.ev(g)],([v,C,S,R,I])=>{if(v==null)g.result=v;else if(s==="first")g.result=$t(v,0,T(C));else if(s==="last")g.result=$t(v,-T(C));else if(s==="random"){let A=K(v)?Array.from(v):[],M=()=>A.splice(Math.floor(Math.random()*A.length),1)[0];g.result=C==null?M():Array.from({length:Math.min(T(C),A.length)},M)}else if(s==="range"){let A=T(S??0)+(f==="exclusive"?1:0),M=m?T(w(v,"length")):R==null?void 0:T(R),q=M===void 0?A+1:M+(f==="inclusive"?1:0);g.result=$t(v,A,q)}else s==="match"?g.result=new RegExp(I instanceof RegExp?I:String(I),d).exec(String(v)):g.result=Xo(I,d,String(v))})}}}var Zo={json:"json",JSON:"json",Object:"json",response:"response",Response:"response",html:"html",HTML:"html",text:"text",Text:"text",String:"text"};function Rr(t){t.commands.fetch=(e,n,r)=>{let o=e.withFollow(["as"],()=>Lt(e)),s=()=>{if(!e.match("as"))return;e.match("a")||e.match("an");let m=Se(e)??e.err("Expected dotOrColonPath");return Zo[m]??":"+m},i=s(),c;e.match("with")&&e.cur().value!=="{"?c=He(e):e.cur().op&&e.cur().value==="{"&&(c=Ge(e)),i??=s()??"text";let a=!1;e.match("do")?(e.req("not"),e.req("throw"),a=!0):e.cur().value==="don"&&e.tok(1,!0).value==="'"&&e.tok(2,!0).value==="t"&&(e.consume(),e.consume(),e.consume(),e.req("throw"),a=!0);let u=i;return{type:"fetchCommand",url:o,options:c,as:u,dontThrow:a,start:r,end:e.endPos(),run:m=>N([o.ev(m),c?.ev(m)],([f,p])=>{let d=m.me,y=W(p)?p:{};y.headers||={},y.conversion=u.startsWith(":")?u.slice(1):u;let g=new AbortController,v=()=>g.abort();Q(d)&&d.addEventListener("fetch:abort",v,{once:!0}),y.signal=g.signal,_(d,"hyperscript:beforeFetch",y,d),_(d,"fetch:beforeRequest",y,d);let C=!1;y.timeout&&setTimeout(()=>C||v(),T(y.timeout));let S=I=>{m.result=I,_(d,"fetch:afterRequest",{result:I}),C=!0},R=Reflect.apply(fetch,globalThis,[f,y]);return Promise.resolve(R).then(I=>{let A={response:I};_(d,"fetch:afterResponse",A);let M=A.response;if(!(M instanceof Response))throw new Error("fetch did not return a Response");if(!a&&u!=="response"&&Z.fetchThrowsOn.some(k=>k.test(String(M.status))))throw Object.assign(new Error(`fetch failed: ${M.status} ${M.statusText} (${f})`),{response:M,status:M.status});if(u==="response")return S(M);if(u==="json")return M.json().then(S);let q=u.startsWith(":")?u.slice(1):void 0,b=q?ge[q]:void 0;return b&&w(b,"_rawResponse")?S(b(M)):M.text().then(k=>S(u==="html"?ve(k):q?ot(k,q):k))}).catch(I=>{throw _(d,"fetch:error",{reason:I}),I}).finally(()=>Q(d)&&d.removeEventListener("fetch:abort",v))})}}}var es={top:"start",middle:"center",bottom:"end"},ts={left:"start",center:"center",right:"end"},Ir=t=>{let e=t.matchAny("smoothly","instantly");return e?e.value==="smoothly"?"smooth":"instant":void 0};function Or(t){t.match("the");let e=t.matchAny("top","middle","bottom"),n=t.matchAny("left","center","right");(e||n)&&t.req("of");let r=$(t),o=t.matchAnyOp("+","-"),s=o?t.withFollow(["px"],()=>h(t)):void 0;t.match("px");let i=t.match("in")?$(t):void 0,c={block:e?es[e.value]:"start",inline:n?ts[n.value]:"nearest"},a=Ir(t);return a&&(c.behavior=a),{target:r,offset:s,sign:o?.value==="-"?-1:o?1:0,options:c,container:i}}function Ar(t,e){return N([t.target.ev(e),t.offset?.ev(e),t.container?.ev(e)],([n,r,o])=>{let s=t.sign*T(r??0);O(n,i=>{let c=i===window?document.body:i;c instanceof HTMLElement&&(o instanceof HTMLElement?o.scrollTo({top:c.offsetTop-o.offsetTop+s,left:c.offsetLeft-o.offsetLeft,behavior:t.options.behavior??"auto"}):(t.sign?ns(c,s,t.options):c).scrollIntoView(t.options))})})}function ns(t,e,n){let r=t.getBoundingClientRect(),o=i=>i==="start"||i==="end"?e:0,s=document.createElement("div");return Object.assign(s.style,{position:"absolute",top:r.top+window.scrollY+o(n.block)+"px",left:r.left+window.scrollX+o(n.inline)+"px",height:r.height+"px",width:r.width+"px",zIndex:String(Number.MIN_SAFE_INTEGER),opacity:"0"}),document.body.appendChild(s),setTimeout(()=>s.remove(),100),s}function Lr(t){t.commands.scroll=(e,n,r)=>{let o={type:"scrollCommand",start:r,end:r,run:()=>{}};if(e.match("to")){let s=o.to=Or(e);o.run=i=>Ar(s,i)}else{let s=["up","down","left","right"],i=e.matchAny(...s),c;!i&&e.cur().value!=="by"&&(c=o.target=$(e),i=e.matchAny(...s)),e.req("by");let a=o.by=e.withFollow(["px"],()=>h(e));e.match("px");let u=o.behavior=Ir(e),l=o.direction=i?.value??"down";o.run=m=>N([c?.ev(m),a.ev(m)],([f,p])=>{let d=T(p)*(l==="up"||l==="left"?-1:1),y=l==="left"||l==="right",g={top:y?0:d,left:y?d:0};u&&(g.behavior=u),(x(f)?f:document.documentElement).scrollBy(g)})}return o.end=e.endPos(),o}}function Fr(t){t.commands.go=(e,n,r)=>{let o={type:"goCommand",back:!1,newWindow:!1,start:r,end:r,run:()=>{}},s=()=>e.match("in")?(e.req("new"),e.req("window"),!0):!1,i=c=>{if(c==null)return;if(x(c))return c.scrollIntoView({block:"start",inline:"nearest"});let a=String(c);a.startsWith("#")?window.location.hash=a:o.newWindow?window.open(a):window.location.href=a};if(e.match("back"))o.back=!0,o.run=()=>window.history.back();else if(e.match("to"),e.match("url")){let c=o.url=$e(e);o.newWindow=s(),o.run=()=>i(c)}else if(["the","top","middle","bottom","left","center","right"].includes(e.cur().value)){let c=o.scroll=Or(e);o.run=a=>Ar(c,a)}else{let c=o.target=Lt(e);o.newWindow=s(),o.run=a=>E(c.ev(a),i)}return o.end=e.endPos(),o}}function qr(t){t.commands.set=(e,n,r)=>Wt(e,r)}function Wt(t,e){{if(t.cur().op&&t.cur().value==="{"){let s=Ge(t);t.req("on");let i=h(t);return{type:"setCommand",target:i,object:s,start:e,end:t.endPos(),run:a=>N([s.ev(a),i.ev(a)],([u,l])=>void Object.assign(Object(l),u))}}let n=t.withFollow(["to"],()=>ie(t));t.req("to");let r=h(t);return{type:"setCommand",target:n,value:r,start:e,end:t.endPos(),run:s=>N([n.lhs?.(s),r.ev(s)],([i,c])=>n.put?.(s,i,c))}}}function _r(t){t.commands.default=(e,n,r)=>{let o=e.withFollow(["to"],()=>ie(e));e.req("to");let s=h(e);return{type:"defaultCommand",target:o,value:s,start:r,end:e.endPos(),run:c=>E(o.ev(c),a=>{if(!(a!=null&&a!==""))return N([o.lhs?.(c),s.ev(c)],([u,l])=>o.put?.(c,u,l))})}}}function jr(t){for(let e of["increment","decrement"]){let n=e==="increment"?1:-1;t.commands[e]=(r,o,s)=>{let i=r.withFollow(n<0?["by"]:[],()=>ie(r)),c=r.match("by")?h(r):void 0;return{type:`${e}Command`,target:i,amount:c,start:s,end:r.endPos(),run:u=>N([i.ev(u),c?.ev(u),i.lhs?.(u)],([l,m,f])=>{let p=(l?parseFloat(String(l)):0)+n*(c?parseFloat(String(m)):1);u.result=p,i.put?.(u,f,p)})}}}}function Mr(t,e){t.replaceChildren(ve(e)),z.process(t)}var rs=["arrayIndex","propertyAccess","possessive","ofExpression","attributeRef","styleRef","attributeRefAccess"],os={into:"into",before:"before",after:"after",start:"start",end:"end"},ss={before:"before",after:"after",start:"prepend",end:"append"};function Dr(t){t.commands.put=(e,n,r)=>{let o=h(e),s=e.matchAny("into","before","after");!s&&e.match("at")&&(e.match("the"),s=e.matchAny("start","end"),e.req("of"));let i=os[(s??e.expected("into","before","at start of","at end of","after")).value],c=je(h(e)),a=e.text(c),u=(f,p)=>c.type==="symbol"?E(c.ev(f),d=>{x(d)||d instanceof Document?Mr(d,p):c.put?.(f,void 0,p)}):rs.includes(c.type)?E(c.lhs?.(f),d=>c.put?.(f,d,p)):E(c.ev(f),d=>{F(d,a),O(d,y=>{(x(y)||y instanceof Document)&&Mr(y,p)})}),l=(f,p,d)=>E(c.ev(f),y=>{if(F(y,a),Array.isArray(y)){d==="prepend"?y.unshift(p):y.push(p),P.wroteProperty(y);return}O(y,g=>{x(g)&&(g[d](p instanceof Node?p:ve(p)),z.process(g.parentElement??g))})});return{type:"putCommand",value:o,operation:i,target:c,start:r,end:e.endPos(),run:f=>E(o.ev(f),p=>i==="into"?u(f,p):l(f,p,ss[i]))}}}var Ie=t=>K(t)?Array.from(t):Array.from(Object(t)),Gr=t=>Array.isArray(t)||t instanceof NodeList?Ie(t).map(Gr).join(""):t instanceof HTMLElement?t.outerHTML:t instanceof Node?"":String(t);function is(t){let e={},n=r=>{let o=w(r,"name"),s=w(r,"value"),i=w(r,"type");if(typeof o!="string"||s==null||i==="radio"&&!w(r,"checked")||(i==="checkbox"?s=w(r,"checked")?[s]:void 0:r instanceof HTMLSelectElement&&r.multiple&&(s=Array.from(r.selectedOptions,a=>a.value)),s===void 0))return;let c=e[o];e[o]=c===void 0?s:(Array.isArray(c)?c:[c]).concat(s)};return O(t,r=>{w(r,"name")!=null&&w(r,"value")!=null?n(r):r instanceof Element&&r.querySelectorAll("input,select,textarea").forEach(n)}),e}function Hr(t){Object.assign(ge,{Boolean:e=>!!e,Date:e=>typeof e=="number"||e instanceof Date?new Date(e):new Date(String(e)),Array:Ie,JSON:e=>e instanceof Response?e.json():JSON.parse(String(e)),JSONString:e=>JSON.stringify(e),Object:e=>typeof e=="string"||e instanceof String?JSON.parse(String(e)):{...Object(e)},FormEncoded:e=>new URLSearchParams(Object(e)).toString(),Set:e=>new Set(Ie(e)),Map:e=>new Map(Object.entries(Object(e))),Keys:e=>e instanceof Map?Array.from(e.keys()):Object.keys(Object(e)),Entries:e=>e instanceof Map?Array.from(e.entries()):Object.entries(Object(e)),Reversed:e=>Ie(e).reverse(),Unique:e=>[...new Set(Ie(e))],Flat:e=>Ie(e).flat(),HTML:Gr}),Me.push((e,n)=>{if(e==="Fixed"||e.startsWith("Fixed:"))return Number(n).toFixed(parseInt(e.split(":")[1])||0)},(e,n)=>e==="Values"?is(n):void 0)}var $r="=;expires=Thu, 01 Jan 1970 00:00:00 GMT",Ve=()=>document.cookie?document.cookie.split("; ").map(t=>{let e=t.indexOf("=");return{name:t.slice(0,e),value:decodeURIComponent(t.slice(e+1))}}):[],as=new Proxy({},{get(t,e){if(e===Symbol.iterator){let n=Ve();return n[Symbol.iterator].bind(n)}if(!(typeof e!="string"||e==="then"))return e==="length"?Ve().length:e==="clear"?n=>void(document.cookie=n+$r):e==="clearAll"?()=>Ve().forEach(n=>document.cookie=n.name+$r):e!==""&&!Number.isNaN(Number(e))?Ve()[parseInt(e)]:Ve().find(n=>n.name===e)?.value},set(t,e,n){let r=[];if(typeof n=="string")r.push(encodeURIComponent(n),"samesite=lax");else{r.push(encodeURIComponent(String(w(n,"value"))));let o=(s,i)=>{let c=w(n,s);c&&r.push(`${i}=${c}`)};o("expires","expires"),o("maxAge","max-age"),o("partitioned","partitioned"),o("path","path"),o("samesite","samesite"),w(n,"secure")&&r.push("secure")}return document.cookie=String(e)+"="+r.join(";"),!0}});function Wr(t){xt.cookies=as}var Bt=t=>K(t)?Array.from(t):[];function cs(t){let e=t.pos(),n=t.matchAny("first","last","random");if(!n)return;t.matchAny("in","from","of");let r=$(t),o=n.value;return{type:"positionalExpression",operator:o,root:r,start:e,end:t.endPos(),ev:i=>E(r.ev(i),c=>{if(!c)return;let a=Array.isArray(c)?c:Bt(w(c,"children")??c),u=o==="first"?0:o==="last"?a.length-1:Math.floor(Math.random()*a.length);return a[u]})}}function us(t){let e=t.pos(),n=t.matchAny("next","previous");if(!n)return;let r=n.value==="next",o=At(t)??t.err("Expected leaf"),s=t.match("from")?t.withFollow(["in"],()=>$(t)):U(t),i=t.match("in")?$(t):void 0,c=!i&&t.match("within")?$(t):void 0,a=!!t.match("with");a&&t.req("wrapping");let u=t.text(o),l=(p,d,y)=>{let g=d instanceof Element||d instanceof Document?d:document.body,v=Array.from(g.querySelectorAll(y));if(!(p instanceof Node))return;let C=r?Node.DOCUMENT_POSITION_PRECEDING:Node.DOCUMENT_POSITION_FOLLOWING,S=r?v:v.reverse();return S.find(R=>R.compareDocumentPosition(p)===C)??(a?S[0]:void 0)},m=(p,d,y)=>{let g=Bt(d).filter(R=>R===p||x(R)&&R.matches(y)),v=r?g:g.reverse(),C=v[v.indexOf(p)+1];if(v.includes(p)&&C!==void 0)return C;let S=v[0];return a&&x(S)&&S.matches(y)?S:void 0};return{type:"relativePositionalExpression",operator:n.value,thing:o,from:s,inElt:i,withinElt:c,wrapping:a,start:e,end:t.endPos(),ev:p=>N([o.ev(p),s.ev(p),i?.ev(p),c?.ev(p)],([d,y,g,v])=>{let C=w(d,"css");if(typeof C!="string")throw new Error("Expected a CSS value to be returned by "+u);return i?g&&m(y,g,C):l(y,v,C)})}}function ls(t){let e=t.pos();if(!t.match("closest"))return;let n=!!t.match("parent"),r=t.cur().type==="ATTRIBUTE_REF"?Y(t):void 0,o=r?`[${r.name}]`:$(t).css??t.err("Expected a CSS expression"),s=t.match("to")?h(t):U(t),i={type:"closestExpr",css:o,parentSearch:n,to:s,start:e,end:t.endPos(),ev:c=>E(s.ev(c),a=>{if(a==null)return null;let u=[];return O(a,l=>{let m=n?w(l,"parentElement"):l;u.push(x(m)?m.closest(o):null)}),Ne(a)?u:u[0]}),lhs:c=>i.ev(c),put:(c,a,u)=>{a&&Ee(a,u)}};return r?Mt(t,i,r):i}var Br=["where","sorted","mapped","split","joined"];function ds(t,e){let n=t.matchAny(...Br);if(!n)return;let r=n.value;r==="mapped"?t.req("to"):r!=="where"&&t.req("by");let o=t.withFollow(Br,()=>h(t)),s=r==="sorted"&&!!t.match("descending"),i=(u,l)=>{let m=l.map(f=>(u.beingTested=f,a.varName&&(u.locals[a.varName]=f),o.ev(u)));return u.beingTested=null,m},c=(u,l)=>{if(!l)return l;if(r==="split")return E(o.ev(u),d=>String(l).split(String(d)));let m=Bt(l);if(r==="joined")return E(o.ev(u),d=>m.join(String(d)));let f=i(u,m);if(r==="where")return m.filter((d,y)=>f[y]);if(r==="mapped")return f;let p=s?-1:1;return m.map((d,y)=>y).sort((d,y)=>f[d]==f[y]?0:(T(f[d])<T(f[y])?-1:1)*p).map(d=>m[d])},a={type:"collectionExpression",operator:r==="where"||r==="sorted"||r==="mapped"||r==="split"?r:"joined",root:e,operand:o,descending:s,start:e.start,end:t.endPos(),ev:u=>E(e.ev(u),l=>c(u,l))};return a}function fs(t){let e=t.pos();if(!t.matchOp("\\"))return;let n=[],r=t.matchType("IDENTIFIER");if(r)for(n.push(r.value);t.matchOp(",");)n.push(t.reqType("IDENTIFIER").value);t.reqOp("-"),t.reqOp(">");let o=h(t);return{type:"blockLiteral",params:n,expr:o,start:e,end:t.endPos(),ev:i=>(...c)=>(n.forEach((a,u)=>i.locals[a]=c[u]),o.ev(i))}}function ms(t){let e=t.pos();if(t.match("some"))return Ce(t,"some",e,h(t),n=>!_e(n),!1)}function ps(t,e){if(!t.matchOp(":"))return;let n=t.reqType("IDENTIFIER").value,r=!t.matchOp("!");return{type:"typeCheckExpression",root:e,suffix:n,start:e.start,end:t.endPos(),ev:s=>E(e.ev(s),i=>{if(rt(i,n,r))return i;throw new Error("Typecheck failed! Expected: "+n)})}}function Ur(t,e,n,r){if(_(t.me,"hyperscript:beep",{element:t.me,expression:e,value:r})){let o=r==null?"object (null)":w(w(r,"constructor"),"name")??"unknown",s=typeof r=="string"?`"${r}"`:Ne(r)?Array.from(r):r;console.log(`///_ BEEP! The expression (${n}) evaluates to:`,s,"of type "+o)}}function hs(t){let e=t.pos();if(!t.match("beep!"))return;let n=$(t),r=t.text(n);return Ce(t,"beepExpression",e,n,(o,s)=>(Ur(s,n,r,o),o),!1)}function ys(t,e,n){let r=[h(t)];for(;t.matchOp(",");)r.push(h(t));let o=r.map(s=>t.text(s));return{type:"beepCommand",values:r,start:n,end:t.endPos(),run:s=>N(r.map(i=>i.ev(s)),i=>i.forEach((c,a)=>Ur(s,r[a],o[a],c)))}}function Vr(t){t.leaves.push(ls,ms,fs),t.unaries.push(hs,us,cs),t.commands["beep!"]=ys,t.postfixes.push(ps),t.collections.push(ds)}var Ut=t=>Se(t)??t.err("Expected dotOrColonPath");function zr(t){t.features.def=(e,n)=>{let r=Ut(e),o=r.split("."),s=o.pop()??r,i=[];if(e.matchOp("(")&&!e.matchOp(")")){do i.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let c=D(e),a={type:"defFeature",name:r,displayName:`${s}(${i.join(", ")})`,params:i,body:c,...ft(e),start:n,end:e.endPos(),install:(u,l)=>{kt(u,o,s,Object.assign((...f)=>{let p=B(l,a,u,null);i.forEach((y,g)=>p.locals[y]=f[g]);let d=E(it(p,c,a),y=>w(y,"value"));return J(d)&&a.finallyHandler?d.then(void 0,()=>{}):d},{hyperfunc:!0,hypername:r}))}};return a}}function Qr(t){t.features.init=(e,n)=>{let r=!!e.match("immediately"),o=D(e),s={type:"initFeature",body:o,immediately:r,start:n,end:e.endPos(),install:i=>{let c=()=>void j(o,B(i,s,i,null));r?c():queueMicrotask(c)}};return s}}function Jr(t){t.features.behavior=(e,n)=>{let r=Ut(e),o=r.split("."),s=o.pop()??r,i=[];if(e.matchOp("(")&&!e.matchOp(")")){do i.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}let c=We(e).features;for(let u of c)u.behavior=r;return{type:"behaviorFeature",name:r,params:i,features:c,start:n,end:e.endPos(),install:()=>kt(null,o,s,(u,l,m)=>{if(W(u))for(let f of i)Te(u,r+"Scope")[f]=w(m,f);for(let f of c)f.install(u,l)})}}}function Kr(t){t.features.install=(e,n)=>{let r=Ut(e),o=lt(e),s={type:"installFeature",name:r,args:o,start:n,end:e.endPos(),install:(i,c)=>{let a=globalThis;for(let u of r.split("."))if(a=w(a,u),typeof a!="object"&&typeof a!="function")throw new Error("No such behavior defined as "+r);if(!H(a))throw new Error(r+" is not a behavior");a(i,c,o?.ev(B(i,s,i,null)))}};return s}}function Yr(t){t.features.set=(e,n)=>{let r=Wt(e,n);"scope"in r.target&&r.target.scope==="local"&&e.err("variables declared at the feature level cannot be locally scoped (use :foo, ^foo, $foo, or an @attribute target instead).");let o={type:"setFeature",command:r,start:n,end:e.endPos(),install:s=>queueMicrotask(()=>void r.run(B(s,o,s,null)))};return o}}function gs(t,e){if(typeof t!="object"||t===null)return{queue:[],executing:!1};let n=V(t).eventQueues??=new Map,r=n.get(e);return r||n.set(e,r={queue:[],executing:!1}),r}function Vt(t,e){let n=gs(t.me,e);if(n.executing&&!e.every){if(e.queue==="none"||e.queue==="first"&&n.queue.length>0)return;e.queue!=="all"&&(n.queue.length=0),n.queue.push(t);return}n.executing=!0;let r=o=>{n.executing=!1;let s=n.queue.shift();if(s&&setTimeout(()=>Vt(s,e),1),o){let{error:i}=o;console.error(w(i,"message")??i),console.error(w(i,"stack")),_(t.me,"exception",{error:i})}};ye(()=>E(it(t,e.body,e),()=>r()),o=>r({error:o}))}function ws(t,e){if(!Q(e))return;let n=V(e),r=n.listeners??=[],o=n.observers??=[],s=n.timers??=new Set;for(let i of t.events){let c={execCount:0},a=i.elsewhere?[document]:i.from?i.from.ev(B(e,t,e,null)):[e];O(a,u=>{if(!Q(u)){console.warn("'%s' feature ignored because target does not exists:",t.displayName,e);return}let l=i.on;if(i.mutationSpec&&u instanceof Node){l="hyperscript:mutation";let f=new MutationObserver(p=>_(u,l,{mutationList:p,observer:f}));f.observe(u,i.mutationSpec),o.push(f)}if(i.intersectionSpec&&u instanceof Element){l="hyperscript:intersection";let f=new IntersectionObserver(p=>{for(let d of p)_(u,l,{observer:f,entry:d,intersecting:d.isIntersecting,isIntersecting:d.isIntersecting,intersectionRatio:d.intersectionRatio})},i.intersectionSpec);f.observe(u),o.push(f)}if(i.resizeSpec&&u instanceof Element){l="hyperscript:resize";let f=new ResizeObserver(p=>{for(let d of p){let{width:y,height:g}=d.contentRect;_(u,l,{width:y,height:g,contentRect:d.contentRect,entry:d})}});f.observe(u),o.push(f)}let m=f=>{if(e instanceof Node&&u!==e&&!e.isConnected){u.removeEventListener(l,m);return}let p=B(e,t,e,f);if(!(i.elsewhere&&e instanceof Node&&f.target instanceof Node&&e.contains(f.target))){i.from&&(p.result=u);for(let d of i.args){let y=w(f,d);y!==void 0?p.locals[d]=y:p.detail!=null&&(p.locals[d]=w(p.detail,d))}if(i.filter){p.meta.context=f;try{if(!i.filter.ev(p))return}finally{p.meta.context=void 0}}if(i.inExpr?.css){let d=f.target instanceof Element?f.target:null;for(;d&&!d.matches(i.inExpr.css);)d=d.parentElement;if(!d)return;p.result=d}if(c.execCount++,i.startCount){let d=c.execCount;if(i.endCount?d<i.startCount||d>i.endCount:i.unbounded?d<i.startCount:d!==i.startCount)return}if(i.debounceTime){c.debounced&&(clearTimeout(c.debounced),s.delete(c.debounced)),s.add(c.debounced=setTimeout(()=>Vt(p,t),i.debounceTime));return}if(i.throttleTime){if(c.lastExec&&Date.now()<c.lastExec+i.throttleTime)return;c.lastExec=Date.now()}Vt(p,t)}};u.addEventListener(l,m),r.push({target:u,event:l,handler:m})})}}function vs(t){if(!t.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let e={};do if(t.match("anything"))Object.assign(e,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(t.match("childList"))e.childList=!0;else if(t.match("attributes"))e.attributes=!0;else if(t.match("subtree"))e.subtree=!0;else if(t.match("characterData"))e.characterData=!0;else if(t.cur().type==="ATTRIBUTE_REF"){let n=t.consume().value;n.startsWith("@")||t.err("Only shorthand attribute references are allowed here"),(e.attributeFilter??=[]).push(n.substring(1))}else t.err("Unknown mutation config specification");while(t.match("or"));return(e.attributes||e.attributeFilter)&&(e.attributeOldValue=!0),e.characterData&&(e.characterDataOldValue=!0),e}function Es(t){let e={};if(t.match("with")){let n=De(h(t));n instanceof Element&&(e.root=n)}if(t.match("having"))do t.match("margin")?e.rootMargin=$e(t):t.match("threshold")?e.threshold=Number(De(h(t))):t.err("Unknown intersection config specification");while(t.match("and"));return e}function bs(t,e){let n=ae(t),r=mt(t),o;t.matchOp("[")&&(o=h(t),t.reqOp("]"));let s,i,c=!1;e?s=1:t.cur().type==="NUMBER"&&(s=parseInt(t.consume().value),t.match("to")?i=parseInt(t.consume().value):t.match("and")&&(c=!0,t.req("on")));let a={on:n,args:r,filter:o,startCount:s,endCount:i,unbounded:c,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=Es(t):n==="mutation"&&(a.mutationSpec=vs(t)),t.match("from")&&(t.match("elsewhere")?a.elsewhere=!0:a.from=t.withFollow(["or"],()=>h(t))),!a.from&&!a.elsewhere&&t.match("elsewhere")&&(a.elsewhere=!0),t.match("in")&&(a.inExpr=$(t));let u=()=>(t.req("at"),Number(De($(t))));return t.match("debounced")?a.debounceTime=u():t.match("throttled")&&(a.throttleTime=u()),a}function Xr(t){t.features.on=(e,n)=>{let r=!!e.match("every"),o=!r&&!!e.match("first"),s=[];do s.push(bs(e,o));while(e.match("or"));let i="last";!r&&e.match("queue")&&(e.match("all")?i="all":e.match("first")?i="first":e.match("none")?i="none":e.req("last"));let c=D(e),a={type:"onFeature",displayName:"on "+s.map(u=>u.on).join(" or "),events:s,body:c,every:r,queue:i,...ft(e),start:n,end:e.endPos(),install:u=>ws(a,u)};return a}}var Ae=new WeakMap,to=new Map,Jt=new Map,wt=new Map,Kt=new Map,ze=new Set,Qe=new WeakMap,xs=0,me,zt=!1;function ke(t){let e=Ae.get(t);return e||Ae.set(t,e={id:++xs}),e}var ht=t=>typeof t=="object"&&t!==null;function ks(t,e){let n=me;me=t,P.tracking=!0;try{return e()}finally{me=n,P.tracking=n!==void 0}}var Qt=class{constructor(e,n,r){this.expression=e;this.handler=n;this.element=r}dependencies=new Map;stopped=!1;last;triggers=0;evaluate(){try{return this.next=ks(this,this.expression),!0}catch(e){return console.error("Error in reactive expression:",e),!1}}next;handle(e){try{this.handler(e)}catch(n){console.error("Error in reactive handler:",n)}}initialize(){this.evaluate()&&(this.last=this.next),Zr(this),this.last!=null&&this.handle(this.last)}run(){if(++this.triggers>100){console.error("Reactivity loop detected: an effect triggered 100 consecutive times without settling. This usually means an effect is modifying a variable it also depends on.",this.element??this);return}eo(this);let e=this.dependencies;this.dependencies=new Map;let n=this.evaluate();n||(this.dependencies=e),Zr(this),n&&!Object.is(this.next,this.last)&&(this.last=this.next,this.handle(this.next))}settled(){this.triggers=0}stop(){this.stopped||(this.stopped=!0,eo(this),ze.delete(this))}};function Ns(t){t.stopped||(ze.add(t),!zt&&(zt=!0,queueMicrotask(()=>{zt=!1;let e=Array.from(ze);ze.clear();for(let n of e)n.stopped||(n.element&&!n.element.isConnected?n.stop():n.run());if(ze.size===0)for(let n of e)n.settled()})))}var Oe=t=>t?.forEach(Ns);function no(t){for(let[e,n]of Kt)for(let r of t)if(e.contains(r)){Oe(n);break}}var yt;function Ts(){yt??=new MutationObserver(t=>{let e=new Set;for(let n of t){if(n.type==="attributes"){let r=Ae.get(n.target);r&&Oe(Jt.get(`${n.attributeName}:${r.id}`))}e.add(n.target)}no(e)}),yt.observe(document,{attributes:!0,childList:!0,subtree:!0}),document.addEventListener("input",gt,!0),document.addEventListener("change",gt,!0)}function gt(t){let e=t.target;if(!(e instanceof Element))return;let n=Ae.get(e);n&&Oe(wt.get(n.id)),no([e])}function Cs(t,e,n){let r=t.get(e);r||t.set(e,r=new Set),r.add(n)}function Ss(t,e,n){let r=t.get(e);r?.delete(n),r?.size===0&&t.delete(e)}function ro(t,e){let n=!1;for(let r of t.dependencies.values())r.type==="global"?e(to,r.name,t):r.type==="element"?e(ke(r.element).symbols??=new Map,r.name,t):(n=!0,r.type==="query"?e(Kt,r.root,t):r.type==="property"?e(wt,ke(r.object).id,t):e(Jt,`${r.name}:${ke(r.element).id}`,t));return n}function Zr(t){ro(t,Cs)&&Ts()}function eo(t){ro(t,Ss),yt&&!Jt.size&&!wt.size&&!Kt.size&&(yt.disconnect(),document.removeEventListener("input",gt,!0),document.removeEventListener("change",gt,!0))}function Le(t,e,n){let r=new Qt(t,e,n);return r.initialize(),n&&(Qe.has(n)||Qe.set(n,new Set),Qe.get(n)?.add(r)),()=>r.stop()}function Ps(){P.readGlobal=t=>void me?.dependencies.set("symbol:global:"+t,{type:"global",name:t}),P.readElement=(t,e)=>{ht(e)&&me?.dependencies.set(`symbol:element:${t}:${ke(e).id}`,{type:"element",name:t,element:e})},P.readProperty=t=>{ht(t)&&!w(t,"_hsSkipTracking")&&me?.dependencies.set("property:"+ke(t).id,{type:"property",object:t})},P.readAttribute=(t,e)=>{x(t)&&me?.dependencies.set(`attribute:${e}:${ke(t).id}`,{type:"attribute",name:e,element:t})},P.wroteGlobal=t=>Oe(to.get(t)),P.wroteElement=(t,e)=>{ht(e)&&Oe(Ae.get(e)?.symbols?.get(t))},P.readQuery=t=>void me?.dependencies.set("query:"+ke(t).id,{type:"query",root:t}),P.wroteProperty=t=>{let e=ht(t)&&!w(t,"_hsSkipTracking")&&Ae.get(t);e&&Oe(wt.get(e.id))},P.stop=t=>{Qe.get(t)?.forEach(e=>e.stop()),Qe.delete(t)}}var Rs=t=>e=>{console.error(w(e,"message")??e),_(t,"exception",{error:e})};function Is(t){t.features.when=(e,n)=>{let r=[];do r.push(e.withFollow(["or"],()=>h(e)));while(e.match("or"));for(let i of r)i.type==="symbol"&&"scope"in i&&i.scope==="local"&&i.name&&e.err(`Cannot watch local variable '${i.name}'. Local variables are not reactive. Use '$${i.name}' (global) or ':${i.name}' (element-scoped) instead.`);e.req("changes");let o=D(e),s={type:"whenFeature",displayName:"when ... changes",watched:r,body:o,start:n,end:e.endPos(),install:i=>queueMicrotask(()=>{let c=()=>B(i,s,i,null);for(let a of r)Le(()=>a.ev(c()),u=>{let l=c();l.result=u,ye(()=>E(j(o,l),()=>{}),Rs(i))},x(i)?i:void 0)})};return s}}function Os(t){t.features.live=(e,n)=>{let r=D(e),o={type:"liveFeature",displayName:"live",body:r,start:n,end:e.endPos(),install:s=>queueMicrotask(()=>Le(()=>void j(r,B(s,o,s,null)),()=>{},x(s)?s:void 0))};return o}}function As(t){if(t instanceof HTMLInputElement){let n=t.getAttribute("type")??"text";return n==="checkbox"?"checked":n==="number"||n==="range"?"valueAsNumber":"value"}if(t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)return"value";let e=t.getAttribute("contenteditable");if(e!==null&&e!=="false")return"textContent";if(t.tagName.includes("-")&&"value"in t)return"value";throw new Error(`bind cannot auto-detect a property for <${t.tagName.toLowerCase()}>. Use an explicit property (e.g. 'bind $var to #el's value').`)}function Ls(t){if(t instanceof HTMLInputElement&&t.type==="radio")return{element:t,writable:!0,read:()=>ue(t,"checked")?t.value:void 0,write:n=>t.checked=n===t.value};let e=As(t);return{element:t,writable:!0,read:()=>{let n=ue(t,e);return e==="valueAsNumber"&&Number.isNaN(n)?null:n},write:n=>void Reflect.set(t,e,n)}}function Fs(t,e,n){let r=e.you||e.me;if(t.type==="classRef"&&"className"in t&&typeof t.className=="string")x(r)&&r.classList.toggle(t.className,!!n);else if(t.type==="attributeRef"&&typeof n=="boolean"&&t.name){if(!x(r))return;t.name.startsWith("aria-")?r.setAttribute(t.name,String(n)):r.toggleAttribute(t.name,n)}else E(t.lhs?.(e),o=>t.put?.(e,o,n))}function Ms(t,e,n){let r=()=>B(e,n,e,null);if(t.type==="classRef"&&"className"in t&&typeof t.className=="string"){let o=t.className;return{writable:!0,read:()=>(we(e,"class"),x(e)&&e.classList.contains(o)),write:s=>void(x(e)&&e.classList.toggle(o,!!s))}}return{writable:t.type==="attributeRef"||!!t.put,read:()=>t.ev(r()),write:o=>Fs(t,r(),o)}}function qs(t){t.features.bind=(e,n)=>{let r=e.withFollow(["and","with","to"],()=>h(e));e.matchAny("and","with","to")||e.expected("and","with","to");let o=h(e),s={type:"bindFeature",displayName:"bind",left:r,right:o,start:n,end:e.endPos(),install:i=>queueMicrotask(()=>{let c=x(i)?i:void 0,a=u=>{let l=u.ev(B(i,s,i,null));return x(l)?Ls(l):Ms(u,i,s)};try{let u=a(r),l=a(o);if(!u.writable&&!l.writable)throw new Error("bind requires at least one writable side");u.writable&&Le(l.read,u.write,c),l.writable&&Le(u.read,l.write,c);for(let[m,f]of[[u,l],[l,u]]){let p=m.element?.closest("form");if(!p||!c)continue;let d=()=>setTimeout(()=>c.isConnected&&f.write(m.read()),0);p.addEventListener("reset",d),(V(c).listeners??=[]).push({target:p,event:"reset",handler:d})}}catch(u){console.error(w(u,"message")??u)}})};return s}}function oo(t){Ps(),Is(t),Os(t),qs(t)}var so="#text";function _s(t){let e=[],n=0,r=0;for(let o of t.split(/(?<=\n)/)){n++;let s=o.trimStart(),i=r+o.length-s.length;if(r+=o.length,!s||/^(--|\/\/)(\s|$|[-/])/.test(s))continue;let c=i-(r-o.length);if(/^#[a-zA-Z]/.test(s))for(let a of de(s.slice(1)))a.start+=i+1,a.end+=i+1,a.line=n,a.column+=c+1,e.push(a);else{let a=s.replace(/\r?\n$/,`
19
19
  `);e.push({type:"IDENTIFIER",value:so,content:a,start:i,end:r,line:n,column:c})}}return e}var Yt=[];function Xt(t,e){let n=Yt=[],r=new Pe(t,_s(e),e),o=D(r);return r.hasMore()&&r.err(),{commands:o,errors:n}}var io=t=>String(t).replace(/[&<>"']/g,e=>`&${js[e]};`),js={"&":"amp","<":"lt",">":"gt",'"':"quot","'":"#039"};function Ds(t,e){let n=t.child(de(e),e),r=!n.match("unescaped"),o=h(n);if(!n.match("if"))return{value:o,escape:r};let s=h(n);return{value:o,condition:s,otherwise:n.match("else")?h(n):void 0,escape:r}}function Gs(t,e){let{content:n="",line:r}=t.last,o=[];for(let c=0;c<n.length;){let a=n.indexOf("${",c);if(a===-1){o.push(n.slice(c));break}a>c&&o.push(n.slice(c,a));let u=1,l=a+2;for(;l<n.length&&u>0;l++)n[l]==="{"?u++:n[l]==="}"&&u--;if(u>0){let f=n.slice(a);Yt.push({line:r,message:"Unterminated ${} expression",expr:f});break}let m=n.slice(a+2,l-1);try{o.push(Ds(t,m))}catch(f){Yt.push({line:r,message:f instanceof Error?f.message:String(f),expr:m})}c=l}let s=(c,a)=>typeof c=="string"?c:c.condition?E(c.condition.ev(a),u=>u?c.value.ev(a):c.otherwise?.ev(a)):c.value.ev(a),i=(c,a)=>typeof c=="string"?c:a==null?"":c.escape?io(a):String(a);return{type:"templateText",parts:o,start:e,end:t.endPos(),run:c=>N(o.map(a=>s(a,c)),a=>{c.meta.template?.out.push(a.map((u,l)=>i(o[l],u)).join(""))})}}var Hs=/<!--hs-scope:[^>]*-->/g;function Zt(t,e,n){let r=[],o={};return e.meta.template={out:r,loops:o},E(j(t,e),()=>n(r.join(""),o))}function $s(t){let e=t.closest('[data-live-template], [dom-scope="isolated"]'),n=e&&ce(e)?.loops;if(n)for(let r=t;r&&r!==e;r=r.parentElement)for(let o=r.previousSibling;o;o=o.previousSibling){if(!(o instanceof Comment)||!o.data.startsWith("hs-scope:"))continue;let[,s,i]=o.data.split(":"),c=n[s];if(c){let a=parseInt(i),u=Te(t);c.identifier&&(u[c.identifier]=Reflect.get(Object(c.source),a)),c.indexIdentifier&&(u[c.indexIdentifier]=a)}break}}function ao(t){z.enter=$s,t.commands[so]=(e,n,r)=>Gs(e,r),t.commands.render=(e,n,r)=>{let o=h(e),s=e.match("with")?He(e):void 0,i=!!e.match("here"),c=!i&&e.match("into")?h(e):void 0,a=e.text(o);return{type:"renderCommand",template:o,args:s,here:i,target:c,start:r,end:e.endPos(),run:l=>N([o.ev(l),s?.ev(l),c?.ev(l)],([m,f,p])=>{if(!x(m))throw new Error(a+" is not an element");let d;try{d=Xt(t,m.textContent??"")}catch(g){console.error("hyperscript template parse error:",g instanceof Error?g.message:g),l.result="";return}for(let g of d.errors)console.error(`hyperscript template error (line ${g.line}): ${g.message}`+(g.expr?" in ${"+g.expr+"}":""));let y=B(l.me,void 0,l.me,null);return Object.assign(y.locals,l.locals,f),Zt(d.commands,y,(g,v)=>{l.result=g.replace(Hs,"");for(let C of[i?l.me:void 0,p])x(C)&&(V(C).loops=v,C.innerHTML=g)})})}},t.leaves.push(e=>{let n=e.pos();if(!e.match("escape"))return;let r=e.reqType("IDENTIFIER").value,o=!!e.match("unescaped"),s=h(e);return{type:"escapeExpression",value:s,start:n,end:e.endPos(),ev:c=>E(s.ev(c),a=>{if(o)return a;if(a==null)return"";if(r!=="html")throw new Error("Unknown escape: "+r);return io(a)})}})}function co(t){let e=new WeakSet;Re.addBeforeProcessHook(n=>{for(let r of n.querySelectorAll('script[type="text/hyperscript-template"][live]')){if(e.has(r))continue;e.add(r);let o=r.textContent??"",s=r.getAttribute("_")||r.getAttribute("data-script");r.removeAttribute("_"),r.removeAttribute("data-script");let i=document.createElement("div");i.style.display="contents",i.setAttribute("data-live-template",""),r.after(i),s&&(i.setAttribute("_",s),z.process(i));let c=()=>{let l;try{l=Xt(t,o).commands}catch(f){return console.error("live-template parse error:",f instanceof Error?f.message:f),""}let m=B(i,void 0,i,null);return Zt(l,m,(f,p)=>(V(i).loops=p,f))},a=!1,u=l=>{if(J(l))return void l.then(u);if(a)return Ht(i,l);i.innerHTML=String(l),z.process(i),a=!0};queueMicrotask(()=>E(c(),l=>{u(l),Le(c,u,i)}))}})}var uo=[Xr,zr,Qr,Jr,Kr,Yr,dr,oo,co,Hr,Vr,Wr,zn,Qn,Kn,Zn,er,tr,rr,or,sr,ir,ar,qr,_r,jr,Dr,Pr,_n,mr,pr,hr,Dn,Gn,Hn,cr,ur,Rr,Fr,Lr,Mn,Fn,qn,kr,Nr,Tr,Cr,Sr,ao,xr,On,An];xn(...uo);In();Reflect.set(globalThis,"hyperfixi",Reflect.get(globalThis,"hyperfixi")??Re);})();
package/dist/index.js CHANGED
@@ -1129,6 +1129,7 @@ function symbol(p) {
1129
1129
  type: "symbol",
1130
1130
  name,
1131
1131
  scope,
1132
+ ...on2 ? { on: on2 } : {},
1132
1133
  start,
1133
1134
  end: p.endPos(),
1134
1135
  ev: (ctx) => resolveSymbol(name, ctx, scope, on2?.ev(ctx)),
@@ -2024,7 +2025,7 @@ var api = Object.assign(evaluate, {
2024
2025
  cleanup,
2025
2026
  /** The part of upstream's `internals` that pages and tests reach for. */
2026
2027
  internals: { runtime: { cleanup, processNode } },
2027
- version: false ? "dev" : "4.0.1"
2028
+ version: false ? "dev" : "4.2.0"
2028
2029
  });
2029
2030
  function boot() {
2030
2031
  Object.assign(globalThis, { _hyperscript: api });
@@ -4037,7 +4038,7 @@ function go(g) {
4037
4038
  } else {
4038
4039
  p.match("to");
4039
4040
  if (p.match("url")) {
4040
- const address = stringLike(p);
4041
+ const address = node.url = stringLike(p);
4041
4042
  node.newWindow = newWindow();
4042
4043
  node.run = () => navigate(address);
4043
4044
  } else if (["the", "top", "middle", "bottom", "left", "center", "right"].includes(p.cur().value)) {
package/dist/minimal.js CHANGED
@@ -1074,6 +1074,7 @@
1074
1074
  type: "symbol",
1075
1075
  name,
1076
1076
  scope,
1077
+ ...on2 ? { on: on2 } : {},
1077
1078
  start,
1078
1079
  end: p.endPos(),
1079
1080
  ev: (ctx) => resolveSymbol(name, ctx, scope, on2?.ev(ctx)),
@@ -2293,7 +2294,7 @@
2293
2294
  cleanup,
2294
2295
  /** The part of upstream's `internals` that pages and tests reach for. */
2295
2296
  internals: { runtime: { cleanup, processNode } },
2296
- version: false ? "dev" : "4.0.1"
2297
+ version: false ? "dev" : "4.2.0"
2297
2298
  });
2298
2299
  function boot() {
2299
2300
  Object.assign(globalThis, { _hyperscript: api });