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

hyperscript.org

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperscript.org - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

dist/_hyperscript.min.js

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

(function(e,r){if(typeof define==="function"&&define.amd){define([],r)}else{e._hyperscript=r()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";var E={lexer:T,parser:y,runtime:g,evaluate:e,processNode:a,toJS:l,config:{attributes:"_, script, data-script"}};function r(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}return e}function t(e){try{return JSON.parse(e)}catch(e){n(e);return null}}function n(e){if(console.error){console.error(e)}else if(console.log){console.log("ERROR: ",e)}}var T=function(){var k={"+":"PLUS","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",".":"PERIOD","\\":"BACKSLASH",":":"COLON","%":"PERCENT","|":"PIPE","!":"EXCLAMATION","?":"QUESTION","#":"POUND","&":"AMPERSAND",";":"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 x(e){return L(e)||R(e)||e==="-"||e==="_"}function O(e){return L(e)||R(e)||e==="-"||e==="_"||e===":"}function C(e){return e===" "||e==="\t"||A(e)}function b(e){return"[Line: "+e.line+", Column: "+e.col+"]"}function A(e){return e==="\r"||e==="\n"}function R(e){return e>="0"&&e<="9"}function L(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function G(e){return e==="_"||e==="$"}function I(r,t,e){var n=true;u("WHITESPACE");function i(e,r){y.raiseParseError(e,r)}function a(e){var r=s(e);if(r){return r}else{i(this,"Expected '"+e+"' but found '"+h().value+"'")}}function o(e,r,t){for(var n=0;n<arguments.length;n++){var a=arguments[n];var i=s(a);if(i){return i}}}function s(e){if(h()&&h().op&&h().value===e){return c()}}function l(e,r,t,n){var a=u(e,r,t,n);if(a){return a}else{i(this,"Expected one of "+JSON.stringify([e,r,t]))}}function u(e,r,t,n){if(h()&&h().type&&[e,r,t,n].indexOf(h().type)>=0){return c()}}function p(e,r){var t=m(e,r);if(t){return t}else{i(this,"Expected '"+e+"' but found '"+h().value+"'")}}function m(e,r){var r=r||"IDENTIFIER";if(h()&&h().value===e&&h().type===r){return c()}}function c(){var e=r.shift();t.push(e);if(n){u("WHITESPACE")}return e}function f(){var e=[];n=false;while(h()&&h().type!=="WHITESPACE"){e.push(c())}n=true;return e}function v(){return r.length>0}function h(){return r[0]}return{matchAnyOpToken:o,matchOpToken:s,requireOpToken:a,matchTokenType:u,requireTokenType:l,consumeToken:c,matchToken:m,requireToken:p,list:r,source:e,hasMore:v,currentToken:h,consumeUntilWhitespace:f}}function e(e){var r=e;var t=[];var n=0;var a=0;var i=1;var o="<START>";while(n<r.length){if(d()==="-"&&E()==="-"){u()}else{if(C(d())){t.push(g())}else if(!y()&&d()==="."&&L(E())){t.push(p())}else if(!y()&&d()==="#"&&L(E())){t.push(m())}else if(L(d())||G(d())){t.push(c())}else if(R(d())){t.push(f())}else if(d()==='"'||d()==="'"){t.push(h())}else if(k[d()]){t.push(v())}else{if(n<r.length){throw Error("Unknown token: "+d()+" ")}}}}return I(t,[],r);function s(e,r){var t=l(e,r);t.op=true;return t}function l(e,r){return{type:e,value:r,start:n,end:n+1,column:a,line:i}}function u(){while(d()&&!A(d())){T()}T()}function p(){var e=l("CLASS_REF");var r=T();while(x(d())){r+=T()}e.value=r;e.end=n;return e}function m(){var e=l("ID_REF");var r=T();while(O(d())){r+=T()}e.value=r;e.end=n;return e}function c(){var e=l("IDENTIFIER");var r=T();while(L(d())||G(d())){r+=T()}e.value=r;e.end=n;return e}function f(){var e=l("NUMBER");var r=T();while(R(d())){r+=T()}if(d()==="."){r+=T()}while(R(d())){r+=T()}e.value=r;e.end=n;return e}function v(){var e=T();while(d()&&k[e+d()]){e+=T()}var r=s(k[e],e);r.value=e;r.end=n;return r}function h(){var e=l("STRING");var r=T();var t="";while(d()&&d()!==r){if(d()==="\\"){T()}t+=T()}if(d()!==r){throw Error("Unterminated string at "+b(e))}else{T()}e.value=t;e.end=n;return e}function d(){return r.charAt(n)}function E(){return r.charAt(n+1)}function T(){o=d();n++;a++;return o}function y(){return L(o)||R(o)||o===")"||o==="}"||o==="]"}function g(){var e=l("WHITESPACE");var r="";while(d()&&C(d())){if(A(d())){a=0;i++}r+=T()}e.value=r;e.end=n;return e}}return{tokenize:e}}();var y=function(){var a={};function e(e,r){a[e]=r}function n(e){var r=e.currentToken();var t=e.source;var n=t.split("\n");var a=r?r.line-1:n.length-1;var i=n[a];var o=r?r.column:i.length-1;return i+"\n"+" ".repeat(o)+"^^\n\n"}function r(e,r){r=(r||"Unexpected Token : "+e.currentToken().value)+"\n\n"+n(e);var t=new Error(r);t.tokens=e;throw t}function i(e,r,t){var n=a[e];if(n)return n(y,r,t)}function t(e,r){for(var t=0;t<e.length;t++){var n=e[t];var a=i(n,r);if(a){return a}}}function o(e){return i("hyperscript",e)}function s(e,r){if(e==null){return r}var t=e.transpile();if(e.next){return t+"\n"+s(e.next)}else{return t}}return{parseElement:i,parseAnyOf:t,parseHyperScript:o,raiseParseError:r,addGrammarElement:e,transpile:s}}();var g=function(){function t(e,r){var t=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return t&&t.call(e,r)}function i(e,r){var t;if(window.CustomEvent&&typeof window.CustomEvent==="function"){t=new CustomEvent(e,{bubbles:true,cancelable:true,detail:r})}else{t=document.createEvent("CustomEvent");t.initCustomEvent(e,true,true,r)}return t}function e(e,r,t){var t=t||{};t["sentBy"]=e;var n=i(r,t);var a=e.dispatchEvent(n);return a}function n(e,r){if(e.length){for(var t=0;t<e.length;t++){r(e[t])}}else{r(e)}}function r(e,r){if(e.length){var t=e}else{var t=[e]}while(r.length>0){var n=r.shift();var a=[];for(var i=0;i<t.length;i++){var o=t[i];var s=o[n];if(s&&s.length){a=a.concat(s)}else{a.push(s)}}t=a}return t}var a=null;function o(){if(a==null){a=E.config.attributes.replace(/ /g,"").split(",")}return a}function s(e){for(var r=0;r<o().length;r++){var t=o()[r];if(e.hasAttribute&&e.hasAttribute(t)){return e.getAttribute(t)}}return null}function l(e,r){n(e.eventListeners,function(e){e(r)})}function u(){return o().map(function(e){return"["+e+"]"}).join(", ")}function p(e,r){return Object.prototype.toString.call(e)==="[object "+r+"]"}function m(e,r,t){if(p(r,"Object")){var n=e;var a=r;var i="expression"}else if(p(r,"String")){var n=r;var i=e;var a=t}else{var n=e;var a={};var i="expression"}a=a||{};var o=y.parseElement(i,T.tokenize(n)).transpile();var s="(function("+Object.keys(a).join(",")+"){return "+o+"})";var l=Object.keys(a).map(function(e){return a[e]});return eval(s).apply(null,l)}function c(e){var r=g.getScriptSelector();if(t(e,r)){f(e)}n(e.querySelectorAll(r),function(e){f(e)})}function f(e){var r=v(e);if(!r.initialized){var t=s(e);if(t){r.initialized=true;r.script=t;var n=T.tokenize(t);var a=y.parseHyperScript(n);var i=y.transpile(a);if(e.getAttribute("debug")==="true"){console.log(i)}var o=eval(i);o.applyEventListenersTo(e)}}}function v(e){var r="hyperscript-internal-data";var t=e[r];if(!t){t=e[r]={}}return t}function h(e,r,t,n){var a=new XMLHttpRequest;a.onload=function(){t(this.response,a)};a.open(e,r);a.send(JSON.stringify(n))}function d(e,r,t){if(e==null&&t){return e}var n=Object.prototype.toString.call(e).slice(8,-1);var a=e&&n===r;if(a){return e}else{throw new Error("Typecheck failed! Expected: "+r+", Found: "+n)}}return{typeCheck:d,forEach:n,evalTarget:r,triggerEvent:e,matchesSelector:t,getScript:s,applyEventListeners:l,processNode:c,evaluate:m,getScriptSelector:u,ajax:h}}();{y.addGrammarElement("parenthesized",function(e,r){if(r.matchOpToken("(")){var t=e.parseElement("expression",r);r.requireOpToken(")");return{type:"parenthesized",expr:t,transpile:function(){return"("+e.transpile(t)+")"}}}});y.addGrammarElement("string",function(e,r){var t=r.matchTokenType("STRING");if(t){return{type:"string",token:t,transpile:function(){if(t.value.indexOf("'")===0){return"'"+t.value+"'"}else{return'"'+t.value+'"'}}}}});y.addGrammarElement("nakedString",function(e,r){if(r.hasMore()){var t=r.consumeUntilWhitespace();r.matchTokenType("WHITESPACE");return{type:"nakedString",tokens:t,transpile:function(){return"'"+t.map(function(e){return e.value}).join("")+"'"}}}});y.addGrammarElement("number",function(e,r){var t=r.matchTokenType("NUMBER");if(t){var n=t;var a=parseFloat(t.value);return{type:"number",value:a,numberToken:n,transpile:function(){return n.value}}}});y.addGrammarElement("idRef",function(e,r){var t=r.matchTokenType("ID_REF");if(t){return{type:"idRef",value:t.value.substr(1),transpile:function(){return"document.getElementById('"+this.value+"')"}}}});y.addGrammarElement("classRef",function(e,r){var t=r.matchTokenType("CLASS_REF");if(t){return{type:"classRef",value:t.value,className:function(){return this.value.substr(1)},transpile:function(){return"document.querySelectorAll('"+this.value+"')"}}}});y.addGrammarElement("attributeRef",function(e,r){if(r.matchOpToken("[")){var t=r.matchTokenType("IDENTIFIER");var n=null;if(r.matchOpToken("=")){n=e.parseElement("expression",r)}r.requireOpToken("]");return{type:"attribute_expression",name:t.value,value:n,transpile:function(){if(this.value){return"({name: '"+this.name+"', value: "+e.transpile(this.value)+"})"}else{return"({name: '"+this.name+"'})"}}}}});y.addGrammarElement("objectLiteral",function(r,e){if(e.matchOpToken("{")){var t=[];if(!e.matchOpToken("}")){do{var n=e.requireTokenType("IDENTIFIER");e.requireOpToken(":");var a=r.parseElement("expression",e);t.push({name:n,value:a})}while(e.matchOpToken(","));e.requireOpToken("}")}return{type:"objectLiteral",fields:t,transpile:function(){return"({"+t.map(function(e){return e.name.value+":"+r.transpile(e.value)}).join(", ")+"})"}}}});y.addGrammarElement("namedArgumentList",function(r,e){if(e.matchOpToken("(")){var t=[];if(!e.matchOpToken(")")){do{var n=e.requireTokenType("IDENTIFIER");e.requireOpToken(":");var a=r.parseElement("expression",e);t.push({name:n,value:a})}while(e.matchOpToken(","));e.requireOpToken(")")}return{type:"namedArgumentList",fields:t,transpile:function(){return"({_namedArgList_:true, "+t.map(function(e){return e.name.value+":"+r.transpile(e.value)}).join(", ")+"})"}}}});y.addGrammarElement("symbol",function(e,r){var t=r.matchTokenType("IDENTIFIER");if(t){return{type:"symbol",name:t.value,transpile:function(){return t.value}}}});y.addGrammarElement("implicitMeTarget",function(e,r){return{type:"implicitMeTarget",transpile:function(){return"[me]"}}});y.addGrammarElement("implicitAllTarget",function(e,r){return{type:"implicitAllTarget",transpile:function(){return'document.querySelectorAll("*")'}}});y.addGrammarElement("millisecondLiteral",function(e,r){var t=r.requireTokenType(r,"NUMBER");var n=1;if(r.matchToken("s")){n=1e3}else if(r.matchToken("ms")){}return{type:"millisecondLiteral",number:t,factor:n,transpile:function(){return n*parseFloat(this.number.value)}}});y.addGrammarElement("boolean",function(e,r){var t=r.matchToken("true")||r.matchToken("false");if(t){return{type:"boolean",transpile:function(){return t.value}}}});y.addGrammarElement("null",function(e,r){if(r.matchToken("null")){return{type:"null",transpile:function(){return"null"}}}});y.addGrammarElement("arrayLiteral",function(r,e){if(e.matchOpToken("[")){var t=[];if(!e.matchOpToken("]")){do{var n=r.parseElement("expression",e);if(n==null){r.raiseParseError(e,"Expected an expression")}t.push(n)}while(e.matchOpToken(","));e.requireOpToken("]")}return{type:"arrayLiteral",values:t,transpile:function(){return"["+t.map(function(e){return r.transpile(e)}).join(", ")+"]"}}}});y.addGrammarElement("blockLiteral",function(e,r){if(r.matchOpToken("\\")){var t=[];var n=r.matchTokenType("IDENTIFIER");if(n){t.push(n);while(r.matchOpToken(",")){t.push(r.requireTokenType("IDENTIFIER"))}}r.requireOpToken("-");r.requireOpToken(">");var a=e.parseElement("expression",r);if(a==null){e.raiseParseError(r,"Expected an expression")}return{type:"blockLiteral",args:t,expr:a,transpile:function(){return"function("+t.map(function(e){return e.value}).join(", ")+"){ return "+e.transpile(a)+" }"}}}});y.addGrammarElement("leaf",function(e,r){return e.parseAnyOf(["parenthesized","boolean","null","string","number","idRef","classRef","symbol","propertyRef","objectLiteral","arrayLiteral","blockLiteral"],r)});y.addGrammarElement("propertyAccess",function(e,r,t){if(r.matchOpToken(".")){var n=r.requireTokenType("IDENTIFIER");var a={type:"propertyAccess",root:t,prop:n,transpile:function(){return e.transpile(t)+"."+n.value}};return y.parseElement("indirectExpression",r,a)}});y.addGrammarElement("functionCall",function(r,e,t){if(e.matchOpToken("(")){var n=[];if(!e.matchOpToken(")")){do{n.push(r.parseElement("expression",e))}while(e.matchOpToken(","));e.requireOpToken(")")}var a={type:"functionCall",root:t,args:n,transpile:function(){return r.transpile(t)+"("+n.map(function(e){return r.transpile(e)}).join(",")+")"}};return y.parseElement("indirectExpression",e,a)}});y.addGrammarElement("indirectExpression",function(e,r,t){var n=e.parseElement("propertyAccess",r,t);if(n){return n}var a=e.parseElement("functionCall",r,t);if(a){return a}return t});y.addGrammarElement("primaryExpression",function(e,r){var t=e.parseElement("leaf",r);if(t){return e.parseElement("indirectExpression",r,t)}e.raiseParseError(r,"Unexpected value: "+r.currentToken().value)});y.addGrammarElement("postfixExpression",function(e,r){var t=e.parseElement("primaryExpression",r);if(r.matchOpToken(":")){var n=r.requireTokenType("IDENTIFIER");var a=!r.matchOpToken("!");return{type:"typeCheck",typeName:n,root:t,nullOk:a,transpile:function(){return"_hyperscript.runtime.typeCheck("+e.transpile(t)+", '"+n.value+"', "+a+")"}}}else{return t}});y.addGrammarElement("logicalNot",function(e,r){if(r.matchToken("not")){var t=e.parseElement("unaryExpression",r);return{type:"logicalNot",root:t,transpile:function(){return"!"+e.transpile(t)}}}});y.addGrammarElement("negativeNumber",function(e,r){if(r.matchOpToken("-")){var t=e.parseElement("unaryExpression",r);return{type:"negativeNumber",root:t,transpile:function(){return"-"+e.transpile(t)}}}});y.addGrammarElement("unaryExpression",function(e,r){return e.parseAnyOf(["logicalNot","negativeNumber","postfixExpression"],r)});y.addGrammarElement("mathOperator",function(e,r){var t=e.parseElement("unaryExpression",r);var n,a=null;n=r.matchAnyOpToken("+","-","*","/","%");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize math operations with different operators")}var i=e.parseElement("unaryExpression",r);t={type:"mathOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+this.operator+" "+e.transpile(this.rhs)}};n=r.matchAnyOpToken("+","-","*","/","%")}return t});y.addGrammarElement("mathExpression",function(e,r){return e.parseAnyOf(["mathOperator","unaryExpression"],r)});y.addGrammarElement("comparisonOperator",function(e,r){var t=e.parseElement("mathExpression",r);var n,a=null;n=r.matchAnyOpToken("<",">","<=",">=","==","===","!=","!==");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize comparison operations with different operators")}var i=e.parseElement("mathExpression",r);t={type:"comparisonOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+this.operator+" "+e.transpile(this.rhs)}};n=r.matchAnyOpToken("<",">","<=",">=","==","===","!=","!==")}return t});y.addGrammarElement("comparisonExpression",function(e,r){return e.parseAnyOf(["comparisonOperator","mathExpression"],r)});y.addGrammarElement("logicalOperator",function(e,r){var t=e.parseElement("comparisonExpression",r);var n,a=null;n=r.matchToken("and")||r.matchToken("or");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize logical operations with different operators")}var i=e.parseElement("comparisonExpression",r);t={type:"logicalOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+(this.operator==="and"?" && ":" || ")+" "+e.transpile(this.rhs)}};n=r.matchToken("and")||r.matchToken("or")}return t});y.addGrammarElement("logicalExpression",function(e,r){return e.parseAnyOf(["logicalOperator","mathExpression"],r)});y.addGrammarElement("expression",function(e,r){return e.parseElement("logicalExpression",r)});y.addGrammarElement("target",function(e,r){var t=e.parseAnyOf(["symbol","classRef","idRef"],r);if(t==null){e.raiseParseError(r,"Expected a valid target expression")}var n=[];while(r.matchOpToken(".")){n.push(r.requireTokenType("IDENTIFIER").value)}return{type:"target",propPath:n,root:t,transpile:function(){return"_hyperscript.runtime.evalTarget("+e.transpile(t)+", ["+n.map(function(e){return'"'+e+'"'}).join(", ")+"])"}}});y.addGrammarElement("command",function(e,r){return e.parseAnyOf(["onCmd","addCmd","removeCmd","toggleCmd","waitCmd","sendCmd","triggerCmd","takeCmd","logCmd","callCmd","putCmd","setCmd","ifCmd","ajaxCmd"],r)});y.addGrammarElement("commandList",function(e,r){var t=e.parseElement("command",r);if(t){r.matchToken("then");t.next=e.parseElement("commandList",r);return t}});y.addGrammarElement("hyperscript",function(r,e){var t=[];do{t.push(r.parseElement("eventListener",e))}while(e.matchToken("end")&&e.hasMore());if(e.hasMore()){r.raiseParseError(e)}return{type:"hyperscript",eventListeners:t,transpile:function(){return"(function(){\n"+"var eventListeners = []\n"+t.map(function(e){return" eventListeners.push("+r.transpile(e)+");\n"}).join("")+" function applyEventListenersTo(elt) { _hyperscript.runtime.applyEventListeners(this, elt) }\n"+" return {eventListeners:eventListeners, applyEventListenersTo:applyEventListenersTo}\n"+"})()"}}});y.addGrammarElement("eventListener",function(e,r){r.requireToken("on");var t=e.parseElement("dotOrColonPath",r);if(t==null){e.raiseParseError(r,"Expected event name")}if(r.matchToken("from")){var n=e.parseElement("target",r);if(n==null){e.raiseParseError(r,"Expected target value")}}else{var n=e.parseElement("implicitMeTarget",r)}var a=[];if(r.matchOpToken("(")){do{a.push(r.requireTokenType("IDENTIFIER"))}while(r.matchOpToken(","));r.requireOpToken(")")}var i=e.parseElement("commandList",r);var o={type:"eventListener",on:t,from:n,start:i,transpile:function(){return"(function(me){"+"var my = me;\n"+"_hyperscript.runtime.forEach( "+e.transpile(n)+", function(target){\n"+" target.addEventListener('"+e.transpile(t)+"', function(event){\n"+a.map(function(e){return"var "+e.value+" = event.detail."+e.value+";"}).join("\n")+"\n"+e.transpile(i)+" })\n"+"})\n"+"})"}};return o});y.addGrammarElement("addCmd",function(e,r){if(r.matchToken("add")){var t=e.parseElement("classRef",r);var n=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){e.raiseParseError(r,"Expected either a class reference or attribute expression")}}if(r.matchToken("to")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"addCmd",classRef:t,attributeRef:n,to:a,transpile:function(){if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.classList.add('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.setAttribute('"+n.name+"', "+e.transpile(n)+".value)"+"})"}}}}});y.addGrammarElement("removeCmd",function(e,r){if(r.matchToken("remove")){var t=e.parseElement("classRef",r);var n=null;var a=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){a=e.parseElement("expression",r);if(a==null){e.raiseParseError(r,"Expected either a class reference, attribute expression or value expression")}}}if(r.matchToken("from")){var i=e.parseElement("target",r)}else{var i=e.parseElement("implicitMeTarget")}return{type:"removeCmd",classRef:t,attributeRef:n,elementExpr:a,from:i,transpile:function(){if(this.elementExpr){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.parentElement.removeChild(target)"+"})"}else{if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(i)+", function (target) {"+" target.classList.remove('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(i)+", function (target) {"+" target.removeAttribute('"+n.name+"')"+"})"}}}}}});y.addGrammarElement("toggleCmd",function(e,r){if(r.matchToken("toggle")){var t=e.parseElement("classRef",r);var n=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){e.raiseParseError(r,"Expected either a class reference or attribute expression")}}if(r.matchToken("on")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"toggleCmd",classRef:t,attributeRef:n,on:a,transpile:function(){if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.classList.toggle('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" if(target.hasAttribute('"+n.name+"')) {\n"+" target.removeAttribute('"+n.name+"');\n"+" } else { \n"+" target.setAttribute('"+n.name+"', "+e.transpile(n)+".value)"+" }"+"})"}}}}});y.addGrammarElement("waitCmd",function(r,e){if(e.matchToken("wait")){var t=r.parseElement("millisecondLiteral",e);return{type:"waitCmd",time:t,transpile:function(){var e=this.next;delete this.next;return"setTimeout(function () { "+r.transpile(e)+" }, "+r.transpile(this.time)+")"}}}});y.addGrammarElement("dotOrColonPath",function(e,r){var t=r.matchTokenType("IDENTIFIER");if(t){var n=[t.value];var a=r.matchOpToken(".")||r.matchOpToken(":");if(a){do{n.push(r.requireTokenType("IDENTIFIER").value)}while(r.matchOpToken(a.value))}return{type:"dotOrColonPath",path:n,transpile:function(){return n.join(a?a.value:"")}}}});y.addGrammarElement("sendCmd",function(e,r){if(r.matchToken("send")){var t=e.parseElement("dotOrColonPath",r);var n=e.parseElement("namedArgumentList",r);if(r.matchToken("to")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"sendCmd",eventName:t,details:n,to:a,transpile:function(){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" _hyperscript.runtime.triggerEvent(target, '"+e.transpile(t)+"',"+e.transpile(n,"{}")+")"+"})"}}}});y.addGrammarElement("triggerCmd",function(e,r){if(r.matchToken("trigger")){var t=e.parseElement("dotOrColonPath",r);var n=e.parseElement("namedArgumentList",r);return{type:"triggerCmd",eventName:t,details:n,transpile:function(){return"_hyperscript.runtime.triggerEvent(me, '"+e.transpile(t)+"',"+e.transpile(n,"{}")+");"}}}});y.addGrammarElement("takeCmd",function(r,e){if(e.matchToken("take")){var t=e.requireTokenType(e,"CLASS_REF");if(e.matchToken("from")){var n=r.parseElement("target",e)}else{var n=r.parseElement("implicitAllTarget")}if(e.matchToken("for")){var a=r.parseElement("target",e)}else{var a=r.parseElement("implicitMeTarget")}return{type:"takeCmd",classRef:t,from:n,forElt:a,transpile:function(){var e=this.classRef.value.substr(1);return" _hyperscript.runtime.forEach("+r.transpile(n)+", function (target) { target.classList.remove('"+e+"') }); "+"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.classList.add('"+e+"')"+"})"}}}});y.addGrammarElement("logCmd",function(r,e){if(e.matchToken("log")){var t=[r.parseElement("expression",e)];while(e.matchOpToken(",")){t.push(r.parseElement("expression",e))}if(e.matchToken("with")){var n=r.parseElement("expression",e)}return{type:"logCmd",exprs:t,withExpr:n,transpile:function(){if(n){return r.transpile(n)+"("+t.map(function(e){return r.transpile(e)}).join(", ")+")"}else{return"console.log("+t.map(function(e){return r.transpile(e)}).join(", ")+")"}}}}});y.addGrammarElement("callCmd",function(e,r){if(r.matchToken("call")||r.matchToken("get")){return{type:"callCmd",expr:e.parseElement("expression",r),transpile:function(){return"var it = "+e.transpile(this.expr)}}}});y.addGrammarElement("putCmd",function(r,e){if(e.matchToken("put")){var t=r.parseElement("expression",e);var n=e.matchToken("into")||e.matchToken("before")||e.matchToken("after");if(n==null&&e.matchToken("at")){n=e.matchToken("start")||e.matchToken("end");e.requireToken("of")}if(n==null){r.raiseParseError(e,"Expected one of 'into', 'before', 'at start of', 'at end of', 'after'")}var a=r.parseElement("target",e);var i=a.propPath.length===0&&n.value==="into";var o=i&&a.root.type==="symbol";if(i&&!o){r.raiseParseError(e,"Can only put directly into symbols, not references")}return{type:"putCmd",target:a,op:n.value,symbolWrite:o,value:t,transpile:function(){if(this.symbolWrite){return"var "+a.root.name+" = "+r.transpile(t)}else{if(this.op==="into"){var e=a.propPath.pop();return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target."+e+"="+r.transpile(t)+"})"}else if(this.op==="before"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('beforebegin', "+r.transpile(t)+")"+"})"}else if(this.op==="start"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('afterbegin', "+r.transpile(t)+")"+"})"}else if(this.op==="end"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('beforeend', "+r.transpile(t)+")"+"})"}else if(this.op==="after"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('afterend', "+r.transpile(t)+")"+"})"}}}}}});y.addGrammarElement("setCmd",function(r,e){if(e.matchToken("set")){var t=r.parseElement("target",e);e.requireToken("to");var n=r.parseElement("expression",e);var a=t.propPath.length===0;var i=a&&t.root.type==="symbol";if(a&&!i){r.raiseParseError(e,"Can only put directly into symbols, not references")}return{type:"setCmd",target:t,symbolWrite:i,value:n,transpile:function(){if(this.symbolWrite){return"var "+t.root.name+" = "+r.transpile(n)}else{var e=t.propPath.pop();return"_hyperscript.runtime.forEach( "+r.transpile(t)+", function (target) {"+" target."+e+"="+r.transpile(n)+"})"}}}}});y.addGrammarElement("ifCmd",function(e,r){if(r.matchToken("if")){var t=e.parseElement("expression",r);r.matchToken("then");var n=e.parseElement("commandList",r);if(r.matchToken("else")){var a=e.parseElement("commandList",r)}if(r.hasMore()){r.requireToken("end")}return{type:"ifCmd",expr:t,trueBranch:n,falseBranch:a,transpile:function(){return"if("+e.transpile(t)+"){"+""+e.transpile(n)+"}"+" else {"+e.transpile(a,"")+"}"}}}});y.addGrammarElement("ajaxCmd",function(r,e){if(e.matchToken("ajax")){var t=e.matchToken("GET")||e.matchToken("POST");if(t==null){r.raiseParseError(e,"Requires either GET or POST")}if(t.value!=="GET"){if(!e.matchToken("to")){var n=r.parseElement("expression",e);e.requireToken("to")}}var a=r.parseElement("string",e);if(a==null){var a=r.parseElement("nakedString",e)}return{type:"requestCommand",method:t,transpile:function(){var e=this.next;delete this.next;return"_hyperscript.runtime.ajax('"+t.value+"', "+r.transpile(a)+", "+"function(response, xhr){ "+r.transpile(e)+" },"+r.transpile(n,"null")+")"}}}})}function a(e){g.processNode(e)}function e(e){return g.evaluate(e)}function i(e){if(document.readyState!=="loading"){e()}else{document.addEventListener("DOMContentLoaded",e)}}function o(){var e=document.querySelector('meta[name="htmx-config"]');if(e){return t(e.content)}else{return null}}function s(){var e=o();if(e){E.config=r(E.config,e)}}function l(e){var r=T.tokenize(e);var t=y.parseHyperScript(r);return y.transpile(t)}i(function(){s();a(document.body);document.addEventListener("htmx:load",function(e){a(e.detail.elt)})});return E}()});
(function(e,r){if(typeof define==="function"&&define.amd){define([],r)}else{e._hyperscript=r()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";function r(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}return e}function t(e){try{return JSON.parse(e)}catch(e){n(e);return null}}function n(e){if(console.error){console.error(e)}else if(console.log){console.log("ERROR: ",e)}}var E=function(){var k={"+":"PLUS","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",".":"PERIOD","\\":"BACKSLASH",":":"COLON","%":"PERCENT","|":"PIPE","!":"EXCLAMATION","?":"QUESTION","#":"POUND","&":"AMPERSAND",";":"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 x(e){return L(e)||R(e)||e==="-"||e==="_"}function O(e){return L(e)||R(e)||e==="-"||e==="_"||e===":"}function C(e){return e===" "||e==="\t"||A(e)}function b(e){return"[Line: "+e.line+", Column: "+e.col+"]"}function A(e){return e==="\r"||e==="\n"}function R(e){return e>="0"&&e<="9"}function L(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function G(e){return e==="_"||e==="$"}function I(r,t,e){var n=true;u("WHITESPACE");function i(e,r){T.raiseParseError(e,r)}function a(e){var r=s(e);if(r){return r}else{i(this,"Expected '"+e+"' but found '"+h().value+"'")}}function o(e,r,t){for(var n=0;n<arguments.length;n++){var a=arguments[n];var i=s(a);if(i){return i}}}function s(e){if(h()&&h().op&&h().value===e){return m()}}function l(e,r,t,n){var a=u(e,r,t,n);if(a){return a}else{i(this,"Expected one of "+JSON.stringify([e,r,t]))}}function u(e,r,t,n){if(h()&&h().type&&[e,r,t,n].indexOf(h().type)>=0){return m()}}function p(e,r){var t=c(e,r);if(t){return t}else{i(this,"Expected '"+e+"' but found '"+h().value+"'")}}function c(e,r){var r=r||"IDENTIFIER";if(h()&&h().value===e&&h().type===r){return m()}}function m(){var e=r.shift();t.push(e);if(n){u("WHITESPACE")}return e}function f(){var e=[];n=false;while(h()&&h().type!=="WHITESPACE"){e.push(m())}n=true;return e}function v(){return r.length>0}function h(){return r[0]}return{matchAnyOpToken:o,matchOpToken:s,requireOpToken:a,matchTokenType:u,requireTokenType:l,consumeToken:m,matchToken:c,requireToken:p,list:r,source:e,hasMore:v,currentToken:h,consumeUntilWhitespace:f}}function e(e){var r=e;var t=[];var n=0;var a=0;var i=1;var o="<START>";while(n<r.length){if(d()==="-"&&E()==="-"){u()}else{if(C(d())){t.push(g())}else if(!y()&&d()==="."&&L(E())){t.push(p())}else if(!y()&&d()==="#"&&L(E())){t.push(c())}else if(L(d())||G(d())){t.push(m())}else if(R(d())){t.push(f())}else if(d()==='"'||d()==="'"){t.push(h())}else if(k[d()]){t.push(v())}else{if(n<r.length){throw Error("Unknown token: "+d()+" ")}}}}return I(t,[],r);function s(e,r){var t=l(e,r);t.op=true;return t}function l(e,r){return{type:e,value:r,start:n,end:n+1,column:a,line:i}}function u(){while(d()&&!A(d())){T()}T()}function p(){var e=l("CLASS_REF");var r=T();while(x(d())){r+=T()}e.value=r;e.end=n;return e}function c(){var e=l("ID_REF");var r=T();while(O(d())){r+=T()}e.value=r;e.end=n;return e}function m(){var e=l("IDENTIFIER");var r=T();while(L(d())||G(d())){r+=T()}e.value=r;e.end=n;return e}function f(){var e=l("NUMBER");var r=T();while(R(d())){r+=T()}if(d()==="."){r+=T()}while(R(d())){r+=T()}e.value=r;e.end=n;return e}function v(){var e=T();while(d()&&k[e+d()]){e+=T()}var r=s(k[e],e);r.value=e;r.end=n;return r}function h(){var e=l("STRING");var r=T();var t="";while(d()&&d()!==r){if(d()==="\\"){T()}t+=T()}if(d()!==r){throw Error("Unterminated string at "+b(e))}else{T()}e.value=t;e.end=n;return e}function d(){return r.charAt(n)}function E(){return r.charAt(n+1)}function T(){o=d();n++;a++;return o}function y(){return L(o)||R(o)||o===")"||o==="}"||o==="]"}function g(){var e=l("WHITESPACE");var r="";while(d()&&C(d())){if(A(d())){a=0;i++}r+=T()}e.value=r;e.end=n;return e}}return{tokenize:e}}();var T=function(){var a={};function e(e,r){a[e]=r}function n(e){var r=e.currentToken();var t=e.source;var n=t.split("\n");var a=r?r.line-1:n.length-1;var i=n[a];var o=r?r.column:i.length-1;return i+"\n"+" ".repeat(o)+"^^\n\n"}function r(e,r){r=(r||"Unexpected Token : "+e.currentToken().value)+"\n\n"+n(e);var t=new Error(r);t.tokens=e;throw t}function i(e,r,t){var n=a[e];if(n)return n(T,r,t)}function t(e,r){for(var t=0;t<e.length;t++){var n=e[t];var a=i(n,r);if(a){return a}}}function o(e){return i("hyperscript",e)}function s(e,r){if(e==null){return r}var t=e.transpile();if(e.next){return t+"\n"+s(e.next)}else{return t}}return{parseElement:i,parseAnyOf:t,parseHyperScript:o,raiseParseError:r,addGrammarElement:e,transpile:s}}();var y=function(){function t(e,r){var t=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return t&&t.call(e,r)}function i(e,r){var t;if(window.CustomEvent&&typeof window.CustomEvent==="function"){t=new CustomEvent(e,{bubbles:true,cancelable:true,detail:r})}else{t=document.createEvent("CustomEvent");t.initCustomEvent(e,true,true,r)}return t}function e(e,r,t){var t=t||{};t["sentBy"]=e;var n=i(r,t);var a=e.dispatchEvent(n);return a}function n(e,r){if(e.length){for(var t=0;t<e.length;t++){r(e[t])}}else{r(e)}}function r(e,r){if(e.length){var t=e}else{var t=[e]}while(r.length>0){var n=r.shift();var a=[];for(var i=0;i<t.length;i++){var o=t[i];var s=o[n];if(s&&s.length){a=a.concat(s)}else{a.push(s)}}t=a}return t}var a=null;function o(){if(a==null){a=_hyperscript.config.attributes.replace(/ /g,"").split(",")}return a}function s(e){for(var r=0;r<o().length;r++){var t=o()[r];if(e.hasAttribute&&e.hasAttribute(t)){return e.getAttribute(t)}}return null}function l(e,r){n(e.eventListeners,function(e){e(r)})}function u(){return o().map(function(e){return"["+e+"]"}).join(", ")}function p(e,r){return Object.prototype.toString.call(e)==="[object "+r+"]"}function c(e,r,t){if(p(r,"Object")){var n=e;var a=r;var i="expression"}else if(p(r,"String")){var n=r;var i=e;var a=t}else{var n=e;var a={};var i="expression"}a=a||{};var o=T.parseElement(i,E.tokenize(n)).transpile();var s="(function("+Object.keys(a).join(",")+"){return "+o+"})";var l=Object.keys(a).map(function(e){return a[e]});return eval(s).apply(null,l)}function m(e){var r=y.getScriptSelector();if(t(e,r)){f(e)}n(e.querySelectorAll(r),function(e){f(e)})}function f(e){var r=v(e);if(!r.initialized){var t=s(e);if(t){r.initialized=true;r.script=t;var n=E.tokenize(t);var a=T.parseHyperScript(n);var i=T.transpile(a);if(e.getAttribute("debug")==="true"){console.log(i)}var o=eval(i);o.applyEventListenersTo(e)}}}function v(e){var r="hyperscript-internal-data";var t=e[r];if(!t){t=e[r]={}}return t}function h(e,r,t,n){var a=new XMLHttpRequest;a.onload=function(){t(this.response,a)};a.open(e,r);a.send(JSON.stringify(n))}function d(e,r,t){if(e==null&&t){return e}var n=Object.prototype.toString.call(e).slice(8,-1);var a=e&&n===r;if(a){return e}else{throw new Error("Typecheck failed! Expected: "+r+", Found: "+n)}}return{typeCheck:d,forEach:n,evalTarget:r,triggerEvent:e,matchesSelector:t,getScript:s,applyEventListeners:l,processNode:m,evaluate:c,getScriptSelector:u,ajax:h}}();{T.addGrammarElement("parenthesized",function(e,r){if(r.matchOpToken("(")){var t=e.parseElement("expression",r);r.requireOpToken(")");return{type:"parenthesized",expr:t,transpile:function(){return"("+e.transpile(t)+")"}}}});T.addGrammarElement("string",function(e,r){var t=r.matchTokenType("STRING");if(t){return{type:"string",token:t,transpile:function(){if(t.value.indexOf("'")===0){return"'"+t.value+"'"}else{return'"'+t.value+'"'}}}}});T.addGrammarElement("nakedString",function(e,r){if(r.hasMore()){var t=r.consumeUntilWhitespace();r.matchTokenType("WHITESPACE");return{type:"nakedString",tokens:t,transpile:function(){return"'"+t.map(function(e){return e.value}).join("")+"'"}}}});T.addGrammarElement("number",function(e,r){var t=r.matchTokenType("NUMBER");if(t){var n=t;var a=parseFloat(t.value);return{type:"number",value:a,numberToken:n,transpile:function(){return n.value}}}});T.addGrammarElement("idRef",function(e,r){var t=r.matchTokenType("ID_REF");if(t){return{type:"idRef",value:t.value.substr(1),transpile:function(){return"document.getElementById('"+this.value+"')"}}}});T.addGrammarElement("classRef",function(e,r){var t=r.matchTokenType("CLASS_REF");if(t){return{type:"classRef",value:t.value,className:function(){return this.value.substr(1)},transpile:function(){return"document.querySelectorAll('"+this.value+"')"}}}});T.addGrammarElement("attributeRef",function(e,r){if(r.matchOpToken("[")){var t=r.matchTokenType("IDENTIFIER");var n=null;if(r.matchOpToken("=")){n=e.parseElement("expression",r)}r.requireOpToken("]");return{type:"attribute_expression",name:t.value,value:n,transpile:function(){if(this.value){return"({name: '"+this.name+"', value: "+e.transpile(this.value)+"})"}else{return"({name: '"+this.name+"'})"}}}}});T.addGrammarElement("objectLiteral",function(r,e){if(e.matchOpToken("{")){var t=[];if(!e.matchOpToken("}")){do{var n=e.requireTokenType("IDENTIFIER");e.requireOpToken(":");var a=r.parseElement("expression",e);t.push({name:n,value:a})}while(e.matchOpToken(","));e.requireOpToken("}")}return{type:"objectLiteral",fields:t,transpile:function(){return"({"+t.map(function(e){return e.name.value+":"+r.transpile(e.value)}).join(", ")+"})"}}}});T.addGrammarElement("namedArgumentList",function(r,e){if(e.matchOpToken("(")){var t=[];if(!e.matchOpToken(")")){do{var n=e.requireTokenType("IDENTIFIER");e.requireOpToken(":");var a=r.parseElement("expression",e);t.push({name:n,value:a})}while(e.matchOpToken(","));e.requireOpToken(")")}return{type:"namedArgumentList",fields:t,transpile:function(){return"({_namedArgList_:true, "+t.map(function(e){return e.name.value+":"+r.transpile(e.value)}).join(", ")+"})"}}}});T.addGrammarElement("symbol",function(e,r){var t=r.matchTokenType("IDENTIFIER");if(t){return{type:"symbol",name:t.value,transpile:function(){return t.value}}}});T.addGrammarElement("implicitMeTarget",function(e,r){return{type:"implicitMeTarget",transpile:function(){return"[me]"}}});T.addGrammarElement("implicitAllTarget",function(e,r){return{type:"implicitAllTarget",transpile:function(){return'document.querySelectorAll("*")'}}});T.addGrammarElement("millisecondLiteral",function(e,r){var t=r.requireTokenType(r,"NUMBER");var n=1;if(r.matchToken("s")){n=1e3}else if(r.matchToken("ms")){}return{type:"millisecondLiteral",number:t,factor:n,transpile:function(){return n*parseFloat(this.number.value)}}});T.addGrammarElement("boolean",function(e,r){var t=r.matchToken("true")||r.matchToken("false");if(t){return{type:"boolean",transpile:function(){return t.value}}}});T.addGrammarElement("null",function(e,r){if(r.matchToken("null")){return{type:"null",transpile:function(){return"null"}}}});T.addGrammarElement("arrayLiteral",function(r,e){if(e.matchOpToken("[")){var t=[];if(!e.matchOpToken("]")){do{var n=r.parseElement("expression",e);if(n==null){r.raiseParseError(e,"Expected an expression")}t.push(n)}while(e.matchOpToken(","));e.requireOpToken("]")}return{type:"arrayLiteral",values:t,transpile:function(){return"["+t.map(function(e){return r.transpile(e)}).join(", ")+"]"}}}});T.addGrammarElement("blockLiteral",function(e,r){if(r.matchOpToken("\\")){var t=[];var n=r.matchTokenType("IDENTIFIER");if(n){t.push(n);while(r.matchOpToken(",")){t.push(r.requireTokenType("IDENTIFIER"))}}r.requireOpToken("-");r.requireOpToken(">");var a=e.parseElement("expression",r);if(a==null){e.raiseParseError(r,"Expected an expression")}return{type:"blockLiteral",args:t,expr:a,transpile:function(){return"function("+t.map(function(e){return e.value}).join(", ")+"){ return "+e.transpile(a)+" }"}}}});T.addGrammarElement("leaf",function(e,r){return e.parseAnyOf(["parenthesized","boolean","null","string","number","idRef","classRef","symbol","propertyRef","objectLiteral","arrayLiteral","blockLiteral"],r)});T.addGrammarElement("propertyAccess",function(e,r,t){if(r.matchOpToken(".")){var n=r.requireTokenType("IDENTIFIER");var a={type:"propertyAccess",root:t,prop:n,transpile:function(){return e.transpile(t)+"."+n.value}};return T.parseElement("indirectExpression",r,a)}});T.addGrammarElement("functionCall",function(r,e,t){if(e.matchOpToken("(")){var n=[];if(!e.matchOpToken(")")){do{n.push(r.parseElement("expression",e))}while(e.matchOpToken(","));e.requireOpToken(")")}var a={type:"functionCall",root:t,args:n,transpile:function(){return r.transpile(t)+"("+n.map(function(e){return r.transpile(e)}).join(",")+")"}};return T.parseElement("indirectExpression",e,a)}});T.addGrammarElement("indirectExpression",function(e,r,t){var n=e.parseElement("propertyAccess",r,t);if(n){return n}var a=e.parseElement("functionCall",r,t);if(a){return a}return t});T.addGrammarElement("primaryExpression",function(e,r){var t=e.parseElement("leaf",r);if(t){return e.parseElement("indirectExpression",r,t)}e.raiseParseError(r,"Unexpected value: "+r.currentToken().value)});T.addGrammarElement("postfixExpression",function(e,r){var t=e.parseElement("primaryExpression",r);if(r.matchOpToken(":")){var n=r.requireTokenType("IDENTIFIER");var a=!r.matchOpToken("!");return{type:"typeCheck",typeName:n,root:t,nullOk:a,transpile:function(){return"_hyperscript.runtime.typeCheck("+e.transpile(t)+", '"+n.value+"', "+a+")"}}}else{return t}});T.addGrammarElement("logicalNot",function(e,r){if(r.matchToken("not")){var t=e.parseElement("unaryExpression",r);return{type:"logicalNot",root:t,transpile:function(){return"!"+e.transpile(t)}}}});T.addGrammarElement("negativeNumber",function(e,r){if(r.matchOpToken("-")){var t=e.parseElement("unaryExpression",r);return{type:"negativeNumber",root:t,transpile:function(){return"-"+e.transpile(t)}}}});T.addGrammarElement("unaryExpression",function(e,r){return e.parseAnyOf(["logicalNot","negativeNumber","postfixExpression"],r)});T.addGrammarElement("mathOperator",function(e,r){var t=e.parseElement("unaryExpression",r);var n,a=null;n=r.matchAnyOpToken("+","-","*","/","%");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize math operations with different operators")}var i=e.parseElement("unaryExpression",r);t={type:"mathOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+this.operator+" "+e.transpile(this.rhs)}};n=r.matchAnyOpToken("+","-","*","/","%")}return t});T.addGrammarElement("mathExpression",function(e,r){return e.parseAnyOf(["mathOperator","unaryExpression"],r)});T.addGrammarElement("comparisonOperator",function(e,r){var t=e.parseElement("mathExpression",r);var n,a=null;n=r.matchAnyOpToken("<",">","<=",">=","==","===","!=","!==");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize comparison operations with different operators")}var i=e.parseElement("mathExpression",r);t={type:"comparisonOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+this.operator+" "+e.transpile(this.rhs)}};n=r.matchAnyOpToken("<",">","<=",">=","==","===","!=","!==")}return t});T.addGrammarElement("comparisonExpression",function(e,r){return e.parseAnyOf(["comparisonOperator","mathExpression"],r)});T.addGrammarElement("logicalOperator",function(e,r){var t=e.parseElement("comparisonExpression",r);var n,a=null;n=r.matchToken("and")||r.matchToken("or");while(n){a=a||n;if(a.value!==n.value){e.raiseParseError(r,"You must parenthesize logical operations with different operators")}var i=e.parseElement("comparisonExpression",r);t={type:"logicalOperator",operator:n.value,lhs:t,rhs:i,transpile:function(){return e.transpile(this.lhs)+" "+(this.operator==="and"?" && ":" || ")+" "+e.transpile(this.rhs)}};n=r.matchToken("and")||r.matchToken("or")}return t});T.addGrammarElement("logicalExpression",function(e,r){return e.parseAnyOf(["logicalOperator","mathExpression"],r)});T.addGrammarElement("expression",function(e,r){return e.parseElement("logicalExpression",r)});T.addGrammarElement("target",function(e,r){var t=e.parseAnyOf(["symbol","classRef","idRef"],r);if(t==null){e.raiseParseError(r,"Expected a valid target expression")}var n=[];while(r.matchOpToken(".")){n.push(r.requireTokenType("IDENTIFIER").value)}return{type:"target",propPath:n,root:t,transpile:function(){return"_hyperscript.runtime.evalTarget("+e.transpile(t)+", ["+n.map(function(e){return'"'+e+'"'}).join(", ")+"])"}}});T.addGrammarElement("command",function(e,r){return e.parseAnyOf(["onCmd","addCmd","removeCmd","toggleCmd","waitCmd","sendCmd","triggerCmd","takeCmd","logCmd","callCmd","putCmd","setCmd","ifCmd","ajaxCmd"],r)});T.addGrammarElement("commandList",function(e,r){var t=e.parseElement("command",r);if(t){r.matchToken("then");t.next=e.parseElement("commandList",r);return t}});T.addGrammarElement("hyperscript",function(r,e){var t=[];do{t.push(r.parseElement("eventListener",e))}while(e.matchToken("end")&&e.hasMore());if(e.hasMore()){r.raiseParseError(e)}return{type:"hyperscript",eventListeners:t,transpile:function(){return"(function(){\n"+"var eventListeners = []\n"+t.map(function(e){return" eventListeners.push("+r.transpile(e)+");\n"}).join("")+" function applyEventListenersTo(elt) { _hyperscript.runtime.applyEventListeners(this, elt) }\n"+" return {eventListeners:eventListeners, applyEventListenersTo:applyEventListenersTo}\n"+"})()"}}});T.addGrammarElement("eventListener",function(e,r){r.requireToken("on");var t=e.parseElement("dotOrColonPath",r);if(t==null){e.raiseParseError(r,"Expected event name")}if(r.matchToken("from")){var n=e.parseElement("target",r);if(n==null){e.raiseParseError(r,"Expected target value")}}else{var n=e.parseElement("implicitMeTarget",r)}var a=[];if(r.matchOpToken("(")){do{a.push(r.requireTokenType("IDENTIFIER"))}while(r.matchOpToken(","));r.requireOpToken(")")}var i=e.parseElement("commandList",r);var o={type:"eventListener",on:t,from:n,start:i,transpile:function(){return"(function(me){"+"var my = me;\n"+"_hyperscript.runtime.forEach( "+e.transpile(n)+", function(target){\n"+" target.addEventListener('"+e.transpile(t)+"', function(event){\n"+a.map(function(e){return"var "+e.value+" = event.detail."+e.value+";"}).join("\n")+"\n"+e.transpile(i)+" })\n"+"})\n"+"})"}};return o});T.addGrammarElement("addCmd",function(e,r){if(r.matchToken("add")){var t=e.parseElement("classRef",r);var n=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){e.raiseParseError(r,"Expected either a class reference or attribute expression")}}if(r.matchToken("to")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"addCmd",classRef:t,attributeRef:n,to:a,transpile:function(){if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.classList.add('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.setAttribute('"+n.name+"', "+e.transpile(n)+".value)"+"})"}}}}});T.addGrammarElement("removeCmd",function(e,r){if(r.matchToken("remove")){var t=e.parseElement("classRef",r);var n=null;var a=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){a=e.parseElement("expression",r);if(a==null){e.raiseParseError(r,"Expected either a class reference, attribute expression or value expression")}}}if(r.matchToken("from")){var i=e.parseElement("target",r)}else{var i=e.parseElement("implicitMeTarget")}return{type:"removeCmd",classRef:t,attributeRef:n,elementExpr:a,from:i,transpile:function(){if(this.elementExpr){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.parentElement.removeChild(target)"+"})"}else{if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(i)+", function (target) {"+" target.classList.remove('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(i)+", function (target) {"+" target.removeAttribute('"+n.name+"')"+"})"}}}}}});T.addGrammarElement("toggleCmd",function(e,r){if(r.matchToken("toggle")){var t=e.parseElement("classRef",r);var n=null;if(t==null){n=e.parseElement("attributeRef",r);if(n==null){e.raiseParseError(r,"Expected either a class reference or attribute expression")}}if(r.matchToken("on")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"toggleCmd",classRef:t,attributeRef:n,on:a,transpile:function(){if(this.classRef){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" target.classList.toggle('"+t.className()+"')"+"})"}else{return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" if(target.hasAttribute('"+n.name+"')) {\n"+" target.removeAttribute('"+n.name+"');\n"+" } else { \n"+" target.setAttribute('"+n.name+"', "+e.transpile(n)+".value)"+" }"+"})"}}}}});T.addGrammarElement("waitCmd",function(r,e){if(e.matchToken("wait")){var t=r.parseElement("millisecondLiteral",e);return{type:"waitCmd",time:t,transpile:function(){var e=this.next;delete this.next;return"setTimeout(function () { "+r.transpile(e)+" }, "+r.transpile(this.time)+")"}}}});T.addGrammarElement("dotOrColonPath",function(e,r){var t=r.matchTokenType("IDENTIFIER");if(t){var n=[t.value];var a=r.matchOpToken(".")||r.matchOpToken(":");if(a){do{n.push(r.requireTokenType("IDENTIFIER").value)}while(r.matchOpToken(a.value))}return{type:"dotOrColonPath",path:n,transpile:function(){return n.join(a?a.value:"")}}}});T.addGrammarElement("sendCmd",function(e,r){if(r.matchToken("send")){var t=e.parseElement("dotOrColonPath",r);var n=e.parseElement("namedArgumentList",r);if(r.matchToken("to")){var a=e.parseElement("target",r)}else{var a=e.parseElement("implicitMeTarget")}return{type:"sendCmd",eventName:t,details:n,to:a,transpile:function(){return"_hyperscript.runtime.forEach( "+e.transpile(a)+", function (target) {"+" _hyperscript.runtime.triggerEvent(target, '"+e.transpile(t)+"',"+e.transpile(n,"{}")+")"+"})"}}}});T.addGrammarElement("triggerCmd",function(e,r){if(r.matchToken("trigger")){var t=e.parseElement("dotOrColonPath",r);var n=e.parseElement("namedArgumentList",r);return{type:"triggerCmd",eventName:t,details:n,transpile:function(){return"_hyperscript.runtime.triggerEvent(me, '"+e.transpile(t)+"',"+e.transpile(n,"{}")+");"}}}});T.addGrammarElement("takeCmd",function(r,e){if(e.matchToken("take")){var t=e.requireTokenType(e,"CLASS_REF");if(e.matchToken("from")){var n=r.parseElement("target",e)}else{var n=r.parseElement("implicitAllTarget")}if(e.matchToken("for")){var a=r.parseElement("target",e)}else{var a=r.parseElement("implicitMeTarget")}return{type:"takeCmd",classRef:t,from:n,forElt:a,transpile:function(){var e=this.classRef.value.substr(1);return" _hyperscript.runtime.forEach("+r.transpile(n)+", function (target) { target.classList.remove('"+e+"') }); "+"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.classList.add('"+e+"')"+"})"}}}});T.addGrammarElement("logCmd",function(r,e){if(e.matchToken("log")){var t=[r.parseElement("expression",e)];while(e.matchOpToken(",")){t.push(r.parseElement("expression",e))}if(e.matchToken("with")){var n=r.parseElement("expression",e)}return{type:"logCmd",exprs:t,withExpr:n,transpile:function(){if(n){return r.transpile(n)+"("+t.map(function(e){return r.transpile(e)}).join(", ")+")"}else{return"console.log("+t.map(function(e){return r.transpile(e)}).join(", ")+")"}}}}});T.addGrammarElement("callCmd",function(e,r){if(r.matchToken("call")||r.matchToken("get")){return{type:"callCmd",expr:e.parseElement("expression",r),transpile:function(){return"var it = "+e.transpile(this.expr)}}}});T.addGrammarElement("putCmd",function(r,e){if(e.matchToken("put")){var t=r.parseElement("expression",e);var n=e.matchToken("into")||e.matchToken("before")||e.matchToken("after");if(n==null&&e.matchToken("at")){n=e.matchToken("start")||e.matchToken("end");e.requireToken("of")}if(n==null){r.raiseParseError(e,"Expected one of 'into', 'before', 'at start of', 'at end of', 'after'")}var a=r.parseElement("target",e);var i=a.propPath.length===0&&n.value==="into";var o=i&&a.root.type==="symbol";if(i&&!o){r.raiseParseError(e,"Can only put directly into symbols, not references")}return{type:"putCmd",target:a,op:n.value,symbolWrite:o,value:t,transpile:function(){if(this.symbolWrite){return"var "+a.root.name+" = "+r.transpile(t)}else{if(this.op==="into"){var e=a.propPath.pop();return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target."+e+"="+r.transpile(t)+"})"}else if(this.op==="before"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('beforebegin', "+r.transpile(t)+")"+"})"}else if(this.op==="start"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('afterbegin', "+r.transpile(t)+")"+"})"}else if(this.op==="end"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('beforeend', "+r.transpile(t)+")"+"})"}else if(this.op==="after"){return"_hyperscript.runtime.forEach( "+r.transpile(a)+", function (target) {"+" target.insertAdjacentHTML('afterend', "+r.transpile(t)+")"+"})"}}}}}});T.addGrammarElement("setCmd",function(r,e){if(e.matchToken("set")){var t=r.parseElement("target",e);e.requireToken("to");var n=r.parseElement("expression",e);var a=t.propPath.length===0;var i=a&&t.root.type==="symbol";if(a&&!i){r.raiseParseError(e,"Can only put directly into symbols, not references")}return{type:"setCmd",target:t,symbolWrite:i,value:n,transpile:function(){if(this.symbolWrite){return"var "+t.root.name+" = "+r.transpile(n)}else{var e=t.propPath.pop();return"_hyperscript.runtime.forEach( "+r.transpile(t)+", function (target) {"+" target."+e+"="+r.transpile(n)+"})"}}}}});T.addGrammarElement("ifCmd",function(e,r){if(r.matchToken("if")){var t=e.parseElement("expression",r);r.matchToken("then");var n=e.parseElement("commandList",r);if(r.matchToken("else")){var a=e.parseElement("commandList",r)}if(r.hasMore()){r.requireToken("end")}return{type:"ifCmd",expr:t,trueBranch:n,falseBranch:a,transpile:function(){return"if("+e.transpile(t)+"){"+""+e.transpile(n)+"}"+" else {"+e.transpile(a,"")+"}"}}}});T.addGrammarElement("ajaxCmd",function(r,e){if(e.matchToken("ajax")){var t=e.matchToken("GET")||e.matchToken("POST");if(t==null){r.raiseParseError(e,"Requires either GET or POST")}if(t.value!=="GET"){if(!e.matchToken("to")){var n=r.parseElement("expression",e);e.requireToken("to")}}var a=r.parseElement("string",e);if(a==null){var a=r.parseElement("nakedString",e)}return{type:"requestCommand",method:t,transpile:function(){var e=this.next;delete this.next;return"_hyperscript.runtime.ajax('"+t.value+"', "+r.transpile(a)+", "+"function(response, xhr){ "+r.transpile(e)+" },"+r.transpile(n,"null")+")"}}}})}function a(e){y.processNode(e)}function e(e){return y.evaluate(e)}function i(e){if(document.readyState!=="loading"){e()}else{document.addEventListener("DOMContentLoaded",e)}}function o(){var e=document.querySelector('meta[name="htmx-config"]');if(e){return t(e.content)}else{return null}}function s(){var e=o();if(e){_hyperscript.config=r(_hyperscript.config,e)}}function l(e){var r=E.tokenize(e);var t=T.parseHyperScript(r);return T.transpile(t)}i(function(){s();a(document.body);document.addEventListener("htmx:load",function(e){a(e.detail.elt)})});return{lexer:E,parser:T,runtime:y,evaluate:e,processNode:a,toJS:l,config:{attributes:"_, script, data-script"}}}()});

@@ -8,3 +8,3 @@ {

],
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://hyperscript.org/",

@@ -11,0 +11,0 @@ "bugs": {

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc