"use strict";(()=>{var Ri=Object.defineProperty;var N=(s,e)=>{for(var t in e)Ri(s,t,{get:e[t],enumerable:!0})};var pe=class{#t;#i=[];#s=null;#o=[];source;constructor(e,t){this.#t=e,this.source=t,this.consumeWhitespace()}get list(){return this.#t}get consumed(){return this.#i}toString(){var e=this.currentToken(),t=this.source.split(` `),r=e?.line?e.line-1:t.length-1,i=e?.line?e.column:0,n=t[r]||"",o=Math.max(1,e?.value?.length||1),a=String(r+1).length,l="Tokens(";return l+=this.#i.filter(u=>u.type!=="WHITESPACE").length+" consumed, ",l+=this.#t.filter(u=>u.type!=="WHITESPACE").length+" remaining",l+=", line "+(r+1)+`) `,l+=" "+String(r+1).padStart(a)+" | "+n+` `,l+=" ".repeat(a+5)+" ".repeat(i)+"^".repeat(o),e&&(l+=" "+e.type+" '"+e.value+"'"),l}currentToken(){return this.token(0)}token(e,t){var r,i=0;do{if(!t)for(;this.#t[i]&&this.#t[i].type==="WHITESPACE";)i++;r=this.#t[i],e--,i++}while(e>-1);return r||{type:"EOF",value:"<<>>"}}hasMore(){return this.#t.length>0}lastMatch(){return this.#s}matchToken(e,t){if(!this.#o.includes(e)&&(t=t||"IDENTIFIER",this.currentToken()&&this.currentToken().value===e&&this.currentToken().type===t))return this.consumeToken()}matchOpToken(e){if(this.currentToken()&&this.currentToken().op&&this.currentToken().value===e)return this.consumeToken()}matchTokenType(...e){if(this.currentToken()&&this.currentToken().type&&e.includes(this.currentToken().type))return this.consumeToken()}matchAnyToken(...e){for(var t=0;t0;)i++,this.#t[i]?.type!=="WHITESPACE"&&t--;if(this.#t[i]&&this.#t[i].value===e&&this.#t[i].type===r)return this.#t[i]}lastWhitespace(){var e=this.#i.at(-1);return e&&e.type==="WHITESPACE"?e.value:""}pushFollow(e){this.#o.push(e)}popFollow(){this.#o.pop()}pushFollows(...e){for(var t=0;t":"R_ANG","<=":"LTE_ANG",">=":"GTE_ANG","==":"EQ","===":"EQQ","!=":"NEQ","!==":"NEQQ","{":"L_BRACE","}":"R_BRACE","[":"L_BRACKET","]":"R_BRACKET","=":"EQUALS","~":"TILDE","^":"CARET"},O=class s{#t="";#i=0;#s=0;#o=1;#a="";#h=0;#n=[];#p=!1;#c;#l(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}#u(e){return e>="0"&&e<="9"}#v(e){return e===" "||e===" "||e==="\r"||e===` `}#d(e){return e==="\r"||e===` `}#E(e){return this.#l(e)||this.#u(e)||e==="-"||e==="_"||e===":"}#y(e){return e==="_"||e==="$"}#w(e){return e==="`"}static tokenize(e,t){return new s().tokenize(e,t)}tokenize(e,t){return this.#t=e,this.#i=0,this.#s=0,this.#o=1,this.#a="",this.#h=0,this.#n=[],this.#p=t||!1,this.#c="indeterminant",this.#U()}#e(){return this.#t.charAt(this.#i)}#f(){return this.#t.charAt(this.#i+1)}#x(e=1){return this.#t.charAt(this.#i+e)}#r(){return this.#a=this.#e(),this.#i++,this.#a===` `?(this.#o++,this.#s=0):this.#s++,this.#a}#T(){return this.#p&&this.#h===0}#k(){return!this.#T()||this.#c==="command"}#g(){return this.#l(this.#a)||this.#u(this.#a)||this.#a===")"||this.#a==='"'||this.#a==="'"||this.#a==="`"||this.#a==="}"||this.#a==="]"}#b(){if(this.#n.length>0){var e=this.#n.at(-1);if(e.type==="IDENTIFIER"||e.type==="CLASS_REF"||e.type==="ID_REF"||e.op&&(e.value===">"||e.value===")"))return!1}return!0}#m(e,t){return{type:e,value:t||"",start:this.#i,end:this.#i+1,column:this.#s,line:this.#o}}#A(e,t){var r=this.#m(e,t);return r.op=!0,r}#I(){for(;this.#e()&&!this.#d(this.#e());)this.#r();this.#r()}#L(){for(var e=this.#m("WHITESPACE"),t="";this.#e()&&this.#v(this.#e());)this.#d(this.#e())&&(this.#c="indeterminant"),t+=this.#r();return e.value=t,e.end=this.#i,e}#O(){var e=this.#m("CLASS_REF"),t=this.#r();if(this.#e()==="{"){for(e.template=!0,t+=this.#r();this.#e()&&this.#e()!=="}";)t+=this.#r();if(this.#e()!=="}")throw new Error("Unterminated class reference");t+=this.#r()}else for(;this.#E(this.#e())||this.#e()==="\\";)this.#e()==="\\"&&this.#r(),t+=this.#r();return e.value=t,e.end=this.#i,e}#M(){var e=this.#m("ID_REF"),t=this.#r();if(this.#e()==="{"){for(e.template=!0,t+=this.#r();this.#e()&&this.#e()!=="}";)t+=this.#r();if(this.#e()!=="}")throw new Error("Unterminated id reference");this.#r()}else for(;this.#E(this.#e());)t+=this.#r();return e.value=t,e.end=this.#i,e}#F(){for(var e=this.#m("ATTRIBUTE_REF"),t=this.#r();this.#ike,BooleanLiteral:()=>ve,NakedNamedArgumentList:()=>we,NakedString:()=>W,NamedArgumentList:()=>V,NullLiteral:()=>de,NumberLiteral:()=>ye,ObjectKey:()=>Ee,ObjectLiteral:()=>ge,StringLike:()=>be,StringLiteral:()=>Te});var W=class s extends y{static grammarName="nakedString";constructor(e){super(),this.tokens=e}static parse(e){if(e.hasMore()){var t=e.consumeUntilWhitespace();return e.matchTokenType("WHITESPACE"),new s(t)}}evalStatically(){return this.resolve()}resolve(e){return this.tokens.map(function(t){return t.value}).join("")}},ve=class s extends y{static grammarName="boolean";static expressionType="leaf";constructor(e){super(),this.value=e}static parse(e){var t=e.matchToken("true")||e.matchToken("false");if(!t)return;let r=t.value==="true";return new s(r)}evalStatically(){return this.value}resolve(e){return this.value}},de=class s extends y{static grammarName="null";static expressionType="leaf";constructor(){super()}static parse(e){if(e.matchToken("null"))return new s}evalStatically(){return null}resolve(e){return null}},ye=class s extends y{static grammarName="number";static expressionType="leaf";constructor(e,t){super(),this.value=e,this.numberToken=t}static parse(e){var t=e.matchTokenType("NUMBER");if(t){var r=t,i=parseFloat(t.value);return new s(i,r)}}evalStatically(){return this.value}resolve(e){return this.value}},Te=class s extends y{static grammarName="string";static expressionType="leaf";constructor(e,t,r){super(),this.token=e,this.rawValue=t,this.args=r.length>0?{parts:r}:null}static parse(e){var t=e.matchTokenType("STRING");if(t){var r=t.value,i;if(t.template){var n=O.tokenize(r,!0),o=e.createChildParser(n);i=o.parseStringTemplate()}else i=[];return new s(t,r,i)}}evalStatically(){return this.args===null?this.rawValue:super.evalStatically()}resolve(e,{parts:t}={}){if(!t||t.length===0)return this.rawValue;for(var r="",i=0;ix[0]-E[0]),f=-1,p="";for(var[o,c]of h){(f!==-1&&o>f+1||f===-1&&o>0)&&(p+=" ".repeat(l+1)+`... `),f=o;var T=String(o+1).padStart(l),m=r[o]||"";p+=" "+T+" | "+m+` `,c.sort((E,q)=>(E.column||0)-(q.column||0));var v=Array(m.length+10).fill(" ");for(var n of c)for(var k=n.token?.line?n.token.column:Math.max(0,m.length-1),b=Math.max(1,n.token?.value?.length||1),g=0;g"'"+r+"'").join(", ");this.raiseError(t,e)}parseStringTemplate(){var e=[""];do if(e.push(this.lastWhitespace()),this.currentToken().value==="$"){this.consumeToken();var t=this.matchOpToken("{");e.push(this.requireElement("expression")),t&&this.requireOpToken("}"),e.push("")}else if(this.currentToken().value==="\\")this.consumeToken(),this.consumeToken();else{var r=this.consumeToken();e[e.length-1]+=r?r.value:""}while(this.hasMore());return e.push(this.lastWhitespace()),e}commandBoundary(e){return!!(e.value=="end"||e.value=="then"||e.value=="else"||e.value=="otherwise"||e.value==")"||this.commandStart(e)||this.featureStart(e)||e.type=="EOF")}commandStart(e){return this.#t.commandStart(e)}featureStart(e){return this.#t.featureStart(e)}setParent(e,t){typeof e=="object"&&(e.parent=t,typeof t=="object"&&(t.children=t.children||new Set,t.children.add(e)),this.setParent(e.next,t))}parseURLOrExpression(){var e=this.currentToken();if(e.value==="/"&&e.type==="DIVIDE"){var t=this.consumeUntilWhitespace();return this.matchTokenType("WHITESPACE"),new W(t)}if(e.type==="IDENTIFIER"&&(e.value==="http"||e.value==="https"||e.value==="ws"||e.value==="wss")){var t=this.consumeUntilWhitespace();return this.matchTokenType("WHITESPACE"),new W(t)}return this.requireElement("expression")}ensureTerminated(e){for(var t=new Z,r=e;r.next;)r=r.next;r.next=t}};var ee=class{#t={};#i={};#s={};#o=[];#a=[];#h=[];#n=[];#p=[];#c=[];constructor(){this.addGrammarElement("hyperscript",this.parseHyperscriptProgram.bind(this)),this.addGrammarElement("feature",this.parseFeature.bind(this)),this.addGrammarElement("commandList",this.parseCommandList.bind(this)),this.addGrammarElement("command",this.parseCommand.bind(this)),this.addGrammarElement("indirectStatement",this.parseIndirectStatement.bind(this)),this.addGrammarElement("expression",this.parseExpression.bind(this)),this.addGrammarElement("assignableExpression",this.parseAssignableExpression.bind(this)),this.addGrammarElement("unaryExpression",this.parseUnaryExpression.bind(this)),this.addGrammarElement("postfixExpression",this.parsePostfixExpression.bind(this)),this.addGrammarElement("primaryExpression",this.parsePrimaryExpression.bind(this)),this.addGrammarElement("indirectExpression",this.parseIndirectExpression.bind(this)),this.addGrammarElement("leaf",this.parseLeaf.bind(this))}parseFeature(e){if(e.matchOpToken("(")){var t=e.requireElement("feature");return e.requireOpToken(")"),t}var r=this.#s[e.currentToken().value||""];if(r)return r(e)}parseCommand(e){if(e.matchOpToken("(")){let i=e.requireElement("command");return e.requireOpToken(")"),i}var t=this.#i[e.currentToken().value||""];let r;return t?r=t(e):e.currentToken().type==="IDENTIFIER"&&(r=e.parseElement("pseudoCommand")),r&&this.parseElement("indirectStatement",e,r)}parseCommandList(e){if(e.hasMore()){var t=e.currentToken().value,r;try{r=e.parseElement("command")}catch(i){if(i instanceof D)r=new X(i.parseError,t),this.#u(e);else throw i}if(r){e.matchToken("then");let i=e.parseElement("commandList");return i&&(r.next=i),r}}return new K}parseLeaf(e){var t=e.parseAnyOf(this.#o);return t??e.parseElement("symbol")}parseIndirectExpression(e,t){for(var r=0;rn.selected).map(n=>n.value):r=e.value,r!=null)if(this.result[t]==null)this.result[t]=r;else{var i=Array.isArray(this.result[t])?this.result[t]:[this.result[t]];this.result[t]=i.concat(r)}}}addContainer(e){if(e.name!=null&&e.value!=null){this.addElement(e);return}e.querySelectorAll&&e.querySelectorAll("input,select,textarea").forEach(t=>this.addElement(t))}};function ui(s){if(s instanceof Array)return s.map(r=>ui(r)).join("");if(s instanceof HTMLElement)return s.outerHTML;if(s instanceof NodeList){for(var e="",t=0;tr.addContainer(i)),r.result}}],String:function(s){return s.toString?s.toString():""+s},Int:function(s){return parseInt(s)},Float:function(s){return parseFloat(s)},Number:function(s){return Number(s)},Boolean:function(s){return!!s},Date:function(s){return new Date(s)},Array:function(s){return Array.from(s)},JSON:function(s){return typeof Response<"u"&&s instanceof Response?s.json():JSON.parse(s)},JSONString:function(s){return JSON.stringify(s)},Object:function(s){return s instanceof String&&(s=s.toString()),typeof s=="string"?JSON.parse(s):Object.assign({},s)},FormEncoded:function(s){return new URLSearchParams(s).toString()},Set:function(s){return new Set(s)},Map:function(s){return new Map(Object.entries(s))},Keys:function(s){return s instanceof Map?Array.from(s.keys()):Object.keys(s)},Entries:function(s){return s instanceof Map?Array.from(s.entries()):Object.entries(s)},Reversed:function(s){return Array.from(s).reverse()},Unique:function(s){return[...new Set(s)]},Flat:function(s){return Array.from(s).flat()},HTML:ui,Stream:function(){throw new Error("The Stream conversion requires the SSE extension. Include dist/ext/sse.js or dist/ext/sse.esm.js after hyperscript.")},Fragment:function(s,e){var t=document.createDocumentFragment();return e.implicitLoop(s,r=>{if(r instanceof Node)t.append(r);else{var i=document.createElement("template");i.innerHTML=r,t.append(i.content)}}),t}};var te=class{#t(){return document.cookie?document.cookie.split("; ").map(e=>{var t=e.indexOf("=");return{name:e.slice(0,t),value:decodeURIComponent(e.slice(t+1))}}):[]}get(e,t){if(t==="then")return null;if(t==="length")return this.#t().length;if(t==="clear")return n=>{document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"};if(t==="clearAll")return()=>{for(let n of this.#t())document.cookie=n.name+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"};if(t===Symbol.iterator){var r=this.#t();return r[Symbol.iterator].bind(r)}else if(typeof t=="string"){if(!isNaN(t))return this.#t()[parseInt(t)];var i=this.#t().find(n=>n.name===t);return i?i.value:void 0}}set(e,t,r){var i=[];return typeof r=="string"?(i.push(encodeURIComponent(r)),i.push("samesite=lax")):(i.push(encodeURIComponent(r.value)),r.expires&&i.push("expires="+r.expires),r.maxAge&&i.push("max-age="+r.maxAge),r.partitioned&&i.push("partitioned="+r.partitioned),r.path&&i.push("path="+r.path),r.samesite&&i.push("samesite="+r.samesite),r.secure&&i.push("secure")),document.cookie=String(t)+"="+i.join(";"),!0}proxy(){return new Proxy({},this)}};var Ae=Symbol(),R=class{constructor(e,t,r,i){this._css=e,this.relativeToElement=t,this.escape=r,this._runtime=i,this[Ae]=!0}get css(){return this.escape?this._runtime.escapeSelector(this._css):this._css}get className(){return this._css.slice(1)}get id(){return this.className}contains(e){for(let t of this)if(t.contains(e))return!0;return!1}get length(){return this.selectMatches().length}[Symbol.iterator](){return this.selectMatches()[Symbol.iterator]()}selectMatches(){return this._runtime.getRootNode(this.relativeToElement).querySelectorAll(this.css)}},re=class extends R{constructor(e,t,r,i){super(e,t,!1,i),this.templateParts=r,this.elements=r.filter(n=>n instanceof Element)}get css(){let e="",t=0;for(let r of this.templateParts)r instanceof Element?e+="[data-hs-query-id='"+t+++"']":e+=r;return e}[Symbol.iterator](){this.elements.forEach((t,r)=>t.dataset.hsQueryId=r);let e=super[Symbol.iterator]();return this.elements.forEach(t=>t.removeAttribute("data-hs-query-id")),e}},Ne=class{constructor(e,t){this.re=e,this.str=t}next(){let e=this.re.exec(this.str);return e===null?{done:!0}:(e[0].length===0&&this.re.lastIndex++,{value:e})}},ie=class{constructor(e,t,r){this.re=e,this.flags=t,this.str=r}[Symbol.iterator](){return new Ne(new RegExp(this.re,this.flags),this.str)}},ne=class extends EventTarget{constructor(e){super(),this.module=e}toString(){return this.module.id}};var Ci=new te().proxy(),se=class{constructor(e,t,r,i,n,o,a,l){this.meta={parser:a,tokenizer:l,runtime:n,owner:e,feature:t,iterators:{},ctx:this},this.locals={cookies:Ci},typeof navigator<"u"&&navigator.clipboard&&Object.defineProperty(this.locals,"clipboard",{get(){return navigator.clipboard.readText()},set(u){navigator.clipboard.writeText(String(u))},enumerable:!1,configurable:!0}),typeof window<"u"&&window.getSelection&&Object.defineProperty(this.locals,"selection",{get(){return window.getSelection().toString()},enumerable:!0,configurable:!0}),this.me=r,this.you=void 0,this.result=void 0,this.beingTested=null,this.event=i,this.target=i?.target??null,this.detail=i?.detail??null,this.sender=i?.detail?.sender??null,this.body="document"in o?document.body:null,n.addFeatures(e,this)}},oe=class s{static HALT={};HALT=s.HALT;#t;#i;#s;#o;#a;#h=null;constructor(e,t,r,i,n){this.#s=e,this.#t=t,this.#i=r,this.#o=i,this.#a=n}get globalScope(){return this.#s}get reactivity(){return this.#o}unifiedExec(e,t){for(;;){try{var r=this.unifiedEval(e,t)}catch(i){if(t.meta.handlingFinally)console.error(" Exception in finally block: ",i),r=s.HALT;else if(this.registerHyperTrace(t,i),t.meta.errorHandler&&!t.meta.handlingError){t.meta.handlingError=!0,t.locals[t.meta.errorSymbol]=i,e=t.meta.errorHandler;continue}else t.meta.currentException=i,r=s.HALT}if(r==null)throw new Error("Command "+(e.type||"unknown")+" did not return a next element to execute");if(r.then){r.then(i=>{this.unifiedExec(i,t)}).catch(i=>{this.unifiedExec({resolve:function(){throw i}},t)});return}else if(r===s.HALT)if(t.meta.finallyHandler&&!t.meta.handlingFinally)t.meta.handlingFinally=!0,e=t.meta.finallyHandler;else if(t.meta.onHalt&&t.meta.onHalt(),t.meta.currentException)if(t.meta.reject){t.meta.reject(t.meta.currentException);return}else throw t.meta.currentException;else return;else e=r}}unifiedEval(e,t){var r=!1,i={};if(e.args)for(var[n,o]of Object.entries(e.args))if(o==null)i[n]=null;else if(Array.isArray(o)){for(var a=[],l=0;l{var c=Object.keys(i),T=Object.values(i).map(m=>Array.isArray(m)?Promise.all(m):m);Promise.all(T).then(function(m){try{var v={};c.forEach((k,b)=>v[k]=m[b]),f(e.resolve(t,v))}catch(k){p(k)}}).catch(function(m){p(m)})}):e.resolve(t,i)}findNext(e,t){if(e)return e.resolveNext?e.resolveNext(t):e.next?e.next:this.findNext(e.parent,t)}makeContext(e,t,r,i){return new se(e,t,r,i,this,this.#s,this.#t,this.#i)}getHyperscriptFeatures(e){var t=this.getInternalData(e);return t.features||(t.features={}),t.features}addFeatures(e,t){e&&(Object.assign(t.locals,this.getHyperscriptFeatures(e)),this.addFeatures(e.parentElement,t))}#n(e){return["meta","it","result","locals","event","target","detail","sender","body"].includes(e)}#p(e){return e instanceof se}resolveSymbol(e,t,r,i){if(e==="me"||e==="my"||e==="I")return t.me;if(e==="it"||e==="its")return t.beingTested??t.result;if(e==="result")return t.result;if(e==="you"||e==="your"||e==="yourself")return t.you;if(r==="global"){this.reactivity.isTracking&&this.reactivity.trackGlobalSymbol(e);var h=this.#s[e];return this.#v(h),h}if(r==="element"){this.reactivity.isTracking&&this.reactivity.trackElementSymbol(e,t.meta.owner);var h=this.#l(t)[e];return this.#v(h),h}if(r==="inherited"){var n=this.#c(e,t,i);if(this.reactivity.isTracking){var o=n.element||i||t.meta?.owner;o&&this.reactivity.trackElementSymbol(e,o)}return this.#v(n.value),n.value}if(t.meta?.context){var a=t.meta.context[e];if(typeof a<"u"||t.meta.context.detail&&(a=t.meta.context.detail[e],typeof a<"u"))return a}var l=this.#p(t)&&!this.#n(e)?t.locals[e]:t[e];if(typeof l<"u")return l;var u=this.#l(t);if(l=u[e],typeof l<"u")return this.reactivity.isTracking&&this.reactivity.trackElementSymbol(e,t.meta.owner),this.#v(l),l;this.reactivity.isTracking&&this.reactivity.trackGlobalSymbol(e);var h=this.#s[e];return this.#v(h),h}setSymbol(e,t,r,i,n){if(r==="global"){this.#s[e]=i,this.reactivity.notifyGlobalSymbol(e);return}if(r==="element"){this.#l(t)[e]=i,this.reactivity.notifyElementSymbol(e,t.meta.owner);return}if(r==="inherited"){var o=this.#c(e,t,n);if(o.element)this.getInternalData(o.element).elementScope[e]=i,this.reactivity.notifyElementSymbol(e,o.element);else{var a=n||t.meta?.owner;if(a){var l=this.getInternalData(a);l.elementScope||(l.elementScope={}),l.elementScope[e]=i,this.reactivity.notifyElementSymbol(e,a)}}return}if(this.#p(t)&&!this.#n(e)&&typeof t.locals[e]<"u"){t.locals[e]=i;return}var u=this.#l(t);typeof u[e]<"u"?(u[e]=i,this.reactivity.notifyElementSymbol(e,t.meta.owner)):this.#p(t)&&!this.#n(e)?t.locals[e]=i:t[e]=i}getInternalData(e){return e._hyperscript||(e._hyperscript={}),e._hyperscript}#c(e,t,r){for(var i=r||t.meta&&t.meta.owner;i;){var n=i._hyperscript;if(n&&n.elementScope&&e in n.elementScope)return{value:n.elementScope[e],element:i};var o=i.getAttribute&&i.getAttribute("dom-scope");if(o){if(o==="isolated")return{value:void 0,element:null};var a=o.match(/^closest\s+(.+)/);if(a){i=i.parentElement&&i.parentElement.closest(a[1]);continue}if(a=o.match(/^parent\s+of\s+(.+)/),a){var l=i.closest(a[1]);i=l&&l.parentElement;continue}}i=i.parentElement}return{value:void 0,element:null}}#l(e){var t=e.meta&&e.meta.owner;if(t){var r=this.getInternalData(t),i="elementScope";e.meta.feature&&e.meta.feature.behavior&&(i=e.meta.feature.behavior+"Scope");var n=r[i];return n||(n={},r[i]=n),n}else return{}}#u(e,t,r){if(e!=null){var i=r(e,t);if(typeof i<"u")return i;if(this.shouldAutoIterate(e)){var n=[];for(var o of e){var a=r(o,t);n.push(a)}return n}}}resolveProperty(e,t){return this.reactivity.isTracking&&this.reactivity.trackProperty(e,t),this.#u(e,t,(r,i)=>r[i])}setProperty(e,t,r){e[t]=r,this.reactivity.notifyProperty(e)}notifyMutation(e){this.reactivity.notifyProperty(e)}morph(e,t){this.#a.morph(e,t,{beforeNodeRemoved:r=>{r.nodeType===1&&this.cleanup(r)},afterNodeAdded:r=>{r.nodeType===1&&this.processNode(r)},afterNodeMorphed:r=>{r.nodeType===1&&this.processNode(r)}})}replaceInDom(e,t){this.implicitLoop(e,r=>{var i=r.parentElement;t instanceof Node?r.replaceWith(t.cloneNode(!0)):r.replaceWith(this.convertValue(t,"Fragment")),i&&this.processNode(i)})}maybeNotify(e,t){if(!(e==null||typeof e!="object")){var r=e.constructor&&e.constructor.name,i=r&&A.mutatingMethods[r];i&&i.includes(t)&&this.notifyMutation(e)}}#v(e){this.reactivity.isTracking&&e!=null&&typeof e=="object"&&this.reactivity.trackProperty(e,"__mutation__")}resolveAttribute(e,t){return this.reactivity.isTracking&&this.reactivity.trackAttribute(e,t),this.#u(e,t,(r,i)=>r.getAttribute&&r.getAttribute(i))}resolveStyle(e,t){return this.#u(e,t,(r,i)=>r.style&&r.style[i])}resolveComputedStyle(e,t){return this.#u(e,t,(r,i)=>getComputedStyle(r).getPropertyValue(i))}assignToNamespace(e,t,r,i){let n;e==null||typeof document<"u"&&e===document.body?n=this.#s:n=this.getHyperscriptFeatures(e);for(var o;(o=t.shift())!==void 0;){var a=n[o];a==null&&(a={},n[o]=a),n=a}n[r]=i}#d(e){return Array.isArray(e)||typeof NodeList<"u"&&(e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList)}#E(e){return typeof e=="object"&&Symbol.iterator in e&&typeof e[Symbol.iterator]=="function"}shouldAutoIterate(e){return e!=null&&e[Ae]||this.#d(e)}forEach(e,t){if(e!=null)if(this.#E(e))for(let i of e)t(i);else if(this.#d(e))for(var r=0;r{r.result=this.#y(o,u,i,n)});r.result=this.#y(o,a,i,n)}#y(e,t,r,i){for(var n=[],o=0;o"["+e+"]").join(", ")),this.#f}#r(e){for(var t=5381,r=0;r{this.triggerEvent(t||e,"load",{hyperscript:!0})},1)}catch(l){this.triggerEvent(e,"exception",{error:l}),console.error("hyperscript errors were found on the following element:",e,` `,l.message,l.stack)}}}}}#k(e){var t=e.closest('[data-live-template], [dom-scope="isolated"]');if(!(!t||!t.__hs_scopes)){for(var r=[],i=e;i&&i!==t;){for(var n=i.previousSibling;n;){if(n.nodeType===8){var o=n.data;if(o.startsWith("hs-scope:")){r.push(o);break}}n=n.previousSibling}i=i.parentElement}if(r.length){var a=this.getInternalData(e);a.elementScope||(a.elementScope={});for(var l=0;l{this.#T(i,i instanceof HTMLScriptElement&&i.type==="text/hyperscript"?document.body:i)});for(var t of this.#b)t(e)}getHyperTrace(e,t){for(var r=[],i=e;i.meta.caller;)i=i.meta.caller;if(i.meta.traceMap)return i.meta.traceMap.get(t,r)}registerHyperTrace(e,t){for(var r=[],i=null;e!=null;)r.push(e),i=e,e=e.meta.caller;if(i.meta.traceMap==null&&(i.meta.traceMap=new Map),!i.meta.traceMap.get(t)){var n={trace:r,print:function(o){o=o||console.error,o("hypertrace /// ");for(var a=0,l=0;l",u.meta.feature.displayName.padEnd(a+2),"-",u.meta.owner)}}};i.meta.traceMap.set(t,n)}}beepValueToConsole(e,t,r){if(this.triggerEvent(e,"hyperscript:beep",{element:e,expression:t,value:r})){var i=r?r instanceof R?"ElementCollection":r.constructor?.name||"unknown":"object (null)",n=i==="String"?'"'+r+'"':r instanceof R?Array.from(r):r;console.log("///_ BEEP! The expression ("+t.sourceFor().replace("beep! ","")+") evaluates to:",n,"of type "+i)}}};function _i(s,e){return s===e?s!==0||1/s===1/e:s!==s&&e!==e}var Ie=class{constructor(e,t,r,i){this.expression=e,this.handler=t,this.element=r,this._reactivity=i,this.dependencies=new Map,this._lastValue=void 0,this._isStopped=!1,this._consecutiveTriggers=0}initialize(){var e=this._reactivity,t=e._currentEffect;e._currentEffect=this;try{this._lastValue=this.expression()}catch(r){console.error("Error in reactive expression:",r)}if(e._currentEffect=t,e._subscribeEffect(this),this._lastValue!=null)try{this.handler(this._lastValue)}catch(r){console.error("Error in reactive handler:",r)}}run(){if(this._consecutiveTriggers++,this._consecutiveTriggers>100)return 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),!1;var e=this._reactivity;e._unsubscribeEffect(this);var t=this.dependencies;this.dependencies=new Map;var r=e._currentEffect;e._currentEffect=this;var i;try{i=this.expression()}catch(n){return console.error("Error in reactive expression:",n),this.dependencies=t,e._currentEffect=r,e._subscribeEffect(this),!0}if(e._currentEffect=r,e._subscribeEffect(this),e._cleanupOrphanedDeps(t),!_i(i,this._lastValue)){this._lastValue=i;try{this.handler(i)}catch(n){console.error("Error in reactive handler:",n)}}return!0}resetTriggerCount(){this._consecutiveTriggers=0}stop(){this._isStopped||(this._isStopped=!0,this._reactivity._unsubscribeEffect(this),this._reactivity._cleanupOrphanedDeps(this.dependencies),this._reactivity._pendingEffects.delete(this))}},ae=class{constructor(){this._objectState=new WeakMap,this._globalSubscriptions=new Map,this._nextId=0,this._currentEffect=null,this._pendingEffects=new Set,this._isRunScheduled=!1}_getObjectState(e){var t=this._objectState.get(e);return t||this._objectState.set(e,t={id:String(++this._nextId),subscriptions:null,propertyHandler:null,attributeObservers:null}),t}get isTracking(){return this._currentEffect!==null}trackGlobalSymbol(e){this._currentEffect.dependencies.set("symbol:global:"+e,{type:"symbol",name:e,scope:"global"})}trackElementSymbol(e,t){if(t){var r=this._getObjectState(t).id;this._currentEffect.dependencies.set("symbol:element:"+e+":"+r,{type:"symbol",name:e,scope:"element",element:t})}}trackProperty(e,t){e==null||typeof e!="object"||e._hsSkipTracking||this._currentEffect.dependencies.set("property:"+this._getObjectState(e).id,{type:"property",object:e,name:t})}trackAttribute(e,t){e instanceof Element&&this._currentEffect.dependencies.set("attribute:"+t+":"+this._getObjectState(e).id,{type:"attribute",element:e,name:t})}notifyGlobalSymbol(e){var t=this._globalSubscriptions.get(e);if(t)for(var r of t)this._scheduleEffect(r)}notifyElementSymbol(e,t){if(t){var r=this._getObjectState(t);if(r.subscriptions){var i=r.subscriptions.get(e);if(i)for(var n of i)this._scheduleEffect(n)}}}notifyProperty(e){if(!(e==null||typeof e!="object"||e._hsSkipTracking)){var t=this._objectState.get(e);t&&t.propertyHandler&&t.propertyHandler.queueAll()}}_scheduleEffect(e){if(!e._isStopped&&(this._pendingEffects.add(e),!this._isRunScheduled)){this._isRunScheduled=!0;var t=this;queueMicrotask(function(){t._runPendingEffects()})}}_runPendingEffects(){this._isRunScheduled=!1;var e=Array.from(this._pendingEffects);this._pendingEffects.clear();for(var t=0;ta.has(f)))return u;if(!h){if(o>0&&u.isEqualNode(e))return u;i||(i=u)}}if(n+=h?.size||0,n>l||u.contains(document.activeElement)||--o<1&&l===0)break;u=u.nextSibling}return i&&pi(s,i,e)?null:i}function pi(s,e,t){if(s.futureMatches.has(e))return!0;for(var r=t.nextSibling,i=0;r&&i<10;r=r.nextSibling,i++)if(r instanceof Element&&e.isEqualNode(r))return s.futureMatches.add(e),!0;return!1}function ci(s,e){s.idMap.has(e)?Le(s.pantry,e,null):(s.callbacks.beforeNodeRemoved?.(e),e.remove())}function Le(s,e,t){if(s.moveBefore)try{s.moveBefore(e,t);return}catch{}s.insertBefore(e,t)}function vi(s,e){for(var t of e.attributes)s.getAttribute(t.name)!==t.value&&(s.setAttribute(t.name,t.value),t.name==="value"&&s instanceof HTMLInputElement&&s.type!=="file"&&(s.value=t.value));for(var r=s.attributes.length-1;r>=0;r--){var t=s.attributes[r];t&&!e.hasAttribute(t.name)&&s.removeAttribute(t.name)}}function Di(s,e){return!(s instanceof Element)||s.tagName!==e.tagName||s.tagName==="SCRIPT"&&!s.isEqualNode(e)?!1:!s.id||s.id===e.id}function Hi(s,e){var t=ji(s,"[id]"),r=e.querySelectorAll("[id]"),i=Wi(t,r),n=new Map;return fi(n,i,s.parentElement,t),fi(n,i,e,r),{persistentIds:i,idMap:n}}function Wi(s,e){var t=new Set,r=new Map;for(var{id:i,tagName:n}of s)r.has(i)?t.add(i):i&&r.set(i,n);var o=new Set;for(var{id:i,tagName:n}of e)o.has(i)?t.add(i):r.get(i)===n&&o.add(i);for(var i of t)o.delete(i);return o}function fi(s,e,t,r){for(var i of r)if(e.has(i.id))for(var n=i;n&&n!==t;){var o=s.get(n);o==null&&(o=new Set,s.set(n,o)),o.add(i.id),n=n.parentElement}}function ji(s,e){var t=[...s.querySelectorAll?.(e)??[]];return s.matches?.(e)&&t.unshift(s),t}var ue=class s{#t=!1;constructor(e,t){this.globalScope=e,this.hyperscript=t}init(){var e=this,t=this.globalScope,r=this.hyperscript;t.document.addEventListener("htmx:load",function(i){e.#t=!0,r.process(i.detail.elt),e.#t=!1}),t.document.addEventListener("htmx:after:process",function(i){e.#t=!0,r.process(i.target),e.#t=!1}),typeof htmx<"u"&&(r.addAfterProcessHook(function(i){e.#t||htmx.process(i)}),htmx.version?.startsWith("4")&&htmx.registerExtension("hs-include",{htmx_config_request:function(i,n){var o=n?.ctx;if(o){var a=o.sourceElement||i,l=s.#i(a);if(l){var u=s.#h(l.value,l.scopeElt),h=o.request?.body;if(h instanceof FormData)for(var f in u)h.set(f,u[f])}}}}))}static#i(e){var t=e.getAttribute("hs-include");if(t!==null)return{value:t,scopeElt:e};for(var r=e.parentElement;r;){if(t=r.getAttribute("hs-include:inherited"),t!==null)return{value:t,scopeElt:r};r=r.parentElement}return null}static#s(e){return e?._hyperscript?.elementScope||{}}static#o(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return""}return String(e)}static#a(e,t){for(var r=t;r;){var i=r._hyperscript?.elementScope;if(i&&e in i)return i[e];r=r.parentElement}}static#h(e,t){var r={},i=e.trim();if(i==="*"){var n=this.#s(t);for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o[0]===":"?o.slice(1):o]=this.#o(n[o]));return r}var a=this;return i.split(",").forEach(function(l){if(l=l.trim(),!!l){if(l[0]===":"){var u=l.slice(1),h=a.#s(t),f=":"+u;f in h&&(r[u]=a.#o(h[f]))}else if(l[0]==="^"){var u=l.slice(1),p=a.#a(":"+u,t);p!==void 0&&(r[u]=a.#o(p))}else if(l[0]==="#"){var c=l.lastIndexOf(":");if(c>0){var T=l.slice(0,c),u=l.slice(c+1),m=document.querySelector(T);if(m){var h=a.#s(m),f=":"+u;f in h&&(r[u]=a.#o(h[f]))}}}}}),r}};var tt={};N(tt,{ArrayIndex:()=>Be,AsExpression:()=>je,AttributeRefAccess:()=>G,BeepExpression:()=>_e,BlockLiteral:()=>Me,CollectionExpression:()=>Ye,ComparisonOperator:()=>Ge,DotOrColonPath:()=>et,FunctionCall:()=>Ue,InExpression:()=>We,LogicalNot:()=>Re,LogicalOperator:()=>$e,MathOperator:()=>ze,NegativeNumber:()=>Fe,OfExpression:()=>De,ParenthesizedExpression:()=>Oe,PossessiveExpression:()=>He,PropertyAccess:()=>Pe,SymbolRef:()=>Ce});var Oe=class s extends y{static grammarName="parenthesized";static expressionType="leaf";constructor(e){super(),this.expr=e,this.args={value:e}}static parse(e){if(e.matchOpToken("(")){var t=e.clearFollows();try{var r=e.requireElement("expression")}finally{e.restoreFollows(t)}return e.requireOpToken(")"),new s(r)}}resolve(e,{value:t}){return t}},Me=class s extends y{static grammarName="blockLiteral";static expressionType="leaf";constructor(e,t){super(),this.params=e,this.expr=t}static parse(e){if(e.matchOpToken("\\")){var t=[],r=e.matchTokenType("IDENTIFIER");if(r)for(t.push(r);e.matchOpToken(",");)t.push(e.requireTokenType("IDENTIFIER"));e.requireOpToken("-"),e.requireOpToken(">");var i=e.requireElement("expression");return new s(t,i)}}resolve(e){var t=this.params,r=this.expr;return function(){for(var i=0;i{i.setProperty(n,this.prop.value,r)})}delete(e,t){e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=this.prop.value;r.implicitLoop(t.root,n=>{delete n[i],r.notifyMutation(n)})}},De=class s extends y{static grammarName="ofExpression";static expressionType="indirect";static assignable=!0;constructor(e,t,r,i,n,o){super(),this.prop=e,this.root=t,this.attribute=r,this.expression=i,this.args=n,this._urRoot=o,this._prop=o.name,this._isAttribute=o.type==="attributeRef",this._isStyle=o.type==="styleRef",this._isComputed=o.type==="computedStyleRef"}static parse(e,t){if(e.matchToken("of")){for(var r=e.requireElement("unaryExpression"),i=null,n=t;n.root;)i=n,n=n.root;var o=["symbol","attributeRef","styleRef","computedStyleRef"];o.includes(n.type)||e.raiseError("Cannot take a property of a non-symbol: "+n.type);var a=n.type==="attributeRef",l=n.type==="styleRef"||n.type==="computedStyleRef",u=a||l?n:null,h=n.name,f=new s(n.token,r,u,t,{root:r},n);return n.type==="attributeRef"&&(f.attribute=n),i?(i.root=f,i.args={root:f}):t=f,e.parseElement("indirectExpression",t)}}resolve(e,{root:t}){return this._isAttribute?e.meta.runtime.resolveAttribute(t,this._prop):this._isComputed?e.meta.runtime.resolveComputedStyle(t,this._prop):this._isStyle?e.meta.runtime.resolveStyle(t,this._prop):e.meta.runtime.resolveProperty(t,this._prop)}get lhs(){return{root:this.root}}set(e,t,r){if(e.meta.runtime.nullCheck(t.root,this.root),this._isAttribute)e.meta.runtime.implicitLoop(t.root,n=>{r==null?n.removeAttribute(this._prop):n.setAttribute(this._prop,r)});else if(this._isStyle)e.meta.runtime.implicitLoop(t.root,n=>{n.style[this._prop]=r});else{var i=e.meta.runtime;i.implicitLoop(t.root,n=>{i.setProperty(n,this._prop,r)})}}delete(e,t){e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=this._prop;this._isAttribute?r.implicitLoop(t.root,n=>n.removeAttribute(i)):this._isStyle?r.implicitLoop(t.root,n=>n.style.removeProperty(i)):r.implicitLoop(t.root,n=>{delete n[i],r.notifyMutation(n)})}},He=class s extends y{static grammarName="possessive";static expressionType="indirect";static assignable=!0;constructor(e,t,r){super(),this.root=e,this.attribute=t,this.prop=r,this.args={root:e}}static parse(e,t){var r=e.matchOpToken("'");if(r||t.type==="symbol"&&(t.name==="my"||t.name==="its"||t.name==="your")&&(e.currentToken().type==="IDENTIFIER"||e.currentToken().type==="ATTRIBUTE_REF"||e.currentToken().type==="STYLE_REF")){r&&e.requireToken("s");var i,n,o;i=e.parseElement("attributeRef"),i==null&&(n=e.parseElement("styleRef"),n==null&&(o=e.requireTokenType("IDENTIFIER")));var a=new s(t,i||n,o);return e.parseElement("indirectExpression",a)}}resolve(e,{root:t}){var r;return this.attribute?this.attribute.type==="computedStyleRef"?r=e.meta.runtime.resolveComputedStyle(t,this.attribute.name):this.attribute.type==="styleRef"?r=e.meta.runtime.resolveStyle(t,this.attribute.name):r=e.meta.runtime.resolveAttribute(t,this.attribute.name):r=e.meta.runtime.resolveProperty(t,this.prop.value),r}get lhs(){return{root:this.root}}set(e,t,r){if(e.meta.runtime.nullCheck(t.root,this.root),this.attribute){var i=this.attribute.name;this.attribute.type==="styleRef"?e.meta.runtime.implicitLoop(t.root,a=>{a.style[i]=r}):e.meta.runtime.implicitLoop(t.root,a=>{r==null?a.removeAttribute(i):a.setAttribute(i,r)})}else{var n=e.meta.runtime,o=this.prop.value;n.implicitLoop(t.root,a=>{n.setProperty(a,o,r)})}}},We=class s extends y{static grammarName="inExpression";static expressionType="indirect";static assignable=!0;constructor(e,t){super(),this.root=e,this.target=t,this.args={root:e,target:t}}static parse(e,t){if(e.matchToken("in")){var r=e.requireElement("unaryExpression"),i=new s(t,r);return e.parseElement("indirectExpression",i)}}resolve(e,{root:t,target:r}){if(t==null)return[];var i=[];if(t.css)e.meta.runtime.implicitLoop(r,function(o){for(var a=o.querySelectorAll(t.css),l=0;l{r==null?i.removeAttribute(this.attribute.name):i.setAttribute(this.attribute.name,r)})}},Be=class s extends y{static grammarName="arrayIndex";static expressionType="indirect";static assignable=!0;constructor(e,t,r,i,n){super(),this.root=e,this.prop=t,this.firstIndex=t,this.secondIndex=r,this.andBefore=i,this.andAfter=n,this.args={root:e,firstIndex:t,secondIndex:r}}static parse(e,t){if(e.matchOpToken("[")){var r=!1,i=!1,n=null,o=null;if(e.matchOpToken(".."))r=!0,n=e.requireElement("expression");else if(n=e.requireElement("expression"),e.matchOpToken("..")){i=!0;var a=e.currentToken();a.type!=="R_BRACKET"&&(o=e.parseElement("expression"))}e.requireOpToken("]");var l=new s(t,n,o,r,i);return e.parseElement("indirectExpression",l)}}resolve(e,{root:t,firstIndex:r,secondIndex:i}){return t==null?null:this.andBefore?(r<0&&(r=t.length+r),t.slice(0,r+1)):this.andAfter?i!=null?(i<0&&(i=t.length+i),t.slice(r,i+1)):t.slice(r):t[r]}get lhs(){return{root:this.root,index:this.firstIndex}}set(e,t,r){e.meta.runtime.nullCheck(t.root,this.root),t.root[t.index]=r}delete(e,t){if(this.andBefore||this.andAfter)throw new Error("Cannot remove a slice - use a single index");e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=t.root,n=t.index;Array.isArray(i)?(n<0&&(n=i.length+n),i.splice(n,1)):delete i[n],r.notifyMutation(i)}},ze=class s extends y{static grammarName="mathOperator";constructor(e,t,r){super(),this.lhs=e,this.rhs=r,this.operator=t,this.args={lhs:e,rhs:r}}static parse(e){var t=e.parseElement("collectionExpression"),r,i=null;for(r=e.matchAnyOpToken("+","-","*","/")||e.matchToken("mod");r;){i=i||r;var n=r.value;i.value!==n&&e.raiseError("You must parenthesize math operations with different operators");var o=e.parseElement("collectionExpression");t=new s(t,n,o),r=e.matchAnyOpToken("+","-","*","/")||e.matchToken("mod")}return t}resolve(e,{lhs:t,rhs:r}){if(this.operator==="+")return Array.isArray(t)?t.concat(r):t+r;if(this.operator==="-")return t-r;if(this.operator==="*")return t*r;if(this.operator==="/")return t/r;if(this.operator==="mod")return t%r}},Ge=class s extends y{static grammarName="comparisonOperator";constructor(e,t,r,i,n,o,a){super(),this.operator=t,this.typeName=i,this.nullOk=n,this.ignoringCase=o,this.lhs=e,this.rhs=r,this.rhs2=a,this.args={lhs:e,rhs:r,rhs2:a}}sloppyContains(e,t,r){if(t.contains)return t.contains(r);if(t.includes)return t.includes(r);throw new Error("The value of "+e.sourceFor()+" does not have a contains or includes method on it")}sloppyMatches(e,t,r){if(t.match)return!!t.match(r);if(t.matches)return t.matches(r);throw new Error("The value of "+e.sourceFor()+" does not have a match or matches method on it")}static parse(e){var t=e.parseElement("mathOperator"),r=e.matchAnyOpToken("<",">","<=",">=","==","===","!=","!=="),i=r?r.value:null,n=!0,o=!1;if(i==null&&(e.matchToken("is")||e.matchToken("am")?e.matchToken("not")?e.matchToken("in")?i="not in":e.matchToken("a")||e.matchToken("an")?(i="not a",o=!0):e.matchToken("empty")?(i="not empty",n=!1):e.matchToken("between")?i="not between":e.matchToken("really")?(i="!==",e.matchToken("equal")&&e.matchToken("to")):e.matchToken("equal")?(e.matchToken("to"),i="!="):i="is not":e.matchToken("in")?i="in":e.matchToken("a")||e.matchToken("an")?(i="a",o=!0):e.matchToken("empty")?(i="empty",n=!1):e.matchToken("between")?i="between":e.matchToken("less")?(e.requireToken("than"),e.matchToken("or")?(e.requireToken("equal"),e.requireToken("to"),i="<="):i="<"):e.matchToken("greater")?(e.requireToken("than"),e.matchToken("or")?(e.requireToken("equal"),e.requireToken("to"),i=">="):i=">"):e.matchToken("really")?(i="===",e.matchToken("equal")&&e.matchToken("to")):e.matchToken("equal")?(e.matchToken("to"),i="=="):i="is":e.matchToken("equals")?i="==":e.matchToken("really")?(e.requireToken("equals"),i="==="):e.matchToken("exist")||e.matchToken("exists")?(i="exist",n=!1):e.matchToken("matches")||e.matchToken("match")?i="match":e.matchToken("contains")||e.matchToken("contain")?i="contain":e.matchToken("includes")||e.matchToken("include")?i="include":e.matchToken("starts")?(e.requireToken("with"),i="start with"):e.matchToken("ends")?(e.requireToken("with"),i="end with"):e.matchToken("precedes")||e.matchToken("precede")?i="precede":e.matchToken("follows")||e.matchToken("follow")?i="follow":(e.matchToken("do")||e.matchToken("does"))&&(e.requireToken("not"),e.matchToken("matches")||e.matchToken("match")?i="not match":e.matchToken("contains")||e.matchToken("contain")?i="not contain":e.matchToken("exist")?(i="not exist",n=!1):e.matchToken("include")?i="not include":e.matchToken("start")?(e.requireToken("with"),i="not start with"):e.matchToken("end")?(e.requireToken("with"),i="not end with"):e.matchToken("precede")?i="not precede":e.matchToken("follow")?i="not follow":e.raiseExpected("matches","contains","starts with","ends with","precede","follow"))),i){var a,l,u;o?(a=e.requireTokenType("IDENTIFIER"),l=!e.matchOpToken("!")):n&&(u=e.requireElement("mathOperator"),(i==="match"||i==="not match")&&(u=u.css?u.css:u));var h=null;(i==="between"||i==="not between")&&(e.requireToken("and"),h=e.requireElement("mathOperator"));var f=!1;e.matchToken("ignoring")&&(e.requireToken("case"),f=!0);var p=t;t=new s(p,i,u,a,l,f,h)}return t}resolve(e,{lhs:t,rhs:r,rhs2:i}){let n=this.operator,o=this.lhs,a=this.rhs,l=this.typeName,u=this.nullOk;if(this.ignoringCase&&(typeof t=="string"&&(t=t.toLowerCase()),typeof r=="string"&&(r=r.toLowerCase())),n==="is")return r===void 0&&a.type==="symbol"&&a.scope==="local"&&a.name!=="undefined"&&a.name!=="null"?!!e.meta.runtime.resolveProperty(t,a.name):t==r;if(n==="is not")return r===void 0&&a.type==="symbol"&&a.scope==="local"&&a.name!=="undefined"&&a.name!=="null"?!e.meta.runtime.resolveProperty(t,a.name):t!=r;if(n==="==")return t==r;if(n==="!=")return t!=r;if(n==="===")return t===r;if(n==="!==")return t!==r;if(n==="<")return t")return t>r;if(n==="<=")return t<=r;if(n===">=")return t>=r;if(n==="match")return t!=null&&this.sloppyMatches(o,t,r);if(n==="not match")return t==null||!this.sloppyMatches(o,t,r);if(n==="in")return r!=null&&this.sloppyContains(a,r,t);if(n==="not in")return r==null||!this.sloppyContains(a,r,t);if(n==="contain"||n==="include")return t!=null&&this.sloppyContains(o,t,r);if(n==="not contain"||n==="not include")return t==null||!this.sloppyContains(o,t,r);if(n==="start with")return t!=null&&String(t).startsWith(r);if(n==="not start with")return t==null||!String(t).startsWith(r);if(n==="end with")return t!=null&&String(t).endsWith(r);if(n==="not end with")return t==null||!String(t).endsWith(r);if(n==="between")return t>=r&&t<=i;if(n==="not between")return ti;if(n==="precede")return t!=null&&r!=null&&(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)!==0;if(n==="not precede")return t==null||r==null||(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)===0;if(n==="follow")return t!=null&&r!=null&&(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING)!==0;if(n==="not follow")return t==null||r==null||(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING)===0;if(n==="empty")return e.meta.runtime.isEmpty(t);if(n==="not empty")return!e.meta.runtime.isEmpty(t);if(n==="exist")return e.meta.runtime.doesExist(t);if(n==="not exist")return!e.meta.runtime.doesExist(t);if(n==="a")return e.meta.runtime.typeCheck(t,l.value,u);if(n==="not a")return!e.meta.runtime.typeCheck(t,l.value,u);throw new Error("Unknown comparison : "+n)}},$e=class s extends y{static grammarName="logicalOperator";static expressionType="top";constructor(e,t,r){super(),this.operator=t,this.lhs=e,this.rhs=r,this.args={lhs:e,rhs:r}}static parse(e){var t=e.parseElement("comparisonOperator"),r,i=null;for(r=e.matchToken("and")||e.matchToken("or");r;){i=i||r,i.value!==r.value&&e.raiseError("You must parenthesize logical operations with different operators");var n=e.requireElement("comparisonOperator");let o=r.value;t=new s(t,o,n),r=e.matchToken("and")||e.matchToken("or")}return t}resolve(e,{lhs:t,rhs:r}){return this.operator==="and"?t&&r:t||r}evaluate(e){var t=this,r=this.operator==="or",i=this.lhs.evaluate(e),n=function(o){if(!!o===r)return o;var a=t.rhs.evaluate(e);return a&&a.then?a.then(l=>t.resolve(e,{lhs:o,rhs:l})):t.resolve(e,{lhs:o,rhs:a})};return i&&i.then?i.then(n):n(i)}},Qe=class extends y{constructor(e,t){super(),this.type="dotOrColonPath",this.path=e,this.separator=t}evalStatically(){return this.path.join(this.separator?this.separator:"")}resolve(){return this.evalStatically()}},Ye=class extends y{static grammarName="collectionExpression";static KEYWORDS=["where","sorted","mapped","split","joined"];static parseOperand(e){var t=e.pushFollows(...this.KEYWORDS);try{return e.requireElement("expression")}finally{e.popFollows(t)}}static parse(e){for(var t=e.parseElement("unaryExpression"),r=!0;r;)if(r=!1,e.matchToken("where"))t=new Ke(t,this.parseOperand(e)),r=!0;else if(e.matchToken("sorted")){e.requireToken("by");var i=this.parseOperand(e),n=e.matchToken("descending");t=new Je(t,i,!!n),r=!0}else e.matchToken("mapped")?(e.requireToken("to"),t=new Xe(t,this.parseOperand(e)),r=!0):e.matchToken("split")?(e.requireToken("by"),t=new Ze(t,this.parseOperand(e)),r=!0):e.matchToken("joined")&&(e.requireToken("by"),t=new Ve(t,this.parseOperand(e)),r=!0);return t}},Ke=class extends y{constructor(e,t){super(),this.root=e,this.condition=t,this.args={root:e}}resolve(e,{root:t}){if(!t)return t;for(var r=[],i=Array.from(t),n=0;nst,ClassRef:()=>it,IdRef:()=>rt,QueryRef:()=>nt,StyleLiteral:()=>at,StyleRef:()=>ot});var rt=class s extends y{static grammarName="idRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r,i){super(),this.variant=e,this.type=e==="template"?"idRefTemplate":"idRef",this.css=t,this.value=r,this.args=e==="template"?{expr:i}:null}static parse(e){var t=e.matchTokenType("ID_REF");if(t&&t.value)if(t.template){var r=t.value.substring(2),i=O.tokenize(r),n=e.createChildParser(i),o=n.requireElement("expression");return new s("template",null,null,o)}else{let a=t.value.substring(1);return new s("static",t.value,a,null)}}resolve(e,{expr:t}={}){return this.variant==="template"?e.meta.runtime.getRootNode(e.me).getElementById(t):e.meta.runtime.getRootNode(e.me).getElementById(this.value)}get lhs(){return{}}set(e,t,r){var i=this.resolve(e);i&&e.meta.runtime.replaceInDom(i,r)}},it=class s extends y{static grammarName="classRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r,i){super(),this.variant=e,this.type=e==="template"?"classRefTemplate":"classRef",this.css=t,this.className=r,this.args=e==="template"?{expr:i}:null}static parse(e){var t=e.matchTokenType("CLASS_REF");if(t&&t.value)if(t.template){var r=t.value.substring(2),i=O.tokenize(r),n=e.createChildParser(i),o=n.requireElement("expression");return new s("template",null,null,o)}else{let a=t.value,l=a.slice(1);return new s("static",a,l,null)}}resolve(e,{expr:t}={}){return this.variant==="template"?new R("."+t,e.me,!0,e.meta.runtime):new R(this.css,e.me,!0,e.meta.runtime)}get lhs(){return{}}set(e,t,r){var i=Array.from(this.resolve(e));e.meta.runtime.replaceInDom(i,r)}},nt=class s extends y{static grammarName="queryRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r){super(),this.css=e,this.templateArgs=t,this.args=r?{parts:t}:null,this.template=r}static parse(e){var t=e.matchOpToken("<");if(t){var r=e.consumeUntil("/");e.requireOpToken("/"),e.requireOpToken(">");var i=r.map(function(u){return u.type==="STRING"?'"'+u.value+'"':u.value}).join(""),n,o,a;if(/\$[^=]/.test(i)){n=!0,o=O.tokenize(i,!0);var l=e.createChildParser(o);a=l.parseStringTemplate()}return new s(i,a,n)}}resolve(e,{parts:t}={}){return this.template?new re(this.css,e.me,t,e.meta.runtime):new R(this.css,e.me,!1,e.meta.runtime)}get lhs(){return this.template?{parts:this.templateArgs}:{}}set(e,t,r){var i=Array.from(this.resolve(e,t));e.meta.runtime.replaceInDom(i,r)}},st=class s extends y{static grammarName="attributeRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r){super(),this.name=e,this.css=t,this.value=r}static parse(e){var t=e.matchTokenType("ATTRIBUTE_REF");if(t&&t.value){var r=t.value;if(r.startsWith("["))var i=r.substring(2,r.length-1);else var i=r.substring(1);var n="["+i+"]",o=i.split("="),a=o[0],l=o[1];return l&&(l.startsWith('"')||l.startsWith("'"))&&(l=l.substring(1,l.length-1)),new s(a,n,l)}}resolve(e){var t=e.you||e.me;if(t)return e.meta.runtime.resolveAttribute(t,this.name)}get lhs(){return{}}set(e,t,r){var i=e.you||e.me;i&&(r==null?i.removeAttribute(this.name):i.setAttribute(this.name,r))}},ot=class s extends y{static grammarName="styleRef";static expressionType="leaf";static assignable=!0;constructor(e,t){super(),this.variant=e,this.type=e==="computed"?"computedStyleRef":"styleRef",this.name=t}static parse(e){var t=e.matchTokenType("STYLE_REF");if(t&&t.value){var r=t.value.slice(1);return r.startsWith("computed-")?(r=r.slice(9),new s("computed",r)):new s("style",r)}}resolve(e){var t=e.you||e.me;if(t)return this.variant==="computed"?e.meta.runtime.resolveComputedStyle(t,this.name):e.meta.runtime.resolveStyle(t,this.name)}get lhs(){return{}}set(e,t,r){var i=e.you||e.me;i&&(i.style[this.name]=r)}},at=class s extends y{static grammarName="styleLiteral";constructor(e,t){super(),this.stringParts=e,this.args={exprs:t}}static parse(e){if(e.matchOpToken("{")){for(var t=[""],r=[];e.hasMore();){if(e.matchOpToken("\\"))e.consumeToken();else{if(e.matchOpToken("}"))break;if(e.matchToken("$")){var i=e.matchOpToken("{"),n=e.parseElement("expression");i&&e.requireOpToken("}"),r.push(n),t.push("")}else{var o=e.consumeToken();t[t.length-1]+=e.source.substring(o.start,o.end)}}t[t.length-1]+=e.lastWhitespace()}return new s(t,r)}}resolve(e,{exprs:t}){var r="";return this.stringParts.forEach(function(n,o){r+=n,o in t&&(r+=t[o])}),r}};var ft={};N(ft,{StringPostfixExpression:()=>ut,TimeExpression:()=>ht,TypeCheckExpression:()=>ct});var Ui=["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","pc","pt","px"],ut=class s extends y{static grammarName="stringPostfixExpression";static expressionType="postfix";constructor(e,t){super(),this.postfix=t,this.args={value:e}}static parse(e,t){let r=e.matchAnyToken(...Ui)||e.matchOpToken("%");if(r)return new s(t,r.value)}resolve(e,{value:t}){return""+t+this.postfix}},ht=class s extends y{static grammarName="timeExpression";static expressionType="postfix";constructor(e,t){super(),this.time=e,this.factor=t,this.args={value:e}}static parse(e,t){var r=null;if(e.matchToken("s")||e.matchToken("seconds")?r=1e3:(e.matchToken("ms")||e.matchToken("milliseconds"))&&(r=1),!!r)return new s(t,r)}evalStatically(){return this.time.evalStatically()*this.factor}resolve(e,{value:t}){return t*this.factor}},ct=class s extends y{static grammarName="typeCheckExpression";static expressionType="postfix";constructor(e,t,r){super(),this.typeName=t,this.nullOk=r,this.args={value:e}}static parse(e,t){if(e.matchOpToken(":")){var r=e.requireTokenType("IDENTIFIER");if(r.value){var i=!e.matchOpToken("!");return new s(t,r,i)}}}resolve(e,{value:t}){var r=e.meta.runtime.typeCheck(t,this.typeName.value,this.nullOk);if(r)return t;throw new Error("Typecheck failed! Expected: "+this.typeName.value)}};var yt={};N(yt,{ClosestExpr:()=>dt,PositionalExpression:()=>pt,RelativePositionalExpression:()=>mt});var mt=class s extends y{static grammarName="relativePositionalExpression";static expressionType="unary";constructor(e,t,r,i,n,o,a,l){super(),this.thingElt=e,this.from=t,this.forwardSearch=r,this.inSearch=i,this.wrapping=n,this.inElt=o,this.withinElt=a,this.operator=l,this.args={thing:e,from:t,inElt:o,withinElt:a}}static parse(e){var t=e.matchAnyToken("next","previous");if(t){var r=t.value==="next",i=e.parseElement("leaf");if(e.matchToken("from")){e.pushFollow("in");try{var n=e.requireElement("unaryExpression")}finally{e.popFollow()}}else var n=e.requireElement("implicitMeTarget");var o=!1,a;if(e.matchToken("in")){o=!0;var l=e.requireElement("unaryExpression")}else e.matchToken("within")?a=e.requireElement("unaryExpression"):a=null;var u=!1;return e.matchToken("with")&&(e.requireToken("wrapping"),u=!0),new s(i,n,r,o,u,l,a,t.value)}}scanForwardQuery(e,t,r,i){for(var n=t.querySelectorAll(r),o=0;o=0;o--){var a=n[o];if(a.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return a}if(i)return n[n.length-1]}scanForwardArray(e,t,r,i){var n=[];for(var o of t)(o.matches(r)||o===e)&&n.push(o);for(var a=0;aTt,SomeExpression:()=>kt});var Tt=class s extends y{static grammarName="noExpression";static expressionType="unary";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchToken("no")){var t=e.requireElement("collectionExpression");return new s(t)}}resolve(e,{value:t}){return e.meta.runtime.isEmpty(t)}},kt=class s extends y{static grammarName="some";static expressionType="leaf";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchToken("some")){var t=e.requireElement("expression");return new s(t)}}resolve(e,{value:t}){return!e.meta.runtime.isEmpty(t)}};var wt={};N(wt,{ImplicitMeTarget:()=>gt});var gt=class s extends y{static grammarName="implicitMeTarget";constructor(){super()}static parse(e){return new s}resolve(e){return e.you||e.me}};var Ct={};N(Ct,{AppendCommand:()=>Lt,BeepCommand:()=>St,ExitCommand:()=>he,FetchCommand:()=>Mt,GoCommand:()=>Rt,HaltCommand:()=>At,LogCommand:()=>xt,MakeCommand:()=>It,PickCommand:()=>Ot,ReturnCommand:()=>Nt,ScrollCommand:()=>Ft,ThrowCommand:()=>qt});var bt=class extends y{constructor(){super(),this.type="symbol"}resolve(e){return e.meta.runtime.resolveSymbol("result",e)}get lhs(){return{}}set(e,t,r){e.meta.runtime.setSymbol("result",e,null,r)}},xt=class s extends d{static keyword="log";constructor(e,t){super(),this.exprs=e,this.withExpr=t,this.args={logger:t,values:e}}static parse(e){if(e.matchToken("log")){for(var t=[e.parseElement("expression")];e.matchOpToken(",");)t.push(e.requireElement("expression"));if(e.matchToken("with"))var r=e.requireElement("expression");return new s(t,r)}}resolve(e,{logger:t,values:r}){return t?t(...r):console.log(...r),this.findNext(e)}},St=class s extends d{static keyword="beep!";constructor(e){super(),this.exprs=e,this.args={values:e}}static parse(e){if(e.matchToken("beep!")){for(var t=[e.parseElement("expression")];e.matchOpToken(",");)t.push(e.requireElement("expression"));return new s(t)}}resolve(e,{values:t}){for(let r=0;r0;u++){var h=Math.floor(Math.random()*a.length);l.push(a.splice(h,1)[0])}e.result=l}else this.variant==="range"?(this.range.toEnd&&(i=t.length),this.range.includeStart||r++,this.range.includeEnd&&i++,i==null&&(i=r+1),e.result=t.slice(r,i)):this.variant==="match"?e.result=new RegExp(n,this.flags).exec(t):e.result=new ie(n,this.flags,t);return this.findNext(e)}},Mt=class s extends d{static keyword="fetch";constructor(e,t,r,i,n){super(),this.url=e,this.argExpressions=t,this.args={url:e,options:t},this.conversionType=r,this.conversion=i,this.dontThrow=n}static parseConversionInfo(e){var t="text",r;return e.matchToken("a")||e.matchToken("an"),e.matchToken("json")||e.matchToken("JSON")||e.matchToken("Object")?t="json":e.matchToken("response")||e.matchToken("Response")?t="response":e.matchToken("html")||e.matchToken("HTML")?t="html":e.matchToken("text")||e.matchToken("Text")||e.matchToken("String")||(r=e.requireElement("dotOrColonPath").evalStatically()),{type:t,conversion:r}}static parse(e){if(e.matchToken("fetch")){var t=e.parseURLOrExpression();if(e.matchToken("as"))var r=s.parseConversionInfo(e);if(e.matchToken("with")&&e.currentToken().value!=="{")var i=e.parseElement("nakedNamedArgumentList");else var i=e.parseElement("objectLiteral");r==null&&e.matchToken("as")&&(r=s.parseConversionInfo(e));var n=!1;e.matchToken("do")?(e.requireToken("not"),e.requireToken("throw"),n=!0):e.currentToken().value==="don"&&e.token(1).value==="'"&&e.token(2).value==="t"&&e.token(1).start===e.currentToken().end&&e.token(2).start===e.token(1).end&&(e.consumeToken(),e.consumeToken(),e.consumeToken(),e.requireToken("throw"),n=!0);var o=r?r.type:"text",a=r?r.conversion:null;return new s(t,i,o,a,n)}}resolve(e,{url:t,options:r}){var i=r||{};i.sender=e.me,i.headers=i.headers||{};var n=new AbortController,o=()=>n.abort();e.me.addEventListener("fetch:abort",o,{once:!0}),i.signal=n.signal,e.meta.runtime.triggerEvent(e.me,"hyperscript:beforeFetch",i),e.meta.runtime.triggerEvent(e.me,"fetch:beforeRequest",i);var a=!1;i.timeout&&setTimeout(()=>{a||n.abort()},i.timeout);var l=h=>(e.result=h,e.meta.runtime.triggerEvent(e.me,"fetch:afterRequest",{result:h}),a=!0,this.findNext(e)),u=!this.dontThrow&&this.conversionType!=="response";return fetch(t,i).then(h=>{var f={response:h};if(e.meta.runtime.triggerEvent(e.me,"fetch:afterResponse",f),h=f.response,u){for(var p=String(h.status),c=A.fetchThrowsOn||[],T=0;T(this.conversion&&(k=e.meta.runtime.convertValue(k,this.conversion)),this.conversionType==="html"&&(k=e.meta.runtime.convertValue(k,"Fragment")),l(k)))}).catch(h=>{throw e.meta.runtime.triggerEvent(e.me,"fetch:error",{reason:h}),h}).finally(()=>{e.me.removeEventListener("fetch:abort",o)})}};function di(s){s.matchToken("the");var e=s.matchAnyToken("top","middle","bottom"),t=s.matchAnyToken("left","center","right");(e||t)&&s.requireToken("of");var r=s.requireElement("unaryExpression"),i=s.matchAnyOpToken("+","-"),n;if(i){s.pushFollow("px");try{n=s.requireElement("expression")}finally{s.popFollow()}}s.matchToken("px");var o;s.matchToken("in")&&(o=s.requireElement("unaryExpression"));var a=s.matchAnyToken("smoothly","instantly"),l={block:"start",inline:"nearest"},u={top:"start",bottom:"end",middle:"center"},h={left:"start",center:"center",right:"end"},f={smoothly:"smooth",instantly:"instant"};return e&&(l.block=u[e.value]),t&&(l.inline=h[t.value]),a&&(l.behavior=f[a.value]),{target:r,offset:n,plusOrMinus:i,scrollOptions:l,container:o}}function Bi(s){var e=s.matchAnyToken("smoothly","instantly");if(e)return e.value==="smoothly"?"smooth":"instant"}function yi(s,e,t,r,i,n){s.meta.runtime.implicitLoop(e,function(o){if(o===window&&(o=document.body),n){var a=(n instanceof Element,n),l=o.offsetTop-a.offsetTop,u=o.offsetLeft-a.offsetLeft;if(r){var h=r.value==="+"?t:t*-1;l+=h}a.scrollTo({top:l,left:u,behavior:i.behavior||"auto"});return}if(r){var f=o.getBoundingClientRect(),p=document.createElement("div"),c=r.value==="+"?t:t*-1,T=i.inline=="start"||i.inline=="end"?c:0,m=i.block=="start"||i.block=="end"?c:0;p.style.position="absolute",p.style.top=f.top+window.scrollY+m+"px",p.style.left=f.left+window.scrollX+T+"px",p.style.height=f.height+"px",p.style.width=f.width+"px",p.style.zIndex=""+Number.MIN_SAFE_INTEGER,p.style.opacity="0",document.body.appendChild(p),setTimeout(function(){document.body.removeChild(p)},100),o=p}o.scrollIntoView(i)})}var Ft=class s extends d{static keyword="scroll";constructor(e,t,r,i,n,o){super(),this.target=e,this.plusOrMinus=r,this.scrollOptions=i,this.byMode=o,this.args={target:e,offset:t,container:n}}static parse(e){if(e.matchToken("scroll")){if(e.matchToken("to")){var t=di(e);return new s(t.target,t.offset,t.plusOrMinus,t.scrollOptions,t.container)}var r=e.matchAnyToken("up","down","left","right"),i;!r&&e.currentToken().value!=="by"&&(i=e.requireElement("unaryExpression"),r=e.matchAnyToken("up","down","left","right")),e.requireToken("by"),e.pushFollow("px");var n;try{n=e.requireElement("expression")}finally{e.popFollow()}e.matchToken("px");var o=Bi(e),a={};o&&(a.behavior=o);var l={direction:r?r.value:"down"};return new s(i,n,null,a,null,l)}}resolve(e,{target:t,offset:r,container:i}){if(this.byMode){var n=t||document.documentElement,o=this.byMode.direction,a=0,l=0;o==="up"?a=-r:o==="down"?a=r:o==="left"?l=-r:o==="right"&&(l=r);var u={top:a,left:l};this.scrollOptions.behavior&&(u.behavior=this.scrollOptions.behavior),n.scrollBy(u)}else yi(e,t,r,this.plusOrMinus,this.scrollOptions,i);return this.findNext(e)}},Rt=class s extends d{static keyword="go";constructor(e,t,r,i,n,o){super(),this.target=e,this.args={target:e,offset:t},this.back=r,this.newWindow=i,this.plusOrMinus=n,this.scrollOptions=o}static parse(e){if(e.matchToken("go")){if(e.matchToken("back"))return new s(null,null,!0);if(e.matchToken("to"),e.matchToken("url")){var i=e.requireElement("stringLike"),n=!1;return e.matchToken("in")&&(e.requireToken("new"),e.requireToken("window"),n=!0),new s(i,null,!1,n)}var t=e.currentToken();if(t.value==="the"||t.value==="top"||t.value==="middle"||t.value==="bottom"||t.value==="left"||t.value==="center"||t.value==="right"){var r=di(e);return new s(r.target,r.offset,!1,!1,r.plusOrMinus,r.scrollOptions)}var i=e.parseURLOrExpression(),n=!1;return e.matchToken("in")&&(e.requireToken("new"),e.requireToken("window"),n=!0),new s(i,null,!1,n)}}resolve(e,{target:t,offset:r}){if(this.back)window.history.back();else if(this.scrollOptions)yi(e,t,r,this.plusOrMinus,this.scrollOptions);else if(t!=null)if(t instanceof Element)t.scrollIntoView({block:"start",inline:"nearest"});else{var i=String(t);i.startsWith("#")?window.location.hash=i:this.newWindow?window.open(i):window.location.href=i}return this.findNext(e)}};var jt={};N(jt,{DecrementCommand:()=>Dt,DefaultCommand:()=>_t,IncrementCommand:()=>Pt,PutCommand:()=>Wt,SetCommand:()=>ce,SwapCommand:()=>Ht});var ce=class s extends d{static keyword="set";constructor(e,t,r=null){super(),this.target=e,this.objectLiteral=r,r?this.args={obj:r,setTarget:e}:this.args={...e.lhs,value:t}}static parse(e){if(e.matchToken("set")){if(e.currentToken().type==="L_BRACE"){var t=e.requireElement("objectLiteral");e.requireToken("on");var r=e.requireElement("expression");return new s(r,null,t)}try{e.pushFollow("to");var r=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;r.type==="parenthesized";)r=r.expr;e.requireToken("to");var i=e.requireElement("expression");return new s(r,i)}}resolve(e,t){if(this.objectLiteral){var{obj:r,setTarget:i}=t;Object.assign(i,r)}else{var{value:n,...o}=t;this.target.set(e,o,n)}return this.findNext(e)}},_t=class s extends d{static keyword="default";constructor(e,t){super(),this.target=e,this.setter=t,this.args={targetValue:e}}static parse(e){if(e.matchToken("default")){try{e.pushFollow("to");var t=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;t.type==="parenthesized";)t=t.expr;e.requireToken("to");var r=e.requireElement("expression"),i=new ce(t,r),n=new s(t,i);return i.parent=n,n}}resolve(e,{targetValue:t}){return t!=null&&t!==""?this.findNext(e):this.setter}},Pt=class s extends d{static keyword="increment";constructor(e,t){super(),this.target=e,this.amountExpr=t,this.args={targetValue:e,amount:t,...e.lhs}}static parse(e){if(e.matchToken("increment")){for(var t,r=e.parseElement("assignableExpression");r.type==="parenthesized";)r=r.expr;return e.matchToken("by")&&(t=e.requireElement("expression")),new s(r,t)}}resolve(e,t){var{targetValue:r,amount:i,...n}=t;r=r?parseFloat(r):0,i=this.amountExpr?parseFloat(i):1;var o=r+i;return e.result=o,this.target.set(e,n,o),this.findNext(e)}},Dt=class s extends d{static keyword="decrement";constructor(e,t){super(),this.target=e,this.amountExpr=t,this.args={targetValue:e,amount:t,...e.lhs}}static parse(e){if(e.matchToken("decrement")){var t;try{e.pushFollow("by");var r=e.parseElement("assignableExpression")}finally{e.popFollow()}for(;r.type==="parenthesized";)r=r.expr;return e.matchToken("by")&&(t=e.requireElement("expression")),new s(r,t)}}resolve(e,t){var{targetValue:r,amount:i,...n}=t;r=r?parseFloat(r):0,i=this.amountExpr?parseFloat(i):1;var o=r-i;return e.result=o,this.target.set(e,n,o),this.findNext(e)}},Ht=class s extends d{static keyword="swap";constructor(e,t){super(),this.target1=e,this.target2=t,this.args={value1:e,value2:t,root1:e.lhs.root,index1:e.lhs.index,root2:t.lhs.root,index2:t.lhs.index}}static parse(e){if(e.matchToken("swap")){try{e.pushFollow("with");var t=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;t.type==="parenthesized";)t=t.expr;e.requireToken("with");for(var r=e.requireElement("assignableExpression");r.type==="parenthesized";)r=r.expr;return new s(t,r)}}resolve(e,{value1:t,value2:r,root1:i,index1:n,root2:o,index2:a}){if(t instanceof Element&&r instanceof Element){var l=document.createComment("");t.replaceWith(l),r.replaceWith(t),l.replaceWith(r)}else this.target1.set(e,{root:i,index:n},r),this.target2.set(e,{root:o,index:a},t);return this.findNext(e)}},Wt=class s extends d{static keyword="put";constructor(e,t,r,i){super(),this.target=e,this.operation=t,this.value=r,this.rootExpr=i,this.symbolWrite=e.type==="symbol"&&t==="into",this.arrayIndex=e.type==="arrayIndex",this.attributeWrite=(e.type==="attributeRef"||e.attribute&&e.attribute.type==="attributeRef")&&t==="into",this.styleWrite=(e.type==="styleRef"||e.attribute&&e.attribute.type==="styleRef")&&t==="into",this.arrayIndex?this.prop=e.prop:this.symbolWrite?this.prop=e.name:e.type==="attributeRef"||e.type==="styleRef"?this.prop=e.name:e.attribute?this.prop=e.attribute.name:e.prop?this.prop=e.prop.value:this.prop=null,this.args={root:i,prop:this.prop,value:r}}static parse(e){if(e.matchToken("put")){var t=e.requireElement("expression"),r=e.matchAnyToken("into","before","after");r==null&&e.matchToken("at")&&(e.matchToken("the"),r=e.matchAnyToken("start","end"),e.requireToken("of")),r==null&&e.raiseExpected("into","before","at start of","at end of","after");for(var i=e.requireElement("expression");i.type==="parenthesized";)i=i.expr;var n=r.value,o;return i.type==="arrayIndex"&&n==="into"||i.prop&&i.root&&n==="into"?o=i.root:i.type==="symbol"&&n==="into"?o=null:i.type==="attributeRef"&&n==="into"||i.type==="styleRef"&&n==="into"?o=e.requireElement("implicitMeTarget"):i.attribute&&n==="into"?o=i.root:o=i,new s(i,n,t,o)}}putInto(e,t,r,i){if(t==null)var n=e.meta.runtime.resolveSymbol(r,e);else var n=t;if((t==null||r==null)&&(n instanceof Element||n instanceof Document)){for(;n.firstChild;)n.removeChild(n.firstChild);n.append(e.meta.runtime.convertValue(i,"Fragment")),e.meta.runtime.processNode(n)}else t==null?e.meta.runtime.setSymbol(r,e,null,i):t[r]=i}resolve(e,{root:t,prop:r,value:i}){if(this.symbolWrite)this.putInto(e,t,r,i);else if(e.meta.runtime.nullCheck(t,this.rootExpr),this.operation==="into")if(this.attributeWrite)e.meta.runtime.implicitLoop(t,function(l){i==null?l.removeAttribute(r):l.setAttribute(r,i)});else if(this.styleWrite)e.meta.runtime.implicitLoop(t,function(l){l.style[r]=i});else if(this.arrayIndex)t[r]=i;else{var n=this;e.meta.runtime.implicitLoop(t,function(l){n.putInto(e,l,r,i)})}else if(Array.isArray(t))this.operation==="start"?t.unshift(i):t.push(i),e.meta.runtime.notifyMutation(t);else{var o={before:Element.prototype.before,after:Element.prototype.after,start:Element.prototype.prepend,end:Element.prototype.append},a=o[this.operation]||Element.prototype.append;e.meta.runtime.implicitLoop(t,function(l){a.call(l,i instanceof Node?i:e.meta.runtime.convertValue(i,"Fragment")),l.parentElement?e.meta.runtime.processNode(l.parentElement):e.meta.runtime.processNode(l)})}return this.findNext(e)}};var Gt={};N(Gt,{EventName:()=>zt,SendCommand:()=>Bt,WaitCommand:()=>Ut});var Ut=class s extends d{static keyword="wait";constructor(e,t,r,i){super(),this.variant=e,this.event=t,this.on=r,this.time=i,this.args=e==="event"?{on:r}:{time:i}}static parse(e){if(e.matchToken("wait"))if(e.matchToken("for")){e.matchToken("a");var t=[];do{var r=e.token(0);r.type==="NUMBER"||r.type==="L_PAREN"?t.push(e.requireElement("expression")):t.push({name:e.requireElement("dotOrColonPath","Expected event name").evalStatically(),args:I.parseEventArgs(e)})}while(e.matchToken("or"));if(e.matchToken("from"))var i=e.requireElement("expression");return new s("event",t,i,null)}else{var n;return e.matchToken("a")?(e.requireToken("tick"),n=0):n=e.requireElement("expression"),new s("time",null,null,n)}}resolve(e,{on:t,time:r}){if(this.variant==="event"){var i=t||e.me;if(!(i instanceof EventTarget))throw new Error("Not a valid event target: "+this.on.sourceFor());let n=this.event;return new Promise(o=>{var a=!1;for(let u of n){var l=h=>{if(e.result=h,u.name&&u.args)for(let f of u.args)e.locals[f.value]=h[f.value]||(h.detail?h.detail[f.value]:null);a||(a=!0,o(this.findNext(e)))};if(u.name)i.addEventListener(u.name,l,{once:!0});else{let h=u.evaluate(e);setTimeout(l,h,h)}}})}else return new Promise(n=>{setTimeout(()=>{n(this.findNext(e))},r)})}},Bt=class s extends d{static keyword=["send","trigger"];constructor(e,t,r){super(),this.eventName=e,this.details=t,this.to=r,this.args={to:r,eventName:e,details:t},this.toExpr=r}static parse(e){var t=e.matchToken("trigger");if(!(!t&&!e.matchToken("send"))){var r=e.requireElement("eventName"),i=e.parseElement("namedArgumentList");if(e.matchToken(t?"on":"to"))var n=e.requireElement("expression");else var n=e.requireElement("implicitMeTarget");return new s(r,i,n)}}resolve(e,{to:t,eventName:r,details:i}){return e.meta.runtime.nullCheck(t,this.toExpr),e.meta.runtime.implicitLoop(t,function(n){e.meta.runtime.triggerEvent(n,r,i,e.me)}),this.findNext(e)}},zt=class s extends y{static grammarName="eventName";constructor(e){super(),this.value=e}evalStatically(){return this.value}resolve(e){return this.value}static parse(e){var t;return(t=e.matchTokenType("STRING"))?new s(t.value):e.parseElement("dotOrColonPath")}};var Vt={};N(Vt,{BreakCommand:()=>Xt,ContinueCommand:()=>Jt,IfCommand:()=>Yt,RepeatCommand:()=>Kt,TellCommand:()=>Zt});var $t=class extends d{constructor(){super(),this.type="waitATick"}resolve(e){return new Promise(t=>{setTimeout(()=>t(e.meta.runtime.findNext(this)),0)})}},Qt=class extends d{constructor(e,t,r){super(),this.identifier=e.identifier,this.indexIdentifier=e.indexIdentifier,this.slot=e.slot,this.expression=e.expression,this.forever=e.forever,this.times=e.times,this.until=e.until,this.event=e.event,this.on=e.on,this.whileExpr=e.whileExpr,this.bottomTested=e.bottomTested,this.loop=t,this.elseBranch=r,this.args={whileValue:e.whileExpr,times:e.times}}resolveNext(){return this}resolve(e,{whileValue:t,times:r}){var i=e.meta.iterators[this.slot],n=!1,o=null;if(this.bottomTested&&i.index===0)n=!0;else if(this.forever)n=!0;else if(this.until)this.event?n=e.meta.iterators[this.slot].eventFired===!1:n=t!==!0;else if(this.whileExpr)n=t;else if(r)n=i.index")}return t.didIterate=!0,t.index++,this.loop}_endLoop(e,t){var r=t.didIterate;return e.meta.iterators[this.slot]=null,!r&&this.elseBranch?this.elseBranch:e.meta.runtime.findNext(this.parent,e)}},Yt=class s extends d{static keyword="if";constructor(e,t,r){super(),this.expr=e,this.trueBranch=t,this.falseBranch=r,this.args={value:e}}static parse(e){if(!e.matchToken("if"))return;var t=e.requireElement("expression");e.matchToken("then");var r=e.parseElement("commandList"),i=!1;let n=e.matchToken("else")||e.matchToken("otherwise");if(n){let l=e.peekToken("if");if(i=l!=null&&l.line===n.line,i)var o=e.parseElement("command");else var o=e.parseElement("commandList")}e.hasMore()&&!i&&e.requireToken("end");var a=new s(t,r,o);return e.setParent(r,a),e.setParent(o,a),a}resolve(e,{value:t}){return t?this.trueBranch:this.falseBranch?this.falseBranch:this.findNext(e)}},Kt=class s extends d{static keyword=["repeat","for"];constructor(e,t,r,i,n){super(),this.expression=e,this.evt=t,this.on=r,this.slot=i,this.repeatLoopCommand=n,this.args={value:e,event:t,on:r}}static parseRepeatExpression(e,t){var r=e.currentToken(),i;if(e.matchToken("for")||t){var n=e.requireTokenType("IDENTIFIER");i=n.value,e.requireToken("in");for(var o=e.requireElement("expression"),a=o;a;)a.condition&&(a.varName=i),a=a.root}else if(e.matchToken("in")){i="it";var o=e.requireElement("expression")}else if(e.matchToken("while"))var l=e.requireElement("expression");else if(e.matchToken("until")){var u=!0;if(e.matchToken("event")){var h=e.requireElement("dotOrColonPath","Expected event name");if(e.matchToken("from"))var f=e.requireElement("expression")}else var l=e.requireElement("expression")}else if(!e.commandBoundary(e.currentToken())&&e.currentToken().value!=="forever"){var p=e.requireElement("expression");e.requireToken("times")}else{e.matchToken("forever");var c=!0}if(e.matchToken("index"))var n=e.requireTokenType("IDENTIFIER"),T=n.value;else if(e.matchToken("indexed")){e.requireToken("by");var n=e.requireTokenType("IDENTIFIER"),T=n.value}var m=e.parseElement("commandList");if(m&&h){for(var v=m;v.next;)v=v.next;var k=new $t;v.next=k}var b=!1;c&&e.hasMore()&&(e.matchToken("until")?(c=!1,u=!0,b=!0,l=e.requireElement("expression")):e.matchToken("while")&&(c=!1,b=!0,l=e.requireElement("expression")));var g=null;if(e.matchToken("else")&&(g=e.parseElement("commandList")),e.hasMore()&&e.requireToken("end"),i==null){i="_implicit_repeat_"+r.start;var x=i}else var x=i+"_"+r.start;let E={identifier:i,indexIdentifier:T,slot:x,expression:o,forever:c,times:p,until:u,event:h,on:f,whileExpr:l,bottomTested:b},q=new Qt(E,m,g),M=new s(o,h,f,x,q);return e.setParent(m,q),g&&e.setParent(g,M),e.setParent(q,M),M}static parse(e){if(e.matchToken("for"))return s.parseRepeatExpression(e,!0);if(e.matchToken("repeat"))return s.parseRepeatExpression(e,!1)}resolve(e,{value:t,event:r,on:i}){var n={index:0,value:t,eventFired:!1};if(e.meta.iterators[this.slot]=n,t?t[Symbol.asyncIterator]?(n.iterator=t[Symbol.asyncIterator](),n.async=!0):t[Symbol.iterator]?n.iterator=t[Symbol.iterator]():n.iterator=Object.keys(t)[Symbol.iterator]():this.repeatLoopCommand.elseBranch&&(n.iterator=[][Symbol.iterator]()),this.evt){var o=i||e.me;let a=this.slot;o.addEventListener(r,function(l){e.meta.iterators[a].eventFired=!0},{once:!0})}return this.repeatLoopCommand}},Jt=class s extends d{static keyword="continue";static parse(e){if(e.matchToken("continue"))return new s}resolve(e){for(var t=this.parent;t;t=t.parent)if(t.loop!=null)return t.resolveNext(e);throw new Error("Command `continue` cannot be used outside of a `repeat` loop.")}},Xt=class s extends d{static keyword="break";static parse(e){if(e.matchToken("break"))return new s}resolve(e){for(var t=this.parent;t;t=t.parent)if(t.loop!=null)return e.meta.runtime.findNext(t.parent,e);throw new Error("Command `break` cannot be used outside of a `repeat` loop.")}},Zt=class s extends d{static keyword="tell";constructor(e,t,r){super(),this.value=e,this.body=t,this.slot=r,this.args={value:e}}static parse(e){var t=e.currentToken();if(e.matchToken("tell")){var r=e.requireElement("expression"),i=e.requireElement("commandList");e.hasMore()&&!e.featureStart(e.currentToken())&&e.requireToken("end");var n="tell_"+t.start,o=new s(r,i,n);return e.setParent(i,o),o}}resolveNext(e){var t=e.meta.iterators[this.slot];return t.indexrr,JsBody:()=>er,JsCommand:()=>tr});var er=class s{static grammarName="jsBody";constructor(e,t){this.type="jsBody",this.jsSource=e,this.exposedFunctionNames=t}static parse(e){for(var t=e.currentToken().start,r=e.currentToken(),i=[],n="",o=!1;e.hasMore();){r=e.consumeToken();var a=e.token(0,!0);if(a.type==="IDENTIFIER"&&a.value==="end")break;o?r.type==="IDENTIFIER"||r.type==="NUMBER"?n+=r.value:(n!==""&&i.push(n),n="",o=!1):r.type==="IDENTIFIER"&&r.value==="function"&&(o=!0)}var l=r.end+1;return new s(e.source.substring(t,l),i)}},tr=class s extends d{static keyword="js";constructor(e,t,r){super(),this.jsSource=e,this.function=t,this.inputs=r}static parse(e){if(e.matchToken("js")){var t=[];if(e.matchOpToken("(")&&!e.matchOpToken(")")){do{var r=e.requireTokenType("IDENTIFIER");t.push(r.value)}while(e.matchOpToken(","));e.requireOpToken(")")}var i=e.requireElement("jsBody");e.matchToken("end");var n=new Function(...t,i.jsSource);return new s(i.jsSource,n,t)}}resolve(e){var t=this.inputs.map(i=>e.meta.runtime.resolveSymbol(i,e,"local")),r=this.function.apply(e.meta.runtime.globalScope,t);return r&&typeof r.then=="function"?r.then(i=>(e.result=i,this.findNext(e))):(e.result=r,this.findNext(e))}},rr=class s extends d{static keyword=["get","call"];constructor(e){super(),this.expr=e,this.args={result:e}}static parse(e){var t=e.matchToken("call");if(!(!t&&!e.matchToken("get"))){var r=e.requireElement("expression");return t&&r&&r.type!=="functionCall"&&e.raiseError("Must be a function invocation"),new s(r)}}resolve(e,{result:t}){return e.result=t,this.findNext(e)}};var sr={};N(sr,{PseudoCommand:()=>nr});var nr=class s extends d{static grammarName="pseudoCommand";constructor(e,t,r,i){super(),this.variant=e,this.expr=t,this._root=i,this._realRoot=r,e==="target"?(this.root=r,this.argExpressions=i.argExpressions,this.args={target:r,argVals:i.argExpressions}):this.args={result:t}}static parse(e){let t=e.token(1);if(!(t&&t.op&&(t.value==="."||t.value==="(")))return null;for(var r=e.requireElement("primaryExpression"),i=r.root,n=r;i.root!=null;)n=n.root,i=i.root;if(r.type!=="functionCall"&&e.raiseError("Pseudo-commands must be function calls"),n.type==="functionCall"&&n.root.root==null){if(e.matchAnyToken("the","to","on","with","into","from","at"))var o=e.requireElement("expression");else if(e.matchToken("me"))var o=e.requireElement("implicitMeTarget")}return o?new s("target",r,o,n):new s("simple",r,null,null)}resolve(e,{target:t,argVals:r,result:i}){if(this.variant==="target"){e.meta.runtime.nullCheck(t,this._realRoot);var n=this._root.root.name,o=t[n];e.meta.runtime.nullCheck(o,this._root),o.hyperfunc&&r.push(e),e.result=o.apply(t,r),e.meta.runtime.maybeNotify(t,n)}else e.result=i;return this.findNext(e)}};var xr={};N(xr,{AddCommand:()=>or,AnswerCommand:()=>wr,AskCommand:()=>gr,BlurCommand:()=>pr,CloseCommand:()=>Tr,EmptyCommand:()=>vr,FocusCommand:()=>mr,HideCommand:()=>ur,MeasureCommand:()=>fr,MorphCommand:()=>br,OpenCommand:()=>yr,RemoveCommand:()=>ar,ResetCommand:()=>dr,SelectCommand:()=>Er,ShowCommand:()=>hr,SpeakCommand:()=>kr,TakeCommand:()=>cr,ToggleCommand:()=>lr});var H={display:function(s,e,t,r){if(!t&&e instanceof HTMLDialogElement){s==="hide"?e.close():s==="show"?e.open||e.show():s==="toggle"&&(e.open?e.close():e.show());return}if(t)e.style.display=t;else if(s==="toggle")getComputedStyle(e).display==="none"?H.display("show",e,t,r):H.display("hide",e,t,r);else if(s==="hide"){let i=r.getInternalData(e);i.originalDisplay==null&&(i.originalDisplay=e.style.display),e.style.display="none"}else{let i=r.getInternalData(e);i.originalDisplay&&i.originalDisplay!=="none"?e.style.display=i.originalDisplay:e.style.removeProperty("display")}},visibility:function(s,e,t){t?e.style.visibility=t:s==="toggle"?getComputedStyle(e).visibility==="hidden"?H.visibility("show",e,t):H.visibility("hide",e,t):s==="hide"?e.style.visibility="hidden":e.style.visibility="visible"},opacity:function(s,e,t){t?e.style.opacity=t:s==="toggle"?getComputedStyle(e).opacity==="0"?H.opacity("show",e,t):H.opacity("hide",e,t):s==="hide"?e.style.opacity="0":e.style.opacity="1"},hidden:function(s,e){s==="toggle"&&(s=e.hasAttribute("hidden")?"show":"hide"),s==="hide"?e.setAttribute("hidden",""):e.removeAttribute("hidden")}};function Ti(s){return s.split(";").map(function(e){return e.split(":")[0].trim()}).filter(Boolean)}function ki(s,e){for(var t=0;t-1&&n.splice(T,1),o.notifyMutation(n)}else n instanceof Set||n instanceof Map?(n.delete(t),o.notifyMutation(n)):o.implicitLoop(t,function(k){k.parentElement&&(n==null||n.contains(k))&&k.parentElement.removeChild(k)})}else if(this.variant==="css"){o.nullCheck(n,this.fromExpr);var m=Ti(i);o.implicitLoop(n,function(k){ki(k,m)})}else if(o.nullCheck(n,this.fromExpr),r)o.forEach(r,function(k){a.when?l=o.implicitLoopWhen(n,a.when,e,function(b){b.classList.remove(k.className)},function(b){b.classList.add(k.className)}):o.implicitLoop(n,function(b){b.classList.remove(k.className)})});else{var v=this.attributeRef;this.when?l=o.implicitLoopWhen(n,this.when,e,function(k){k.removeAttribute(v.name)},function(k){k.setAttribute(v.name,v.value)}):o.implicitLoop(n,function(k){k.removeAttribute(v.name)})}return l&&l.then?l.then(function(){return o.findNext(a,e)}):o.findNext(this,e)}isDOMTarget(e){return e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection}},lr=class s extends C{static keyword="toggle";constructor(e,t,r,i,n,o,a,l,u,h,f,p,c,T,m,v){super(),this.classRef=e,this.classRef2=t,this.classRefs=r,this.attributeRef=i,this.attributeRef2=n,this.on=o,this.time=a,this.evt=l,this.from=u,this.visibility=h,this.betweenClass=f,this.betweenAttr=p,this.hideShowStrategy=c,this.betweenValues=T,this.toggleExpr=m,this.styleProp=v,this.onExpr=o,this.args={on:o,time:a,evt:l,from:u,classRef:e,classRef2:t,classRefs:r,betweenValues:T}}static parse(e){if(e.matchToken("toggle")){e.matchAnyToken("the","my");var t=!1,r=null,i=null,n=null,o=null,a=null,l=null,u=null,h=!1,f=!1,p=null,c=null;if(e.currentToken().type==="STYLE_REF")if(c=e.consumeToken().value.slice(1),t=!0,r=C.resolveHideShowStrategy(e,c),e.matchToken("of")){var T=e.pushFollows("with","between");try{i=e.requireElement("expression")}finally{e.popFollows(T)}}else i=e.requireElement("implicitMeTarget");else if(e.matchToken("between"))n=e.parseElement("classRef"),n!=null?(h=!0,e.requireToken("and"),o=e.requireElement("classRef")):(f=!0,l=e.parseElement("attributeRef"),l==null&&e.raiseError("Expected either a class reference or attribute expression"),e.requireToken("and"),u=e.requireElement("attributeRef"));else if(n=e.parseElement("classRef"))for(a=[n];n=e.parseElement("classRef");)a.push(n);else(l=e.parseElement("attributeRef"))||(e.pushFollow("between"),p=e.parseElement("assignableExpression"),e.popFollow(),p==null&&e.raiseError("Expected a class reference, attribute, style property, or settable expression"));!t&&!p&&(e.matchToken("on")?i=e.requireElement("expression"):i=e.requireElement("implicitMeTarget"));var m=null;if(e.matchToken("between")){for(e.pushFollow("and"),m=[e.requireElement("expression")];e.matchOpToken(",");)m.push(e.requireElement("expression"));e.popFollow(),e.requireToken("and"),m.push(e.requireElement("expression"))}p&&!m&&e.raiseError("toggle requires 'between' with values");var v=null,k=null,b=null;return e.peekToken("for")&&!e.peekToken("in",2)?(e.matchToken("for"),v=e.requireElement("expression")):e.matchToken("until")&&(k=e.requireElement("dotOrColonPath","Expected event name"),e.matchToken("from")&&(b=e.requireElement("expression"))),new s(n,o,a,l,u,i,v,k,b,t,h,f,r,m,p,c)}}toggle(e,t,r,i,n,o){if(this.betweenValues){if(this.visibility)e.meta.runtime.implicitLoop(t,c=>{var T=c.style[this.styleProp]||getComputedStyle(c)[this.styleProp],m=o.findIndex(v=>v==T);c.style[this.styleProp]=o[(m+1)%o.length]});else{var a=this.toggleExpr.evaluate(e),l=o.findIndex(c=>c==a),u=o[(l+1)%o.length],h={};for(var f in this.toggleExpr.lhs){var p=this.toggleExpr.lhs[f];h[f]=p&&p.evaluate?p.evaluate(e):p}this.toggleExpr.set(e,h,u)}return}e.meta.runtime.nullCheck(t,this.onExpr),this.visibility?e.meta.runtime.implicitLoop(t,c=>{this.hideShowStrategy("toggle",c,null,e.meta.runtime)}):this.betweenClass?e.meta.runtime.implicitLoop(t,c=>{c.classList.contains(r.className)?(c.classList.remove(r.className),c.classList.add(i.className)):(c.classList.add(r.className),c.classList.remove(i.className))}):this.betweenAttr?e.meta.runtime.implicitLoop(t,c=>{c.hasAttribute(this.attributeRef.name)&&c.getAttribute(this.attributeRef.name)===this.attributeRef.value?(c.removeAttribute(this.attributeRef.name),c.setAttribute(this.attributeRef2.name,this.attributeRef2.value)):(c.hasAttribute(this.attributeRef2.name)&&c.removeAttribute(this.attributeRef2.name),c.setAttribute(this.attributeRef.name,this.attributeRef.value))}):n?e.meta.runtime.forEach(n,c=>{e.meta.runtime.implicitLoop(t,T=>{T.classList.toggle(c.className)})}):e.meta.runtime.implicitLoop(t,c=>{c.hasAttribute(this.attributeRef.name)?c.removeAttribute(this.attributeRef.name):c.setAttribute(this.attributeRef.name,this.attributeRef.value)})}resolve(e,{on:t,time:r,evt:i,from:n,classRef:o,classRef2:a,classRefs:l,betweenValues:u}){return r?new Promise(h=>{this.toggle(e,t,o,a,l,u),setTimeout(()=>{this.toggle(e,t,o,a,l,u),h(this.findNext(e))},r)}):i?new Promise(h=>{var f=n||e.me;f.addEventListener(i,()=>{this.toggle(e,t,o,a,l,u),h(this.findNext(e))},{once:!0}),this.toggle(e,t,o,a,l,u)}):(this.toggle(e,t,o,a,l,u),this.findNext(e))}},ur=class s extends C{static keyword="hide";constructor(e,t,r){super(),this.target=e,this.targetExpr=e,this.when=t,this.hideShowStrategy=r,this.args={target:e}}static parse(e){if(e.matchToken("hide")){var t=C.parseShowHideTarget(e),r=null;if(e.matchToken("with")&&(r=e.requireTokenType("IDENTIFIER","STYLE_REF").value,r.startsWith("*")&&(r=r.slice(1))),e.matchToken("when"))var i=e.requireElement("expression");var n=C.resolveHideShowStrategy(e,r);return new s(t,i,n)}}resolve(e,{target:t}){var r=e.meta.runtime,i=this;if(r.nullCheck(t,this.targetExpr),this.when){var n=r.implicitLoopWhen(t,this.when,e,function(o){i.hideShowStrategy("hide",o,null,r)},function(o){i.hideShowStrategy("show",o,null,r)});if(n&&n.then)return n.then(function(){return r.findNext(i,e)})}else r.implicitLoop(t,function(o){i.hideShowStrategy("hide",o,null,r)});return r.findNext(this,e)}},hr=class s extends C{static keyword="show";constructor(e,t,r,i){super(),this.target=e,this.targetExpr=e,this.when=t,this.arg=r,this.hideShowStrategy=i,this.args={target:e}}static parse(e){if(e.matchToken("show")){var t=C.parseShowHideTarget(e),r=null;e.matchToken("with")&&(r=e.requireTokenType("IDENTIFIER","STYLE_REF").value,r.startsWith("*")&&(r=r.slice(1)));var i=null;if(e.matchOpToken(":")){var n=e.consumeUntilWhitespace();e.matchTokenType("WHITESPACE"),i=n.map(function(l){return l.value}).join("")}if(e.matchToken("when"))var o=e.requireElement("expression");var a=C.resolveHideShowStrategy(e,r);return new s(t,o,i,a)}}resolve(e,{target:t}){var r=e.meta.runtime,i=this;if(r.nullCheck(t,this.targetExpr),this.when){var n=r.implicitLoopWhen(t,this.when,e,function(o){i.hideShowStrategy("show",o,i.arg,r)},function(o){i.hideShowStrategy("hide",o,null,r)});if(n&&n.then)return n.then(function(){return r.findNext(i,e)})}else r.implicitLoop(t,function(o){i.hideShowStrategy("show",o,i.arg,r)});return r.findNext(this,e)}},cr=class s extends d{static keyword="take";constructor(e,t,r,i,n,o,a){super(),this.variant=e,this.classRefs=t,this.attributeRef=r,this.from=i,this.fromExpr=i,this.forElt=n,this.forExpr=n,this.replacementValue=o,this.replacementClass=a,e==="class"?this.args={classRefs:t,from:i,forElt:n}:this.args={from:i,forElt:n,replacementValue:o}}static parse(e){if(e.matchToken("take")){let a=null,l=[];for(;a=e.parseElement("classRef");)l.push(a);var t=null,r=null,i=null;let u=l.length>0;if(u?e.matchToken("with")&&(l.length>1&&e.raiseError("`with` cannot be combined with multiple class refs"),i=e.requireElement("classRef")):(t=e.parseElement("attributeRef"),t==null&&e.raiseError("Expected either a class reference or attribute expression"),e.matchToken("with")&&(r=e.requireElement("expression"))),e.matchToken("from")){var n=e.requireElement("expression");e.matchToken("giving")&&(u?(i&&e.raiseError("`giving` cannot be combined with `with`"),l.length>1&&e.raiseError("`giving` cannot be combined with multiple class refs"),i=e.requireElement("classRef")):(r&&e.raiseError("`giving` cannot be combined with `with`"),r=e.requireElement("expression")))}if(e.matchToken("for"))var o=e.requireElement("expression");else var o=e.requireElement("implicitMeTarget");return u?new s("class",l,null,n,o,null,i):new s("attribute",null,t,n,o,r,null)}}resolve(e,{classRefs:t,from:r,forElt:i,replacementValue:n}){if(this.variant==="class"){e.meta.runtime.nullCheck(i,this.forExpr);var o=this.replacementClass?this.replacementClass.className:null;e.meta.runtime.implicitLoop(t,a=>{var l=a.className;r?e.meta.runtime.implicitLoop(r,u=>{u.classList.remove(l),o&&u.classList.add(o)}):e.meta.runtime.implicitLoop(a,u=>{u.classList.remove(l),o&&u.classList.add(o)}),e.meta.runtime.implicitLoop(i,u=>{u.classList.add(l),o&&u.classList.remove(o)})})}else e.meta.runtime.nullCheck(r,this.fromExpr),e.meta.runtime.nullCheck(i,this.forExpr),e.meta.runtime.implicitLoop(r,a=>{n?a.setAttribute(this.attributeRef.name,n):a.removeAttribute(this.attributeRef.name)}),e.meta.runtime.implicitLoop(i,a=>{a.setAttribute(this.attributeRef.name,this.attributeRef.value||"")});return this.findNext(e)}},fr=class s extends d{static keyword="measure";constructor(e,t){super(),this.properties=t,this.targetExpr=e,this.args={target:e}}static parse(e){if(e.matchToken("measure")){var t,r=[],i=["x","y","left","top","right","bottom","width","height","bounds","scrollLeft","scrollTop","scrollLeftMax","scrollTopMax","scrollWidth","scrollHeight","scroll"];if(e.commandBoundary(e.currentToken()))t=e.parseElement("implicitMeTarget");else{var n=e.requireElement("expression");n.type==="symbol"&&i.includes(n.name)?(t=e.parseElement("implicitMeTarget"),r.push(n.name)):n.type==="possessive"&&n.prop||n.type==="ofExpression"&&n.prop?(t=n.root,r.push(n.prop.value)):t=n}for(;e.matchOpToken(",");)r.push(e.requireTokenType("IDENTIFIER").value);return new s(t,r)}}resolve(e,{target:t}){e.meta.runtime.nullCheck(t,this.targetExpr),0 in t&&(t=t[0]);var r=t.getBoundingClientRect(),i={top:t.scrollTop,left:t.scrollLeft,topMax:t.scrollTopMax,leftMax:t.scrollLeftMax,height:t.scrollHeight,width:t.scrollWidth};return e.result={x:r.x,y:r.y,left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height,bounds:r,scrollLeft:i.left,scrollTop:i.top,scrollLeftMax:i.leftMax,scrollTopMax:i.topMax,scrollWidth:i.width,scrollHeight:i.height,scroll:i},e.meta.runtime.forEach(this.properties,n=>{if(n in e.result)e.locals[n]=e.result[n];else throw new Error("No such measurement as "+n)}),this.findNext(e)}},mr=class s extends d{static keyword="focus";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("focus")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){return(t||e.me).focus(),this.findNext(e)}},pr=class s extends d{static keyword="blur";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("blur")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){return(t||e.me).blur(),this.findNext(e)}},vr=class s extends d{static keyword=["empty","clear"];constructor(e){super(),this.args={target:e}}static parse(e){if(!(!e.matchToken("empty")&&!e.matchToken("clear"))){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return Array.isArray(r)?(r.splice(0),e.meta.runtime.notifyMutation(r)):r instanceof Set||r instanceof Map?(r.clear(),e.meta.runtime.notifyMutation(r)):e.meta.runtime.implicitLoop(r,function(i){var n=i.tagName;n==="INPUT"?i.type==="checkbox"||i.type==="radio"?i.checked=!1:i.value="":n==="TEXTAREA"?i.value="":n==="SELECT"?i.selectedIndex=-1:n==="FORM"?i.querySelectorAll("input, textarea, select").forEach(function(o){o.tagName==="INPUT"?o.type==="checkbox"||o.type==="radio"?o.checked=!1:o.value="":o.tagName==="TEXTAREA"?o.value="":o.tagName==="SELECT"&&(o.selectedIndex=-1)}):i.replaceChildren()}),this.findNext(e)}},dr=class s extends d{static keyword="reset";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("reset")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return e.meta.runtime.implicitLoop(r,function(i){var n=i.tagName;if(n==="FORM")i.reset();else if(n==="INPUT")i.type==="checkbox"||i.type==="radio"?i.checked=i.defaultChecked:i.value=i.defaultValue;else if(n==="TEXTAREA")i.value=i.defaultValue;else if(n==="SELECT")for(var o=0;othis.findNext(e)):(e.meta.runtime.implicitLoop(r,zi),this.findNext(e))}},Tr=class s extends d{static keyword="close";constructor(e,t){super(),this.fullscreen=t,this.args={target:e}}static parse(e){if(e.matchToken("close")){var t=e.matchToken("fullscreen"),r=null;return e.commandBoundary(e.currentToken())||(r=e.requireElement("expression")),new s(r,!!t)}}resolve(e,{target:t}){if(this.fullscreen)return document.exitFullscreen().then(()=>this.findNext(e));var r=t||e.me;return e.meta.runtime.implicitLoop(r,Gi),this.findNext(e)}},kr=class s extends d{static keyword="speak";constructor(e,t,r,i,n){super(),this.voice=t,this.rate=r,this.pitch=i,this.volume=n,this.args={text:e,voice:t,rate:r,pitch:i,volume:n}}static parse(e){if(e.matchToken("speak")){for(var t=e.requireElement("expression"),r=null,i=null,n=null,o=null;e.matchToken("with");)e.matchToken("voice")?r=e.requireElement("expression"):e.matchToken("rate")?i=e.requireElement("expression"):e.matchToken("pitch")?n=e.requireElement("expression"):e.matchToken("volume")?o=e.requireElement("expression"):e.raiseExpected("voice","rate","pitch","volume");return new s(t,r,i,n,o)}}resolve(e,{text:t,voice:r,rate:i,pitch:n,volume:o}){var a=new SpeechSynthesisUtterance(String(t));if(r){var l=speechSynthesis.getVoices(),u=l.find(f=>f.name===r);u&&(a.voice=u)}i!=null&&(a.rate=i),n!=null&&(a.pitch=n),o!=null&&(a.volume=o);var h=this;return new Promise(function(f){a.onend=function(){f(e.meta.runtime.findNext(h,e))},speechSynthesis.speak(a)})}},Er=class s extends d{static keyword="select";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("select")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return typeof r.select=="function"&&r.select(),this.findNext(e)}},gr=class s extends d{static keyword="ask";constructor(e){super(),this.args={message:e}}static parse(e){if(e.matchToken("ask")){var t=e.requireElement("expression");return new s(t)}}resolve(e,{message:t}){return e.result=prompt(String(t)),this.findNext(e)}},wr=class s extends d{static keyword="answer";constructor(e,t,r){super(),this.choiceA=t,this.choiceB=r,this.args={message:e,choiceA:t,choiceB:r}}static parse(e){if(e.matchToken("answer")){var t=e.requireElement("expression"),r=null,i=null;if(e.matchToken("with")){e.pushFollow("or");try{r=e.requireElement("expression")}finally{e.popFollow()}e.requireToken("or"),i=e.requireElement("expression")}return new s(t,r,i)}}resolve(e,{message:t,choiceA:r,choiceB:i}){return r?e.result=confirm(String(t))?r:i:alert(String(t)),this.findNext(e)}},br=class s extends d{static keyword="morph";constructor(e,t){super(),this.args={target:e,content:t}}static parse(e){if(e.matchToken("morph")){var t=e.requireElement("expression");e.requireToken("to");var r=e.requireElement("expression");return new s(t,r)}}resolve(e,{target:t,content:r}){return e.meta.runtime.implicitLoop(t,function(i){e.meta.runtime.morph(i,r)}),this.findNext(e)}};var Or={};N(Or,{SettleCommand:()=>Sr,TransitionCommand:()=>qr,ViewTransitionCommand:()=>Lr});var Sr=class s extends d{static keyword="settle";constructor(e){super(),this.onExpr=e,this.args={on:e}}static parse(e){if(e.matchToken("settle")){if(e.commandBoundary(e.currentToken()))var t=e.requireElement("implicitMeTarget");else var t=e.requireElement("expression");return new s(t)}}resolve(e,{on:t}){e.meta.runtime.nullCheck(t,this.onExpr);var r=this,i=t instanceof Element?[t]:Array.from(t);return Promise.all(i.map($i)).then(function(){return e.meta.runtime.findNext(r,e)})}};function $i(s){return new Promise(function(e){var t=!1,r=!1;s.addEventListener("transitionstart",function(){r=!0},{once:!0}),setTimeout(function(){!r&&!t&&(t=!0,e())},500),s.addEventListener("transitionend",function(){t||(t=!0,e())},{once:!0})})}var qr=class s extends d{static keyword="transition";constructor(e,t,r,i,n){super(),this.propExprs=e,this.from=t,this.to=r,this.usingExpr=i,this.over=n,this.args={from:t,to:r,using:i,over:n}}static parse(e){if(e.matchToken("transition")){var t=[],r=[],i=[];do{var n=e.pushFollows("from","to");try{t.push(e.requireElement("expression"))}finally{e.popFollows(n)}r.push(e.matchToken("from")?e.requireElement("expression"):null),e.requireToken("to"),i.push(e.matchToken("initial")?"initial":e.requireElement("expression"))}while(!e.commandBoundary(e.currentToken())&&e.currentToken().value!=="over"&&e.currentToken().value!=="using");var o,a;return e.matchToken("over")?o=e.requireElement("expression"):e.matchToken("using")&&(a=e.requireElement("expression")),new s(t,r,i,a,o)}}resolve(e,{from:t,to:r,using:i,over:n}){var o=this,a=e.meta.runtime,l;this.propExprs[0].root?(l=this.propExprs[0].root.evaluate(e),a.nullCheck(l,this.propExprs[0].root)):l=e.me;var u=[];return a.implicitLoop(l,function(h){u.push(new Promise(function(f){var p=h.style.transition;n?h.style.transition="all "+n+"ms ease-in":i?h.style.transition=i:h.style.transition=A.defaultTransition;var c=a.getInternalData(h);c.transitionInitials||(c.transitionInitials={});for(var T=c.transitionInitials,m=0;m{setTimeout(()=>t(e.meta.runtime.findNext(this)),0)})}},Ir=class extends d{constructor(){super(),this.type="viewTransitionEnd"}resolve(e){var t=e.meta.viewTransition;return t?(t.bodyDone(),t.finished.then(()=>(e.meta.viewTransition=null,e.meta.runtime.findNext(this.parent,e)))):e.meta.runtime.findNext(this.parent,e)}},Lr=class s extends d{static keyword="start";constructor(e,t){super(),this.body=e,this.transitionType=t,this.args={type:t}}static parse(e){if(e.matchToken("start")){e.matchToken("a"),e.requireToken("view"),e.requireToken("transition"),e.matchToken("using");var t=e.matchTokenType("STRING"),r=t?t.value:null,i=e.requireElement("commandList"),n=new Ar;n.next=i;for(var o=new Ir,a=i;a.next;)a=a.next;a.next=o,e.hasMore()&&e.requireToken("end"),Ei(i,!1);var l=new s(n,r);return e.setParent(n,l),e.setParent(i,l),o.parent=l,l}}resolve(e,{type:t}){if(!document.startViewTransition)return this.body;if(e.meta.viewTransition)throw new Error("A view transition is already in progress");var r,i=new Promise(function(a){r=a}),n=function(){return i};t&&(n={update:function(){return i},types:[t]});var o=document.startViewTransition(n);return e.meta.viewTransition={bodyDone:r,finished:o.finished,transition:o},this.body}};var Fr={};N(Fr,{BreakpointCommand:()=>Mr});var Mr=class s extends d{static keyword="breakpoint";static parse(e){if(e.matchToken("breakpoint"))return new s}resolve(e){debugger;return this.findNext(e)}};var Cr={};N(Cr,{OnFeature:()=>Rr});var Rr=class s extends S{static keyword="on";constructor(e,t,r,i,n,o,a,l,u,h,f){super(),this.displayName=e,this.events=t,this.start=r,this.every=i,this.errorHandler=n,this.errorSymbol=o,this.finallyHandler=a,this.queueAll=l,this.queueFirst=u,this.queueNone=h,this.queueLast=f}execute(e){let t=this,r=this.every,i=this.queueNone,n=this.queueFirst,o=this.queueLast,a=this.start,l=e.meta.runtime.getEventQueueFor(e.me,t);if(l.executing&&r===!1){if(i||n&&l.queue.length>0)return;o&&(l.queue.length=0),l.queue.push(e);return}l.executing=!0,e.meta.onHalt=function(){l.executing=!1;var u=l.queue.shift();u&&setTimeout(function(){t.execute(u)},1)},e.meta.reject=function(u){console.error(u.message?u.message:u),console.error(u.stack);var h=e.meta.runtime.getHyperTrace(e,u);h&&h.print(),e.meta.runtime.triggerEvent(e.me,"exception",{error:u})},a.execute(e)}install(e,t,r,i){let n=this,o=this.displayName,a=this.errorHandler,l=this.errorSymbol,u=this.finallyHandler;for(let c of n.events){var h;c.elsewhere?h=[document]:c.from?h=c.from.evaluate(i.makeContext(e,n,e,null)):h=[e];var f=i.getInternalData(e);f.eventState||(f.eventState=new Map),f.eventState.has(c)||f.eventState.set(c,{execCount:0,debounced:void 0,lastExec:void 0});var p=f.eventState.get(c);i.implicitLoop(h,function(T){var m=c.on;if(T==null){console.warn("'%s' feature ignored because target does not exists:",o,e);return}var v=i.getInternalData(e);if(v.listeners||(v.listeners=[]),v.observers||(v.observers=[]),c.mutationSpec){m="hyperscript:mutation";let g=new MutationObserver(function(x,E){n.executing||i.triggerEvent(T,m,{mutationList:x,observer:E})});g.observe(T,c.mutationSpec),v.observers.push(g)}if(c.intersectionSpec){m="hyperscript:intersection";let g=new IntersectionObserver(function(x){for(let q of x){var E={observer:g};E=Object.assign(E,q),E.intersecting=q.isIntersecting,i.triggerEvent(T,m,E)}},c.intersectionSpec);g.observe(T),v.observers.push(g)}if(c.resizeSpec&&T instanceof Element){m="hyperscript:resize";let g=new ResizeObserver(function(x){for(let q of x){var E={width:q.contentRect.width,height:q.contentRect.height,contentRect:q.contentRect,entry:q};i.triggerEvent(T,m,E)}});g.observe(T),v.observers.push(g)}var k=T.addEventListener||T.on,b;k.call(T,m,b=function g(x){if(typeof Node<"u"&&e instanceof Node&&T!==e&&!e.isConnected){T.removeEventListener(m,g);return}var E=i.makeContext(e,n,e,x);if(!(c.elsewhere&&e.contains(x.target))){c.from&&(E.result=T);for(let P of c.args){let Y=E.event[P.value];Y!==void 0?E.locals[P.value]=Y:E.event.detail!=null&&(E.locals[P.value]=E.event.detail[P.value])}if(E.meta.errorHandler=a,E.meta.errorSymbol=l,E.meta.finallyHandler=u,c.filter){var q=E.meta.context;E.meta.context=E.event;try{var M=c.filter.evaluate(E);if(!M)return}finally{E.meta.context=q}}if(c.inExpr){for(var L=x.target;;)if(L.matches&&L.matches(c.inExpr.css)){E.result=L;break}else if(L=L.parentElement,L==null)return}if(p.execCount++,c.startCount){if(c.endCount){if(p.execCountc.endCount)return}else if(c.unbounded){if(p.execCount_r});var _r=class s extends S{static keyword="def";constructor(e,t,r,i,n,o,a,l){super(),this.displayName=e+"("+i.map(function(u){return u.value}).join(", ")+")",this.name=e,this.args=i,this.start=n,this.errorHandler=o,this.errorSymbol=a,this.finallyHandler=l,this.nameSpace=t,this.nameVal=r}install(e,t,r,i){let n=this.args,o=this.start,a=this.errorHandler,l=this.errorSymbol,u=this.finallyHandler,h=this.nameVal,f=this.nameSpace,p=this.name,c=this;var T=function(){var m=i.makeContext(t,c,e,null);m.meta.errorHandler=a,m.meta.errorSymbol=l,m.meta.finallyHandler=u;for(var v=0;vDr});var Dr=class s extends S{static keyword="set";constructor(e){super(),this.start=e}install(e,t,r,i){this.start&&this.start.execute(i.makeContext(e,this,e,null))}static parse(e){let t=e.parseElement("setCommand");if(t){t.target.scope==="local"&&e.raiseError("variables declared at the feature level cannot be locally scoped (use :foo, ^foo, $foo, or an @attribute target instead).");let r=new s(t);return e.ensureTerminated(t),r}}};var jr={};N(jr,{InitFeature:()=>Wr});var Wr=class s extends S{static keyword="init";constructor(e,t){super(),this.start=e,this.immediately=t}install(e,t,r,i){var n=()=>{this.start?.execute(i.makeContext(e,this,e,null))};this.immediately?n():queueMicrotask(n)}static parse(e){if(e.matchToken("init")){var t=e.matchToken("immediately"),r=e.requireElement("commandList"),i=new s(r,t);return e.ensureTerminated(r),e.setParent(r,i),i}}};var Br={};N(Br,{WorkerFeature:()=>Ur});var Ur=class extends S{static keyword="worker";static parse(e){if(e.matchToken("worker")){e.raiseError("In order to use the 'worker' feature, include the _hyperscript worker plugin. See https://hyperscript.org/features/worker/ for more info.");return}}};var Gr={};N(Gr,{BehaviorFeature:()=>zr});var zr=class s extends S{static keyword="behavior";constructor(e,t,r,i,n){super(),this.path=e,this.nameSpace=t,this.name=r,this.formalParams=i,this.hs=n}install(e,t,r,i){let n=this.path,o=this.nameSpace,a=this.name,l=this.formalParams,u=this.hs;i.assignToNamespace(null,o,a,function(h,f,p){for(var c=i.getInternalData(h),T=n+"Scope",m=c[T]||(c[T]={}),v=0;v$r});var $r=class s extends S{static keyword="install";constructor(e,t,r){super(),this.behaviorPath=e,this.behaviorNamespace=t,this.behaviorArgs=r}install(e,t,r,i){for(var n=i.makeContext(e,this,e,null),o=this.behaviorArgs?this.behaviorArgs.evaluate(n):null,a=i.globalScope,l=0;lYr});var Yr=class s extends S{static keyword="js";constructor(e,t,r){super(),this.jsSource=e,this.function=t,this.exposedFunctionNames=r}install(e,t,r,i){Object.assign(i.globalScope,this.function())}static parse(e){if(e.matchToken("js")){var t=e.requireElement("jsBody"),r=t.jsSource+` return { `+t.exposedFunctionNames.map(function(n){return n+":"+n}).join(",")+" } ",i=new Function(r);return new s(r,i,t.exposedFunctionNames)}}};var Xr={};N(Xr,{WhenFeature:()=>Jr});var Jr=class s extends S{static keyword="when";static parse(e){if(e.matchToken("when")){var t=[];do{e.pushFollow("or");try{t.push(e.requireElement("expression"))}finally{e.popFollow()}}while(e.matchToken("or"));for(var r=0;rZr});var Zr=class s extends S{static keyword="bind";static parse(e){if(e.matchToken("bind")){var t=e.pushFollows("and","with","to"),r;try{r=e.requireElement("expression")}finally{e.popFollows(t)}!e.matchToken("and")&&!e.matchToken("with")&&!e.matchToken("to")&&e.raiseExpected("and","with","to");var i=e.requireElement("expression");return new s(r,i)}}constructor(e,t){super(),this.left=e,this.right=t,this.displayName="bind"}install(e,t,r,i){var n=this;queueMicrotask(function(){try{Ji(n.left,n.right,e,n,i)}catch(o){console.error(o.message||o)}})}};function Ki(s,e,t,r,i){var n=s.getInternalData(e);n.listeners||(n.listeners=[]),n.listeners.push({target:t,event:r,handler:i})}function gi(s){return s.type==="classRef"||s.type==="attributeRef"?!0:typeof s.set=="function"}function Ji(s,e,t,r,i){var n=i.makeContext(t,r,t,null),o=wi(s,t,r,i,n),a=wi(e,t,r,i,n),l=o.element||gi(s),u=a.element||gi(e);if(!l&&!u)throw new Error("bind requires at least one writable side");l&&i.reactivity.createEffect(function(){return a.read()},function(h){o.write(h)},{element:t}),u&&i.reactivity.createEffect(function(){return o.read()},function(h){a.write(h)},{element:t}),Vi(o,a,t,i)}function wi(s,e,t,r,i){var n=s.evaluate(i);return n instanceof Element?Xi(n,r):Zi(s,e,t,r)}var bi={"INPUT:checkbox":"checked","INPUT:number":"valueAsNumber","INPUT:range":"valueAsNumber",INPUT:"value",TEXTAREA:"value",SELECT:"value"};function Xi(s,e){var t=s.tagName,r=t==="INPUT"?s.getAttribute("type")||"text":null;if(t==="INPUT"&&r==="radio"){var i=s.value;return{element:s,read:function(){var a=e.resolveProperty(s,"checked");return a?i:void 0},write:function(a){s.checked=a===i}}}var n=bi[t+":"+r]||bi[t];if(!n&&s.hasAttribute("contenteditable")&&s.getAttribute("contenteditable")!=="false"&&(n="textContent"),!n&&t.includes("-")&&"value"in s&&(n="value"),!n)throw new Error("bind cannot auto-detect a property for <"+t.toLowerCase()+">. Use an explicit property (e.g. 'bind $var to #el's value').");var o=n==="valueAsNumber";return{element:s,read:function(){var a=e.resolveProperty(s,n);return o&&a!==a?null:a},write:function(a){s[n]=a}}}function Zi(s,e,t,r){return s.type==="classRef"?{read:function(){return r.resolveAttribute(e,"class"),e.classList.contains(s.className)},write:function(i){i?e.classList.add(s.className):e.classList.remove(s.className)}}:{read:function(){return s.evaluate(r.makeContext(e,t,e,null))},write:function(i){var n=r.makeContext(e,t,e,null);tn(r,s,n,i)}}}function Vi(s,e,t,r){xi(s,e,t,r),xi(e,s,t,r)}function xi(s,e,t,r){if(s.element){var i=s.element.closest("form");if(i){var n=()=>{setTimeout(()=>{t.isConnected&&e.write(s.read())},0)};i.addEventListener("reset",n),Ki(r,t,i,"reset",n)}}}function en(s,e,t){typeof t=="boolean"?e.startsWith("aria-")?s.setAttribute(e,String(t)):t?s.setAttribute(e,""):s.removeAttribute(e):t==null?s.removeAttribute(e):s.setAttribute(e,t)}function tn(s,e,t,r){if(e.type==="classRef"){var i=t.you||t.me;i&&(r?i.classList.add(e.className):i.classList.remove(e.className))}else if(e.type==="attributeRef"&&typeof r=="boolean"){var i=t.you||t.me;i&&en(i,e.name,r)}else{var n={};if(e.lhs)for(var o in e.lhs){var a=e.lhs[o];n[o]=a&&a.evaluate?a.evaluate(t):a}e.set(t,n,r)}}var ti={};N(ti,{LiveFeature:()=>ei});var ei=class s extends S{static keyword="live";constructor(e){super(),this.commands=e,this.displayName="live"}static parse(e){if(e.matchToken("live")){var t=e.requireElement("commandList"),r=new s(t);return e.ensureTerminated(t),e.setParent(t,r),r}}install(e,t,r,i){var n=this;queueMicrotask(function(){i.reactivity.createEffect(function(){n.commands.execute(i.makeContext(e,n,e,null))},function(){},{element:e})})}};var oi={};N(oi,{EscapeExpression:()=>ni,RenderCommand:()=>ii,TemplateTextCommand:()=>ri,initLiveTemplates:()=>si});function qi(s){return s.textContent}var rn='script[type="text/hyperscript-template"][live]';function si(s,e,t,r,i){var n=new WeakSet;s.addBeforeProcessHook(function(o){!o||!o.querySelectorAll||o.querySelectorAll(rn).forEach(function(a){if(n.has(a))return;n.add(a);var l=qi(a),u=a.getAttribute("_")||a.getAttribute("data-script")||"";a.removeAttribute("_"),a.removeAttribute("data-script");var h=document.createElement("div");h.style.display="contents",h.setAttribute("data-live-template",""),a.after(h),u&&(h.setAttribute("_",u),s.processNode(h));var f=!1;function p(m){f?s.morph(h,m):(h.innerHTML=m,s.processNode(h),f=!0)}function c(){var m=s.makeContext(h,null,h,null),v=[];m.meta.__ht_template_result=v;var k=e.tokenize(l,"lines"),b=new t(r,k),g;try{g=b.parseElement("commandList"),b.ensureTerminated(g)}catch(q){return console.error("live-template parse error:",q.message||q),""}if(g.execute(m),h.__hs_scopes=m.meta.__ht_scopes||null,m.meta.returned||!m.meta.resolve)return v.join("");var x,E=new Promise(function(q){x=q});return m.meta.resolve=x,E.then(function(){return v.join("")})}queueMicrotask(function(){var m=c();m&&m.then?m.then(function(v){p(v),T()}):(p(m),T())});function T(){i.createEffect(c,p,{element:h})}})})}function Si(s,e){return e.type==="literal"?s:s==null?"":e.escape?Ni(String(s)):String(s)}function Ni(s){return String(s).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var ri=class s extends d{static keyword="TEMPLATE_LINE";constructor(e,t){super(),this.parts=e,this.errors=t}static parse(e){var t=e.currentToken();if(t.type==="TEMPLATE_LINE"){e.consumeToken();for(var r=[],i=[],n=t.content,o=0;oo&&r.push({type:"literal",value:n.slice(o,a)});for(var l=1,u=a+2;u0;)n[u]==="{"?l++:n[u]==="}"&&l--,u++;if(l>0){i.push({line:t.line,message:"Unterminated ${} expression",expr:n.slice(a)}),r.push({type:"literal",value:""});break}var h=n.slice(a+2,u-1),f=!0;try{var p=new O().tokenize(h),c=e.createChildParser(p);c.matchToken("unescaped")&&(f=!1);var T=c.requireElement("expression");if(c.matchToken("if")){var m=c.requireElement("expression"),v=c.matchToken("else")?c.requireElement("expression"):null;r.push({type:"conditional",valueNode:T,conditionNode:m,elseNode:v,escape:f})}else r.push({type:"expr",node:T,escape:f})}catch(k){i.push({line:t.line,column:t.column+a,message:k.message||String(k),expr:h}),r.push({type:"literal",value:""})}o=u}return new s(r,i)}}resolve(e){var t=this.parts,r=t.map(i=>{if(i.type==="literal")return i.value;if(i.type==="conditional"){var n=i.conditionNode.evaluate(e);return n?i.valueNode.evaluate(e):i.elseNode?i.elseNode.evaluate(e):void 0}return i.node.evaluate(e)});return r.some(i=>i&&i.then)?Promise.all(r).then(i=>(e.meta.__ht_template_result.push(i.map((n,o)=>Si(n,t[o])).join("")),this.findNext(e))):(e.meta.__ht_template_result.push(r.map((i,n)=>Si(i,t[n])).join("")),this.findNext(e))}},ii=class s extends d{static keyword="render";constructor(e,t,r,i){super(),this.template_=e,this.insertHere=r,this.args={template:e,templateArgs:t,target:i}}static parse(e){if(e.matchToken("render")){var t=e.requireElement("expression"),r={};e.matchToken("with")&&(r=e.parseElement("nakedNamedArgumentList"));var i=!!e.matchToken("here"),n=null;!i&&e.matchToken("into")&&(n=e.requireElement("expression"));var o=new s(t,r,i,n);return o._parser=e,o}}resolve(e,{template:t,templateArgs:r,target:i}){if(!(t instanceof Element))throw new Error(this.template_.sourceFor()+" is not an element");var n=[],o=e.meta.runtime,a=o.makeContext(e.me,null,e.me,null);a.locals=Object.assign({},e.locals,r),a.meta.__ht_template_result=n;var l=new O().tokenize(qi(t),"lines"),u=this._parser.createChildParser(l),h;try{h=u.parseElement("commandList"),u.ensureTerminated(h)}catch(g){return console.error("hyperscript template parse error:",g.parseError?.message||g.message||g),e.result="",o.findNext(this,e)}var f=h.collectErrors();if(f.length)for(var p of f)console.error("hyperscript template error (line "+p.line+"): "+p.message+(p.expr?" in ${"+p.expr+"}":""));var c,T,m=new Promise(function(g,x){c=g,T=x});h.execute(a);var v=a.meta.__ht_scopes||null,k=//g,b=g=>(e.result=g.replace(k,""),this.insertHere&&(e.me.__hs_scopes=v,e.me.innerHTML=g),i&&(i.__hs_scopes=v,i.innerHTML=g),o.findNext(this,e));return a.meta.returned?b(n.join("")):(a.meta.resolve=c,a.meta.reject=T,m.then(()=>b(n.join(""))))}},ni=class s extends y{static grammarName="escape";static expressionType="leaf";constructor(e,t,r){super(),this.unescaped=t,this.escapeType=r,this.args={value:e}}static parse(e){if(e.matchToken("escape")){var t=e.matchTokenType("IDENTIFIER").value,r=e.matchToken("unescaped"),i=e.requireElement("expression");return new s(i,r,t)}}resolve(e,{value:t}){if(this.unescaped)return t;if(t==null)return"";if(this.escapeType==="html")return Ni(t);throw new Error("Unknown escape: "+this.escapeType)}};var $=typeof self<"u"?self:typeof global<"u"?global:void 0;A.conversions=z;var w=new ee,Q=new O,ai=new ae,nn=new le,_=new oe($,w,Q,ai,nn);w.registerModule(tt);w.registerModule(xe);w.registerModule(lt);w.registerModule(ft);w.registerModule(yt);w.registerModule(Et);w.registerModule(wt);w.registerModule(Ct);w.registerModule(jt);w.registerModule(Gt);w.registerModule(Vt);w.registerModule(ir);w.registerModule(sr);w.registerModule(xr);w.registerModule(Or);w.registerModule(Fr);w.registerModule(Cr);w.registerModule(Pr);w.registerModule(Hr);w.registerModule(jr);w.registerModule(Br);w.registerModule(Gr);w.registerModule(Qr);w.registerModule(Kr);w.registerModule(Xr);w.registerModule(Vr);w.registerModule(ti);w.registerModule(oi);si(_,Q,F,w,ai);function Ai(s,e,t){let r;"document"in $?r=$.document.body:r=new ne(t&&t.module),e=Object.assign(_.makeContext(r,null,r,null),e||{});let i=w.parse(Q,s);if(i&&i.errors&&i.errors.length>0)throw new Error(i.errors[0].message+` `+F.formatErrors(i.errors));return i.execute?(i.execute(e),e.meta.returnValue!==void 0?e.meta.returnValue:e.result):i.apply?(i.apply(r,r,t,_),_.getHyperscriptFeatures(r)):i.evaluate(e)}var j=Object.assign(Ai,{config:A,use(s){s(j)},internals:{tokenizer:Q,runtime:_,reactivity:ai,createParser:s=>new F(w,s)},addFeature:w.addFeature.bind(w),addCommand:w.addCommand.bind(w),addLeafExpression:w.addLeafExpression.bind(w),addBeforeProcessHook:s=>_.addBeforeProcessHook(s),addAfterProcessHook:s=>_.addAfterProcessHook(s),evaluate:Ai,parse:s=>w.parse(Q,s),process:s=>_.processNode(s),processNode:s=>_.processNode(s),cleanup:s=>_.cleanup(s),version:"0.9.91"});function sn(s){document.readyState!=="loading"?setTimeout(s):document.addEventListener("DOMContentLoaded",s)}function on(){let s=document.querySelector('meta[name="htmx-config"]');if(s){let e=JSON.parse(s.content);Object.assign(A,e)}}typeof document<"u"&&(async function(){on();let s=$.document.querySelectorAll("script[type='text/hyperscript'][src]"),e=Array.from(s);(await Promise.all(e.map(async r=>(await fetch(r.src)).text()))).forEach(r=>j(r)),sn(()=>{j.process(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready")),new ue($,j).init()})})();typeof self<"u"&&(self._hyperscript=j);var As=j;})();