@hyperfixi/engine 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +246 -1
- package/dist/ast.d.ts +2 -0
- package/dist/commands/platform.d.ts +2 -0
- package/dist/common.js +2 -1
- package/dist/common.min.js +2 -2
- package/dist/core.js +2 -1
- package/dist/core.min.js +2 -2
- package/dist/full.js +3 -2
- package/dist/full.min.js +3 -3
- package/dist/hyperfixi-hs.dev.js +3 -2
- package/dist/hyperfixi-hs.js +3 -3
- package/dist/index.js +3 -2
- package/dist/minimal.js +2 -1
- package/dist/minimal.min.js +2 -2
- package/package.json +1 -1
package/dist/core.min.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`,r:"\r",t:" ",v:"\v"},q=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",_=e=>e>="0"&&e<="9",xe=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
3
|
`,ke=e=>q(e)||_(e)||e==="-"||e==="_"||e===":",Te=e=>q(e)||_(e)||e==="_"||e==="$";function te(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",c=0,a=()=>e.charAt(r),l=f=>e.charAt(r+f),u=()=>(s=e.charAt(r++),s===`
|
|
4
4
|
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;a()&&f(a());)h+=u();return h},y=()=>t&&c===0,I=()=>q(s)||_(s)||")\"'`}]".includes(s),j=(f,h)=>{let b=p(f),T=u();if(a()==="{"){if(b.template=!0,T+=u(),T+=d(Ft=>Ft!=="}"),a()!=="}")throw new Error("Unterminated "+(h?"class":"id")+" reference");let oe=u();h&&(T+=oe)}else if(h)for(;ke(a())||a()==="\\";)a()==="\\"&&u(),T+=u();else T+=d(ke);return m(b,T)},F=()=>{let f=p("STRING"),h=u();f.template=h==="`";let b="";for(;a()&&a()!==h;)if(a()==="\\"){u();let T=u();if(T in Ye)b+=Ye[T];else if(f.template&&T==="$")b+="\\$";else if(T==="x"){let oe=a()&&l(1)?parseInt(u()+u(),16):NaN;if(Number.isNaN(oe))throw new Error(`Invalid hexadecimal escape at [Line: ${f.line}, Column: ${f.column}]`);b+=String.fromCharCode(oe)}else b+=T}else b+=u();if(a()!==h)throw new Error(`Unterminated string at [Line: ${f.line}, Column: ${f.column}]`);return u(),m(f,b)},qe=()=>{let f=p("IDENTIFIER"),h=u()+d(Te);return a()==="!"&&h==="beep"&&(h+=u()),m(f,h)},Rt=()=>{let f=p("IDENTIFIER"),h=u(),b=h==="\\";for(b&&(h="");(Te(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!b);)a()==="\\"?(b=!0,u()):(b=!1,h+=u());return m(f,h)},Ot=()=>{let f=p("NUMBER"),h=u()+d(_);return a()==="."&&_(l(1))&&(h+=u()),h+=d(_),(a()==="e"||a()==="E")&&(_(l(1))?h+=u():l(1)==="-"&&(h+=u()+u())),m(f,h+d(_))},_e=()=>{let f=p("OP");f.op=!0;let h=u();for(;a()&&Ve.has(h+a());)h+=u();return m(f,h)},It=()=>{let f=p("ATTRIBUTE_REF"),h=u();return h==="["?(h+=d(b=>b!=="]"),a()==="]"&&(h+=u())):(h+=d(ke),a()==="="&&(h+=u(),a()==='"'||a()==="'"?h+=F().value:Te(a())&&(h+=qe().value))),m(f,h)},Ct=()=>{let f=n.at(-1);return f?f.type==="IDENTIFIER"||f.type==="CLASS_REF"||f.type==="ID_REF"?!1:!(f.op&&(f.value===">"||f.value===")")):!0},At=()=>{let f=a(),h=l(2);return(f==="-"||f==="/")&&l(1)===f&&(xe(h)||h===""||h===f)};for(;r<e.length;){let f=a(),h=l(1);if(At())d(b=>b!=="\r"&&b!==`
|
|
5
|
-
`),u();else if(xe(f))n.push(m(p("WHITESPACE"),d(xe)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(It());else if(f==="*"&&q(h)){let b=p("STYLE_REF");n.push(m(b,u()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(Rt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(qe());else if(_(f))n.push(Ot());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Ct()?F():_e());else if(Ve.has(f))s==="$"&&f==="{"&&c++,f==="}"&&c--,n.push(_e());else if(y()||f==="`"){let b=p("RESERVED");n.push(m(b,u()))}else throw new Error("Unknown token: "+f+" ")}return n}function x(e){return e.match("the"),Dt(e)}function Dt(e){let t=Je(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=Mt(o.value,t,Je(e));return t}function Mt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var jt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Pe(e){let t=Se(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Se(e),c=jt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([u,p])=>c(u,p))}}return t}function Se(e){let t=D(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function D(e){e.match("the");let t=e.pos();if(e.match("not"))return Re(e,"logicalNot",t,D(e),n=>!n);if(e.match("no"))return Re(e,"noExpression",t,Se(e),be);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return $t(e)}function Re(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return i?O(e,s):s}var Ht="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function $t(e){let t=tt(e),n=e.matchAny(...Ht)??e.matchOp("%");if(n)return Ze(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return Ze(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function Ze(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function tt(e){let t=e.pos();return e.matchOp("-")?Re(e,"negativeNumber",t,tt(e),n=>-v(n)):Ut(e)}function Ut(e){let t=zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Wt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,u=!1)=>({operator:a,right:l,isType:u}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",c=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(c("match","matches"))return n(s+"match");if(c("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(c("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(c("precede","precedes"))return n(s+"precede");if(c("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function Je(e){let t=Pe(e),n=Wt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,c;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Pe(e),r.endsWith("match")&&(c=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Pe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let u=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),c??s?.ev(d),a?.ev(d)],([y,I,j])=>{if(o){let F=He(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!Z(y,p);return r==="is"?F:!F}return nt(r,u(y),u(I),j)})}}function Ke(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Gt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Xe=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function nt(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!nt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Gt(t,n);case"in":return n!=null&&Ke(n,t);case"contain":case"include":return t!=null&&Ke(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return v(t)>=v(n)&&v(t)<=v(r);case"precede":return Xe(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Xe(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return be(t);case"exist":return je(t)}throw new Error("Unknown comparison : "+e)}function zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ne("number",parseFloat(t.value),t);case"STRING":return Vt(e);case"ID_REF":return Kt(e);case"CLASS_REF":return Xt(e);case"ATTRIBUTE_REF":return Ie(e);case"STYLE_REF":return it(e)}if(t.op){if(t.value==="(")return Bt(e);if(t.value==="[")return Yt(e);if(t.value==="{")return Zt(e);if(t.value==="<")return en(e)}let n=e.match("true")??e.match("false");if(n)return Ne("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ne("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Jt(e)}function Ne(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Bt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>x(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Qt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function rt(e,t){let n=e.child(te(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,x(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function Vt(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=rt(e,n);r.ev=i=>Qt(o,i)}else r.stat=()=>n;return r}function Yt(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(x(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function Zt(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(x(e)),e.reqOp("]");else{let s="";for(let c=e.matchType("IDENTIFIER")??e.matchOp("-");c;c=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=c.value;n.push(s)}e.reqOp(":"),r.push(x(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((c,a)=>[String(s[a]),s[n.length+a]])))}}function ot(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Jt(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>x(e))),{type:"symbol",name:s,scope:a,start:t,end:e.endPos(),ev:u=>ze(s,u,a,l?.ev(u)),lhs:()=>{},put:(u,p,m)=>Be(s,u,a,m,l?.ev(u))}}var st=(e,t)=>{let n=t.value.substring(2);return x(e.child(te(n),n))};function Kt(e){let t=e.consume(),n=(o,i)=>ve(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>c&&X(c,s))};if(t.template){let o=r.expr=st(e,t);r.ev=i=>E(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Xt(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>E(n.ev(r),s=>X(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=st(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Oe=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function en(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>X(Array.from(c instanceof A?c:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=rt(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Oe(i.me,s))}return r}function Ie(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>J(s.you||s.me,r),lhs:()=>{},put:(s,c,a)=>K(s.you||s.me,r,a)}}function it(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?le:ce)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>fe(o.you||o.me,r,s)}}function at(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function ut(e,t="Expected event name"){return e.matchType("STRING")?.value??at(e)??e.err(t)}function O(e,t){return nn(e,t)??rn(e,t)??cn(e,t)??on(e,t)??sn(e,t)??an(e,t)??un(e,t)??fn(e,t)??tn(e,t)??t}function tn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function nn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),de(s,n,c)},del:(i,s)=>{R(s,r),P(s,c=>{C(c)&&delete c[n],w.wroteProperty(c)})}};return O(e,o)}function rn(e,t){if(!e.match("of"))return;let n=D(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!s||c===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:Z,attribute:J,style:ce,computed:le}[s],u={type:"ofExpression",root:n,name:c,kind:s,start:t.start,end:e.endPos(),ev:p=>E(u.root.ev(p),m=>l(m,c)),lhs:p=>u.root.ev(p),put:(p,m,d)=>{R(m,a),s==="attribute"?K(m,c,d):s==="property"?de(m,c,d):fe(m,c,d)},del:(p,m)=>{R(m,a),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(c):s==="property"?(C(d)&&delete d[c],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(c)})}};return r?(r.root=u,O(e,t)):O(e,u)}function on(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Ie(e)??it(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),c=l=>i!==void 0?Z(l,i):o?.type==="attributeRef"?J(l,o.name):o?.type==="computedStyleRef"?le(l,o.name):o&&ce(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(a.root.ev(l),c),lhs:l=>a.root.ev(l),put:(l,u,p)=>{R(u,s),i!==void 0?de(u,i,p):o?.type==="attributeRef"?K(u,o.name,p):o&&fe(u,o.name,p)}};return O(e,a)}function sn(e,t){if(!e.match("in"))return;let n=D(e),r=(s,c)=>{if(s==null)return[];let a=[],l=g(s,"css");if(typeof l=="string")P(c,u=>k(u)&&a.push(...we(u,l)));else if(k(s)){let u=!1;if(P(c,p=>{p instanceof Node&&p.contains(s)&&(u=!0)}),u)return s}else P(s,u=>P(c,p=>u===p&&a.push(u)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([c,a])=>r(c,a)),lhs:s=>o.ev(s),put:(s,c,a)=>X(c,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function an(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=at(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:c=>E(s.root.ev(c),a=>$e(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function un(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(x(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let c=i.root,a=c.prop,l=a===void 0?void 0:c.root;return S([(l??c).ev(s),...n.map(u=>u.ev(s))],([u,...p])=>{if(!l||a===void 0)return et(u,void 0,p,s,r);R(u,o);let m=et(g(u,a),u,p,s,r);return Me(u,a),m})}};return O(e,i)}function et(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function cn(e,t){let n=Ie(e);return n&&ln(e,t,n)}function ln(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),K(s,n.name,c)}};return o}function fn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=x(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=x(e))),e.reqOp("]");let s=e.text(t),c=(u,p)=>v(p)<0?v(g(u,"length"))+v(p):v(p),a=(u,p,m)=>{let d=g(u,"slice");return L(d)?Reflect.apply(d,u,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:u=>S([l.root.ev(u),r.ev(u),i?.ev(u)],([p,m,d])=>p==null?null:n?a(p,0,c(p,m)+1):o?d==null?a(p,v(m)):a(p,v(m),c(p,d)+1):g(p,String(m))),lhs:u=>S([l.root.ev(u),r.ev(u)],p=>p),put:(u,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(u,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(c(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var M=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},ct=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),me=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new M(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Ce(e){let t=e.source.split(`
|
|
5
|
+
`),u();else if(xe(f))n.push(m(p("WHITESPACE"),d(xe)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(It());else if(f==="*"&&q(h)){let b=p("STYLE_REF");n.push(m(b,u()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(Rt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(qe());else if(_(f))n.push(Ot());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Ct()?F():_e());else if(Ve.has(f))s==="$"&&f==="{"&&c++,f==="}"&&c--,n.push(_e());else if(y()||f==="`"){let b=p("RESERVED");n.push(m(b,u()))}else throw new Error("Unknown token: "+f+" ")}return n}function x(e){return e.match("the"),Dt(e)}function Dt(e){let t=Je(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=Mt(o.value,t,Je(e));return t}function Mt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var jt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Pe(e){let t=Se(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Se(e),c=jt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([u,p])=>c(u,p))}}return t}function Se(e){let t=D(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function D(e){e.match("the");let t=e.pos();if(e.match("not"))return Re(e,"logicalNot",t,D(e),n=>!n);if(e.match("no"))return Re(e,"noExpression",t,Se(e),be);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return $t(e)}function Re(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return i?O(e,s):s}var Ht="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function $t(e){let t=tt(e),n=e.matchAny(...Ht)??e.matchOp("%");if(n)return Ze(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return Ze(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function Ze(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function tt(e){let t=e.pos();return e.matchOp("-")?Re(e,"negativeNumber",t,tt(e),n=>-v(n)):Ut(e)}function Ut(e){let t=zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Wt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,u=!1)=>({operator:a,right:l,isType:u}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",c=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(c("match","matches"))return n(s+"match");if(c("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(c("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(c("precede","precedes"))return n(s+"precede");if(c("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function Je(e){let t=Pe(e),n=Wt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,c;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Pe(e),r.endsWith("match")&&(c=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Pe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let u=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),c??s?.ev(d),a?.ev(d)],([y,I,j])=>{if(o){let F=He(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!Z(y,p);return r==="is"?F:!F}return nt(r,u(y),u(I),j)})}}function Ke(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Gt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Xe=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function nt(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!nt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Gt(t,n);case"in":return n!=null&&Ke(n,t);case"contain":case"include":return t!=null&&Ke(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return v(t)>=v(n)&&v(t)<=v(r);case"precede":return Xe(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Xe(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return be(t);case"exist":return je(t)}throw new Error("Unknown comparison : "+e)}function zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ne("number",parseFloat(t.value),t);case"STRING":return Vt(e);case"ID_REF":return Kt(e);case"CLASS_REF":return Xt(e);case"ATTRIBUTE_REF":return Ie(e);case"STYLE_REF":return it(e)}if(t.op){if(t.value==="(")return Bt(e);if(t.value==="[")return Yt(e);if(t.value==="{")return Zt(e);if(t.value==="<")return en(e)}let n=e.match("true")??e.match("false");if(n)return Ne("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ne("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Jt(e)}function Ne(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Bt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>x(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Qt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function rt(e,t){let n=e.child(te(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,x(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function Vt(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=rt(e,n);r.ev=i=>Qt(o,i)}else r.stat=()=>n;return r}function Yt(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(x(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function Zt(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(x(e)),e.reqOp("]");else{let s="";for(let c=e.matchType("IDENTIFIER")??e.matchOp("-");c;c=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=c.value;n.push(s)}e.reqOp(":"),r.push(x(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((c,a)=>[String(s[a]),s[n.length+a]])))}}function ot(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Jt(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>x(e))),{type:"symbol",name:s,scope:a,...l?{on:l}:{},start:t,end:e.endPos(),ev:u=>ze(s,u,a,l?.ev(u)),lhs:()=>{},put:(u,p,m)=>Be(s,u,a,m,l?.ev(u))}}var st=(e,t)=>{let n=t.value.substring(2);return x(e.child(te(n),n))};function Kt(e){let t=e.consume(),n=(o,i)=>ve(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>c&&X(c,s))};if(t.template){let o=r.expr=st(e,t);r.ev=i=>E(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Xt(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>E(n.ev(r),s=>X(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=st(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Oe=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function en(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>X(Array.from(c instanceof A?c:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=rt(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Oe(i.me,s))}return r}function Ie(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>J(s.you||s.me,r),lhs:()=>{},put:(s,c,a)=>K(s.you||s.me,r,a)}}function it(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?le:ce)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>fe(o.you||o.me,r,s)}}function at(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function ut(e,t="Expected event name"){return e.matchType("STRING")?.value??at(e)??e.err(t)}function O(e,t){return nn(e,t)??rn(e,t)??cn(e,t)??on(e,t)??sn(e,t)??an(e,t)??un(e,t)??fn(e,t)??tn(e,t)??t}function tn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function nn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),de(s,n,c)},del:(i,s)=>{R(s,r),P(s,c=>{C(c)&&delete c[n],w.wroteProperty(c)})}};return O(e,o)}function rn(e,t){if(!e.match("of"))return;let n=D(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!s||c===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:Z,attribute:J,style:ce,computed:le}[s],u={type:"ofExpression",root:n,name:c,kind:s,start:t.start,end:e.endPos(),ev:p=>E(u.root.ev(p),m=>l(m,c)),lhs:p=>u.root.ev(p),put:(p,m,d)=>{R(m,a),s==="attribute"?K(m,c,d):s==="property"?de(m,c,d):fe(m,c,d)},del:(p,m)=>{R(m,a),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(c):s==="property"?(C(d)&&delete d[c],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(c)})}};return r?(r.root=u,O(e,t)):O(e,u)}function on(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Ie(e)??it(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),c=l=>i!==void 0?Z(l,i):o?.type==="attributeRef"?J(l,o.name):o?.type==="computedStyleRef"?le(l,o.name):o&&ce(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(a.root.ev(l),c),lhs:l=>a.root.ev(l),put:(l,u,p)=>{R(u,s),i!==void 0?de(u,i,p):o?.type==="attributeRef"?K(u,o.name,p):o&&fe(u,o.name,p)}};return O(e,a)}function sn(e,t){if(!e.match("in"))return;let n=D(e),r=(s,c)=>{if(s==null)return[];let a=[],l=g(s,"css");if(typeof l=="string")P(c,u=>k(u)&&a.push(...we(u,l)));else if(k(s)){let u=!1;if(P(c,p=>{p instanceof Node&&p.contains(s)&&(u=!0)}),u)return s}else P(s,u=>P(c,p=>u===p&&a.push(u)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([c,a])=>r(c,a)),lhs:s=>o.ev(s),put:(s,c,a)=>X(c,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function an(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=at(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:c=>E(s.root.ev(c),a=>$e(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function un(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(x(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let c=i.root,a=c.prop,l=a===void 0?void 0:c.root;return S([(l??c).ev(s),...n.map(u=>u.ev(s))],([u,...p])=>{if(!l||a===void 0)return et(u,void 0,p,s,r);R(u,o);let m=et(g(u,a),u,p,s,r);return Me(u,a),m})}};return O(e,i)}function et(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function cn(e,t){let n=Ie(e);return n&&ln(e,t,n)}function ln(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),K(s,n.name,c)}};return o}function fn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=x(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=x(e))),e.reqOp("]");let s=e.text(t),c=(u,p)=>v(p)<0?v(g(u,"length"))+v(p):v(p),a=(u,p,m)=>{let d=g(u,"slice");return L(d)?Reflect.apply(d,u,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:u=>S([l.root.ev(u),r.ev(u),i?.ev(u)],([p,m,d])=>p==null?null:n?a(p,0,c(p,m)+1):o?d==null?a(p,v(m)):a(p,v(m),c(p,d)+1):g(p,String(m))),lhs:u=>S([l.root.ev(u),r.ev(u)],p=>p),put:(u,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(u,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(c(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var M=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},ct=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),me=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new M(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Ce(e){let t=e.source.split(`
|
|
6
6
|
`),n=e.token.line?e.token.line-1:t.length-1,r=t[n]??"",o=e.token.line?e.token.column:Math.max(0,r.length-1),i=String(n+1).length,s=" ".repeat(i+5+o);return` ${n+1} | ${r}
|
|
7
7
|
`+s+"^".repeat(Math.max(1,e.token.value.length))+`
|
|
8
8
|
`+s+e.message+`
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
`+Ce(i)+s)}else N(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var kt=[],Tt=[];function re(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of kt)n(e);let t=Et().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&ht(e),e.querySelectorAll(t).forEach(ht);for(let n of Tt)n(e)}function pe(e){let t=$(e);if(t){N(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);w.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(pe),N(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),De(e)}}Y.process=re;function hn(e){try{let t=wt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof M)return{errors:[t]};throw t}}var Pt=Object.assign(pt,{config:Object.assign(ae,{conversions:Object.assign(ge,{dynamicResolvers:ye})}),use(e){e(Pt)},addBeforeProcessHook:e=>void kt.push(e),addAfterProcessHook:e=>void Tt.push(e),addSourceTransform:e=>void xt.push(e),evaluate:pt,parse:hn,process:re,processNode:re,cleanup:pe,internals:{runtime:{cleanup:pe,processNode:re}},version:"4.
|
|
17
|
+
`,i)}}var kt=[],Tt=[];function re(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of kt)n(e);let t=Et().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&ht(e),e.querySelectorAll(t).forEach(ht);for(let n of Tt)n(e)}function pe(e){let t=$(e);if(t){N(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);w.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(pe),N(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),De(e)}}Y.process=re;function hn(e){try{let t=wt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof M)return{errors:[t]};throw t}}var Pt=Object.assign(pt,{config:Object.assign(ae,{conversions:Object.assign(ge,{dynamicResolvers:ye})}),use(e){e(Pt)},addBeforeProcessHook:e=>void kt.push(e),addAfterProcessHook:e=>void Tt.push(e),addSourceTransform:e=>void xt.push(e),evaluate:pt,parse:hn,process:re,processNode:re,cleanup:pe,internals:{runtime:{cleanup:pe,processNode:re}},version:"4.3.0"});function Nt(){if(Object.assign(globalThis,{_hyperscript:Pt}),typeof document>"u")return;let e=()=>{re(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function gn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=U(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function Fe(e,t){let n=gn(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>Fe(i,t),1),o){let{error:s}=o;console.error(g(s,"message")??s),console.error(g(s,"stack")),N(e.me,"exception",{error:s})}};V(()=>E(Qe(e,t.body,t),()=>r()),o=>r({error:o}))}function yn(e,t){if(!B(t))return;let n=U(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let c={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(ee(t,e,t,null)):[t];P(a,l=>{if(!B(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let u=s.on;if(s.mutationSpec&&l instanceof Node){u="hyperscript:mutation";let m=new MutationObserver(d=>N(l,u,{mutationList:d,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){u="hyperscript:intersection";let m=new IntersectionObserver(d=>{for(let y of d)N(l,u,{observer:m,entry:y,intersecting:y.isIntersecting,isIntersecting:y.isIntersecting,intersectionRatio:y.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){u="hyperscript:resize";let m=new ResizeObserver(d=>{for(let y of d){let{width:I,height:j}=y.contentRect;N(l,u,{width:I,height:j,contentRect:y.contentRect,entry:y})}});m.observe(l),o.push(m)}let p=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(u,p);return}let d=ee(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(d.result=l);for(let y of s.args){let I=g(m,y);I!==void 0?d.locals[y]=I:d.detail!=null&&(d.locals[y]=g(d.detail,y))}if(s.filter){d.meta.context=m;try{if(!s.filter.ev(d))return}finally{d.meta.context=void 0}}if(s.inExpr?.css){let y=m.target instanceof Element?m.target:null;for(;y&&!y.matches(s.inExpr.css);)y=y.parentElement;if(!y)return;d.result=y}if(c.execCount++,s.startCount){let y=c.execCount;if(s.endCount?y<s.startCount||y>s.endCount:s.unbounded?y<s.startCount:y!==s.startCount)return}if(s.debounceTime){c.debounced&&(clearTimeout(c.debounced),i.delete(c.debounced)),i.add(c.debounced=setTimeout(()=>Fe(d,e),s.debounceTime));return}if(s.throttleTime){if(c.lastExec&&Date.now()<c.lastExec+s.throttleTime)return;c.lastExec=Date.now()}Fe(d,e)}};l.addEventListener(u,p),r.push({target:l,event:u,handler:p})})}}function vn(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function wn(e){let t={};if(e.match("with")){let n=ne(x(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=ot(e):e.match("threshold")?t.threshold=Number(ne(x(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function En(e,t){let n=ut(e),r=mt(e),o;e.matchOp("[")&&(o=x(e),e.reqOp("]"));let i,s,c=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(c=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:c,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=wn(e):n==="mutation"&&(a.mutationSpec=vn(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>x(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=D(e));let l=()=>(e.req("at"),Number(ne(D(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function St(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(En(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let c=W(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:c,every:r,queue:s,...dt(t),start:n,end:t.endPos(),install:l=>yn(a,l)};return a}}yt(St);Nt();})();
|
package/dist/full.js
CHANGED
|
@@ -1131,6 +1131,7 @@
|
|
|
1131
1131
|
type: "symbol",
|
|
1132
1132
|
name,
|
|
1133
1133
|
scope,
|
|
1134
|
+
...on2 ? { on: on2 } : {},
|
|
1134
1135
|
start,
|
|
1135
1136
|
end: p.endPos(),
|
|
1136
1137
|
ev: (ctx) => resolveSymbol(name, ctx, scope, on2?.ev(ctx)),
|
|
@@ -2026,7 +2027,7 @@
|
|
|
2026
2027
|
cleanup,
|
|
2027
2028
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
2028
2029
|
internals: { runtime: { cleanup, processNode } },
|
|
2029
|
-
version: false ? "dev" : "4.
|
|
2030
|
+
version: false ? "dev" : "4.3.0"
|
|
2030
2031
|
});
|
|
2031
2032
|
function boot() {
|
|
2032
2033
|
Object.assign(globalThis, { _hyperscript: api });
|
|
@@ -4039,7 +4040,7 @@ return { ${functions.map((name) => `${name}:${name}`).join(",")} } `
|
|
|
4039
4040
|
} else {
|
|
4040
4041
|
p.match("to");
|
|
4041
4042
|
if (p.match("url")) {
|
|
4042
|
-
const address = stringLike(p);
|
|
4043
|
+
const address = node.url = stringLike(p);
|
|
4043
4044
|
node.newWindow = newWindow();
|
|
4044
4045
|
node.run = () => navigate(address);
|
|
4045
4046
|
} else if (["the", "top", "middle", "bottom", "left", "center", "right"].includes(p.cur().value)) {
|