hyper-element 1.1.0 → 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 +560 -21
- package/build/hyperElement.min.js +14 -1
- package/build/hyperElement.min.js.map +3 -3
- package/index.d.ts +344 -3
- package/package.json +13 -8
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
(function(){const P=/<+\w+[-]+\w/,k={},H={};function Ue(){for(var e="",t="bcdfghjklmnpqrstvwxyz",n=0;n<15;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function j(e){return typeof e!="string"?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const le=Symbol("safeHtml");function Be(e){return{[le]:!0,value:e}}function J(e){return e&&e[le]===!0}const $=1,fe=2,O=4,ze=8,Y=16,K=32,q=64,Je=128,Ye=256,Ke=512,qe=1024,ae=1,ue=2,G=3,X=8,Ge=11,Xe=O|$,Ze=K|$,he=new Set(["plaintext","script","style","textarea","title","xmp"]),pe=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),A=Object.freeze([]),de=Object.freeze({});let I=document.createElement("template"),W;function Z(e,t=!1){if(t)return W||(W=document.createRange(),W.selectNodeContents(document.createElementNS("http://www.w3.org/2000/svg","svg"))),W.createContextualFragment(e);I.innerHTML=e;const n=I.content;return I=I.cloneNode(!1),n}function Qe(e,t){return t.reduceRight((n,r)=>r<0?n.content:n.childNodes[r],e)}function Ve(e,t,n,r){const s=r.parentNode,o=t.length;let l=e.length,c=o,i=0,f=0,a=null;for(;i<l||f<c;)if(l===i){const u=c<o?f?n(t[f-1],-0).nextSibling:n(t[c],0):r;for(;f<c;)s.insertBefore(n(t[f++],1),u)}else if(c===f)for(;i<l;)(!a||!a.has(e[i]))&&n(e[i],-1).remove(),i++;else if(e[i]===t[f])i++,f++;else if(e[l-1]===t[c-1])l--,c--;else if(e[i]===t[c-1]&&t[f]===e[l-1]){const u=n(e[--l],-0).nextSibling;s.insertBefore(n(t[f++],1),n(e[i++],-0).nextSibling),s.insertBefore(n(t[--c],1),u),e[l]=t[c]}else{if(!a){a=new Map;let d=f;for(;d<c;)a.set(t[d],d++)}const u=a.get(e[i])??-1;if(u<0)n(e[i++],-1).remove();else if(f<u&&u<c){let d=i,p=1;for(;++d<l&&d<c&&a.get(e[d])===u+p;)p++;if(p>u-f){const y=n(e[i],0);for(;f<u;)s.insertBefore(n(t[f++],1),y)}else s.replaceChild(n(t[f++],1),n(e[i++],-1))}else i++}return t}let ye=!1,me;const S=Symbol("nodes"),Q=({firstChild:e,lastChild:t})=>{const n=me||(me=document.createRange());return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e};function V(e,t){return ye&&e.nodeType===11?1/t<0?t?Q(e):e.lastChild:t?e.valueOf():e.firstChild:e}const et={get(){return this.firstChild.parentNode}},tt={value(e){Q(this).replaceWith(e)}},nt={value(){Q(this).remove()}},rt={value(){const{parentNode:e}=this;if(e===this)this[S]===A&&(this[S]=[...this.childNodes]);else{if(e){let{firstChild:t,lastChild:n}=this;for(this[S]=[t];t!==n;)this[S].push(t=t.nextSibling)}this.replaceChildren(...this[S])}return this}};function F(e){const t=document.createComment("<>"),n=document.createComment("</>");return e.replaceChildren(t,...e.childNodes,n),ye=!0,Object.defineProperties(e,{[S]:{writable:!0,value:A},firstChild:{value:t},lastChild:{value:n},parentNode:et,valueOf:rt,replaceWith:tt,remove:nt})}F.prototype=DocumentFragment.prototype;const ge=new WeakMap;class st extends Map{constructor(){super(),this._=new FinalizationRegistry(t=>this.delete(t))}get(t){const n=super.get(t)?.deref();return n&&ge.get(n)}set(t,n,r){ge.set(n,r),this._.register(n,t),super.set(t,new WeakRef(n))}}class D{constructor(t){this.type=t,this.parent=null}}class be extends D{constructor(t){super(X),this.data=t}toString(){return`<!--${this.data}-->`}}class ee extends D{constructor(t){super(G),this.data=t}toString(){return this.data}}class U extends D{constructor(t,n=!1){super(ae),this.name=t,this.xml=n,this.props=de,this.children=A}toString(){const{xml:t,name:n,props:r,children:s}=this,o=s.length;let l=`<${n}`;for(const c in r){const i=r[c];i!=null&&(typeof i=="boolean"?i&&(l+=t?` ${c}=""`:` ${c}`):l+=` ${c}="${i}"`)}if(o){l+=">";for(let c=!t&&he.has(n),i=0;i<o;i++)l+=c?s[i].data:s[i];l+=`</${n}>`}else t?l+=" />":l+=pe.has(n)?">":`></${n}>`;return l}}class it extends D{constructor(){super(Ge),this.name="#fragment",this.children=A}toString(){return this.children.join("")}}const C="\0",ot=`"${C}"`,ct=`'${C}'`,lt=/\x00|<[^><\s]+/g,ft=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,T=(e,t)=>(e.children===A&&(e.children=[]),e.children.push(t),t.parent=e,t),at=(e,t,n)=>{e.props===de&&(e.props={}),e.props[t]=n},te=e=>{const t=[];for(;e.parent;)e.type===ae&&e.name==="template"&&t.push(-1),t.push(e.parent.children.indexOf(e)),e=e.parent;return t},we=(e,t)=>{do e=e.parent;while(t.has(e));return e},ut=(e,t,n,r)=>[t,n,r];function ht(e=ut){return(t,n,r)=>{const s=t.join(C).replace(/^\s+/,""),o=new Set,l=[];let c=new it,i=0,f=0,a=0,u=A;for(const d of s.matchAll(lt)){if(f>0){f--;continue}const p=d[0],y=d.index;if(i<y&&T(c,new ee(s.slice(i,y))),p===C){c.name==="table"&&(c=T(c,new U("tbody",r)),o.add(c));const h=T(c,new be("\u25E6"));l.push(e(h,X,te(h),"",n[a++])),i=y+1}else if(p.startsWith("<!")){const h=s.indexOf(">",y+2);if(s.slice(h-2,h+1)==="-->"){const m=s.slice(y+4,h-2);m[0]==="!"&&T(c,new be(m.slice(1).replace(/!$/,"")))}i=h+1}else if(p.startsWith("</")){const h=s.indexOf(">",y+2);r&&c.name==="svg"&&(r=!1),c=we(c,o),i=h+1}else{const h=y+p.length,m=s.indexOf(">",h),w=p.slice(1);let b=w;if(r||(b=b.toLowerCase(),c.name==="table"&&(b==="tr"||b==="td")&&(c=T(c,new U("tbody",r)),o.add(c)),c.name==="tbody"&&b==="td"&&(c=T(c,new U("tr",r)),o.add(c))),c=T(c,new U(b,r?b!=="svg":!1)),u=A,h<m){let E=!1;for(const[,_,g]of s.slice(h,m).matchAll(ft))if(g===C||g===ot||g===ct||(E=_.endsWith(C))){const L=u===A?u=te(c):u;l.push(e(c,ue,L,E?_.slice(0,-1):_,n[a++])),E=!1,f++}else at(c,_,g?g.slice(1,-1):!0);u=A}i=m+1;const v=m>0&&s[m-1]==="/";if(r)v&&(c=c.parent);else if(v||pe.has(b))c=v?we(c,o):c.parent;else if(b==="svg")r=!0;else if(he.has(b)){const E=s.indexOf(`</${w}>`,i),_=s.slice(i,E);_.trim()===C?(f++,l.push(e(c,G,te(c),"",n[a++]))):T(c,new ee(_)),c=c.parent,i=E+w.length+3,f++;continue}}}return i<s.length&&T(c,new ee(s.slice(i))),[c,l]}}const M=Symbol("ref");let ne=!1;function pt(){const e=ne;return ne=!1,e}const Ee=new WeakMap,dt=(e,t)=>{let n=Ee.get(e);return n?n.data=t:Ee.set(e,n=document.createTextNode(t)),n},_e=new Map,re=e=>{let t=_e.get(e);return t||_e.set(e,t=ve(e)),t},xe=e=>(t,n)=>{n==null?t.removeAttribute(e):t.setAttribute(e,n)},ve=e=>(t,n)=>{t[e]=n},yt=e=>(t,n)=>{t.toggleAttribute(e,!!n)},mt=({dataset:e},t)=>{for(const[n,r]of Object.entries(t))r==null?delete e[n]:e[n]=r},gt=(e,t)=>{if(t==null)e.removeAttribute("style");else if(typeof t=="object")for(const[n,r]of Object.entries(t))r==null?e.style.removeProperty(n):e.style.setProperty(n,r);else e.setAttribute("style",t)},bt=(e,t,n)=>n?(r,s)=>{const o=r[t];o?.length&&r.removeEventListener(e,...o),s&&r.addEventListener(e,...s),r[t]=s}:(r,s)=>{const o=r[t];o&&r.removeEventListener(e,o),s&&r.addEventListener(e,s),r[t]=s},wt=e=>e.map(t=>typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):t),Et=(e,t)=>{const n=wt(t);e[S]=Ve(e[S]||A,n,V,e)},Ae=(e,t)=>{const n=typeof t=="object"?t??e:dt(e,t),r=e[S]??e;n!==r&&r.replaceWith(V(e[S]=n,1))},_t=e=>(t,n)=>{if(n&&typeof n=="object"&&n.__unsafe){const r=n.value,s=t[M]??(t[M]={});s.v!==r&&(s.f=F(Z(r,e)),s.v=r),n=s.f}Ae(t,n)},xt=e=>(t,n)=>{const r=n&&typeof n=="object"&&n.__unsafe?n.value:n,s=t[M]??(t[M]={});s.v!==r&&(s.f=F(Z(r,e)),s.v=r),Ae(t,s.f)};function vt(e,t,n,r,s){switch(t){case X:return Array.isArray(s)?[n,Et,Xe]:s&&typeof s=="object"&&s.__unsafe?[n,xt(e.xml),qe]:[n,_t(e.xml),O];case G:return[n,re("textContent"),Ye];case ue:switch(r.charAt(0)){case"@":{const o=Array.isArray(s);return[n,bt(r.slice(1),Symbol(r),o),o?Ze:K]}case"?":return[n,yt(r.slice(1)),Ke];case".":return r==="..."?[n,(o,l)=>{for(const[c,i]of Object.entries(l))xe(c)(o,i)},Je]:[n,ve(r.slice(1)),Y];default:return r==="data"&&!/^object$/i.test(e.name)?[n,mt,ze]:r==="key"?(ne=!0,[n,!0,q]):r==="ref"?[n,re(M),Y]:r.startsWith("on")?[n,re(r.toLowerCase()),Y]:r==="style"?[n,gt,fe]:[n,xe(r),fe]}}}const R=e=>V(e.n?e.update(e):e.valueOf(),1),Se=(e,t)=>{const n=[],r=e.length,s=t.length;for(let o,l,c=0,i=0;i<s;i++)o=t[i],n[i]=c<r&&(l=e[c++]).t===o.t?(t[i]=l).update(o):o.valueOf();return n},At=(e,t)=>e.t[2]?.get(t)?.update(e)??e.valueOf(),St=(e,t)=>(e.t===t.t?e.update(t):(e.n.replaceWith(R(t)),e=t),e);class N{constructor(t,n){this.t=t,this.v=n,this.n=null,this.k=-1}valueOf(){const[t,n,r]=this.t,s=document.importNode(t,!0),o=this.v;let l=o.length,c=A,i,f;if(l>0)for(c=n.slice(0);l--;){const[p,y,h]=n[l],m=o[l];f!==p&&(i=Qe(s,p),f=p);let w=!0;h&$?h&O&&(w=!1,m.length&&y(i,m[0]instanceof N?Se(A,m):m)):h&O&&m instanceof N&&(w=!1,y(i,R(m))),w&&(h===q?this.k=l:y(i,m)),c[l]=[h,y,m,i]}const{childNodes:a}=s,u=a.length,d=u===1?a[0]:u?F(s):s;return this.v=c,this.n=d,this.k>=0&&r&&r.set(c[this.k][2],d,this),d}update(t){const n=this.k,r=this.v,s=t.v;if(n>=0&&r[n][2]!==s[n])return At(t,s[n]);let{length:o}=r;for(;o--;){const l=r[o],[c,i,f]=l;if(c===q)continue;let a=s[o],u=a;if(c&$){if(c&O)a.length&&a[0]instanceof N&&(u=Se(f,a));else if(c&K&&a[0]===f[0])continue}else c&O&&f instanceof N&&(a=St(f,a),u=a.n);a!==f&&(l[2]=a,i(l[3],u))}return this.n}}const Tt=ht(vt),Te=new WeakMap,Ne=new WeakMap,Ce=(e,t=new WeakMap)=>(n,...r)=>{let s=t.get(n);return s||(s=Tt(n,r,e),s.push(pt()?new st:null),s[0]=Z(s[0].toString(),e),t.set(n,s)),new N(s,r)},se=Ce(!1),Dt=Ce(!0);function ke(e){return(t,...n)=>{const r=se(t,...n),s=Te.get(e);if(!s||s.t!==r.t){const o=R(r);e.replaceChildren(o),Te.set(e,r)}else s.update(r);return e}}function Oe(e,t=""){let n=Ne.get(e);return n||(n=new Map,Ne.set(e,n)),(r,...s)=>{let o=n.get(t);if(!o||o.tpl!==r){const l=se(r,...s);return o={hole:l,tpl:r},n.set(t,o),l}return new N(o.hole.t,s)}}let x=null;const B=[];function Ut(e){let t=e;const n=new Set;return{get value(){return x&&n.add(x),t},set value(r){if(t!==r){t=r;for(const s of n)s()}},peek(){return t},subscribe(r){return n.add(r),()=>n.delete(r)}}}function Bt(e){let t,n=!0;const r=new Set,s=()=>{n=!0;for(const o of r)o()};return{get value(){if(x&&r.add(x),n){const o=x;x=s,B.push(s);try{t=e()}finally{B.pop(),x=o}n=!1}return t},peek(){if(n){const o=x;x=null;try{t=e()}finally{x=o}n=!1}return t}}}function zt(e){let t=null;const n=()=>{typeof t=="function"&&t();const r=x;x=n,B.push(n);try{t=e()}finally{B.pop(),x=r}};return n(),()=>{typeof t=="function"&&t()}}function Jt(e){const t=x;x=null;try{return e()}finally{x=t}}let ie=0,je=new Set;function Yt(e){ie++;try{e()}finally{if(ie--,ie===0){const t=je;je=new Set;for(const n of t)n()}}}function Nt(e,t){if(e==="template"&&t==="")return!0;if(+t+""===t.trim())return+t;const n=t.toLowerCase().trim();return n==="true"?!0:n==="false"?!1:n[0]==="["&&n.slice(-1)==="]"||n[0]==="{"&&n.slice(-1)==="}"?JSON.parse(t):t}function Me(e){return typeof e=="function"?Me(e()):typeof e=="string"?j(e):typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?j(e.join(", ")):e!==null&&typeof e=="object"?j(JSON.stringify(e)):""}function Ct(e,t){let n=e;const r=/\{\+each\s+(\w+)\}([\s\S]*?)\{-each\}/g;n=n.replace(r,(c,i,f)=>{const a=t[i];return Array.isArray(a)?a.map((u,d)=>{let p=f;return p=p.replace(/\{@\}/g,d),p=p.replace(/\{\s*\.\.\.\s*\}/g,Me(u)),typeof u=="object"&&u!==null&&Object.keys(u).forEach(y=>{p=p.replace(new RegExp("\\{"+y+"\\}","g"),j(String(u[y])))}),p}).join(""):""});const s=/\{\+if\s+(\w+)\}([\s\S]*?)\{else\}([\s\S]*?)\{-if\}/g;n=n.replace(s,(c,i,f,a)=>t[i]?f:a);const o=/\{\+if\s+(\w+)\}([\s\S]*?)\{-if\}/g;n=n.replace(o,(c,i,f)=>t[i]?f:"");const l=/\{\+unless\s+(\w+)\}([\s\S]*?)\{-unless\}/g;return n=n.replace(l,(c,i,f)=>t[i]?"":f),n}function Re(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 c=Ct(e,l);return c=c.replace(/\{(\w+)\}/g,(i,f)=>l[f]!=null?j(String(l[f])):""),{html:c}};const n=/(\{[\w]+\})/g,r=e.split(n).reduce((o,l)=>(l[0]==="{"&&l.slice(-1)==="}"?o.keys.push(l.slice(1,-1)):o.markup.push(l),o),{markup:[],keys:[]});r.id=":"+r.markup.join().trim();function s(o){const l=[r.markup,...r.keys.map(c=>o[c]!=null?o[c]:"")];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 Oe(l,r.id)(...s(l))}}function oe(e,t){const n=t.replace(/-([a-z])/g,r=>r[1].toUpperCase());Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>Nt(n,this.dataset[n]),set:r=>{k[this.identifier].attrsToIgnore["data-"+t]=!0,typeof r=="string"?this.dataset[n]=r:this.dataset[n]=JSON.stringify(r)}})}function kt(){const e={};return Object.keys(this.dataset).forEach(t=>oe.call(this,e,t.replace(/([A-Z])/g,n=>`-${n[0].toLowerCase()}`))),e}function Ot(e){const t={};for(let n=0;n<e.length;n++){const{value:r,name:s}=e[n];if(s==="template"&&!r){const o=k[this.identifier];o.Html.template=Re(o.innerHTML),t[s]=!0}else(r.substr(0,3)==="fn-"||r.substr(0,3)==="ob-")&&H[r.substr(3)]&&H[r.substr(3)].localName===this.localName?t[s]=H[r.substr(3)].val:+r+""===(r+"").trim()?t[s]=+r:t[s]=r}return t}function jt(e){return e.some(t=>t.includes("{+each ")||t.includes("{+each{")||t.includes("{+if ")||t.includes("{+unless "))}function Le(e,t){return t.split(".").reduce((n,r)=>n?.[r],e)}function Pe(e){const t=/\{(@|\s*\.\.\.\s*|\w+(?:\.\w+)*)\}/g,n=[],r=[];let s=0,o;for(;(o=t.exec(e))!==null;)n.push(e.substring(s,o.index)),r.push(o[1]),s=t.lastIndex;return n.push(e.substring(s)),{parts:n,props:r}}function Mt(e,t,n,r,s){let o=1;for(let l=t;l<e.length;l++){const c=e[l];let i=l===t?n:0;for(;i<c.length;){const f=c.indexOf(r,i),a=c.indexOf(s,i);if(a!==-1&&(f===-1||a<f)){if(--o===0)return{endIdx:l,endPos:a};i=a+s.length}else if(f!==-1)o++,i=f+r.length;else break}}throw new Error(`Unclosed ${r}} block. Missing ${s}.`)}function z(e){const t=[...e];return t.raw=[...e],t}const He=new WeakMap;function ce(e,t,n){if(e!==null&&typeof e=="object")return e;let r=He.get(n);return r||(r={},He.set(n,r)),r[t]||(r[t]={_value:e,_index:t}),r[t]._value=e,r[t]}function $e(e,t,n){return e==="@"?n:e.trim()==="..."?t:Le(t,e)}function Ie(e,t,n,r,s){const o=/\{\+each\s*\{(\w+(?:\.\w+)*)\}\}([\s\S]*?)\{-each\}/g,l=o.test(e);if(o.lastIndex=0,l){const a=[];let u=e,d;for(;(d=o.exec(e))!==null;){const[b,v,E]=d,_=Le(t,v);if(!Array.isArray(_)){u=u.replace(b,"");continue}const g=_.map((L,Ft)=>Ie(E.trim(),L,Ft,_,s));u=u.replace(b,`__NESTED_${a.length}__`),a.push(g)}const{parts:p,props:y}=Pe(u),h=[],m=[];let w=0;for(let b=0;b<p.length;b++){let v=p[b],E;for(;E=v.match(/__NESTED_(\d+)__/);){const[_,g]=v.split(E[0]);h.push(_),m.push(a[parseInt(E[1],10)]),v=g||""}h.push(v),b<y.length&&m.push($e(y[w++],t,n))}return s(ce(t,n,r),JSON.stringify(h))(z(h),...m)}const{parts:c,props:i}=Pe(e);if(i.length===0)return s(ce(t,n,r),JSON.stringify([e]))(z([e]));const f=i.map(a=>$e(a,t,n));return s(ce(t,n,r),JSON.stringify(c))(z(c),...f)}function We(e){const t=[{type:"each",pattern:"{+each "},{type:"if",pattern:"{+if "},{type:"unless",pattern:"{+unless "}];let n=null;for(const r of t){const s=e.indexOf(r.pattern);s!==-1&&(n===null||s<n.pos)&&(n={type:r.type,pos:s,pattern:r.pattern})}return n}function Rt(e,t,n){const r=[],s=[];let o=0;for(;o<e.length;){const l=e[o],c=We(l);if(!c){r.push(l),o<t.length&&s.push(t[o]),o++;continue}const{type:i,pos:f,pattern:a}=c,u=`{-${i}}`;r.push(l.substring(0,f));const d=t[o],p=e[o+1];if(!p||!p.startsWith("}"))throw new Error(`{+${i}} syntax error: expected "}" after value`);const y=p.substring(1),{endIdx:h,endPos:m}=Mt(e,o+1,1,a.slice(0,-1),u);let w,b="";if(h===o+1)w=y.substring(0,m-1);else{w=y;for(let g=o+2;g<=h;g++)w+=String(t[g-1]??"")+(g<h?e[g]:e[g].substring(0,m))}if(i==="if"||i==="unless"){const g=w.indexOf("{else}");g!==-1&&(b=w.substring(g+6),w=w.substring(0,g))}let v;const E=g=>g.replace(/^\s+/,"");if(i==="each"){if(!Array.isArray(d)&&d!=null)throw new Error(`{+each} expects an array, got ${typeof d}`);v=(d||[]).map((g,L)=>Ie(E(w),g,L,d||[],n))}else i==="if"?v=d?{html:E(w)}:{html:E(b)}:i==="unless"&&(v=d?{html:E(b)}:{html:E(w)});s.push(v);const _=e[h].substring(m+u.length);o=h,We(_)?(e=[...e.slice(0,h),_,...e.slice(h+1)],t=[...t.slice(0,h),...t.slice(h)]):(r.push(_),h<t.length&&s.push(t[h]),o=h+1)}for(;r.length<=s.length;)r.push("");return{strings:z(r),values:s}}function Lt(e){const t=ke(e);function n(...r){if(jt(r[0])){const c=Rt(r[0],r.slice(1),n.wire);r=[c.strings,...c.values]}const s=r.slice(1).some(c=>c!=null&&typeof c!="string"),o=r[0].some(c=>P.test(c));if(s&&o){let c=!1,i="";r[0].forEach((f,a,u)=>{if(P.test(f)?(c=f.substring(f.match(P).index).indexOf(">")===-1,i=c&&f.substring(f.indexOf(f.match(P))).split(/\s/)[0].substr(1)):0<=f.indexOf(">")&&(c=!1,i=""),!c)return;const d=r[a+1];if(d!=null&&typeof d!="string"){const p=f.split(/\s/).pop().slice(0,-1);if(p.substring(0,2)==="on")throw new Error(`'on' is reserve for native elements. Change: "${p}" for "${i}" to something else`);if(p==="style")return;const y=Ue();H[y]={attrName:p,val:d,localName:i},r[a+1]=(typeof d=="function"?"fn-":"ob-")+y}})}const l=[r[0]];for(let c=1;c<r.length;c++){let i=r[c];if(i&&typeof i=="object"&&!Array.isArray(i)&&!J(i)){const f=Object.keys(i);if(f.length===1&&/^[A-Z]/.test(f[0])){const a=f[0],u=i[a];n._fragments&&n._fragments[a]&&(i=n._fragments[a](u))}}J(i)?l.push({__unsafe:!0,value:i.value}):i&&typeof i=="object"&&i.__unsafe?l.push(i):i&&typeof i=="object"&&i.html!==void 0?l.push({__unsafe:!0,value:i.html}):Array.isArray(i)?l.push(i.map(f=>J(f)?{__unsafe:!0,value:f.value}:f)):l.push(i)}return t(...l)}return n._fragments=null,n.wire=function(s,o=""){return Oe(s,o)},n.raw=function(s){return Be(s)},n.lite=function(s,...o){return s&&s.raw?se(s,...o):ke(s)},n}function Pt(e,t){const n=typeof t=="function"?t:()=>t,r=this._baseRender||this.render;this._baseRender=r;const s=(...o)=>{t===void 0?(e.store=void 0,r(...o)):(e.store=n(),r(e.store,...o))};return this.render=s,this._onNextInitialized?s():this._onNextInitialized=!0,s}function Ht(e){const t=e.this;new MutationObserver(r=>{if(!e.observe)return;if(r.filter(l=>l.type==="attributes").length>0){t.attrs=this.attachAttrs(this.attributes)||{},this.render();return}let o=this.textContent;e.innerHTML=this.innerHTML,t.attrs.template&&(t.attrs=this.attachAttrs(this.attributes)||{}),hyperHTML.bind(e.shadow)``,t.wrappedContent=o,this.render()}).observe(this,{attributes:!0,childList:!0,subtree:!0})}function $t(e,t,n,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(s=>{e.text=s,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(s=>{e.html=s,r&&r()}),e.placeholder!==void 0?e.placeholder:""}if(e.template)if(typeof e.template=="string"){n[e.template]||(n[e.template]=Re(e.template));const s=e.values||t;if(Array.isArray(s))return{__unsafe:!0,value:s.map(n[e.template]).map(i=>{if(i&&i.html)return i.html;if(i instanceof N){const f=R(i);if(f.nodeType===11){const a=document.createElement("div");return a.appendChild(f.cloneNode(!0)),a.innerHTML}return f.outerHTML||f.textContent}return String(i)}).join("")};const o=n[e.template](s);if(o&&o.html)return{__unsafe:!0,value:o.html};if(o instanceof N){const l=R(o);if(l.nodeType===11){const c=document.createElement("div");return c.appendChild(l.cloneNode(!0)),{__unsafe:!0,value:c.innerHTML}}return{__unsafe:!0,value:l.outerHTML||l.textContent}}return o}else{if(typeof e.template=="object"&&typeof e.template.then=="function")return e.template.then(s=>{let{template:o,values:l}=s;!o&&typeof s=="string"&&(o=s,l={}),e.template=o,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(s=>{e.any=s,r&&r()}),e.placeholder!==void 0?e.placeholder:""):e.any:e}function It(){this.identifier=Symbol(this.localName);const e=k[this.identifier]={attrsToIgnore:{}};e.innerHTML=this.innerHTML;const t=e.this={element:this};t.wrappedContent=this.textContent;const n={};Ht.call(this,e),Object.getOwnPropertyNames(this.__proto__).filter(o=>!(o==="constructor"||o==="setup"||o==="render")).forEach(o=>{if(/^[A-Z]/.test(o)){const l={};n[o]=c=>{if(n[o]._cached!==void 0)return n[o]._cached;let i;n[o]._asyncResult?i=n[o]._asyncResult:i=this[o](c);const f=i.text&&typeof i.text.then=="function"||i.html&&typeof i.html.then=="function"||i.any&&typeof i.any.then=="function"||i.template&&typeof i.template.then=="function";f&&(n[o]._asyncResult=i);const u=$t(i,c,l,()=>{this.render()});return i.once&&!f&&(n[o]._cached=u),!f&&n[o]._asyncResult&&delete n[o]._asyncResult,u}}else t[o]=this[o].bind(t);delete this[o]}),e.fragments=n;function r(){return"hyper-element: "+this.localName}Object.defineProperty(t,"toString",{value:r.bind(this),writable:!1}),e.shadow=this,e.Html=Lt(e.shadow),e.Html._fragments=n,t.attrs=this.attachAttrs(this.attributes),t.dataset=this.getDataset();const s=this.render;this.render=(...o)=>{e.observe=!1,setTimeout(()=>{e.observe=!0},0),s.call(t,e.Html,...o),Object.getOwnPropertyNames(t.dataset).filter(l=>!this.dataset[l]).forEach(l=>{const c=t.dataset[l];oe.call(this,t.dataset,l.replace(/([A-Z])/g,i=>`-${i[0].toLowerCase()}`)),t.dataset[l]=c})},this.setup&&(e.teardown=this.setup.call(t,Pt.bind(this,t))),this.render()}class Fe extends HTMLElement{identifier;get innerShadow(){return k[this.identifier].shadow.innerHTML}connectedCallback(){It.call(this)}addDataset(t,n){oe.call(this,t,n)}getDataset(){return kt.call(this)}attachAttrs(t){return Ot.call(this,t)}attributeChangedCallback(t,n,r){const s=k[this.identifier];if(!s)return;r!==null&&+r+""===r.trim()&&(r=+r);const{attrsToIgnore:o}=s,l=s.this;if(0<=t.indexOf("data-")){const c=t.slice(5);if(n===null)this.addDataset(l.dataset,c);else if(r===null){const i=c.replace(/-([a-z])/g,f=>f[1].toUpperCase());delete l.dataset[i]}}if(r!==l.attrs[t])if(r===null?delete l.attrs[t]:l.attrs[t]=r,o[t]){delete o[t];return}else this.render()}disconnectedCallback(){const t=k[this.identifier];t.teardown&&t.teardown()}setup(t){}render(t,...n){}}function Wt(e,t){let n=null;if(typeof e=="string"?n=e:t=e,typeof t=="function"&&(t={render:t}),!t||typeof t!="object")throw new Error("hyperElement: definition must be an object or render function");const{observedAttributes:r=[],setup:s,render:o,...l}=t;if(!o||typeof o!="function")throw new Error("hyperElement: render function is required");class c extends Fe{static get observedAttributes(){return r}}s&&(c.prototype.setup=function(i){return s(this,i)}),c.prototype.render=function(i,...f){return o(i,this,...f)};for(const[i,f]of Object.entries(l))typeof f=="function"&&(c.prototype[i]=function(...a){return f(this,...a)});return n&&customElements.define(n,c),c}console.info("hyper-element v1.1.0 by Brian Shannon (github.com/codemeasandwich)");const De=new Proxy(Fe,{apply(e,t,n){if(n.length===0)throw new Error("hyperElement requires a definition object or render function");return Wt(...n)},construct(e,t,n){if(n!==De)return Reflect.construct(e,t,n);throw new Error("hyperElement cannot be instantiated directly. Use class extension or functional API.")}});window.hyperElement=De})();
|
|
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}});
|
|
2
15
|
//# sourceMappingURL=hyperElement.min.js.map
|