!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self)._hyperscript=t()}(this,function(){function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function f(e,t){var n=e[t];if(n)return n;var r={};return e[t]=r,r}function m(e,t){return new(e.bind.apply(e,[e].concat(t)))}var p,d=globalThis,h=function(e){function n(e,t,n){this._css=e,this.relativeToElement=t,this.escape=n}var r=n.prototype;return r.contains=function(e){for(var t,n=l(this);!(t=n()).done;)if(t.value.contains(e))return!0;return!1},r[e]=function(){return this.selectMatches()[Symbol.iterator]()},r.selectMatches=function(){return T.getRootNode(this.relativeToElement).querySelectorAll(this.css)},t(n,[{key:"css",get:function(){return this.escape?T.escapeSelector(this._css):this._css}},{key:"className",get:function(){return this._css.substr(1)}},{key:"id",get:function(){return this.className()}},{key:"length",get:function(){return this.selectMatches().length}}]),n}(Symbol.iterator),v=function(){var e={"+":"PLUS","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",".":"PERIOD","..":"ELLIPSIS","\\":"BACKSLASH",":":"COLON","%":"PERCENT","|":"PIPE","!":"EXCLAMATION","?":"QUESTION","#":"POUND","&":"AMPERSAND",$:"DOLLAR",";":"SEMI",",":"COMMA","(":"L_PAREN",")":"R_PAREN","<":"L_ANG",">":"R_ANG","<=":"LTE_ANG",">=":"GTE_ANG","==":"EQ","===":"EQQ","!=":"NEQ","!==":"NEQQ","{":"L_BRACE","}":"R_BRACE","[":"L_BRACKET","]":"R_BRACKET","=":"EQUALS"};function t(e){return a(e)||i(e)||"-"===e||"_"===e||":"===e}function n(e){return a(e)||i(e)||"-"===e||"_"===e||":"===e}function r(e){return" "===e||"\t"===e||o(e)}function o(e){return"\r"===e||"\n"===e}function i(e){return e>="0"&&e<="9"}function a(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function u(e,t){return"_"===e||"$"===e}function s(e,t,n){o();var r=null;function o(){for(;"WHITESPACE"===f(0,!0).type;)t.push(e.shift())}function i(e,t){y.raiseParseError(e,t)}function a(e){if(m()&&m().op&&m().value===e)return l()}function u(e,t,n,r){if(m()&&m().type&&[e,t,n,r].indexOf(m().type)>=0)return l()}function s(e,t){if(-1===p.indexOf(e))return t=t||"IDENTIFIER",m()&&m().value===e&&m().type===t?l():void 0}function l(){var n=e.shift();return t.push(n),r=n,o(),n}function c(n,r){for(var i=[],a=f(0,!0);!(null!=r&&a.type===r||null!=n&&a.value===n||"EOF"===a.type);){var u=e.shift();t.push(u),i.push(a),a=f(0,!0)}return o(),i}function f(t,n){var r,o=0;do{if(!n)for(;e[o]&&"WHITESPACE"===e[o].type;)o++;r=e[o],t--,o++}while(t>-1);return r||{type:"EOF",value:"<<>>"}}function m(){return f(0)}var p=[];return{pushFollow:function(e){p.push(e)},popFollow:function(){p.pop()},clearFollow:function(){var e=p;return p=[],e},restoreFollow:function(e){p=e},matchAnyToken:function(e,t,n){for(var r=0;r0},currentToken:m,lastMatch:function(){return r},token:f,consumeUntil:c,consumeUntilWhitespace:function(){return c(null,"WHITESPACE")},lastWhitespace:function(){return t[t.length-1]&&"WHITESPACE"===t[t.length-1].type?t[t.length-1].value:""},sourceFor:function(){return n.substring(this.startToken.start,this.endToken.end)},lineFor:function(){return n.split("\n")[this.startToken.line-1]}}}function l(e){if(e.length>0){var t=e[e.length-1];if("IDENTIFIER"===t.type||"CLASS_REF"===t.type||"ID_REF"===t.type)return!1;if(t.op&&(">"===t.value||")"===t.value))return!1}return!0}return{tokenize:function(c,f){var m,p=[],d=c,h=0,v=0,y=1,E="",T=0;function k(){return f&&0===T}for(;h0;){var i=t.shift(),a=o[i];null==a&&(o[i]=a={}),o=a}o[n]=r},registerHyperTrace:function(e,t){for(var n=[],r=null;null!=e;)n.push(e),r=e,e=e.meta.caller;null==r.meta.traceMap&&(r.meta.traceMap=new Map),r.meta.traceMap.get(t)||r.meta.traceMap.set(t,{trace:n,print:function(e){(e=e||console.error)("hypertrace /// ");for(var t=0,r=0;r",o.meta.feature.displayName.padEnd(t+2),"-",o.meta.owner)}}})},getHyperTrace:function(e,t){for(var n=e;n.meta.caller;)n=n.meta.caller;if(n.meta.traceMap)return n.meta.traceMap.get(t,[])},getInternalData:O,getHyperscriptFeatures:w,escapeSelector:function(e){return e.replace(/:/g,function(e){return"\\"+e})},nullCheck:function(e,t){if(null==e)throw new Error("'"+t.sourceFor()+"' is null")},isEmpty:function(e){return null==e||0===e.length},doesExist:function(e){if(null==e)return!1;if(o(e))for(var t=l(e);!t().done;)return!0;return!1},getRootNode:function(e){if(e&&e instanceof Node){var t=e.getRootNode();if(t instanceof Document||t instanceof ShadowRoot)return t}return document},getEventQueueFor:function(e,t){var n=O(e),r=n.eventQueues;null==r&&(r=new Map,n.eventQueues=r);var o=r.get(t);return null==o&&r.set(t,o={queue:[],executing:!1}),o},hyperscriptUrl:"document"in d?"undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("_hyperscript_w9y.min.js",document.baseURI).href:null,HALT:s}}(),k=function(e,t,n){if(t.contains)return t.contains(n);if(t.includes)return t.includes(n);throw Error("The value of "+e.sourceFor()+" does not have a contains or includes method on it")},g=function(e,t,n){if(t.match)return!!t.match(n);if(t.matches)return t.matches(n);throw Error("The value of "+e.sourceFor()+" does not have a match or matches method on it")},x=function(e,t,n,r){var o=t.requireElement("eventName",r),i=t.parseElement("namedArgumentList",r);if("send"===e&&r.matchToken("to")||"trigger"===e&&r.matchToken("on"))var a=t.requireElement("expression",r);else a=t.requireElement("implicitMeTarget",r);var u={eventName:o,details:i,to:a,args:[a,o,i],op:function(e,t,r,o){return n.nullCheck(t,a),n.forEach(t,function(t){n.triggerEvent(t,r,o,e.me)}),n.findNext(u,e)}};return u},b=function(e,t){var n,r="text";return e.matchToken("a")||e.matchToken("an"),e.matchToken("json")||e.matchToken("Object")?r="json":e.matchToken("response")?r="response":e.matchToken("html")?r="html":e.matchToken("text")||(n=t.requireElement("dotOrColonPath",e).evaluate()),{type:r,conversion:n}};y.addLeafExpression("parenthesized",function(e,t,n){if(n.matchOpToken("(")){var r=n.clearFollow();try{var o=e.requireElement("expression",n)}finally{n.restoreFollow(r)}return n.requireOpToken(")"),o}}),y.addLeafExpression("string",function(e,t,n){var r=n.matchTokenType("STRING");if(r){var o,i=r.value;if(r.template){var a=v.tokenize(i,!0);o=e.parseStringTemplate(a)}else o=[];return{type:"string",token:r,args:o,op:function(e){for(var t="",n=1;n");var o=r.map(function(e){return"STRING"===e.type?'"'+e.value+'"':e.value}).join("");if(o.indexOf("$")>=0)var i=!0,a=v.tokenize(o,!0),u=e.parseStringTemplate(a);return{type:"queryRef",css:o,args:u,op:function(e){return i?new w(o,e.me,[].slice.call(arguments,1)):new h(o,e.me)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addLeafExpression("attributeRef",function(e,t,n){var r=n.matchTokenType("ATTRIBUTE_REF");if(r){var o=r.value;if(0===o.indexOf("["))var i=o.substring(2,o.length-1);else i=o.substring(1);var a="["+i+"]",u=i.split("="),s=u[0],l=u[1];return l&&0===l.indexOf('"')&&(l=l.substring(1,l.length-1)),{type:"attributeRef",name:s,css:a,value:l,op:function(e){var t=e.beingTold||e.me;if(t)return t.getAttribute(s)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addLeafExpression("styleRef",function(e,t,n){var r=n.matchTokenType("STYLE_REF");if(r){var o=r.value.substr(1);return o.startsWith("computed-")?{type:"computedStyleRef",name:o=o.substr("computed-".length),op:function(e){var n=e.beingTold||e.me;if(n)return t.resolveComputedStyle(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}}:{type:"styleRef",name:o,op:function(e){var n=e.beingTold||e.me;if(n)return t.resolveStyle(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("objectKey",function(e,t,n){var r;if(r=n.matchTokenType("STRING"))return{type:"objectKey",key:r.value,evaluate:function(){return r.value}};if(n.matchOpToken("[")){var o=e.parseElement("expression",n);return n.requireOpToken("]"),{type:"objectKey",expr:o,args:[o],op:function(e,t){return t},evaluate:function(e){return t.unifiedEval(this,e)}}}var i="";do{(r=n.matchTokenType("IDENTIFIER")||n.matchOpToken("-"))&&(i+=r.value)}while(r);return{type:"objectKey",key:i,evaluate:function(){return i}}}),y.addLeafExpression("objectLiteral",function(e,t,n){if(n.matchOpToken("{")){var r=[],o=[];if(!n.matchOpToken("}")){do{var i=e.requireElement("objectKey",n);n.requireOpToken(":");var a=e.requireElement("expression",n);o.push(a),r.push(i)}while(n.matchOpToken(","));n.requireOpToken("}")}return{type:"objectLiteral",args:[r,o],op:function(e,t,n){for(var r={},o=0;o");var i=e.requireElement("expression",n);return{type:"blockLiteral",args:r,expr:i,evaluate:function(e){return function(){for(var t=0;t0?o:null},evaluate:function(e){return t.unifiedEval(this,e)}};return e.parseElement("indirectExpression",n,o)}}),y.addIndirectExpression("asExpression",function(e,t,n,r){if(n.matchToken("as")){n.matchToken("a")||n.matchToken("an");var o=e.requireElement("dotOrColonPath",n).evaluate();return e.parseElement("indirectExpression",n,{type:"asExpression",root:r,args:[r],op:function(e,n){return t.convertValue(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}})}}),y.addIndirectExpression("functionCall",function(e,t,n,r){if(n.matchOpToken("(")){var o=[];if(!n.matchOpToken(")")){do{o.push(e.requireElement("expression",n))}while(n.matchOpToken(","));n.requireOpToken(")")}if(r.root)var i={type:"functionCall",root:r,argExressions:o,args:[r.root,o],op:function(e,n,o){t.nullCheck(n,r.root);var i=n[r.prop.value];return t.nullCheck(i,r),i.hyperfunc&&o.push(e),i.apply(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}};else i={type:"functionCall",root:r,argExressions:o,args:[r,o],op:function(e,n,o){return t.nullCheck(n,r),n.hyperfunc&&o.push(e),n.apply(null,o)},evaluate:function(e){return t.unifiedEval(this,e)}};return e.parseElement("indirectExpression",n,i)}}),y.addIndirectExpression("attributeRefAccess",function(e,t,n,r){var o=e.parseElement("attributeRef",n);if(o)return{type:"attributeRefAccess",root:r,attribute:o,args:[r],op:function(e,n){return t.resolveAttribute(n,o.name)},evaluate:function(e){return T.unifiedEval(this,e)}}}),y.addIndirectExpression("arrayIndex",function(e,t,n,r){if(n.matchOpToken("[")){var o=!1,i=!1,a=null,u=null;n.matchOpToken("..")?(o=!0,a=e.requireElement("expression",n)):(a=e.requireElement("expression",n),n.matchOpToken("..")&&(i=!0,"R_BRACKET"!==n.currentToken().type&&(u=e.parseElement("expression",n)))),n.requireOpToken("]");var s={type:"arrayIndex",root:r,firstIndex:a,secondIndex:u,args:[r,a,u],op:function(e,t,n,r){return o?t.slice(0,n+1):i?null!=r?t.slice(n,r+1):t.slice(n):t[n]},evaluate:function(e){return T.unifiedEval(this,e)}};return y.parseElement("indirectExpression",n,s)}});var q=["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","pc","pt","px"];y.addGrammarElement("postfixExpression",function(e,t,n){var r=e.parseElement("primaryExpression",n),o=n.matchAnyToken.apply(n,q)||n.matchOpToken("%");if(o)return{type:"stringPostfix",postfix:o.value,args:[r],op:function(e,t){return""+t+o.value},evaluate:function(e){return t.unifiedEval(this,e)}};var i=null;if(n.matchToken("s")||n.matchToken("seconds")?i=1e3:(n.matchToken("ms")||n.matchToken("milliseconds"))&&(i=1),i)return{type:"timeExpression",time:r,factor:i,args:[r],op:function(e,t){return t*i},evaluate:function(e){return t.unifiedEval(this,e)}};if(n.matchOpToken(":")){var a=n.requireTokenType("IDENTIFIER"),u=!n.matchOpToken("!");return{type:"typeCheck",typeName:a,nullOk:u,args:[r],op:function(e,n){if(t.typeCheck(n,a.value,u))return n;throw new Error("Typecheck failed! Expected: "+a.value)},evaluate:function(e){return t.unifiedEval(this,e)}}}return r}),y.addGrammarElement("logicalNot",function(e,t,n){if(n.matchToken("not")){var r=e.requireElement("unaryExpression",n);return{type:"logicalNot",root:r,args:[r],op:function(e,t){return!t},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("noExpression",function(e,t,n){if(n.matchToken("no")){var r=e.requireElement("unaryExpression",n);return{type:"noExpression",root:r,args:[r],op:function(e,n){return t.isEmpty(n)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addLeafExpression("some",function(e,t,n){if(n.matchToken("some")){var r=e.requireElement("expression",n);return{type:"noExpression",root:r,args:[r],op:function(e,n){return!t.isEmpty(n)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("negativeNumber",function(e,t,n){if(n.matchOpToken("-")){var r=e.requireElement("unaryExpression",n);return{type:"negativeNumber",root:r,args:[r],op:function(e,t){return-1*t},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("unaryExpression",function(e,t,n){return e.parseAnyOf(["logicalNot","relativePositionalExpression","positionalExpression","noExpression","negativeNumber","postfixExpression"],n)});var S=function(e,t,n,r){var o=[];T.forEach(t,function(t){(t.matches(n)||t===e)&&o.push(t)});for(var i=0;i=0;i--){var a=o[i];if(a.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return a}if(r)return o[o.length-1]}(n,i,l,c)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("positionalExpression",function(e,t,n){var r=n.matchAnyToken("first","last","random");if(r){n.matchAnyToken("in","from","of");var o=e.requireElement("unaryExpression",n),i=r.value;return{type:"positionalExpression",rhs:o,operator:r.value,args:[o],op:function(e,t){if(t&&!Array.isArray(t)&&(t=t.children?t.children:Array.from(t)),t){if("first"===i)return t[0];if("last"===i)return t[t.length-1];if("random"===i)return t[Math.floor(Math.random()*t.length)]}},evaluate:function(e){return t.unifiedEval(this,e)}}}}),y.addGrammarElement("mathOperator",function(e,t,n){var r,o=e.parseElement("unaryExpression",n),i=null;for(r=n.matchAnyOpToken("+","-","*","/","%");r;){var a=r.value;(i=i||r).value!==a&&e.raiseParseError(n,"You must parenthesize math operations with different operators");var u=e.parseElement("unaryExpression",n);o={type:"mathOperator",lhs:o,rhs:u,operator:a,args:[o,u],op:function(e,t,n){return"+"===a?t+n:"-"===a?t-n:"*"===a?t*n:"/"===a?t/n:"%"===a?t%n:void 0},evaluate:function(e){return t.unifiedEval(this,e)}},r=n.matchAnyOpToken("+","-","*","/","%")}return o}),y.addGrammarElement("mathExpression",function(e,t,n){return e.parseAnyOf(["mathOperator","unaryExpression"],n)}),y.addGrammarElement("comparisonOperator",function(e,t,n){var r=e.parseElement("mathExpression",n),o=n.matchAnyOpToken("<",">","<=",">=","==","===","!=","!=="),i=o?o.value:null,a=!0,u=!1;if(null==i&&(n.matchToken("is")||n.matchToken("am")?n.matchToken("not")?n.matchToken("in")?i="not in":n.matchToken("a")?(i="not a",u=!0):n.matchToken("empty")?(i="not empty",a=!1):i="!=":n.matchToken("in")?i="in":n.matchToken("a")?(i="a",u=!0):n.matchToken("empty")?(i="empty",a=!1):n.matchToken("less")?(n.requireToken("than"),n.matchToken("or")?(n.requireToken("equal"),n.requireToken("to"),i="<="):i="<"):n.matchToken("greater")?(n.requireToken("than"),n.matchToken("or")?(n.requireToken("equal"),n.requireToken("to"),i=">="):i=">"):i="==":n.matchToken("exist")||n.matchToken("exists")?(i="exist",a=!1):n.matchToken("matches")||n.matchToken("match")?i="match":n.matchToken("contains")||n.matchToken("contain")?i="contain":n.matchToken("includes")||n.matchToken("include")?i="include":(n.matchToken("do")||n.matchToken("does"))&&(n.requireToken("not"),n.matchToken("matches")||n.matchToken("match")?i="not match":n.matchToken("contains")||n.matchToken("contain")?i="not contain":n.matchToken("exist")||n.matchToken("exist")?(i="not exist",a=!1):n.matchToken("include")?i="not include":e.raiseParseError(n,"Expected matches or contains"))),i){if(u)var s=n.requireTokenType("IDENTIFIER"),l=!n.matchOpToken("!");else if(a){var c=e.requireElement("mathExpression",n);"match"!==i&&"not match"!==i||(c=c.css?c.css:c)}var f=r;r={type:"comparisonOperator",operator:i,typeName:s,nullOk:l,lhs:r,rhs:c,args:[r,c],op:function(e,n,r){if("=="===i)return n==r;if("!="===i)return n!=r;if("match"===i)return null!=n&&g(f,n,r);if("not match"===i)return null==n||!g(f,n,r);if("in"===i)return null!=r&&k(c,r,n);if("not in"===i)return null==r||!k(c,r,n);if("contain"===i)return null!=n&&k(f,n,r);if("not contain"===i)return null==n||!k(f,n,r);if("include"===i)return null!=n&&k(f,n,r);if("not include"===i)return null==n||!k(f,n,r);if("==="===i)return n===r;if("!=="===i)return n!==r;if("<"===i)return n"===i)return n>r;if("<="===i)return n<=r;if(">="===i)return n>=r;if("empty"===i)return t.isEmpty(n);if("not empty"===i)return!t.isEmpty(n);if("exist"===i)return t.doesExist(n);if("not exist"===i)return!t.doesExist(n);if("a"===i)return t.typeCheck(n,s.value,l);if("not a"===i)return!t.typeCheck(n,s.value,l);throw"Unknown comparison : "+i},evaluate:function(e){return t.unifiedEval(this,e)}}}return r}),y.addGrammarElement("comparisonExpression",function(e,t,n){return e.parseAnyOf(["comparisonOperator","mathExpression"],n)}),y.addGrammarElement("logicalOperator",function(e,t,n){var r,o=e.parseElement("comparisonExpression",n),i=null;r=n.matchToken("and")||n.matchToken("or");for(var a=function(){(i=i||r).value!==r.value&&e.raiseParseError(n,"You must parenthesize logical operations with different operators"),u=e.requireElement("comparisonExpression",n);var a=r.value;o={type:"logicalOperator",operator:a,lhs:o,rhs:u,args:[o,u],op:function(e,t,n){return"and"===a?t&&n:t||n},evaluate:function(e){return t.unifiedEval(this,e)}},r=n.matchToken("and")||n.matchToken("or")};r;){var u;a()}return o}),y.addGrammarElement("logicalExpression",function(e,t,n){return e.parseAnyOf(["logicalOperator","mathExpression"],n)}),y.addGrammarElement("asyncExpression",function(e,t,n){return n.matchToken("async")?{type:"asyncExpression",value:e.requireElement("logicalExpression",n),evaluate:function(e){return{asyncWrapper:!0,value:this.value.evaluate(e)}}}:e.parseElement("logicalExpression",n)}),y.addGrammarElement("expression",function(e,t,n){return n.matchToken("the"),e.parseElement("asyncExpression",n)}),y.addGrammarElement("assignableExpression",function(e,t,n){n.matchToken("the");var r=e.parseElement("primaryExpression",n);return!r||"symbol"!==r.type&&"ofExpression"!==r.type&&"propertyAccess"!==r.type&&"attributeRefAccess"!==r.type&&"attributeRef"!==r.type&&"styleRef"!==r.type&&"possessive"!==r.type?(y.raiseParseError(n,"A target expression must be writable. The expression type '"+(r&&r.type)+"' is not."),r):r}),y.addGrammarElement("hyperscript",function(e,t,n){var r=[];if(n.hasMore())for(;e.featureStart(n.currentToken())||"("===n.currentToken().value;){var o=e.requireElement("feature",n);r.push(o),n.matchToken("end")}return{type:"hyperscript",features:r,apply:function(e,t,n){for(var o,i=l(r);!(o=i()).done;)o.value.install(e,t,n)}}});var N=function(e){var t=[];if("("===e.token(0).value&&(")"===e.token(1).value||","===e.token(2).value||")"===e.token(2).value)){e.matchOpToken("(");do{t.push(e.requireTokenType("IDENTIFIER"))}while(e.matchOpToken(","));e.requireOpToken(")")}return t};y.addFeature("on",function(e,t,n){if(n.matchToken("on")){var r=!1;n.matchToken("every")&&(r=!0);var o=[],i=null;do{var a=e.requireElement("eventName",n,"Expected event name").evaluate();i=i?i+" or "+a:"on "+a;var u=N(n),s=null;if(n.matchOpToken("[")&&(s=e.requireElement("expression",n),n.requireOpToken("]")),"NUMBER"===n.currentToken().type){var f=n.consumeToken(),m=parseInt(f.value);if(n.matchToken("to"))var p=n.consumeToken(),d=parseInt(p.value);else if(n.matchToken("and")){var h=!0;n.requireToken("on")}}if("intersection"===a){var v={};if(n.matchToken("with")&&(v.with=e.requireElement("expression",n).evaluate()),n.matchToken("having"))do{n.matchToken("margin")?v.rootMargin=e.requireElement("stringLike",n).evaluate():n.matchToken("threshold")?v.threshold=e.requireElement("expression",n).evaluate():e.raiseParseError(n,"Unknown intersection config specification")}while(n.matchToken("and"))}else if("mutation"===a){var y={};if(n.matchToken("of"))do{if(n.matchToken("anything"))y.attributes=!0,y.subtree=!0,y.characterData=!0,y.childList=!0;else if(n.matchToken("childList"))y.childList=!0;else if(n.matchToken("attributes"))y.attributes=!0,y.attributeOldValue=!0;else if(n.matchToken("subtree"))y.subtree=!0;else if(n.matchToken("characterData"))y.characterData=!0,y.characterDataOldValue=!0;else if("ATTRIBUTE_REF"===n.currentToken().type){var E=n.consumeToken();null==y.attributeFilter&&(y.attributeFilter=[]),0==E.value.indexOf("@")?y.attributeFilter.push(E.value.substring(1)):e.raiseParseError(n,"Only shorthand attribute references are allowed here")}else e.raiseParseError(n,"Unknown mutation config specification")}while(n.matchToken("or"));else y.attributes=!0,y.characterData=!0,y.childList=!0}var k=null,g=!1;if(n.matchToken("from")&&(n.matchToken("elsewhere")?g=!0:(k=e.parseElement("expression",n))||e.raiseParseError(n,'Expected either target value or "elsewhere".')),null===k&&!1===g&&n.matchToken("elsewhere")&&(g=!0),n.matchToken("in"))var x=e.parseAnyOf(["idRef","queryRef","classRef"],n);if(n.matchToken("debounced")){n.requireToken("at");var b=e.requireElement("expression",n).evaluate({})}else if(n.matchToken("throttled")){n.requireToken("at");var w=e.requireElement("expression",n).evaluate({})}o.push({execCount:0,every:r,on:a,args:u,filter:s,from:k,inExpr:x,elsewhere:g,startCount:m,endCount:d,unbounded:h,debounceTime:b,throttleTime:w,mutationSpec:y,intersectionSpec:v,debounced:void 0,lastExec:void 0})}while(n.matchToken("or"));var q=!0;if(!r&&n.matchToken("queue"))if(n.matchToken("all"))q=!1;else if(n.matchToken("first"))var S=!0;else if(n.matchToken("none"))var C=!0;else n.requireToken("last");var L=e.requireElement("commandList",n);if(e.ensureTerminated(L),n.matchToken("catch")){var O=n.requireTokenType("IDENTIFIER").value,R=e.requireElement("commandList",n);e.ensureTerminated(R)}if(n.matchToken("finally")){var I=e.requireElement("commandList",n);e.ensureTerminated(I)}var A={displayName:i,events:o,start:L,every:r,execCount:0,errorHandler:R,errorSymbol:O,execute:function(e){var n=t.getEventQueueFor(e.me,A);if(n.executing&&!1===r){if(C||S&&n.queue.length>0)return;return q&&(n.queue.length=0),void n.queue.push(e)}A.execCount++,n.executing=!0,e.meta.onHalt=function(){n.executing=!1;var e=n.queue.shift();e&&setTimeout(function(){A.execute(e)},1)},e.meta.reject=function(n){console.error(n.message?n.message:n);var r=t.getHyperTrace(e,n);r&&r.print(),t.triggerEvent(e.me,"exception",{error:n})},L.execute(e)},install:function(e,n){for(var r,o=function(){var n=r.value;a=n.elsewhere?[document]:n.from?n.from.evaluate(t.makeContext(e,A,e,null)):[e],t.implicitLoop(a,function(r){var o=n.on;if(n.mutationSpec&&(o="hyperscript:mutation",new MutationObserver(function(e,t){A.executing||T.triggerEvent(r,o,{mutationList:e,observer:t})}).observe(r,n.mutationSpec)),n.intersectionSpec){o="hyperscript:insersection";var i=new IntersectionObserver(function(e){for(var t,n=l(e);!(t=n()).done;){var a=t.value,u={observer:i};(u=c(u,a)).intersecting=a.isIntersecting,T.triggerEvent(r,o,u)}},n.intersectionSpec);i.observe(r)}(r.addEventListener||r.on).call(r,o,function i(a){if("undefined"!=typeof Node&&e instanceof Node&&r!==e&&!e.isConnected)r.removeEventListener(o,i);else{var u=t.makeContext(e,A,e,a);if(!n.elsewhere||!e.contains(a.target)){n.from&&(u.result=r);for(var s,c=l(n.args);!(s=c()).done;){var f=s.value,m=u.event[f.value];void 0!==m?u[f.value]=m:"detail"in u.event&&(u[f.value]=u.event.detail[f.value])}if(u.meta.errorHandler=R,u.meta.errorSymbol=O,u.meta.finallyHandler=I,n.filter){var p=u.meta.context;u.meta.context=u.event;try{if(!n.filter.evaluate(u))return}finally{u.meta.context=p}}if(n.inExpr)for(var d=a.target;;){if(d.matches&&d.matches(n.inExpr.css)){u.result=d;break}if(null==(d=d.parentElement))return}if(n.execCount++,n.startCount)if(n.endCount){if(n.execCountn.endCount)return}else if(n.unbounded){if(n.execCount=0?null:"noTimeout"===o?e(-1):"timeout"===o?function(t){return e(parseInt(t))}:function(){for(var e=F(),t=[],r=0;r=0&&setTimeout(function(){a[e]&&a[e].reject("Timed out"),delete a[e]},n),s}}})}(s),v={raw:d,dispatchEvent:function(e){var t=e.detail;delete t.sender,delete t._namedArgList_,d.send(JSON.stringify(c({type:e.type},t)))},rpc:h},y={name:i,socket:v,install:function(e){n.assignToNamespace(e,o,i,v)}};return d.onmessage=function(e){var t=e.data;try{var r=JSON.parse(t)}catch(e){}if(r&&r.iid&&(r.throw?a[r.iid].reject(r.throw):a[r.iid].resolve(r.return),delete a[r.iid]),f){var o=n.makeContext(v,y,v);if(l){if(!r)throw"Received non-JSON message from socket: "+t;o.message=r,o.result=r}else o.message=t,o.result=t;f.execute(o)}},d.addEventListener("close",function(e){d=null}),y}})}(A),function(e){e.addFeature("eventsource",function(e,t,n){if(n.matchToken("eventsource")){var r,o=function(e,n){return function(r){var o=i(r.data,e),a=t.makeContext(c,f,c);a.event=r,a.result=o,n.execute(a)}},i=function(e,t){return"json"==t?JSON.parse(e):e},a=function e(n){if(n.next)return e(n.next);n.next={type:"implicitReturn",op:function(e){return t.HALT},execute:function(e){}}},u=!1,s=e.requireElement("dotOrColonPath",n).evaluate().split("."),l=s.pop();n.matchToken("from")&&(r=e.requireElement("stringLike",n)),n.matchToken("with")&&n.matchToken("credentials")&&(u=!0);for(var c={eventSource:null,listeners:[],retryCount:0,open:function(e){if(null==e){if(null==c.eventSource||null==c.eventSource.url)throw"no url defined for EventSource.";e=c.eventSource.url}if(null!=c.eventSource)if(e!=c.eventSource.url)c.eventSource.close();else if(c.eventSource.readyState!=EventSource.CLOSED)return;c.eventSource=new EventSource(e,{withCredentials:u}),c.eventSource.addEventListener("open",function(e){c.retryCount=0}),c.eventSource.addEventListener("error",function(e){if(c.eventSource.readyState==EventSource.CLOSED){c.retryCount=Math.min(7,c.retryCount+1);var t=Math.random()*(2^c.retryCount)*500;window.setTimeout(c.open,t)}});for(var t=0;t/g,">").replace(/\x22/g,""").replace(/\x27/g,"'");throw new Error("Unknown escape: "+r)},evaluate:function(e){return t.unifiedEval(this,e)}}}})}(A),function(e){function t(t,n,r){this.ctx=t,this.runtime=n,this.cmd=r,this._hyperscript=e,this.cmdMap=[],this.bus=new EventTarget}e.addCommand("breakpoint",function(e,n,r){var o;if(r.matchToken("breakpoint"))return{op:function(e){globalThis.hdb=o=new t(e,n,this);try{return o.break(e)}catch(e){console.error(e,e.stack)}}}}),t.prototype.break=function(e){var t=this;return console.log("=== HDB///_hyperscript/debugger ==="),this.ui(),new Promise(function(n,r){t.bus.addEventListener("continue",function(){if(t.ctx!==e){for(var r in e)delete e[r];Object.assign(e,t.ctx)}delete window.hdb,n(t.runtime.findNext(t.cmd,t.ctx))},{once:!0})})},t.prototype.continueExec=function(){this.bus.dispatchEvent(new Event("continue"))},t.prototype.stepOver=function(){var e=this;if(!this.cmd)return this.continueExec();var t=this.cmd&&"breakpointCommand"===this.cmd.type?this.runtime.findNext(this.cmd,this.ctx):this.runtime.unifiedEval(this.cmd,this.ctx);return"implicitReturn"===t.type?this.stepOut():t&&t.then instanceof Function?t.then(function(t){e.cmd=t,e.bus.dispatchEvent(new Event("step")),e.logCommand()}):void(t.halt_flag?this.bus.dispatchEvent(new Event("continue")):(this.cmd=t,this.bus.dispatchEvent(new Event("step")),this.logCommand()))},t.prototype.stepOut=function(){if(!this.ctx.meta.caller)return this.continueExec();var e=this.ctx.meta.callingCommand,t=this.ctx.me;this.ctx=this.ctx.meta.caller,console.log("[hdb] stepping out into "+this.ctx.meta.feature.displayName),this.ctx.me instanceof Element&&this.ctx.me!==t&&console.log("[hdb] me: ",this.ctx.me),this.cmd=this.runtime.findNext(e,this.ctx),this.cmd=this.runtime.findNext(this.cmd,this.ctx),this.logCommand(),this.bus.dispatchEvent(new Event("step"))},t.prototype.skipTo=function(e){this.cmd=e.cmd,this.bus.dispatchEvent(new Event("skip"))},t.prototype.rewrite=function(t,n){console.log("##",t);for(var r,o,i=t.cmd.parent,a=l(i.children);!(o=a()).done&&(r=o.value).next!==t.cmd;);var u=t.next,s=e.internals.lexer.tokenize(n),c=e.internals.parser.requireElement("command",s);console.log(c),c.startToken=t.startToken,c.endToken=t.endToken,c.programSource=t.programSource,c.sourceFor=function(){return n},r.next=c,c.next=u,c.parent=i,this.bus.dispatchEvent(new Event("step"))},t.prototype.logCommand=function(){var e=this.cmd.sourceFor instanceof Function?this.cmd.sourceFor():"-- "+this.cmd.type;console.log("[hdb] current command: "+e)},t.prototype.traverse=function(e){var t=[];return function e(n){t.push(n);for(var r=l(n.children);!r().done;)e(t)}(e),t},t.prototype.ui=function(){var t=document.createElement("div"),n=t.attachShadow({mode:"open"});t.style.cssText="all: initial",n.innerHTML='\n
\n\n\t