hyper-element 1.0.3 → 2.0.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/README.md +673 -29
- package/build/hyperElement.min.js +14 -2
- package/build/hyperElement.min.js.map +3 -3
- package/index.d.ts +450 -1
- package/package.json +18 -13
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
(function(){/*! (c) Andrea Giammarchi (ISC) */var te=function(s){"use strict";var i={};try{i.WeakMap=WeakMap}catch{i.WeakMap=function(e,n){var r=n.defineProperty,o=n.hasOwnProperty,l=h.prototype;return l.delete=function(p){return this.has(p)&&delete p[this._]},l.get=function(p){return this.has(p)?p[this._]:void 0},l.has=function(p){return o.call(p,this._)},l.set=function(p,v){return r(p,this._,{configurable:!0,value:v}),this},h;function h(p){r(this,"_",{value:"_@ungap/weakmap"+e++}),p&&p.forEach(a,this)}function a(p){this.set(p[0],p[1])}}(Math.random(),Object)}var f=i.WeakMap,u={};try{u.WeakSet=WeakSet}catch{(function(e,n){var r=o.prototype;function o(){n(this,"_",{value:"_@ungap/weakmap"+e++})}r.add=function(l){return this.has(l)||n(l,this._,{value:!0,configurable:!0}),this},r.has=function(l){return this.hasOwnProperty.call(l,this._)},r.delete=function(l){return this.has(l)&&delete l[this._]},u.WeakSet=o})(Math.random(),Object.defineProperty)}function d(t,e,n,r,o,l){for(var h=("selectedIndex"in e),a=h;r<o;){var p,v=t(n[r],1);e.insertBefore(v,l),h&&a&&v.selected&&(a=!a,p=e.selectedIndex,e.selectedIndex=p<0?r:B.call(e.querySelectorAll("option"),v)),r++}}function c(t,e){return t==e}function g(t){return t}function w(t,e,n,r,o,l,h){var a=l-o;if(a<1)return-1;for(;a<=n-e;){for(var p=e,v=o;p<n&&v<l&&h(t[p],r[v]);)p++,v++;if(v===l)return e;e=p+1}return-1}function x(t,e,n,r,o){return n<r?t(e[n],0):0<n?t(e[n-1],-0).nextSibling:o}function b(t,e,n,r){for(;n<r;)q(t(e[n++],-1))}function _(t,e,n,r,o,l,h,a,p,v,m,E,P){(function(y,j,S,M,$,O,A,N,k){for(var C=[],R=y.length,J=A,H=0;H<R;)switch(y[H++]){case 0:$++,J++;break;case 1:C.push(M[$]),d(j,S,M,$++,$,J<N?j(O[J],0):k);break;case-1:J++}for(H=0;H<R;)switch(y[H++]){case 0:A++;break;case-1:-1<C.indexOf(O[A])?A++:b(j,O,A++,A)}})(function(y,j,S,M,$,O,A){var N,k,C,R,J,H,ue=S+O,K=[];e:for(T=0;T<=ue;T++){if(50<T)return null;for(H=T-1,R=T?K[T-1]:[0,0],J=K[T]=[],N=-T;N<=T;N+=2){for(k=(C=N===-T||N!==T&&R[H+N-1]<R[H+N+1]?R[H+N+1]:R[H+N-1]+1)-N;C<O&&k<S&&A(M[$+C],y[j+k]);)C++,k++;if(C===O&&k===S)break e;J[T+N]=C}}for(var V=Array(T/2+ue/2),X=V.length-1,T=K.length-1;0<=T;T--){for(;0<C&&0<k&&A(M[$+C-1],y[j+k-1]);)V[X--]=0,C--,k--;if(!T)break;H=T-1,R=T?K[T-1]:[0,0],(N=C-k)===-T||N!==T&&R[H+N-1]<R[H+N+1]?(k--,V[X--]=1):(C--,V[X--]=-1)}return V}(n,r,l,h,a,v,E)||function(y,j,S,M,$,O,A,N){var k=0,C=M<N?M:N,R=Array(C++),J=Array(C);J[0]=-1;for(var H=1;H<C;H++)J[H]=A;for(var ue=$.slice(O,A),K=j;K<S;K++){var V,X=ue.indexOf(y[K]);-1<X&&-1<(k=W(J,C,V=X+O))&&(J[k]=V,R[k]={newi:K,oldi:V,prev:R[k-1]})}for(k=--C,--A;J[k]>A;)--k;C=N+M-k;var T=Array(C),ce=R[k];for(--S;ce;){for(var On=ce.newi,Tn=ce.oldi;On<S;)T[--C]=1,--S;for(;Tn<A;)T[--C]=-1,--A;T[--C]=0,--S,--A,ce=ce.prev}for(;j<=S;)T[--C]=1,--S;for(;O<=A;)T[--C]=-1,--A;return T}(n,r,o,l,h,a,p,v),t,e,n,r,h,a,m,P)}var D=u.WeakSet,B=[].indexOf,W=function(t,e,n){for(var r=1,o=e;r<o;){var l=(r+o)/2>>>0;n<t[l]?o=l:r=1+l}return r},q=function(t){return(t.remove||function(){var e=this.parentNode;e&&e.removeChild(this)}).call(t)};function L(t,e,n,r){for(var o=(r=r||{}).compare||c,l=r.node||g,h=r.before==null?null:l(r.before,0),a=e.length,p=a,v=0,m=n.length,E=0;v<p&&E<m&&o(e[v],n[E]);)v++,E++;for(;v<p&&E<m&&o(e[p-1],n[m-1]);)p--,m--;var P=v===p,y=E===m;if(P&&y)return n;if(P&&E<m)return d(l,t,n,E,m,x(l,e,v,a,h)),n;if(y&&v<p)return b(l,e,v,p),n;var j=p-v,S=m-E,M=-1;if(j<S){if(-1<(M=w(n,E,m,e,v,p,o)))return d(l,t,n,E,M,l(e[v],0)),d(l,t,n,M+j,m,x(l,e,p,a,h)),n}else if(S<j&&-1<(M=w(e,v,p,n,E,m,o)))return b(l,e,v,M),b(l,e,M+S,p),n;return j<2||S<2?(d(l,t,n,E,m,l(e[v],0)),b(l,e,v,p)):j==S&&function($,O,A,N,k,C){for(;N<k&&C(A[N],$[O-1]);)N++,O--;return O===0}(n,m,e,v,p,o)?d(l,t,n,E,m,x(l,e,p,a,h)):_(l,t,n,E,m,S,e,v,p,j,a,o,h),n}var Q,z={};function F(t,e){e=e||{};var n=s.createEvent("CustomEvent");return n.initCustomEvent(t,!!e.bubbles,!!e.cancelable,e.detail),n}z.CustomEvent=typeof CustomEvent=="function"?CustomEvent:(F[Q="prototype"]=new F("").constructor[Q],F);var Z=z.CustomEvent,G={};try{G.Map=Map}catch{G.Map=function(){var e=0,n=[],r=[];return{delete:function(l){var h=o(l);return h&&(n.splice(e,1),r.splice(e,1)),h},forEach:function(l,h){n.forEach(function(a,p){l.call(h,r[p],a,this)},this)},get:function(l){return o(l)?r[e]:void 0},has:o,set:function(l,h){return r[o(l)?e:n.push(l)-1]=h,this}};function o(l){return-1<(e=n.indexOf(l))}}}var I=G.Map;function Y(){return this}function le(t,e){var n="_"+t+"$";return{get:function(){return this[n]||de(this,n,e.call(this,t))},set:function(r){de(this,n,r)}}}var de=function(t,e,n){return Object.defineProperty(t,e,{configurable:!0,value:typeof n=="function"?function(){return t._wire$=n.apply(this,arguments)}:n})[e]};Object.defineProperties(Y.prototype,{ELEMENT_NODE:{value:1},nodeType:{value:-1}});var et,tt,Me,ve,Pe,nt,rt={},ge={},it=[],en=ge.hasOwnProperty,st=0,ie={attributes:rt,define:function(t,e){t.indexOf("-")<0?(t in ge||(st=it.push(t)),ge[t]=e):rt[t]=e},invoke:function(t,e){for(var n=0;n<st;n++){var r=it[n];if(en.call(t,r))return ge[r](t[r],e)}}},ot=Array.isArray||(tt=(et={}.toString).call([]),function(t){return et.call(t)===tt}),at=(Me=s,ve="fragment",nt="content"in se(Pe="template")?function(t){var e=se(Pe);return e.innerHTML=t,e.content}:function(t){var e,n=se(ve),r=se(Pe);return ut(n,/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(t)?(e=RegExp.$1,r.innerHTML="<table>"+t+"</table>",r.querySelectorAll(e)):(r.innerHTML=t,r.childNodes)),n},function(t,e){return(e==="svg"?function(n){var r=se(ve),o=se("div");return o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+n+"</svg>",ut(r,o.firstChild.childNodes),r}:nt)(t)});function ut(t,e){for(var n=e.length;n--;)t.appendChild(e[0])}function se(t){return t===ve?Me.createDocumentFragment():Me.createElementNS("http://www.w3.org/1999/xhtml",t)}var oe,me,be,Le,He,De,ye,we,lt,$e,tn=(me="appendChild",be="cloneNode",Le="createTextNode",De=(He="importNode")in(oe=s),(ye=oe.createDocumentFragment())[me](oe[Le]("g")),ye[me](oe[Le]("")),(De?oe[He](ye,!0):ye[be](!0)).childNodes.length<2?function t(e,n){for(var r=e[be](),o=e.childNodes||[],l=o.length,h=0;n&&h<l;h++)r[me](t(o[h],n));return r}:De?oe[He]:function(t,e){return t[be](!!e)}),ct="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},ee="-"+Math.random().toFixed(6)+"%",Re=!1;try{we=s.createElement("template"),$e="tabindex",(lt="content")in we&&(we.innerHTML="<p "+$e+'="'+ee+'"></p>',we[lt].childNodes[0].getAttribute($e)==ee)||(ee="_dt: "+ee.slice(1,-1)+";",Re=!0)}catch{}var xe="<!--"+ee+"-->",nn=8,rn=1,sn=3,ft=/^(?:style|textarea)$/i,on=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,Ee=" \\f\\n\\r\\t",ht="[^"+Ee+`\\/>"'=]+`,We="["+Ee+"]+"+ht,pt="<([A-Za-z]+[A-Za-z0-9:._-]*)((?:",dt=`(?:\\s*=\\s*(?:'[^']*?'|"[^"]*?"|<[^>]*?>|`+ht.replace("\\/","")+"))?)",an=new RegExp(pt+We+dt+"+)(["+Ee+"]*/?>)","g"),un=new RegExp(pt+We+dt+"*)(["+Ee+"]*/>)","g"),ln=new RegExp("("+We+`\\s*=\\s*)(['"]?)`+xe+"\\2","gi");function cn(t,e,n,r){return"<"+e+n.replace(ln,fn)+r}function fn(t,e,n){return e+(n||'"')+ee+(n||'"')}function hn(t,e,n){return on.test(e)?t:"<"+e+n+"></"+e+">"}var pn=Re?function(t,e){var n=e.join(" ");return e.slice.call(t,0).sort(function(r,o){return n.indexOf(r.name)<=n.indexOf(o.name)?-1:1})}:function(t,e){return e.slice.call(t,0)};function vt(t,e,n,r){for(var o=t.childNodes,l=o.length,h=0;h<l;){var a=o[h];switch(a.nodeType){case rn:var p=r.concat(h);(function(m,E,P,y){for(var j,S=m.attributes,M=[],$=[],O=pn(S,P),A=O.length,N=0;N<A;){var k=O[N++],C=k.value===ee;if(C||1<(j=k.value.split(xe)).length){var R=k.name;if(M.indexOf(R)<0){M.push(R);var J=P.shift().replace(C?/^(?:|[\S\s]*?\s)(\S+?)\s*=\s*('|")?$/:new RegExp("^(?:|[\\S\\s]*?\\s)("+R+`)\\s*=\\s*('|")[\\S\\s]*`,"i"),"$1"),H=S[J]||S[J.toLowerCase()];if(C)E.push(gt(H,y,J,null));else{for(var ue=j.length-2;ue--;)P.shift();E.push(gt(H,y,J,j))}}$.push(k)}}A=$.length;for(var K=(N=0)<A&&Re&&!("ownerSVGElement"in m);N<A;){var V=$[N++];K&&(V.value=""),m.removeAttribute(V.name)}var X=m.nodeName;if(/^script$/i.test(X)){var T=s.createElement(X);for(A=S.length,N=0;N<A;)T.setAttributeNode(S[N++].cloneNode(!0));T.textContent=m.textContent,m.parentNode.replaceChild(T,m)}})(a,e,n,p),vt(a,e,n,p);break;case nn:var v=a.textContent;if(v===ee)n.shift(),e.push(ft.test(t.nodeName)?mt(t,r):{type:"any",node:a,path:r.concat(h)});else switch(v.slice(0,2)){case"/*":if(v.slice(-2)!=="*/")break;case"\u{1F47B}":t.removeChild(a),h--,l--}break;case sn:ft.test(t.nodeName)&&ct.call(a.textContent)===xe&&(n.shift(),e.push(mt(t,r)))}h++}}function gt(t,e,n,r){return{type:"attr",node:t,path:e,name:n,sparse:r}}function mt(t,e){return{type:"text",node:t,path:e}}var Ie,bt=(Ie=new f,{get:function(t){return Ie.get(t)},set:function(t,e){return Ie.set(t,e),e}});function dn(t,e){var n=(t.convert||function(h){return h.join(xe).replace(un,hn).replace(an,cn)})(e),r=t.transform;r&&(n=r(n));var o=at(n,t.type);yt(o);var l=[];return vt(o,l,e.slice(0),[]),{content:o,updates:function(h){for(var a=[],p=l.length,v=0,m=0;v<p;){var E=l[v++],P=function(S,M){for(var $=M.length,O=0;O<$;)S=S.childNodes[M[O++]];return S}(h,E.path);switch(E.type){case"any":a.push({fn:t.any(P,[]),sparse:!1});break;case"attr":var y=E.sparse,j=t.attribute(P,E.name,E.node);y===null?a.push({fn:j,sparse:!1}):(m+=y.length-2,a.push({fn:j,sparse:!0,values:y}));break;case"text":a.push({fn:t.text(P),sparse:!1}),P.textContent=""}}return p+=m,function(){var S=arguments.length;if(p!==S-1)throw new Error(S-1+" values instead of "+p+`
|
|
2
|
-
`+e.join("${value}"));for(var M=1,$=1;M<S;){var O=a[M-$];if(O.sparse){var A=O.values,N=A[0],k=1,C=A.length;for($+=C-2;k<C;)N+=arguments[M++]+A[k++];O.fn(N)}else O.fn(arguments[M++])}return h}}}}var vn=[];function gn(t){var e=vn,n=yt;return function(r){var o,l,h;return e!==r&&(o=t,l=e=r,h=bt.get(l)||bt.set(l,dn(o,l)),n=h.updates(tn.call(s,h.content,!0))),n.apply(null,arguments)}}function yt(t){for(var e=t.childNodes,n=e.length;n--;){var r=e[n];r.nodeType!==1&&ct.call(r.textContent).length===0&&t.removeChild(r)}}var wt,xt,mn=(wt=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,xt=/([^A-Z])([A-Z]+)/g,function(t,e){return"ownerSVGElement"in t?function(n,r){var o;return(o=r?r.cloneNode(!0):(n.setAttribute("style","--hyper:style;"),n.getAttributeNode("style"))).value="",n.setAttributeNode(o),Et(o,!0)}(t,e):Et(t.style,!1)});function bn(t,e,n){return e+"-"+n.toLowerCase()}function Et(t,e){var n,r;return function(o){var l,h,a,p;switch(typeof o){case"object":if(o){if(n==="object"){if(!e&&r!==o)for(h in r)h in o||(t[h]="")}else e?t.value="":t.cssText="";for(h in l=e?{}:t,o)a=typeof(p=o[h])!="number"||wt.test(h)?p:p+"px",!e&&/^--/.test(h)?l.setProperty(h,a):l[h]=a;n="object",e?t.value=function(v){var m,E=[];for(m in v)E.push(m.replace(xt,bn),":",v[m],";");return E.join("")}(r=l):r=o;break}default:r!=o&&(n="string",r=o,e?t.value=o||"":t.cssText=o||"")}}}var Nt,Ne,Ct=(Nt=[].slice,(Ne=St.prototype).ELEMENT_NODE=1,Ne.nodeType=111,Ne.remove=function(t){var e,n=this.childNodes,r=this.firstChild,o=this.lastChild;return this._=null,t&&n.length===2?o.parentNode.removeChild(o):((e=this.ownerDocument.createRange()).setStartBefore(t?n[1]:r),e.setEndAfter(o),e.deleteContents()),r},Ne.valueOf=function(t){var e=this._,n=e==null;if(n&&(e=this._=this.ownerDocument.createDocumentFragment()),n||t)for(var r=this.childNodes,o=0,l=r.length;o<l;o++)e.appendChild(r[o]);return e},St);function St(t){var e=this.childNodes=Nt.call(t,0);this.firstChild=e[0],this.lastChild=e[e.length-1],this.ownerDocument=e[0].ownerDocument,this._=null}function yn(t){return{html:t}}function kt(t,e){switch(t.nodeType){case En:return 1/e<0?e?t.remove(!0):t.lastChild:e?t.valueOf(!0):t.firstChild;case xn:return kt(t.render(),e);default:return t}}function At(t,e){e(t.placeholder),"text"in t?Promise.resolve(t.text).then(String).then(e):"any"in t?Promise.resolve(t.any).then(e):"html"in t?Promise.resolve(t.html).then(yn).then(e):Promise.resolve(ie.invoke(t,e)).then(e)}function Je(t){return t!=null&&"then"in t}var Ot,Tt,Ce,Se,ke,Be="ownerSVGElement",wn="connected",xn=Y.prototype.nodeType,En=Ct.prototype.nodeType,_t=(Tt=(Ot={Event:Z,WeakSet:D}).Event,Ce=Ot.WeakSet,Se=!0,ke=null,function(t){return Se&&(Se=!Se,ke=new Ce,function(e){var n=new Ce,r=new Ce;try{new MutationObserver(a).observe(e,{subtree:!0,childList:!0})}catch{var o=0,l=[],h=function(m){l.push(m),clearTimeout(o),o=setTimeout(function(){a(l.splice(o=0,l.length))},0)};e.addEventListener("DOMNodeRemoved",function(m){h({addedNodes:[],removedNodes:[m.target]})},!0),e.addEventListener("DOMNodeInserted",function(m){h({addedNodes:[m.target],removedNodes:[]})},!0)}function a(v){for(var m,E=v.length,P=0;P<E;P++)p((m=v[P]).removedNodes,"disconnected",r,n),p(m.addedNodes,"connected",n,r)}function p(v,m,E,P){for(var y,j=new Tt(m),S=v.length,M=0;M<S;(y=v[M++]).nodeType===1&&function $(O,A,N,k,C){ke.has(O)&&!k.has(O)&&(C.delete(O),k.add(O),O.dispatchEvent(A));for(var R=O.children||[],J=R.length,H=0;H<J;$(R[H++],A,N,k,C));}(y,j,m,E,P));}}(t.ownerDocument)),ke.add(t),t}),Nn=/^(?:form|list)$/i,Ae=[].slice;function Oe(t){return this.type=t,gn(this)}var jt=!(Oe.prototype={attribute:function(t,e,n){var r,o=Be in t;if(e==="style")return mn(t,n,o);if(e.slice(0,1)===".")return v=t,m=e.slice(1),o?function(y){try{v[m]=y}catch{v.setAttribute(m,y)}}:function(y){v[m]=y};if(e.slice(0,1)==="?")return h=t,a=e.slice(1),function(y){p!==!!y&&((p=!!y)?h.setAttribute(a,""):h.removeAttribute(a))};if(/^on/.test(e)){var l=e.slice(2);return l===wn||l==="disconnected"?_t(t):e.toLowerCase()in t&&(l=l.toLowerCase()),function(y){r!==y&&(r&&t.removeEventListener(l,r,!1),(r=y)&&t.addEventListener(l,y,!1))}}if(e==="data"||!o&&e in t&&!Nn.test(e))return function(y){r!==y&&(r=y,t[e]!==y&&y==null?(t[e]="",t.removeAttribute(e)):t[e]=y)};if(e in ie.attributes)return function(y){var j=ie.attributes[e](t,y);r!==j&&((r=j)==null?t.removeAttribute(e):t.setAttribute(e,j))};var h,a,p,v,m,E=!1,P=n.cloneNode(!0);return function(y){r!==y&&(r=y,P.value!==y&&(y==null?(E&&(E=!1,t.removeAttributeNode(P)),P.value=y):(P.value=y,E||(E=!0,t.setAttributeNode(P)))))}},any:function(t,e){var n,r={node:kt,before:t},o=Be in t?"svg":"html",l=!1;return function h(a){switch(typeof a){case"string":case"number":case"boolean":l?n!==a&&(n=a,e[0].textContent=a):(l=!0,n=a,e=L(t.parentNode,e,[(p=a,t.ownerDocument.createTextNode(p))],r));break;case"function":h(a(t));break;case"object":case"undefined":if(a==null){l=!1,e=L(t.parentNode,e,[],r);break}default:if(l=!1,ot(n=a))if(a.length===0)e.length&&(e=L(t.parentNode,e,[],r));else switch(typeof a[0]){case"string":case"number":case"boolean":h({html:a});break;case"object":if(ot(a[0])&&(a=a.concat.apply([],a)),Je(a[0])){Promise.all(a).then(h);break}default:e=L(t.parentNode,e,a,r)}else"ELEMENT_NODE"in a?e=L(t.parentNode,e,a.nodeType===11?Ae.call(a.childNodes):[a],r):Je(a)?a.then(h):"placeholder"in a?At(a,h):"text"in a?h(String(a.text)):"any"in a?h(a.any):"html"in a?e=L(t.parentNode,e,Ae.call(at([].concat(a.html).join(""),o).childNodes),r):"length"in a?h(Ae.call(a)):h(ie.invoke(a,h))}var p}},text:function(t){var e;return function n(r){var o;e!==r&&((o=typeof(e=r))=="object"&&r?Je(r)?r.then(n):"placeholder"in r?At(r,n):"text"in r?n(String(r.text)):"any"in r?n(r.any):"html"in r?n([].concat(r.html).join("")):"length"in r?n(Ae.call(r).join("")):n(ie.invoke(r,n)):o=="function"?n(r(t)):t.textContent=r??"")}}}),Mt=function(t){var e,n,r,o,l=(e=(s.defaultView.navigator||{}).userAgent,/(Firefox|Safari)\/(\d+)/.test(e)&&!/(Chrom[eium]+|Android)\/(\d+)/.test(e)),h=!("raw"in t)||t.propertyIsEnumerable("raw")||!Object.isFrozen(t.raw);return l||h?(n={},r=function(a){for(var p=".",v=0;v<a.length;v++)p+=a[v].length+"."+a[v];return n[p]||(n[p]=a)},Mt=h?r:(o=new f,function(a){return o.get(a)||(v=r(p=a),o.set(p,v),v);var p,v})):jt=!0,Pt(t)};function Pt(t){return jt?t:Mt(t)}function Lt(t){for(var e=arguments.length,n=[Pt(t)],r=1;r<e;)n.push(arguments[r++]);return n}var Ht=new f,ae=function(t){var e,n,r;return function(){var o=Lt.apply(null,arguments);return r!==o[0]?(r=o[0],n=new Oe(t),e=Cn(n.apply(n,o))):n.apply(n,o),e}},Dt=function(t,e){var n=e.indexOf(":"),r=Ht.get(t),o=e;return-1<n&&(o=e.slice(n+1),e=e.slice(0,n)||"html"),r||Ht.set(t,r={}),r[o]||(r[o]=ae(e))},Cn=function(t){var e=t.childNodes,n=e.length;return n===1?e[0]:n?new Ct(e):t},$t=new f;function Sn(){var t=$t.get(this),e=Lt.apply(null,arguments);return t&&t.template===e[0]?t.tagger.apply(null,e):function(n){var r=new Oe(Be in this?"svg":"html");$t.set(this,{tagger:r,template:n}),this.textContent="",this.appendChild(r.apply(null,arguments))}.apply(this,e),this}var ze,Fe,Rt,Wt,kn=ie.define,An=Oe.prototype;function U(t){return arguments.length<2?t==null?ae("html"):typeof t=="string"?U.wire(null,t):"raw"in t?ae("html")(t):"nodeType"in t?U.bind(t):Dt(t,"html"):("raw"in t?ae("html"):U.wire).apply(null,arguments)}return U.Component=Y,U.bind=function(t){return Sn.bind(t)},U.define=kn,U.diff=L,(U.hyper=U).observe=_t,U.tagger=An,U.wire=function(t,e){return t==null?ae(e||"html"):Dt(t,e||"html")},U._={WeakMap:f,WeakSet:D},ze=ae,Fe=new f,Rt=Object.create,Wt=function(t,e){var n={w:null,p:null};return e.set(t,n),n},Object.defineProperties(Y,{for:{configurable:!0,value:function(t,e){return function(o,l,h,a){var p,v,m,E=l.get(o)||Wt(o,l);switch(typeof a){case"object":case"function":var P=E.w||(E.w=new f);return P.get(a)||(p=P,v=a,m=new o(h),p.set(v,m),m);default:var y=E.p||(E.p=Rt(null));return y[a]||(y[a]=new o(h))}}(this,Fe.get(t)||(n=t,r=new I,Fe.set(n,r),r),t,e??"default");var n,r}}}),Object.defineProperties(Y.prototype,{handleEvent:{value:function(t){var e=t.currentTarget;this["getAttribute"in e&&e.getAttribute("data-call")||"on"+t.type](t)}},html:le("html",ze),svg:le("svg",ze),state:le("state",function(){return this.defaultState}),defaultState:{get:function(){return{}}},dispatch:{value:function(t,e){var n=this._wire$;if(n){var r=new Z(t,{bubbles:!0,cancelable:!0,detail:e});return r.component=this,(n.dispatchEvent?n:n.firstChild).dispatchEvent(r)}return!1}},setState:{value:function(t,e){var n=this.state,r=typeof t=="function"?t.call(this,n):t;for(var o in r)n[o]=r[o];return e!==!1&&this.render(),this}}}),U}(document);const fe=/<+\w+[-]+\w/,ne={},he={};function It(){for(var s="",i="bcdfghjklmnpqrstvwxyz",f=0;f<15;f++)s+=i.charAt(Math.floor(Math.random()*i.length));return s}function re(s){return typeof s!="string"?s:s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ze=Symbol("safeHtml");function Jt(s){return{[Ze]:!0,value:s}}function qe(s){return s&&s[Ze]===!0}function Bt(s,i){if(s==="template"&&i==="")return!0;if(+i+""===i.trim())return+i;const f=i.toLowerCase().trim();return f==="true"?!0:f==="false"?!1:f[0]==="["&&f.slice(-1)==="]"||f[0]==="{"&&f.slice(-1)==="}"?JSON.parse(i):i}function Ge(s){return typeof s=="function"?Ge(s()):typeof s=="string"?re(s):typeof s=="number"||typeof s=="boolean"?String(s):Array.isArray(s)?re(s.join(", ")):s!==null&&typeof s=="object"?re(JSON.stringify(s)):""}function zt(s,i){let f=s;const u=/\{\+each\s+(\w+)\}([\s\S]*?)\{-each\}/g;f=f.replace(u,(w,x,b)=>{const _=i[x];return Array.isArray(_)?_.map((D,B)=>{let W=b;return W=W.replace(/\{@\}/g,B),W=W.replace(/\{\s*\.\.\.\s*\}/g,Ge(D)),typeof D=="object"&&D!==null&&Object.keys(D).forEach(q=>{W=W.replace(new RegExp("\\{"+q+"\\}","g"),re(String(D[q])))}),W}).join(""):""});const d=/\{\+if\s+(\w+)\}([\s\S]*?)\{else\}([\s\S]*?)\{-if\}/g;f=f.replace(d,(w,x,b,_)=>i[x]?b:_);const c=/\{\+if\s+(\w+)\}([\s\S]*?)\{-if\}/g;f=f.replace(c,(w,x,b)=>i[x]?b:"");const g=/\{\+unless\s+(\w+)\}([\s\S]*?)\{-unless\}/g;return f=f.replace(g,(w,x,b)=>i[x]?"":b),f}function Te(s){if(/\{\+(if|each|unless)\s/.test(s))return function(g){if(typeof g!="object")throw new Error("Templates must be passed an object. You passed "+JSON.stringify(g));let w=zt(s,g);return w=w.replace(/\{(\w+)\}/g,(x,b)=>g[b]!=null?re(String(g[b])):""),{html:w}};const f=/(\{[\w]+\})/g,u=s.split(f).reduce((c,g)=>(g[0]==="{"&&g.slice(-1)==="}"?c.keys.push(g.slice(1,-1)):c.markup.push(g),c),{markup:[],keys:[]});u.id=":"+u.markup.join().trim();function d(c){const g=[u.markup,...u.keys.map(w=>c[w])];return g.raw={value:u.markup},g}return function(g){if(typeof g!="object")throw new Error("Templates must be passed an object to be populated with. You passed "+JSON.stringify(g)+" to "+u.id);return te.wire(g,u.id)(...d(g))}}function _e(s,i){const f=i.replace(/-([a-z])/g,u=>u[1].toUpperCase());Object.defineProperty(s,f,{enumerable:!0,configurable:!0,get:()=>Bt(f,this.dataset[f]),set:u=>{ne[this.identifier].attrsToIgnore["data-"+i]=!0,typeof u=="string"?this.dataset[f]=u:this.dataset[f]=JSON.stringify(u)}})}function Ft(){const s={};return Object.keys(this.dataset).forEach(i=>_e.call(this,s,i.replace(/([A-Z])/g,f=>`-${f[0].toLowerCase()}`))),s}function Zt(s){const i={};for(let f=0;f<s.length;f++){const{value:u,name:d}=s[f];if(d==="template"&&!u){const c=ne[this.identifier];c.Html.template=Te(c.innerHTML),i[d]=!0}else(u.substr(0,3)==="fn-"||u.substr(0,3)==="ob-")&&he[u.substr(3)]&&he[u.substr(3)].localName===this.localName?i[d]=he[u.substr(3)].val:+u+""===(u+"").trim()?i[d]=+u:i[d]=u}return i}function qt(s){return s.some(i=>i.includes("{+each ")||i.includes("{+each{")||i.includes("{+if ")||i.includes("{+unless "))}function Ue(s,i){return i.split(".").reduce((f,u)=>f?.[u],s)}function Ve(s){const i=/\{(@|\s*\.\.\.\s*|\w+(?:\.\w+)*)\}/g,f=[],u=[];let d=0,c;for(;(c=i.exec(s))!==null;)f.push(s.substring(d,c.index)),u.push(c[1]),d=i.lastIndex;return f.push(s.substring(d)),{parts:f,props:u}}function Gt(s,i,f,u,d){let c=1;for(let g=i;g<s.length;g++){const w=s[g];let x=g===i?f:0;for(;x<w.length;){const b=w.indexOf(u,x),_=w.indexOf(d,x);if(_!==-1&&(b===-1||_<b)){if(--c===0)return{endIdx:g,endPos:_};x=_+d.length}else if(b!==-1)c++,x=b+u.length;else break}}throw new Error(`Unclosed ${u}} block. Missing ${d}.`)}function pe(s){const i=[...s];return i.raw=[...s],i}const Ye=new WeakMap;function je(s,i,f){if(s!==null&&typeof s=="object")return s;let u=Ye.get(f);return u||(u={},Ye.set(f,u)),u[i]||(u[i]={_value:s,_index:i}),u[i]._value=s,u[i]}function Ke(s,i,f){return s==="@"?f:s.trim()==="..."?i:Ue(i,s)}function Qe(s,i,f,u,d){const c=/\{\+each\s*\{(\w+(?:\.\w+)*)\}\}([\s\S]*?)\{-each\}/g,g=c.test(s);if(c.lastIndex=0,g){const _=[];let D=s,B;for(;(B=c.exec(s))!==null;){const[F,Z,G]=B,I=Ue(i,Z);if(!Array.isArray(I)){D=D.replace(F,"");continue}const Y=I.map((le,de)=>Qe(G.trim(),le,de,I,d));D=D.replace(F,`__NESTED_${_.length}__`),_.push(Y)}const{parts:W,props:q}=Ve(D),L=[],Q=[];let z=0;for(let F=0;F<W.length;F++){let Z=W[F],G;for(;G=Z.match(/__NESTED_(\d+)__/);){const[I,Y]=Z.split(G[0]);L.push(I),Q.push(_[parseInt(G[1],10)]),Z=Y||""}L.push(Z),F<q.length&&Q.push(Ke(q[z++],i,f))}return d(je(i,f,u),JSON.stringify(L))(pe(L),...Q)}const{parts:w,props:x}=Ve(s);if(x.length===0)return d(je(i,f,u),JSON.stringify([s]))(pe([s]));const b=x.map(_=>Ke(_,i,f));return d(je(i,f,u),JSON.stringify(w))(pe(w),...b)}function Xe(s){const i=[{type:"each",pattern:"{+each "},{type:"if",pattern:"{+if "},{type:"unless",pattern:"{+unless "}];let f=null;for(const u of i){const d=s.indexOf(u.pattern);d!==-1&&(f===null||d<f.pos)&&(f={type:u.type,pos:d,pattern:u.pattern})}return f}function Ut(s,i,f){const u=[],d=[];let c=0;for(;c<s.length;){const g=s[c],w=Xe(g);if(!w){u.push(g),c<i.length&&d.push(i[c]),c++;continue}const{type:x,pos:b,pattern:_}=w,D=`{-${x}}`;u.push(g.substring(0,b));const B=i[c],W=s[c+1];if(!W||!W.startsWith("}"))throw new Error(`{+${x}} syntax error: expected "}" after value`);const q=W.substring(1),{endIdx:L,endPos:Q}=Gt(s,c+1,1,_.slice(0,-1),D);let z,F="";if(L===c+1)z=q.substring(0,Q-1);else{z=q;for(let I=c+2;I<=L;I++)z+=String(i[I-1]??"")+(I<L?s[I]:s[I].substring(0,Q))}if(x==="if"||x==="unless"){const I=z.indexOf("{else}");I!==-1&&(F=z.substring(I+6),z=z.substring(0,I))}let Z;if(x==="each"){if(!Array.isArray(B)&&B!=null)throw new Error(`{+each} expects an array, got ${typeof B}`);Z=(B||[]).map((I,Y)=>Qe(z.trim(),I,Y,B||[],f))}else x==="if"?Z=B?{html:z.trim()}:{html:F.trim()}:x==="unless"&&(Z=B?{html:F.trim()}:{html:z.trim()});d.push(Z);const G=s[L].substring(Q+D.length);c=L,Xe(G)?(s=[...s.slice(0,L),G,...s.slice(L+1)],i=[...i.slice(0,L),...i.slice(L)]):(u.push(G),L<i.length&&d.push(i[L]),c=L+1)}for(;u.length<=d.length;)u.push("");return{strings:pe(u),values:d}}function Vt(s){const i=te.bind(s);function f(...u){if(qt(u[0])){const w=Ut(u[0],u.slice(1),f.wire);u=[w.strings,...w.values]}const d=u.slice(1).some(w=>w!=null&&typeof w!="string"),c=u[0].some(w=>fe.test(w));if(d&&c){let w=!1,x="";u[0].forEach((b,_,D)=>{if(fe.test(b)?(w=b.substring(b.match(fe).index).indexOf(">")===-1,x=w&&b.substring(b.indexOf(b.match(fe))).split(/\s/)[0].substr(1)):0<=b.indexOf(">")&&(w=!1,x=""),!w)return;const B=u[_+1];if(B!=null&&typeof B!="string"){const W=b.split(/\s/).pop().slice(0,-1);if(W.substring(0,2)==="on")throw new Error(`'on' is reserve for native elements. Change: "${W}" for "${x}" to something else`);if(W==="style")return;const q=It();he[q]={attrName:W,val:B,localName:x},u[_+1]=(typeof B=="function"?"fn-":"ob-")+q}})}const g=[u[0]];for(let w=1;w<u.length;w++){const x=u[w];qe(x)?g.push({html:x.value}):Array.isArray(x)?g.push(x.map(b=>qe(b)?{html:b.value}:typeof b=="string"?re(b):b)):g.push(x)}return i(...g)}return f.wire=function(...d){return te.wire(...d)},f.lite=function(...d){return te(...d)},f.raw=function(d){return Jt(d)},f}function Yt(s,i){const f=typeof i=="function"?i:()=>i,u=this.render,d=(...c)=>{i===void 0?(s.store=void 0,u(...c)):(s.store=f(),u(s.store,...c))};return this.render=d,d}function Kt(s){const i=s.this;new MutationObserver(u=>{if(!s.observe)return;if(u.filter(g=>g.type==="attributes").length>0){i.attrs=this.attachAttrs(this.attributes)||{},this.render();return}let c=this.textContent;s.innerHTML=this.innerHTML,i.attrs.template&&(i.attrs=this.attachAttrs(this.attributes)||{}),te.bind(s.shadow)``,i.wrappedContent=c,this.render()}).observe(this,{attributes:!0,childList:!0,subtree:!0})}function Qt(){this.identifier=Symbol(this.localName);const s=ne[this.identifier]={attrsToIgnore:{}};s.innerHTML=this.innerHTML;const i=s.this={element:this};i.wrappedContent=this.textContent,Kt.call(this,s),Object.getOwnPropertyNames(this.__proto__).filter(d=>!(d==="constructor"||d==="setup"||d==="render")).forEach(d=>{if(/^[A-Z]/.test(d)){let c;const g={},w=x=>{if(c!==void 0&&c.once)return c;if(c=this[d](x),c.text!==void 0&&typeof c.text=="string"?c={any:c.text,once:c.once}:c.html!==void 0&&typeof c.html=="string"&&(c={any:{html:c.html},once:c.once}),c.template)if(typeof c.template=="string"){g[c.template]||(g[c.template]=Te(c.template));const b=g[c.template](c.values||x);b&&b.html?c={any:{html:b.html},once:c.once}:c={any:b,once:c.once}}else if(typeof c.template=="object"&&typeof c.template.then=="function")c=Object.assign({},c,{any:c.template.then(b=>{let{template:_,values:D}=b;return!_&&typeof b=="string"&&(_=b,D={}),g[_]||(g[_]=Te(_)),Array.isArray(D)?c={any:D.map(g[_]),once:c.once}:c={any:g[_](D||x),once:c.once},c.any})});else throw new Error("unknow template type:"+typeof c.template+" | "+JSON.stringify(c.template));return c};te.define(d,w)}else i[d]=this[d].bind(i);delete this[d]});function f(){return"hyper-element: "+this.localName}Object.defineProperty(i,"toString",{value:f.bind(this),writable:!1}),s.shadow=this,s.Html=Vt(s.shadow),i.attrs=this.attachAttrs(this.attributes),i.dataset=this.getDataset();const u=this.render;this.render=(...d)=>{s.observe=!1,setTimeout(()=>{s.observe=!0},0),u.call(i,s.Html,...d),Object.getOwnPropertyNames(i.dataset).filter(c=>!this.dataset[c]).forEach(c=>{const g=i.dataset[c];_e.call(this,i.dataset,c.replace(/([A-Z])/g,w=>`-${w[0].toLowerCase()}`)),i.dataset[c]=g})},this.setup&&(s.teardown=this.setup.call(i,Yt.bind(this,i))),this.render()}class Xt extends HTMLElement{identifier;get innerShadow(){return ne[this.identifier].shadow.innerHTML}connectedCallback(){Qt.call(this)}addDataset(i,f){_e.call(this,i,f)}getDataset(){return Ft.call(this)}attachAttrs(i){return Zt.call(this,i)}attributeChangedCallback(i,f,u){const d=ne[this.identifier];if(!d)return;u!==null&&+u+""===u.trim()&&(u=+u);const{attrsToIgnore:c}=d,g=d.this;if(0<=i.indexOf("data-")){const w=i.slice(5);if(f===null)this.addDataset(g.dataset,w);else if(u===null){const x=w.replace(/-([a-z])/g,b=>b[1].toUpperCase());delete g.dataset[x]}}if(u!==g.attrs[i])if(u===null?delete g.attrs[i]:g.attrs[i]=u,c[i]){delete c[i];return}else this.render()}disconnectedCallback(){const i=ne[this.identifier];i.teardown&&i.teardown()}setup(i){}render(i,...f){}}console.info("hyper-element v1.0.3 by Brian Shannon (github.com/codemeasandwich)"),window.hyperElement=Xt})();
|
|
1
|
+
(function(j,H){var R=typeof window<"u"&&typeof document<"u",Z=typeof process<"u"&&process.versions&&process.versions.node;if(typeof module=="object"&&module.exports)module.exports=H(R);else if(typeof define=="function"&&define.amd)define(function(){return H(R)});else{var C=H(R);R&&(j.hyperElement=C.default,j.configureSSR=C.configureSSR,j.signal=C.signal,j.computed=C.computed,j.effect=C.effect,j.batch=C.batch,j.untracked=C.untracked,j.withOptions=C.withOptions,j.html=C.html,j.dom=C.dom)}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(j){"use strict";const H=/<+\w+[-]+\w/,R={},Z={};function C(){for(var s="",o="bcdfghjklmnpqrstvwxyz",f=0;f<15;f++)s+=o.charAt(Math.floor(Math.random()*o.length));return s}function k(s){return typeof s!="string"?s:s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ge=Symbol("safeHtml");function Ee(s){return{[Ge]:!0,value:s}}function F(s){return s&&s[Ge]===!0}const ie=1,W=2,P=4,ke=8,B=16,G=32,Q=64,Ae=128,xe=256,Te=512,je=1024,Ce=2048,Qe=1,oe=2,ce=3,le=8,_n=11,Ne=12,Oe=P|ie,Re=G|ie,Ve=new Set(["plaintext","script","style","textarea","title","xmp"]),Me=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),x=Object.freeze([]),et=Object.freeze({});class fe{constructor(o){this.type=o,this.parent=null}}class X extends fe{constructor(o){super(le),this.data=o}toString(){return`<!--${this.data}-->`}}class K extends fe{constructor(o){super(ce),this.data=o}toString(){return this.data}}class T extends fe{constructor(o,f=!1){super(Qe),this.name=o,this.xml=f,this.isStyled=!1,this.propFlags=null,this.props=et,this.children=x}toString(){const{xml:o,name:f,props:p,children:h}=this,e=h.length;let n=`<${f}`;for(const t in p){const r=p[t];r!=null&&(typeof r=="boolean"?r&&(n+=o?` ${t}=""`:` ${t}`):n+=` ${t}="${r}"`)}if(e){n+=">";for(let t=!o&&Ve.has(f),r=0;r<e;r++)n+=t?h[r].data:h[r];n+=`</${f}>`}else o?n+=" />":n+=Me.has(f)?">":`></${f}>`;return n}}class ae extends fe{constructor(){super(_n),this.name="#fragment",this.children=x}toString(){return this.children.join("")}}const tt=new WeakMap;class En extends Map{get(o){const f=super.get(o)?.deref();return f&&tt.get(f)}set(o,f,p){tt.set(f,p),super.set(o,new WeakRef(f))}}const $="\0",kn=`"${$}"`,An=`'${$}'`,xn=/\x00|<[^><\s]+/g,Tn=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,L=(s,o)=>(s.children===x&&(s.children=[]),s.children.push(o),o.parent=s,o),jn=(s,o,f)=>{s.props===et&&(s.props={}),s.props[o]=f},V=s=>{const o=[];for(;s.parent;)s.type===Qe&&s.name==="template"&&o.push(-1),o.push(s.parent.children.indexOf(s)),s=s.parent;return o},nt=(s,o)=>{do s=s.parent;while(o.has(s));return s};function rt(s){return(o,f,p)=>{const h=o.join($).replace(/^\s+/,""),e=new Set,n=[];let t=new ae,r=0,i=0,c=0,l=x;for(const u of h.matchAll(xn)){if(i>0){i--;continue}const a=u[0],d=u.index;if(r<d&&L(t,new K(h.slice(r,d))),a===$){t.name==="table"&&(t=L(t,new T("tbody",p)),e.add(t));const y=L(t,new X("\u25E6"));n.push(s(y,le,V(y),"",f[c++])),r=d+1}else if(a.startsWith("<!")){const y=h.indexOf(">",d+2);if(h.slice(y-2,y+1)==="-->"){const m=h.slice(d+4,y-2);m[0]==="!"&&L(t,new X(m.slice(1).replace(/!$/,"")))}r=y+1}else if(a.startsWith("</")){const y=h.indexOf(">",d+2);p&&t.name==="svg"&&(p=!1),t=nt(t,e),r=y+1}else{const y=d+a.length,m=h.indexOf(">",y),b=a.slice(1);let g=b;const w="+styled";let S=!1;if(p||(g=g.toLowerCase(),g.endsWith(w)&&(S=!0,g=g.slice(0,-w.length)),t.name==="table"&&(g==="tr"||g==="td")&&(t=L(t,new T("tbody",p)),e.add(t)),t.name==="tbody"&&g==="td"&&(t=L(t,new T("tr",p)),e.add(t))),t=L(t,new T(g,p?g!=="svg":!1)),t.isStyled=S,l=x,y<m){let v=!1;for(const[,_,O]of h.slice(y,m).matchAll(Tn))if(O===$||O===kn||O===An||(v=_.endsWith($))){const q=l===x?l=V(t):l,Y=v?_.slice(0,-1):_;n.push(s(t,oe,q,Y,f[c++])),Y==="style"&&(t.hasDynamicStyle=!0),v=!1,i++}else if(O&&O.includes($)){const Y=O.slice(1,-1).split($),_e=Y.length-1,mr=l===x?l=V(t):l;for(let Ze=0;Ze<_e;Ze++)n.push(s(t,Ne,mr,_,{parts:Y,holeIndex:Ze,holeCount:_e,hint:f[c++]})),i++}else if(jn(t,_,O?O.slice(1,-1):!0),t.isStyled&&!O){const q=_[0],Y=q==="@"||q==="?"||q===".",_e=_==="style"||_==="class"||_==="id"||_==="role"||_.startsWith("data-")||_.startsWith("aria-");!Y&&!_e&&(t.propFlags||(t.propFlags=[]),t.propFlags.push({name:_,static:!0}))}l=x}if(t.isStyled&&!t.props.style&&t.props.style!==""&&!t.hasDynamicStyle){const v=l===x?l=V(t):l;n.push(s(t,oe,v,"style",null))}r=m+1;const E=m>0&&h[m-1]==="/";if(p)E&&(t=t.parent);else if(E||Me.has(g))t=E?nt(t,e):t.parent;else if(g==="svg")p=!0;else if(Ve.has(g)){const v=h.indexOf(`</${b}>`,r),_=h.slice(r,v);_.trim()===$?(i++,n.push(s(t,ce,V(t),"",f[c++]))):L(t,new K(_)),t=t.parent,r=v+b.length+3,i++;continue}}}return r<h.length&&L(t,new K(h.slice(r))),[t,n]}}let A=null;const ue=[];let pe=0,$e=new Set;function st(s){let o=s;const f=new Set;return{get value(){return A&&f.add(A),o},set value(p){if(o!==p){o=p;for(const h of f)pe>0?$e.add(h):h()}},peek(){return o},subscribe(p){return f.add(p),()=>f.delete(p)}}}function it(s){let o,f=!0;const p=new Set,h=()=>{f=!0;for(const e of p)e()};return{get value(){if(A&&p.add(A),f){const e=A;A=h,ue.push(h);try{o=s()}finally{ue.pop(),A=e}f=!1}return o},peek(){if(f){const e=A;A=null;try{o=s()}finally{A=e}f=!1}return o}}}function ot(s){let o=null;const f=()=>{typeof o=="function"&&o();const p=A;A=f,ue.push(f);try{o=s()}finally{ue.pop(),A=p}};return f(),()=>{typeof o=="function"&&o()}}function ct(s){const o=A;A=null;try{return s()}finally{A=o}}function lt(s){pe++;try{s()}finally{if(pe--,pe===0){const o=$e;$e=new Set;for(const f of o)f()}}}function Cn(s,o){if(s==="template"&&o==="")return!0;if(+o+""===o.trim())return+o;const f=o.toLowerCase().trim();return f==="true"?!0:f==="false"?!1:f[0]==="["&&f.slice(-1)==="]"||f[0]==="{"&&f.slice(-1)==="}"?JSON.parse(o):o}function ft(s){return typeof s=="function"?ft(s()):typeof s=="string"?k(s):typeof s=="number"||typeof s=="boolean"?String(s):Array.isArray(s)?k(s.join(", ")):s!==null&&typeof s=="object"?k(JSON.stringify(s)):""}function Nn(s,o){let f=s;const p=/\{\+each\s+(\w+)\}([\s\S]*?)\{-each\}/g;f=f.replace(p,(t,r,i)=>{const c=o[r];return Array.isArray(c)?c.map((l,u)=>{let a=i;return a=a.replace(/\{@\}/g,u),a=a.replace(/\{\s*\.\.\.\s*\}/g,ft(l)),typeof l=="object"&&l!==null&&Object.keys(l).forEach(d=>{a=a.replace(new RegExp("\\{"+d+"\\}","g"),k(String(l[d])))}),a}).join(""):""});const h=/\{\+if\s+(\w+)\}([\s\S]*?)\{else\}([\s\S]*?)\{-if\}/g;f=f.replace(h,(t,r,i,c)=>o[r]?i:c);const e=/\{\+if\s+(\w+)\}([\s\S]*?)\{-if\}/g;f=f.replace(e,(t,r,i)=>o[r]?i:"");const n=/\{\+unless\s+(\w+)\}([\s\S]*?)\{-unless\}/g;return f=f.replace(n,(t,r,i)=>o[r]?"":i),f}function at(s){return s.some(o=>o.includes("{+each ")||o.includes("{+each{")||o.includes("{+if ")||o.includes("{+unless "))}function ut(s,o){return o.split(".").reduce((f,p)=>f?.[p],s)}function pt(s){const o=/\{(@|\s*\.\.\.\s*|\w+(?:\.\w+)*)\}/g,f=[],p=[];let h=0,e;for(;(e=o.exec(s))!==null;)f.push(s.substring(h,e.index)),p.push(e[1]),h=o.lastIndex;return f.push(s.substring(h)),{parts:f,props:p}}function On(s,o,f,p,h){let e=1;for(let n=o;n<s.length;n++){const t=s[n];let r=n===o?f:0;for(;r<t.length;){const i=t.indexOf(p,r),c=t.indexOf(h,r);if(c!==-1&&(i===-1||c<i)){if(--e===0)return{endIdx:n,endPos:c};r=c+h.length}else if(i!==-1)e++,r=i+p.length;else break}}throw new Error(`Unclosed ${p} block. Missing ${h}.`)}function de(s){const o=[...s];return o.raw=[...s],o}const dt=new WeakMap;function Le(s,o,f){if(s!==null&&typeof s=="object")return s;let p=dt.get(f);return p||(p={},dt.set(f,p)),p[o]||(p[o]={_value:s,_index:o}),p[o]._value=s,p[o]}function ht(s,o,f){return s==="@"?f:s.trim()==="..."?o:ut(o,s)}function yt(s,o,f,p,h){const e=/\{\+each\s*\{(\w+(?:\.\w+)*)\}\}([\s\S]*?)\{-each\}/g,n=e.test(s);if(e.lastIndex=0,n){const c=[];let l=s,u;for(;(u=e.exec(s))!==null;){const[g,w,S]=u,E=ut(o,w);if(!Array.isArray(E)){l=l.replace(g,"");continue}const v=E.map((_,O)=>yt(S.trim(),_,O,E,h));l=l.replace(g,`__NESTED_${c.length}__`),c.push(v)}const{parts:a,props:d}=pt(l),y=[],m=[];let b=0;for(let g=0;g<a.length;g++){let w=a[g],S;for(;S=w.match(/__NESTED_(\d+)__/);){const[E,v]=w.split(S[0]);y.push(E),m.push(c[parseInt(S[1],10)]),w=v||""}y.push(w),g<d.length&&m.push(ht(d[b++],o,f))}return h(Le(o,f,p),JSON.stringify(y))(de(y),...m)}const{parts:t,props:r}=pt(s);if(r.length===0)return h(Le(o,f,p),JSON.stringify([s]))(de([s]));const i=r.map(c=>ht(c,o,f));return h(Le(o,f,p),JSON.stringify(t))(de(t),...i)}function gt(s){const o=[{type:"each",pattern:"{+each "},{type:"if",pattern:"{+if "},{type:"unless",pattern:"{+unless "}];let f=null;for(const p of o){const h=s.indexOf(p.pattern);h!==-1&&(f===null||h<f.pos)&&(f={type:p.type,pos:h,pattern:p.pattern})}return f}function mt(s,o,f){const p=[],h=[];let e=0;for(;e<s.length;){const n=s[e],t=gt(n);if(!t){p.push(n),e<o.length&&h.push(o[e]),e++;continue}const{type:r,pos:i,pattern:c}=t,l=`{-${r}}`;p.push(n.substring(0,i));const u=o[e],a=s[e+1];if(!a||!a.startsWith("}"))throw new Error(`{+${r}} syntax error: expected "}" after value`);const d=a.substring(1),{endIdx:y,endPos:m}=On(s,e+1,1,c.slice(0,-1),l);let b,g="";if(y===e+1)b=d.substring(0,m-1);else{b=d;for(let v=e+2;v<=y;v++)b+=String(o[v-1]??"")+(v<y?s[v]:s[v].substring(0,m))}if(r==="if"||r==="unless"){const v=b.indexOf("{else}");v!==-1&&(g=b.substring(v+6),b=b.substring(0,v))}let w;const S=v=>v.replace(/^\s+/,"");if(r==="each"){if(!Array.isArray(u)&&u!=null)throw new Error(`{+each} expects an array, got ${typeof u}`);w=(u||[]).map((v,_)=>yt(S(b),v,_,u||[],f))}else r==="if"?w=u?{html:S(b)}:{html:S(g)}:r==="unless"&&(w=u?{html:S(g)}:{html:S(b)});h.push(w);const E=s[y].substring(m+l.length);e=y,gt(E)?(s=[...s.slice(0,y),E,...s.slice(y+1)],o=[...o.slice(0,y),...o.slice(y)]):(p.push(E),y<o.length&&h.push(o[y]),e=y+1)}for(;p.length<=h.length;)p.push("");return{strings:de(p),values:h}}var He,he,Pe,bt,ee,wt,St,ye,z,N,vt,I,br,U,_t,Et,te,ge,Ie,De,kt,At,xt,Tt,Fe,jt,Ct,Nt,me,Ot,Rn,We,be,Rt,Mt,se,wr,Sr,$t,Lt,Ht,we,Se,Pt,It,Dt,Ft,Wt,Bt,Kt,Ut,Yt,Xt,zt,Jt,Be,D,qt,Zt,Gt,Qt,Vt;if(j){var J=null;ee=function(e){J||(J=document.createElement("template")),J.innerHTML=e;const n=J.content;return J=J.cloneNode(!1),n},wt=function(e,n){return n.reduceRight((t,r)=>r<0?t.content:t.childNodes[r],e)},St=function(e,n,t,r){const i=r.parentNode,c=n.length;let l=e.length,u=c,a=0,d=0,y=null;for(;a<l||d<u;)if(l===a){const m=u<c?d?t(n[d-1],-0).nextSibling:t(n[u],0):r;for(;d<u;)i.insertBefore(t(n[d++],1),m)}else if(u===d)for(;a<l;)(!y||!y.has(e[a]))&&t(e[a],-1).remove(),a++;else if(e[a]===n[d])a++,d++;else if(e[l-1]===n[u-1])l--,u--;else if(e[a]===n[u-1]&&n[d]===e[l-1]){const m=t(e[--l],-0).nextSibling;i.insertBefore(t(n[d++],1),t(e[a++],-0).nextSibling),i.insertBefore(t(n[--u],1),m),e[l]=n[u]}else{if(!y){y=new Map;let b=d;for(;b<u;)y.set(n[b],b++)}const m=y.get(e[a])??-1;if(m<0)t(e[a++],-1).remove();else if(d<m&&m<u){let b=a,g=1;for(;++b<l&&b<u&&y.get(e[b])===m+g;)g++;if(g>m-d){const w=t(e[a],0);for(;d<m;)i.insertBefore(t(n[d++],1),w)}else i.replaceChild(t(n[d++],1),t(e[a++],-1))}else a++}return n};var en=!1,tn,N=Symbol("nodes"),nn=({firstChild:e,lastChild:n})=>{const t=tn||(tn=document.createRange());return t.setStartAfter(e),t.setEndAfter(n),t.deleteContents(),e};ye=function(e,n){return en&&e.nodeType===11?1/n<0?n?nn(e):e.lastChild:n?e.valueOf():e.firstChild:e};var Mn={get(){return this.firstChild.parentNode}},$n={value(e){nn(this).replaceWith(e)}},Ln={value(){const{parentNode:e}=this;if(e===this)this[N]===x&&(this[N]=[...this.childNodes]);else{if(e){let{firstChild:n,lastChild:t}=this;for(this[N]=[n];n!==t;)this[N].push(n=n.nextSibling)}this.replaceChildren(...this[N])}return this}};z=function(e){const n=document.createComment("<>"),t=document.createComment("</>");return e.replaceChildren(n,...e.childNodes,t),en=!0,Object.defineProperties(e,{[N]:{writable:!0,value:x},firstChild:{value:n},lastChild:{value:t},parentNode:Mn,valueOf:Ln,replaceWith:$n})},typeof DocumentFragment<"u"&&(z.prototype=DocumentFragment.prototype);var ne=Symbol("ref"),Ke=!1;Et=function(){const e=Ke;return Ke=!1,e};var rn=new WeakMap,Hn=(e,n)=>{let t=rn.get(e);return t?t.data=n:rn.set(e,t=document.createTextNode(n)),t},sn=new Map,Ue=e=>{let n=sn.get(e);return n||sn.set(e,n=cn(e)),n},on=e=>(n,t)=>{t==null?n.removeAttribute(e):n.setAttribute(e,t)},cn=e=>(n,t)=>{n[e]=t},Pn=e=>(n,t)=>{n.toggleAttribute(e,!!t)},In=({dataset:e},n)=>{for(const[t,r]of Object.entries(n))r==null?delete e[t]:e[t]=r},ln=new WeakMap,Dn=(e,n,t,r)=>(i,c)=>{let l=ln.get(i);l||ln.set(i,l=new Map);let u=l.get(e);if(u||l.set(e,u={values:new Array(r),remaining:r}),u.values[t]=c,--u.remaining===0){let a=n[0];for(let d=0;d<r;d++)a+=(u.values[d]??"")+n[d+1];a===""?i.removeAttribute(e):i.setAttribute(e,a),u.remaining=r}},Fn=(e,n)=>{if(n==null)e.removeAttribute("style");else if(typeof n=="object")for(const[t,r]of Object.entries(n))r==null?e.style.removeProperty(t):e.style.setProperty(t,r);else e.setAttribute("style",n)},Wn=(e,n,t)=>t?(r,i)=>{const c=r[n];c?.length&&r.removeEventListener(e,...c),i&&r.addEventListener(e,...i),r[n]=i}:(r,i)=>{const c=r[n];c&&r.removeEventListener(e,c),i&&r.addEventListener(e,i),r[n]=i},Bn=(e,n)=>e.map(t=>typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):t&&typeof t=="object"&&t.__unsafe?z(ee(t.value,n)):t),Kn=e=>(n,t)=>{const r=Bn(t,e);n[N]=St(n[N]||x,r,ye,n)},fn=(e,n)=>{const t=typeof n=="object"?n??e:Hn(e,n),r=e[N]??e;t!==r&&r.replaceWith(ye(e[N]=t,1))},Un=e=>(n,t)=>{if(t&&typeof t=="object"&&t.__unsafe){const r=t.value,i=n[ne]??(n[ne]={});i.v!==r&&(i.f=z(ee(r,e)),i.v=r),t=i.f}fn(n,t)},Yn=e=>(n,t)=>{const r=t&&typeof t=="object"&&t.__unsafe?t.value:t,i=n[ne]??(n[ne]={});i.v!==r&&(i.f=z(ee(r,e)),i.v=r),fn(n,i.f)};vt=function(e,n,t,r,i){switch(n){case Ne:{const{parts:c,holeIndex:l,holeCount:u}=i;return[t,Dn(r,c,l,u),Ce]}case le:return Array.isArray(i)?[t,Kn(e.xml),Oe]:i&&typeof i=="object"&&i.__unsafe?[t,Yn(e.xml),je]:[t,Un(e.xml),P];case ce:return[t,Ue("textContent"),xe];case oe:switch(r.charAt(0)){case"@":{const c=Array.isArray(i);return[t,Wn(r.slice(1),Symbol(r),c),c?Re:G]}case"?":return[t,Pn(r.slice(1)),Te];case".":return r==="..."?[t,(c,l)=>{for(const[u,a]of Object.entries(l))on(u)(c,a)},Ae]:[t,cn(r.slice(1)),B];default:return r==="data"&&!/^object$/i.test(e.name)?[t,In,ke]:r==="key"?(Ke=!0,[t,!0,Q]):r==="ref"?[t,Ue(ne),B]:r.startsWith("on")?[t,Ue(r.toLowerCase()),B]:r==="style"?e.isStyled?[t,Ot(e.name,e.propFlags),W]:[t,Fn,W]:[t,on(r),W]}}};var U=e=>ye(e.n||e.valueOf(),1),an=(e,n)=>{const t=[],r=e.length,i=n.length;for(let c,l,u=0,a=0;a<i;a++)c=n[a],t[a]=u<r&&(l=e[u++]).t===c.t?(n[a]=l).update(c):c.valueOf();return t},Xn=(e,n)=>e.t[2]?.get(n)?.update(e)??e.valueOf(),zn=(e,n)=>(e.t===n.t?e.update(n):(e.n.replaceWith(U(n)),e=n),e);I=class{constructor(e,n){this.t=e,this.v=n,this.n=null,this.k=-1}valueOf(){const[e,n,t]=this.t,r=document.importNode(e,!0),i=this.v;let c=n.length,l=x,u,a;if(c>0)for(l=n.slice(0);c--;){const[b,g,w]=n[c],S=c<i.length?i[c]:void 0;a!==b&&(u=wt(r,b),a=b);let E=!0;w&ie?w&P&&(E=!1,S.length&&g(u,S[0]instanceof I?an(x,S):S)):w&P&&S instanceof I&&(E=!1,g(u,U(S))),E&&(w===Q?this.k=c:g(u,S)),l[c]=[w,g,S,u]}const{childNodes:d}=r,y=d.length,m=y===1?d[0]:y?z(r):r;return this.v=l,this.n=m,this.k>=0&&t&&t.set(l[this.k][2],m,this),m}update(e){const n=this.k,t=this.v,r=e.v;if(n>=0&&t[n][2]!==r[n])return Xn(e,r[n]);let{length:i}=t;for(;i--;){const c=t[i],[l,u,a]=c;if(l===Q)continue;let d=i<r.length?r[i]:void 0,y=d;if(l&ie){if(l&P)d.length&&d[0]instanceof I&&(y=an(a,d));else if(l&G&&d[0]===a[0])continue}else l&P&&a instanceof I&&(d=zn(a,d),y=d.n);d!==a&&(c[2]=d,u(c[3],y))}return this.n}};var Jn=rt(vt),un=new WeakMap,pn=new WeakMap,dn=new WeakMap;te=function(e,...n){let t=dn.get(e);return t||(t=Jn(e,n,!1),t.push(Et()?new En:null),t[0]=ee(t[0].toString()),dn.set(e,t)),new I(t,n)},ge=function(e){return(n,...t)=>{const r=te(n,...t),i=un.get(e);if(!i||i.t!==r.t){const c=U(r);e.replaceChildren(c),un.set(e,r)}else i.update(r);return e}},Ie=function(e,n=""){let t=pn.get(e);return t||(t=new Map,pn.set(e,t)),(r,...i)=>{let c=t.get(n);if(!c||c.tpl!==r){const l=te(r,...i);return c={hole:l,tpl:r},t.set(n,c),l}return new I(c.hole.t,i)}};var Rn="+styled",Ye=new WeakMap,hn=null;De=function(e){hn=e},kt=function(){return hn},At=function(e,n,t,r,i){Ye.set(e,{styled:n,ctx:t,store:r,colors:i})},xt=function(e){Ye.delete(e)},Tt=function(e){return Ye.get(e)},Nt=function(e,n){const t={};for(const[r,i]of Object.entries(e))if(typeof i=="string")if(n[i])t[r]=n[i];else{let c=i;for(const[l,u]of Object.entries(n))c=c.replace(new RegExp(`\\b${l}\\b`,"g"),u);t[r]=c}else t[r]=i;return t},me=function(e){return e&&typeof e=="object"&&"base"in e},Fe=function(e,n,t,r){const{styled:i,ctx:c,colors:l}=e,u=e.store??c?.store;if(!i||!Array.isArray(i)||!i[0])return t&&typeof t=="object"&&!t.__unsafe?t:null;const[a,d]=i;let y={},m=!1;const b=a[n];b&&(m=!0,me(b)?y={...b.base}:y={...b});for(const g of Object.keys(a))g.includes(",")&&g.split(",").map(S=>S.trim()).includes(n)&&(m=!0,y={...y,...a[g]});if(r&&r.length>0&&b&&me(b))for(const g of r)g.active&&b[g.name]&&(m=!0,y={...y,...b[g.name]});if(d&&typeof d[n]=="function"){const g=d[n](t,c,u);g&&typeof g=="object"&&(m=!0,y={...y,...g})}else if(t&&typeof t=="object"&&!t.__unsafe)if(b&&me(b)){const g={};for(const[w,S]of Object.entries(t))typeof S=="boolean"?S&&b[w]&&(m=!0,y={...y,...b[w]}):g[w]=S;Object.keys(g).length>0&&(m=!0,y={...y,...g})}else m=!0,y={...y,...t};return l&&Object.keys(l).length>0&&(y=Nt(y,l)),m?y:null},jt=function(e,n,t,r){const i=Tt(e);return i?Fe(i,n,t,r):t&&typeof t=="object"&&!t.__unsafe?t:null},Ct=function(e,n){if(!(!n||typeof n!="object"))for(const[t,r]of Object.entries(n))if(r==null||r==="")e.style.removeProperty(t.replace(/([A-Z])/g,"-$1").toLowerCase());else{const i=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(i,String(r))}};var Ot=(e,n)=>(t,r)=>{const i=kt(),c=n?n.map(u=>({name:u.name,active:!0})):null,l=jt(i,e,r,c);l&&Ct(t,l)};We=function(e){if(/\{\+(if|each|unless)\s/.test(e))return function(l){if(typeof l!="object")throw new Error("Templates must be passed an object. You passed "+JSON.stringify(l));let u=Nn(e,l);return u=u.replace(/\{(\w+)\}/g,(a,d)=>l[d]!=null?k(String(l[d])):""),{html:u}};const t=/(\{[\w]+\})/g,r=e.split(t).reduce((c,l)=>(l[0]==="{"&&l.slice(-1)==="}"?c.keys.push(l.slice(1,-1)):c.markup.push(l),c),{markup:[],keys:[]});r.id=":"+r.markup.join().trim();function i(c){const l=[r.markup,...r.keys.map(u=>c[u]!=null?c[u]:"")];return l.raw={value:r.markup},l}return function(l){if(typeof l!="object")throw new Error("Templates must be passed an object to be populated with. You passed "+JSON.stringify(l)+" to "+r.id);return Ie(l,r.id)(...i(l))}},be=function(e,n){const t=n.replace(/-([a-z])/g,r=>r[1].toUpperCase());Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>Cn(t,this.dataset[t]),set:r=>{R[this.identifier].attrsToIgnore["data-"+n]=!0,typeof r=="string"?this.dataset[t]=r:this.dataset[t]=JSON.stringify(r)}})},Rt=function(){const e={};return Object.keys(this.dataset).forEach(n=>be.call(this,e,n.replace(/([A-Z])/g,t=>`-${t[0].toLowerCase()}`))),e},Mt=function(e){const n={};for(let t=0;t<e.length;t++){const{value:r,name:i}=e[t];if(i==="template"&&!r){const c=R[this.identifier];c.Html.template=We(c.innerHTML),n[i]=!0}else(r.substr(0,3)==="fn-"||r.substr(0,3)==="ob-")&&Z[r.substr(3)]&&Z[r.substr(3)].localName===this.localName?n[i]=Z[r.substr(3)].val:+r+""===(r+"").trim()?n[i]=+r:n[i]=r}return n},_t=function(e){const n=ge(e);function t(...r){if(at(r[0])){const u=mt(r[0],r.slice(1),t.wire);r=[u.strings,...u.values]}const i=r.slice(1).some(u=>u!=null&&typeof u!="string"),c=r[0].some(u=>H.test(u));if(i&&c){let u=!1,a="";r[0].forEach((d,y,m)=>{if(H.test(d)?(u=d.substring(d.match(H).index).indexOf(">")===-1,a=u&&d.substring(d.indexOf(d.match(H))).split(/\s/)[0].substr(1)):0<=d.indexOf(">")&&(u=!1,a=""),!u)return;const b=r[y+1];if(b!=null&&typeof b!="string"){const g=d.split(/\s/).pop().slice(0,-1);if(g.substring(0,2)==="on")throw new Error(`'on' is reserve for native elements. Change: "${g}" for "${a}" to something else`);if(g==="style")return;const w=C();Z[w]={attrName:g,val:b,localName:a},r[y+1]=(typeof b=="function"?"fn-":"ob-")+w}})}const l=[r[0]];for(let u=1;u<r.length;u++){let a=r[u];if(a&&typeof a=="object"&&!Array.isArray(a)&&!F(a)){const d=Object.keys(a);if(d.length===1&&/^[A-Z]/.test(d[0])){const y=d[0],m=a[y];t._fragments&&t._fragments[y]&&(a=t._fragments[y](m))}}F(a)?l.push({__unsafe:!0,value:a.value}):a&&typeof a=="object"&&a.__unsafe?l.push(a):a&&typeof a=="object"&&a.html!==void 0?l.push({__unsafe:!0,value:a.html}):Array.isArray(a)?l.push(a.map(d=>F(d)?{__unsafe:!0,value:d.value}:d)):l.push(a)}return n(...l)}return t._fragments=null,t.wire=function(i,c=""){return Ie(i,c)},t.raw=function(i){return Ee(i)},t.lite=function(i,...c){return i&&i.raw?te(i,...c):ge(i)},t},Ht=function(e){const n=e.tagName;let t=0,r=e.previousElementSibling;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t},we=function(e,n){if(e===n)return"";const t=[];let r=e;for(;r&&r!==n&&r.parentElement;){const i=r.tagName,c=Ht(r);t.unshift(`${i}:${c}`),r=r.parentElement}return t.join("/")},Se=function(e,n){if(!e)return n;const t=e.split("/");let r=n;for(const i of t){const[c,l]=i.split(":"),u=parseInt(l,10),a=Array.from(r.children).filter(d=>d.tagName===c);if(u>=a.length)return console.warn(`[hyper-element SSR] Could not match path segment "${i}" - found ${a.length} ${c} elements, needed index ${u}`),null;r=a[u]}return r},Pt=function(e,n,t){let r=e.buffer.get(n);r||(r=[],e.buffer.set(n,r)),r.push(t)},It=function(e,n){return e.buffer.get(n)||[]},Dt=function(e,n){e.buffer.delete(n)};var M=null;$t=function(){M||(M=document.createElement("div"),M.id="hyper-element-ssr-indicator",M.innerHTML="SSR Capture Active",M.style.cssText=`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 10px;
|
|
4
|
+
right: 10px;
|
|
5
|
+
background: #ff9800;
|
|
6
|
+
color: white;
|
|
7
|
+
padding: 8px 16px;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
font-family: sans-serif;
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
z-index: 999999;
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
`,document.body?document.body.appendChild(M):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(M)},{once:!0}))},Lt=function(){M&&(M.remove(),M=null)},Ft=function(e){const n=e.tagName.toLowerCase();return n.includes("-")?!customElements.get(n):!1},Wt=function(e){let n=e;for(;n&&n!==document.body;){if(Ft(n))return n;n=n.parentElement}return null},Bt=function(e){const n={type:e.type,bubbles:e.bubbles,cancelable:e.cancelable};if(e instanceof MouseEvent&&(n.clientX=e.clientX,n.clientY=e.clientY,n.button=e.button,n.buttons=e.buttons),e instanceof KeyboardEvent&&(n.key=e.key,n.code=e.code,n.ctrlKey=e.ctrlKey,n.shiftKey=e.shiftKey,n.altKey=e.altKey,n.metaKey=e.metaKey),e.type==="input"||e.type==="change"){const t=e.target;t.type==="checkbox"||t.type==="radio"?n.checked=t.checked:n.value=t.value}return e instanceof TouchEvent&&e.touches&&(n.touches=Array.from(e.touches).map(t=>({clientX:t.clientX,clientY:t.clientY,identifier:t.identifier}))),n},Kt=function(e,n){const t=n.elementStates.get(e)||{scrollPositions:new Map,checkedStates:new Map};e.querySelectorAll("*").forEach(i=>{if(i.scrollTop>0||i.scrollLeft>0){const c=we(i,e);t.scrollPositions.set(c,{scrollTop:i.scrollTop,scrollLeft:i.scrollLeft})}}),n.elementStates.set(e,t)},Ut=function(e,n,t){if(e.type==="checkbox"||e.type==="radio"){const r=t.elementStates.get(n)||{scrollPositions:new Map,checkedStates:new Map},i=we(e,n);r.checkedStates.set(i,e.checked),t.elementStates.set(n,r)}},Yt=function(e,n){if(!n.captureActive||e._hyperElementReplayed)return;const t=e.target;if(!t||!t.tagName)return;const r=Wt(t);if(!r)return;const i=r.tagName.toLowerCase();if(n.registeredTags.has(i))return;const c=we(t,r),l={type:e.type,targetPath:c,timestamp:Date.now(),detail:Bt(e)};Pt(n,r,l),["scroll","focus","blur"].includes(e.type)&&Kt(r,n),(e.type==="change"||e.type==="click")&&Ut(t,r,n)},zt=function(e){const n=t=>Yt(t,e);e.config.events.forEach(t=>{document.addEventListener(t,n,{capture:!0,passive:!0})}),e._captureHandler=n},Zt=function(e){const{type:n,detail:t}=e;let r=Event,i={bubbles:t.bubbles??!0,cancelable:t.cancelable??!0};["click","dblclick","mousedown","mouseup","mousemove"].includes(n)?(r=MouseEvent,Object.assign(i,{clientX:t.clientX,clientY:t.clientY,button:t.button,buttons:t.buttons})):["keydown","keyup","keypress"].includes(n)?(r=KeyboardEvent,Object.assign(i,{key:t.key,code:t.code,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey})):n==="input"&&(r=InputEvent,Object.assign(i,{inputType:"insertText",data:t.value}));const c=new r(n,i);return c._hyperElementReplayed=!0,c},Xt=function(e,n){const t=n.elementStates.get(e);t&&(t.scrollPositions&&t.scrollPositions.forEach((r,i)=>{const c=Se(i,e);c&&(c.scrollTop=r.scrollTop,c.scrollLeft=r.scrollLeft)}),t.checkedStates&&t.checkedStates.forEach((r,i)=>{const c=Se(i,e);c&&(c.type==="checkbox"||c.type==="radio")&&(c.checked=r)}),n.elementStates.delete(e))},Jt=function(e,n,t,r){let i=It(n,e);if(t){const c=t(i);Array.isArray(c)?i=c:c!==void 0&&console.warn("[hyper-element SSR] onBeforeHydrate must return an array")}i.sort((c,l)=>c.timestamp-l.timestamp),i.forEach(c=>{const l=Se(c.targetPath,e);if(!l){console.warn(`[hyper-element SSR] Could not replay event "${c.type}" - target path "${c.targetPath}" not found after hydration`);return}c.detail.value!==void 0&&(l.value=c.detail.value),c.detail.checked!==void 0&&(l.checked=c.detail.checked);const u=Zt(c);l.dispatchEvent(u)}),Xt(e,n),Dt(n,e),r&&r()};var qn=["click","dblclick","input","change","submit","keydown","keyup","keypress","focus","blur","focusin","focusout","touchstart","touchend","touchmove","touchcancel"],D={config:{events:[...qn],devMode:!1},buffer:new Map,elementStates:new WeakMap,captureActive:!1,registeredTags:new Set};Pe=function(e={}){Array.isArray(e.events)&&(D.config.events=e.events),e.devMode!==void 0&&(D.config.devMode=e.devMode,e.devMode?$t():Lt())},Be=function(){D.captureActive||(D.captureActive=!0,zt(D))},qt=function(e){D.registeredTags.add(e.toLowerCase())},typeof document<"u"&&Be(),Gt=function(e,n){const t=typeof n=="function"?n:()=>n,r=this._baseRender||this.render;this._baseRender=r;const i=(...c)=>{n===void 0?(e.store=void 0,r(...c)):(e.store=t(),r(e.store,...c))};return this.render=i,this._onNextInitialized?i():this._onNextInitialized=!0,i},Qt=function(e){const n=e.this,t=this,r=new MutationObserver(i=>{if(!e.observe)return;const c=i.filter(u=>u.type==="attributes");if(c.length>0){c.forEach(u=>{const a=u.attributeName;if(a.startsWith("data-")){const d=a.slice(5),y=d.replace(/-([a-z])/g,m=>m[1].toUpperCase());t.hasAttribute(a)?y in n.dataset||t.addDataset(n.dataset,d):delete n.dataset[y]}}),n.attrs=t.attachAttrs(t.attributes)||{},t.render();return}let l=t.textContent;e.innerHTML=t.innerHTML,n.attrs.template&&(n.attrs=t.attachAttrs(t.attributes)||{}),ge(e.shadow)``,n.wrappedContent=l,t.render()});e.mutationObserver=r,r.observe(t,{attributes:!0,childList:!0,subtree:!0})},se=function(e,n,t,r){if(e.text!==void 0){if(typeof e.text=="string")return e.text;if(e.text&&typeof e.text.then=="function")return e.text.then(i=>{e.text=i,r&&r()}),e.placeholder!==void 0?e.placeholder:""}if(e.html!==void 0){if(typeof e.html=="string")return{__unsafe:!0,value:e.html};if(e.html&&typeof e.html.then=="function")return e.html.then(i=>{e.html=i,r&&r()}),e.placeholder!==void 0?e.placeholder:""}if(e.template)if(typeof e.template=="string"){t[e.template]||(t[e.template]=We(e.template));const i=e.values||n;if(Array.isArray(i))return{__unsafe:!0,value:i.map(t[e.template]).map(a=>{if(a&&a.html)return a.html;const d=U(a);if(d.nodeType===11){const y=document.createElement("div");return y.appendChild(d.cloneNode(!0)),y.innerHTML}return d.outerHTML||d.textContent}).join("")};const c=t[e.template](i);if(c&&c.html)return{__unsafe:!0,value:c.html};if(c instanceof I){const l=U(c);if(l.nodeType===11){const u=document.createElement("div");return u.appendChild(l.cloneNode(!0)),{__unsafe:!0,value:u.innerHTML}}return{__unsafe:!0,value:l.outerHTML||l.textContent}}return c}else{if(typeof e.template=="object"&&typeof e.template.then=="function")return e.template.then(i=>{let{template:c,values:l}=i;!c&&typeof i=="string"&&(c=i,l={}),e.template=c,e.values=l,r&&r()}),e.placeholder!==void 0?e.placeholder:"";throw new Error("unknow template type:"+typeof e.template+" | "+JSON.stringify(e.template))}return e.any!==void 0?e.any&&typeof e.any.then=="function"?(e.any.then(i=>{e.any=i,r&&r()}),e.placeholder!==void 0?e.placeholder:""):e.any:e},Vt=function(){Be(),this.identifier=Symbol(this.localName);const e=R[this.identifier]={attrsToIgnore:{}};e.innerHTML=this.innerHTML;const n=e.this={element:this};n.wrappedContent=this.textContent;const t={};e.observe=!0,Qt.call(this,e),Object.getOwnPropertyNames(this.__proto__).filter(l=>!(l==="constructor"||l==="setup"||l==="render")).forEach(l=>{if(/^[A-Z]/.test(l)){const u={};t[l]=a=>{if(t[l]._cached!==void 0)return t[l]._cached;let d;t[l]._asyncResult?d=t[l]._asyncResult:d=this[l](a);const y=d.text&&typeof d.text.then=="function"||d.html&&typeof d.html.then=="function"||d.any&&typeof d.any.then=="function"||d.template&&typeof d.template.then=="function";y&&(t[l]._asyncResult=d);const b=se(d,a,u,()=>{this.render()});return d.once&&!y&&(t[l]._cached=b),!y&&t[l]._asyncResult&&delete t[l]._asyncResult,b}}else n[l]=this[l].bind(n);delete this[l]}),e.fragments=t;function r(){return"hyper-element: "+this.localName}Object.defineProperty(n,"toString",{value:r.bind(this),writable:!1}),e.shadow=this,e.shadow.__hyperInstance=this,e.Html=_t(e.shadow),e.Html._fragments=t,n.attrs=this.attachAttrs(this.attributes),n.dataset=this.getDataset();const i=this.constructor.__styledConfig;i?.styled&&At(this,i.styled,n,null,i.colors);const c=this.render;this.render=(...l)=>{e.observe=!1,De(this),c.call(n,e.Html,...l),De(null),e.mutationObserver?.takeRecords(),e.observe=!0,Object.getOwnPropertyNames(n.dataset).filter(u=>!this.dataset[u]).forEach(u=>{const a=n.dataset[u];be.call(this,n.dataset,u.replace(/([A-Z])/g,d=>`-${d[0].toLowerCase()}`)),n.dataset[u]=a})},this.setup&&(e.teardown=this.setup.call(n,Gt.bind(this,n))),qt(this.localName),this.render(),queueMicrotask(()=>{Jt(this,D,this.onBeforeHydrate?.bind(n),this.onAfterHydrate?.bind(n))})},He=class extends HTMLElement{identifier;get innerShadow(){return R[this.identifier].shadow.innerHTML}connectedCallback(){Vt.call(this)}addDataset(e,n){be.call(this,e,n)}getDataset(){return Rt.call(this)}attachAttrs(e){return Mt.call(this,e)}attributeChangedCallback(e,n,t){}disconnectedCallback(){const e=R[this.identifier];e.teardown&&e.teardown(),xt(this)}setup(e){}onBeforeHydrate(e){return e}onAfterHydrate(){}render(e,...n){}},he=function(e,n){let t=null;if(typeof e=="string"?t=e:n=e,typeof n=="function"&&(n={render:n}),!n||typeof n!="object")throw new Error("hyperElement: definition must be an object or render function");const{setup:r,render:i,onBeforeHydrate:c,onAfterHydrate:l,...u}=n;if(!i||typeof i!="function")throw new Error("hyperElement: render function is required");class a extends He{}r&&(a.prototype.setup=function(d){return r(this,d)}),a.prototype.render=function(d,...y){return i(d,this,...y)},c&&(a.prototype.onBeforeHydrate=function(d){return c(this,d)}),l&&(a.prototype.onAfterHydrate=function(){return l(this)});for(const[d,y]of Object.entries(u))typeof y=="function"&&(a.prototype[d]=function(...m){return y(this,...m)});return(n.styled||n.__options)&&(a.__styledConfig={styled:n.styled||null,colors:n.__options?.colors||null}),t&&customElements.define(t,a),a},bt=function(e={}){return function(t,r){let i=null,c=null;return typeof t=="string"?(i=t,c=r):c=t,typeof c=="function"&&(c={render:c}),c&&typeof c=="object"&&(c.__options=e),i?he(i,c):he(c)}}}let yn=null;function Zn(s){yn=s}function Gn(){return yn}function gn(s){return!s||typeof s!="object"?"":Object.entries(s).filter(([,o])=>o!=null).map(([o,f])=>`${o.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${f}`).join("; ")}const Qn=s=>o=>o==null?null:k(String(o)),mn=s=>s==null?null:typeof s=="object"?gn(s):k(String(s)),Vn=(s,o)=>f=>{const p=Gn();if(!p||!p.styled)return mn(f);const h={styled:p.styled,ctx:{attrs:p.attrs,store:p.store},store:p.store,colors:p.colors||null},e=o?o.map(t=>({name:t.name,active:!0})):[],n=Fe(h,s,f,e);return n?gn(n):null},er=s=>o=>o?!0:null,tr=()=>()=>null,Xe=()=>()=>null,nr=s=>{if(!s||typeof s!="object")return{};const o={};for(const[f,p]of Object.entries(s))p!=null&&(o[`data-${f}`]=k(String(p)));return o},bn=s=>s==null?"":typeof s=="object"&&s.__unsafe?s.value:k(String(s)),rr=s=>Array.isArray(s)?s.map(o=>o==null?"":typeof o=="object"&&o.__unsafe?o.value:typeof o=="string"||typeof o=="number"?k(String(o)):String(o)).join(""):bn(s),sr=s=>s&&typeof s=="object"&&s.__unsafe?s.value:String(s??""),ir=s=>s==null?"":k(String(s)),or=(s,o,f)=>p=>({value:k(String(p??"")),parts:s,holeIndex:o,holeCount:f});function cr(s,o,f,p,h){switch(o){case Ne:{const{parts:e,holeIndex:n,holeCount:t}=h;return[f,or(e,n,t),Ce,p]}case le:return Array.isArray(h)?[f,rr,Oe,null]:h&&typeof h=="object"&&h.__unsafe?[f,sr,je,null]:[f,bn,P,null];case ce:return[f,ir,xe,null];case oe:switch(p.charAt(0)){case"@":{const e=Array.isArray(h);return[f,tr(),e?Re:G,null]}case"?":{const e=p.slice(1);return[f,er(e),Te,e]}case".":return p==="..."?[f,e=>{const n={};for(const[t,r]of Object.entries(e||{}))r!=null&&(n[t]=k(String(r)));return n},Ae,null]:[f,Xe(),B,null];default:return p==="data"&&!/^object$/i.test(s.name)?[f,nr,ke,"data"]:p==="key"?[f,()=>null,Q,null]:p==="ref"?[f,Xe(),B,null]:p.startsWith("on")?[f,Xe(),B,null]:p==="style"?s.isStyled?[f,Vn(s.name,s.propFlags),W,"style"]:[f,mn,W,"style"]:[f,Qn(p),W,p]}}}const lr=rt(cr),wn=new WeakMap;function ze(s){if(s instanceof X){const o=new X(s.data);return o.parent=null,o}if(s instanceof K){const o=new K(s.data);return o.parent=null,o}if(s instanceof T){const o=new T(s.name,s.xml);return o.props={...s.props},o.isStyled=s.isStyled,o.propFlags=s.propFlags,s.children&&s.children.length>0&&(o.children=s.children.map(f=>{const p=ze(f);return p.parent=o,p})),o}if(s instanceof ae){const o=new ae;return s.children&&s.children.length>0&&(o.children=s.children.map(f=>{const p=ze(f);return p.parent=o,p})),o}}function fr(s,o){let f=s;for(let p=o.length-1;p>=0;p--){const h=o[p];h!==-1&&f.children&&f.children[h]!==void 0&&(f=f.children[h])}return f}function ar(s,o,f){for(let p=0;p<o.length;p++){const[h,e,n,t]=o[p],r=f[p],i=fr(s,h);switch(n){case P:case Oe:case je:{const c=e(r);i instanceof X&&(i._ssrContent=c);break}case xe:{if(i instanceof T){const c=e(r);i.children=[new K(c)]}break}case W:{if(i instanceof T&&t){const c=e(r);c==null?delete i.props[t]:i.props[t]=c}break}case Te:{i instanceof T&&t&&(e(r)?i.props[t]=!0:delete i.props[t]);break}case ke:{if(i instanceof T){const c=e(r);Object.assign(i.props,c)}break}case Ae:{if(i instanceof T&&typeof e=="function"){const c=e(r);c&&typeof c=="object"&&Object.assign(i.props,c)}break}case Ce:{if(i instanceof T&&t){const c=e(r),l=`_template_${t}`;if(i[l]||(i[l]={values:new Array(c.holeCount),parts:c.parts,remaining:c.holeCount}),i[l].values[c.holeIndex]=c.value,i[l].remaining--,i[l].remaining===0){const{parts:u,values:a}=i[l];let d=u[0];for(let y=0;y<a.length;y++)d+=a[y]+u[y+1];i.props[t]=d}}break}case G:case Re:case B:case Q:break}}return s}function Je(s){if(s instanceof X)return s._ssrContent!==void 0?s._ssrContent:s.toString();if(s instanceof K)return s.toString();if(s instanceof T){const{xml:o,name:f,props:p,children:h}=s,e=h.length;let n=`<${f}`;for(const t in p){const r=p[t];r!=null&&(typeof r=="boolean"?r&&(n+=o?` ${t}=""`:` ${t}`):n+=` ${t}="${r}"`)}if(e){n+=">";for(let t=0;t<e;t++)n+=Je(h[t]);n+=`</${f}>`}else o?n+=" />":n+=Me.has(f)?">":`></${f}>`;return n}if(s instanceof ae)return s.children.length===0?"":s.children.map(o=>Je(o)).join("")}function re(s,o,f=!1){let p=wn.get(s);p||(p=lr(s,o,f),wn.set(s,p));const[h,e]=p,n=ze(h);return ar(n,e,o),Je(n)}function Sn(s=!1){return(o,...f)=>re(o,f,s)}const ur=Sn(!1);function pr(s,o=""){return(f,...p)=>re(f,p,!1)}function se(s){return!s||typeof s!="object"?s:s.text!==void 0?k(String(s.text)):s.html!==void 0?{__unsafe:!0,value:s.html}:s.any!==void 0?s.any:s.template!==void 0?{__unsafe:!0,value:s.template}:F(s)?{__unsafe:!0,value:s.value}:s}function vn(s={}){Zn(s);const o=[];function f(h){return F(h)?{__unsafe:!0,value:h.value}:h&&typeof h=="object"&&h.__unsafe?h:h&&typeof h=="object"&&h.html!==void 0?{__unsafe:!0,value:h.html}:Array.isArray(h)?h.map(e=>F(e)?{__unsafe:!0,value:e.value}:typeof e=="string"?{__unsafe:!0,value:e}:e):h}function p(...h){if(at(h[0])){const r=mt(h[0],h.slice(1),p.wire);h=[r.strings,...r.values]}const e=[h[0]],n=[];for(let r=1;r<h.length;r++){let i=h[r];if(i&&typeof i=="object"&&!Array.isArray(i)&&!F(i)&&!i.__unsafe){const c=Object.keys(i);if(c.length===1&&/^[A-Z]/.test(c[0])){const l=c[0],u=i[l];if(s.fragments&&s.fragments[l])if(i=s.fragments[l](u),i&&typeof i.then=="function"){const a=`__SSR_FRAG_${o.length}__`;o.push({id:a,promise:i.then(se)}),n.push(a),i=a}else i=se(i)}}e.push(f(i))}const t=re(e[0],e.slice(1),!1);return o.length>0?Promise.all(o.map(r=>r.promise)).then(r=>{let i=t;for(let c=0;c<o.length;c++){const l=o[c].id;let u=r[c];u&&typeof u=="object"&&u.__unsafe&&(u=u.value),i=i.replace(l,u||"")}return o.length=0,i}):t}return p._context=s,p.wire=function(e,n=""){return pr(e,n)},p.raw=function(e){return Ee(e)},p.lite=function(e,...n){return re(e,n,!1)},p}function dr(s){return!s||typeof s!="object"?"":Object.entries(s).filter(([,o])=>o!=null&&typeof o!="function").map(([o,f])=>typeof f=="boolean"?f?` ${o}`:"":typeof f=="object"?"":` ${o}="${k(String(f))}"`).join("")}async function qe(s,o={}){const{attrs:f={},store:p,shadowDOM:h=!1,fragments:e={},render:n,styled:t,colors:r}=o;if(typeof n!="function")throw new Error("renderElement requires a render function");const i={attrs:f,store:p,fragments:e,styled:t,colors:r,tagName:s.toUpperCase(),localName:s.toLowerCase()},c=vn(i);let l="";const u=(...y)=>{const m=c(...y);return l=m,m};u.wire=c.wire,u.raw=c.raw,u.lite=c.lite,u._context=c._context;const a=n(u,i);a&&typeof a.then=="function"&&await a,l&&typeof l.then=="function"&&(l=await l);const d=dr(f);return h?`<${s}${d}><template shadowrootmode="open">${l}</template></${s}>`:`<${s}${d}>${l}</${s}>`}async function hr(s){return Promise.all(s.map(({tagName:o,options:f})=>qe(o,f)))}function yr(s,o,f={}){return async(p={},h)=>qe(s,{...f,attrs:{...f.attrs,...p},store:h??f.store,render:o})}var gr=typeof window<"u"&&typeof document<"u";if(gr){console.info("hyper-element v2.0.0 by Brian Shannon (github.com/codemeasandwich)");var ve=new Proxy(He,{get:function(s,o,f){return o==="prototype"?s.prototype:Reflect.get(s,o,f)},apply:function(s,o,f){if(f.length===0)throw new Error("hyperElement requires a definition object or render function");return he.apply(null,f)},construct:function(s,o,f){if(f!==ve)return Reflect.construct(s,o,f);throw new Error("hyperElement cannot be instantiated directly. Use class extension or functional API.")}});return ve.configureSSR=Pe,{default:ve,hyperElement:ve,configureSSR:Pe,signal:st,computed:it,effect:ot,batch:lt,untracked:ct,withOptions:bt,html:te,dom:U}}else return{renderElement:qe,renderElements:hr,createRenderer:yr,renderToString:re,ssrHtml:ur,createSSRHtml:vn,createSSRTemplate:Sn,escapeHtml:k,safeHtml:Ee,signal:st,computed:it,effect:ot,batch:lt,untracked:ct}});
|
|
3
15
|
//# sourceMappingURL=hyperElement.min.js.map
|