@estjs/template 0.0.15-beta.8 → 0.0.15
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/dist/template.cjs.js +2 -7
- package/dist/template.cjs.js.map +1 -1
- package/dist/template.d.cts +281 -176
- package/dist/template.d.ts +281 -176
- package/dist/template.dev.cjs.js +785 -742
- package/dist/template.dev.cjs.js.map +1 -0
- package/dist/template.dev.esm.js +767 -734
- package/dist/template.dev.esm.js.map +1 -0
- package/dist/template.esm.js +2 -7
- package/dist/template.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/template.cjs.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');/**
|
|
2
|
-
|
|
3
|
-
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
var ct=Object.defineProperty;var Ne=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var xe=(e,t,n)=>t in e?ct(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,U=(e,t)=>{for(var n in t||(t={}))at.call(t,n)&&xe(e,n,t[n]);if(Ne)for(var n of Ne(t))ft.call(t,n)&&xe(e,n,t[n]);return e};var I=(e,t,n)=>new Promise((r,o)=>{var s=c=>{try{a(n.next(c));}catch(f){o(f);}},i=c=>{try{a(n.throw(c));}catch(f){o(f);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((n=n.apply(e,t)).next());});var w=null,ut=0,q=[];function S(){return w}function lt(e){w=e;}function Ee(e=w){let t={id:++ut,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(t)),t}function _(e,t){let n=w;n&&q.push(n),w=e;try{return t()}finally{w=q.length>0?q.pop():n;}}function B(e){var t,n,r,o,s;if(!(!e||e.isDestroyed)){if(e.children){let i=Array.from(e.children);for(let a of i)B(a);}if(e.onDestroy){for(let i of e.onDestroy)try{i();}catch(a){}e.onDestroy.clear();}if(e.cleanup){for(let i of e.cleanup)try{i();}catch(a){}e.cleanup.clear();}(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),(n=e.children)==null||n.clear(),(r=e.provides)==null||r.clear(),(o=e.onMount)==null||o.clear(),(s=e.onUpdate)==null||s.clear(),lt(e.parent),e.parent=null,e.isDestroyed=true;}}function $(e){let t=w;t&&(t.cleanup||(t.cleanup=new Set),t.cleanup.add(e));}var Ae="_$spread$";var ve="http://www.w3.org/2000/svg",J="http://www.w3.org/2000/xlink",Q="http://www.w3.org/2000/xmlns/",Z=/^\d+-\d+$/;var be=1e3,_e=new WeakMap;function Pe(e){let t=_e.get(e);if(!t){let n=e.name||"anonymous",r=Te(e.toString()).toString(36);t=`${n}_${r}`,_e.set(e,t);}return t}function Te(e){let t=0,n=e.length<100?e.length:100;for(let r=0;r<n;r++)t=Math.trunc((t<<5)-t+e.charCodeAt(r));return t<0?-t:t}var yt=0;function te(e){if(!shared.isFalsy(e)){if(shared.isString(e))return e.length<=be?e:`${e.slice(0,be-10)}_${Te(e).toString(36)}`;if(shared.isNumber(e))return String(e);if(shared.isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${yt++}`}return String(e)}}var ee=Symbol("essor.key");function K(e,t){if(p(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=te(t);shared.isFalsy(n)?delete e[ee]:e[ee]=n;}function k(e){if(e)return p(e)?e.key:e[ee]}function St(e,t){let n=new Set(t);return new Proxy(e,{get(r,o){if(!n.has(o))return Reflect.get(r,o)},ownKeys(r){return Reflect.ownKeys(r).filter(o=>!n.has(o))},getOwnPropertyDescriptor(r,o){if(!n.has(o))return Reflect.getOwnPropertyDescriptor(r,o)},has(r,o){return n.has(o)?false:Reflect.has(r,o)}})}function E(e){if(e)try{if(p(e))e.destroy();else {let t=e;t.parentElement&&t.remove();}}catch(t){shared.error("Failed to remove node:",t);}}function h(e,t,n){if(!(!e||!t))try{let r=p(n)?n.firstChild:n;if(p(t)){t.mount(e,r);return}r?e.insertBefore(t,r):e.appendChild(t);}catch(r){shared.error("Failed to insert node:",r);}}function re(e,t,n){if(!(!e||!t||!n||t===n))try{let r=p(n)?n.beforeNode:n.nextSibling;E(n),h(e,t,r);}catch(r){shared.error("Failed to replace node:",r);}}function P(e){if(e){if(p(e))return e.firstChild;if(!shared.isPrimitive(e))return e}}function T(e,t){let n=k(e),r=k(t);if(n!==r)return false;let o=p(e),s=p(t);if(o&&s)return e.component===t.component;if(o!==s)return false;if(shared.isPrimitive(e)||shared.isPrimitive(t))return e===t;let i=e,a=t;return i.nodeType!==a.nodeType?false:i.nodeType===Node.ELEMENT_NODE?i.tagName===a.tagName:true}function C(e){if(shared.isHTMLElement(e))return e;if(shared.isPrimitive(e)){let t=shared.isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function Ce(e){return e instanceof HTMLInputElement}function De(e){return e instanceof HTMLSelectElement}function Le(e){return e instanceof HTMLTextAreaElement}function oe(e){return e instanceof Text}function we(e,t){if(e===t)return true;if(!e||!t||Array.isArray(e)!==Array.isArray(t))return false;for(let n in e)if(e[n]!==t[n])return false;for(let n in t)if(!(n in e))return false;return true}function Me(e,t){if(p(e)||p(t))return;let n=k(e);n&&!k(t)&&K(t,n);}function D(e,t,n){if(n===t)return t;let r=shared.isHTMLElement(t);if(shared.isHTMLElement(n)&&r){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let a=t.attributes,c=n.attributes;for(let f=a.length-1;f>=0;f--){let l=a[f].name;n.hasAttribute(l)||t.removeAttribute(l);}for(let f=0,l=c.length;f<l;f++){let u=c[f];t.getAttribute(u.name)!==u.value&&t.setAttribute(u.name,u.value);}return Me(t,n),t}}if(oe(t)&&oe(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),Me(t,n),t;let s=p(t),i=p(n);return s&&i&&t.component===n.component?n.update(t):(re(e,n,t),n)}function He(e,t,n,r){let o=t.length,s=n.length;if(o===0&&s===0)return [];if(o===0){for(let i=0;i<s;i++)h(e,n[i],r);return n}if(s===0){for(let i=0;i<o;i++)E(t[i]);return []}if(o===1&&s===1){let i=t[0],a=n[0];return T(i,a)?(D(e,i,a),n[0]=i):re(e,a,i),n}if(o===2&&s===2){let i=t[0],a=t[1],c=n[0],f=n[1];if(T(i,c)&&T(a,f))return D(e,i,c),D(e,a,f),n[0]=i,n[1]=a,n;if(T(i,f)&&T(a,c)){D(e,i,f),D(e,a,c);let l=P(a),u=P(i);return l&&u&&l.parentNode===e&&e.insertBefore(l,u),n[0]=a,n[1]=i,n}}return Nt(e,t,n,r)}function Nt(e,t,n,r){let o=0,s=0,i=t.length-1,a=n.length-1,c=t[0],f=t[i],l=n[0],u=n[a];for(;o<=i&&s<=a;)if(!c)c=t[++o];else if(!f)f=t[--i];else if(T(c,l))D(e,c,l),n[s]=c,c=t[++o],l=n[++s];else break;for(;o<=i&&s<=a;)if(!c)c=t[++o];else if(!f)f=t[--i];else if(T(f,u))D(e,f,u),n[a]=f,f=t[--i],u=n[--a];else break;if(o>i){if(s<=a){let m=a+1<n.length?P(n[a+1]):r;for(let N=s;N<=a;N++)h(e,n[N],m);}}else if(s>a)for(let m=o;m<=i;m++){let N=t[m];N&&E(N);}else xt(e,t,n,o,i,s,a,r);return n}function xt(e,t,n,r,o,s,i,a){let c=i-s+1,f=n.length,l;for(let y=s;y<=i;y++){let g=k(n[y]);g!==void 0&&(l||(l=Object.create(null)),l[g]=y);}let u=new Int32Array(c),m=false,N=0,v=0;for(let y=r;y<=o;y++){let g=t[y];if(!g)continue;if(v>=c){E(g);continue}let x,L=k(g);if(L!==void 0&&l&&L in l)x=l[L];else for(let b=s;b<=i;b++)if(u[b-s]===0&&L===void 0&&k(n[b])===void 0&&T(g,n[b])){x=b;break}x===void 0?E(g):(u[x-s]=y+1,x>=N?N=x:m=true,D(e,g,n[x]),n[x]=g,v++);}let H=m?Et(u):[],W=H.length-1;for(let y=c-1;y>=0;y--){let g=s+y,x=n[g],L=g+1<f?P(n[g+1]):a;if(u[y]===0)h(e,x,L);else if(m)if(W<0||y!==H[W]){let b=P(x);b&&b.parentNode===e&&h(e,b,L);}else W--;}}function Et(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],r=new Int32Array(t),o,s,i,a,c;for(o=0;o<t;o++){let f=e[o];if(f!==0){if(s=n[n.length-1],n.length===0||e[s]<f){r[o]=s,n.push(o);continue}for(i=0,a=n.length-1;i<a;)c=i+a>>1,e[n[c]]<f?i=c+1:a=c;f<e[n[i]]&&(i>0&&(r[o]=n[i-1]),n[i]=o);}}for(i=n.length,a=n[i-1];i-- >0;)n[i]=a,a=r[a];return n}function A(e,t,n,r){e.addEventListener(t,n,r),$(()=>{e.removeEventListener(t,n,r);});}function bt(e,t,n,r){if(Ce(e))switch(e.type){case "checkbox":A(e,"change",()=>{r(!!e.checked);});break;case "radio":A(e,"change",()=>{r(e.checked?e.value:"");});break;case "file":A(e,"change",()=>{r(e.files);});break;case "number":case "range":A(e,"input",()=>{r(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":A(e,"change",()=>{r(e.value||"");});break;default:A(e,"input",()=>{r(e.value);});break}else De(e)?A(e,"change",()=>{if(e.multiple){let o=Array.from(e.options).filter(s=>s.selected).map(s=>s.value);r(o);}else r(e.value);}):Le(e)&&A(e,"input",()=>{r(e.value);});}function ie(e,t,n){if(!e)return;let r=S(),o=[],s=signals.effect(()=>{let i=()=>{let a=shared.isFunction(t)?t():t,c=shared.coerceArray(a).map(f=>shared.isFunction(f)?f():f).flatMap(f=>f).map(C);o=He(e,o,c,n);};r&&!r.isDestroyed?_(r,i):i();});return $(()=>{s(),o.forEach(i=>E(i)),o.length=0;}),o}function se(e,t){let n=t.length,r=new Array(n),o=new Set(t),s=1,i=0,a=c=>{if(c.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(o.has(s)&&(r[i++]=c,i===n))return true;s++;}let f=c.firstChild;for(;f;){if(a(f))return true;f=f.nextSibling;}return false};return a(e),r}function _t(e){let t=S();if(t){if(t.isMounted){try{e();}catch(n){}return}t.onMount||(t.onMount=new Set),t.onMount.add(e);}}function kt(e){let t=S();t&&(t.onUpdate||(t.onUpdate=new Set),t.onUpdate.add(e));}function Pt(e){let t=S();t&&(t.onDestroy||(t.onDestroy=new Set),t.onDestroy.add(e));}function $e(e){!e||e.isDestroyed||e.isMounted||(e.isMounted=true,e.onMount&&_(e,()=>{for(let t of e.onMount)try{t();}catch(n){}}));}function ce(e){if(!(!e||e.isDestroyed)&&e.onUpdate)for(let t of e.onUpdate)try{t();}catch(n){}}function ae(e){_t(e);}function fe(e){Pt(e);}function Tt(e){kt(e);}var je;je="normal";var V=class{constructor(t,n={}){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this.state=0;this.parentScope=null;this[je]=true;this.key=n.key?te(n.key):Pe(t),this.reactiveProps=signals.shallowReactive(U({},n||{})),this.parentScope=S();}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=P(t);if(n)return n}}mount(t,n){var s;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)h(t,i,n);return this.state=2,this.renderedNodes}let r=(s=this.parentScope)!=null?s:S();this.scope=Ee(r);let o=_(this.scope,()=>{var c;let i=this.component(this.reactiveProps);return shared.isFunction(i)&&(i=i(this.reactiveProps)),(signals.isSignal(i)||signals.isComputed(i))&&(i=i.value),(c=ie(t,i,n))!=null?c:[]});return this.renderedNodes=o,_(this.scope,()=>{this.applyProps(this.props||{});}),this.state=2,this.scope&&$e(this.scope),this.renderedNodes}update(t){if(this.key!==t.key)return this.mount(t.parentNode,t.beforeNode),this;if(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.scope=t.scope,this.parentScope=t.parentScope,this.renderedNodes=t.renderedNodes,this.state=t.state,this.reactiveProps=t.reactiveProps,this.props)for(let n in this.props){if(n==="key")continue;let r=this.props[n],o=this.reactiveProps[n];Object.is(o,r)||shared.isObject(o)&&shared.isObject(r)&&we(o,r)||(this.reactiveProps[n]=r);}return !this.isConnected&&this.parentNode&&this.mount(this.parentNode,this.beforeNode),this.scope&&(_(this.scope,()=>{this.applyProps(this.props||{});}),ce(this.scope)),this}forceUpdate(){return I(this,null,function*(){if(yield Promise.resolve(),this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{_(this.scope,()=>{let n=this.component(this.reactiveProps);shared.isFunction(n)&&(n=n(this.reactiveProps)),(signals.isSignal(n)||signals.isComputed(n))&&(n=n.value);let r=shared.coerceArray(n);if(this.parentNode){let o=this.beforeNode;if(!o&&this.renderedNodes.length>0){let s=this.renderedNodes[this.renderedNodes.length-1],i=P(s);i&&(o=i.nextSibling);}for(let s of this.renderedNodes)E(s);for(let s of r)h(this.parentNode,s,o);this.renderedNodes=r;}}),this.scope&&ce(this.scope);}catch(n){throw this.renderedNodes=t,n}})}destroy(){if(this.state===4||this.state===5)return;this.state=4;let t=this.scope;t&&(B(t),this.scope=null);for(let n of this.renderedNodes)E(n);this.renderedNodes=[],this.parentNode=void 0,this.beforeNode=void 0,this.parentScope=null,this.reactiveProps={},this.props={},this.state=5;}applyProps(t){if(!t)return;let n=this.firstChild;for(let[r,o]of Object.entries(t))if(shared.startsWith(r,"on")&&n){let s=r.slice(2).toLowerCase();shared.isHTMLElement(n)&&A(n,s,o);}else r==="ref"&&signals.isSignal(o)&&(o.value=n);this.props=t;}};function p(e){return !!e&&!!e.normal}function F(e,t){return p(e)?e:new V(e,t)}function le(e){let t,n=()=>{let r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;if(!o)throw new Error("Invalid template: empty content");return o};return ()=>(t||(t=n())).cloneNode(true)}function Mt(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n){shared.error(`Target element not found: ${t}`);return}n.innerHTML&&(shared.error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let o=F(e);return o.mount(n),o}function de(e,t){let n=S();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function pe(e,t){let n=S();if(!n)return t;let r=n;for(;r;){if(r.provides){let o=r.provides.get(e);if(o)return o}r=r.parent;}return t}function It(e){let t=e.target,n=`${e.type}`,r=e.target,o=e.currentTarget,s=c=>Object.defineProperty(e,"target",{configurable:true,value:c}),i=()=>{let c=t[`_$${n}`];if(c&&shared.isFunction(c)&&!t.disabled){let f=t[`${n}Data`];if(f?c.call(t,f,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!shared.isString(t.host)&&!t.host._$host&&shared.isFunction(t.contains)&&t.contains(e.target)&&s(t.host),true},a=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();s(c[0]);for(let f=0;f<c.length-2&&(t=c[f],!!i());f++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();s(r);}var Ve=Symbol("_$EVENTS");function $t(e,t=window.document){let n=t,r=n[Ve]||(n[Ve]=new Set);for(let o of e)r.has(o)||(r.add(o),t.addEventListener(o,It));}function Ot(e,t,n,r=false){if(t===n)return;let o=G(n),s=G(t);o&&s===o||(o?r?e.setAttribute("class",o):e.className=o:e.removeAttribute("class"));}function G(e){if(e==null)return "";if(typeof e=="string")return e.trim();if(shared.isArray(e))return e.map(G).filter(Boolean).join(" ");if(shared.isObject(e)){let t=[];for(let n in e)e[n]&&t.push(n);return t.join(" ")}return String(e).trim()}var Ge=/\s*!important$/,Vt=["Webkit","Moz","ms"],me={};function Gt(e,t,n){let r=e.style,o=shared.isString(n);if(n&&o){t!==n&&(r.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t))for(let s in t)(!n||n[s]==null)&&j(r,s,"");else if(t&&shared.isString(t)){let s=t.split(";");for(let i of s){let a=i.indexOf(":");if(a>0){let c=i.slice(0,a).trim();n&&shared.isObject(n)&&n[c]==null&&j(r,c,"");}}}if(n&&!shared.isString(n))for(let s in n){let i=n[s];(!t||shared.isString(t)||t[s]!==i)&&i!=null&&j(r,s,i);}}function j(e,t,n){if(shared.isArray(n)){for(let o of n)j(e,t,o);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let r=Xt(e,t);typeof n=="string"&&Ge.test(n)?e.setProperty(shared.camelCase(r),n.replace(Ge,""),"important"):e[r]=n;}function Xt(e,t){let n=me[t];if(n)return n;let r=shared.camelCase(t);if(r!=="filter"&&r in e)return me[t]=r;r=shared.capitalize(r);for(let o of Vt){let s=o+r;if(s in e)return me[t]=s}return t}function Ye(e,t,n,r){if(t==="key"){r==null?K(e,void 0):K(e,String(r));return}if(t===Ae){Object.keys(r).forEach(u=>{Ye(e,u,n==null?void 0:n[u],r==null?void 0:r[u]);});return}let o=(e==null?void 0:e.namespaceURI)===ve,s=o&&t.startsWith("xlink:"),i=o&&t.startsWith("xmlns:"),a=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(n===r)return;let c=t.toLowerCase();if(/^on[a-z]+/.test(c)||c==="innerhtml")return;if(r==null){if(s)e.removeAttributeNS(J,t.slice(6));else if(i){let u=t.slice(6);e.removeAttributeNS(Q,u);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(J,t,String(r));return}if(i){e.setAttributeNS(Q,t,String(r));return}if(a){shared.includeBooleanAttr(r)?e.setAttribute(t,""):e.removeAttribute(t);return}let f=shared.isSymbol(r)?String(r):r;if((c==="href"||c==="src"||c==="xlink:href")&&typeof f=="string"){let u=f.trim().toLowerCase();if(u.startsWith("javascript:")||u.startsWith("data:"))return}if(o)e.setAttribute(t,String(f));else if(t in e)try{e[t]=f;}catch(u){e.setAttribute(t,String(f));}else e.setAttribute(t,String(f));}function Qt(e,t,n,r){if(!(r!=null&&r.delegate))return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r);let o=r.delegate,s=a=>{let c=a.target;(c.matches(o)||c.closest(o))&&n.call(e,a);},i=U({},r);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function Zt(e){return e==null?void 0:e.children}Zt.fragment=true;function oo(e){return !!e&&!!e.fragment}function tn(e){if(typeof document=="undefined"){let r=e.children;return r?(shared.isArray(r)?r:[r]).map(s=>String(s||"")).join(""):""}let t=document.createComment("portal");t.portal=true;let n=e.children;if(n){let r=shared.isArray(n)?n:[n],o=[];ae(()=>{let s=shared.isString(e.target)?document.querySelector(e.target):e.target;s&&(r.forEach(i=>{if(i!=null){let a=C(i);a&&(h(s,a),o.push(a));}}),$(()=>{o.forEach(i=>{typeof i!="string"&&i.parentNode===s&&s.removeChild(i);});}));});}return t}tn.portal=true;function po(e){return !!e&&!!e.portal}var he=Symbol("SuspenseContext");function on(e){if(shared.isUndefined(document)){let u=e.fallback;return u?String(u||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,r=0,o=false,s=null,i=()=>{if(!o){for(o=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let u=C(e.fallback);u&&h(t,u);}}},a=()=>{if(!(!o||!(s||e.children!=null&&!shared.isPromise(e.children)))){for(o=false;t.firstChild;)t.removeChild(t.firstChild);s?c(s):e.children!=null&&!shared.isPromise(e.children)&&c(e.children);}},c=u=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(u==null)return;let m=S();if((shared.isArray(u)?u:[u]).forEach(v=>{if(v!=null){p(v)&&(v.parentContext=m);let H=C(v);H&&h(t,H);}}),o){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let v=C(e.fallback);v&&h(t,v);}}},f={register:u=>{r++,i(),u.then(()=>{n&&(r--,r===0&&a());}).catch(m=>{n&&(r--,r===0&&a());});},increment:()=>{r++,i();},decrement:()=>{r--,r===0&&a();}};de(he,f);let l=e.children;return shared.isPromise(l)?(l.then(u=>{s=u;}).catch(()=>{}),f.register(l)):l!=null?c(l):i(),fe(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}on.suspense=true;function vo(e){return !!e&&!!e.suspense}function Co(e,t){let n=signals.signal(t==null?void 0:t.initialValue),r=signals.signal(true),o=signals.signal(null),s=signals.signal("pending"),i=0,a=null,c=()=>I(null,null,function*(){let u=++i;r.value=true,s.value="pending",o.value=null;try{let m=e();a=m.then(()=>{}).catch(()=>{});let N=yield m;u===i&&(n.value=N,s.value="ready",r.value=!1);}catch(m){u===i&&(o.value=m instanceof Error?m:new Error(String(m)),s.value="errored",r.value=false);}});c();let f=(()=>{if(r.value&&a){let u=pe(he,null);u&&u.register(a);}return n.value});return f.loading=r,f.error=o,f.state=s,[f,{mutate:u=>{n.value=u,s.value="ready",r.value=false,o.value=null;},refetch:()=>I(null,null,function*(){yield c();})}]}var qe=0;function ge(){return `${qe++}`}function Y(){qe=0;}function Se(){}function R(e,t=false){return shared.isNil(e)?"":shared.isString(e)?e:shared.isArray(e)?e.map(n=>R(n,t)).join(""):shared.isFunction(e)?R(e(),t):String(e)}function Qe(e,t){let n=/^<([a-z]+)(\s*)([^>]*)>/i,r=/data-idx="(\d+)"/g,o=/<!--(.*?)-->/g;return e.replace(n,`<$1$2$3 data-hk="${t}">`).replaceAll(r,`data-idx="${t}-$1"`).replaceAll(o,`<!--${t}-$1-->`)}function un(e,t={}){if(!shared.isFunction(e))return shared.error("Component must be a function"),"";Y();let n=e(t);return R(n)}function ln(e,t,...n){let r="",o=0;for(let i of e)if(r+=i,o<n.length){let a=n[o++];a&&(r+=R(a));}return Qe(r,t)}function dn(e,t={}){if(!shared.isFunction(e))return shared.error("create ssg component: Component is not a function"),"";let n=e(t);return R(n)}function rt(e){if(shared.isArray(e)){let t={};for(let n of e){let r=shared.isString(n)?xn(n):rt(n);if(r)for(let o in r)t[o]=r[o];}return t}if(shared.isString(e)||shared.isObject(e))return e}var gn=/;(?![^(]*\))/g,Sn=/:([\s\S]+)/,Nn=/\/\*[\s\S]*?\*\//g;function xn(e){let t={};return e.replaceAll(Nn,"").split(gn).forEach(n=>{if(n){let r=n.split(Sn);r.length>1&&(t[r[0].trim()]=r[1].trim());}}),t}function En(e){if(!e)return "";if(shared.isString(e))return e;let t="";for(let n in e){let r=e[n];if(shared.isString(r)||shared.isNumber(r)){let o=n.startsWith("--")?n:shared.kebabCase(n);t+=`${o}:${r};`;}}return t}function ot(e){let t="";if(shared.isString(e))t=e;else if(shared.isArray(e))for(let n of e){let r=ot(n);r&&(t+=`${r} `);}else if(shared.isObject(e))for(let n in e)e[n]&&(t+=`${n} `);return t.trim()}function it(e,t,n){if(signals.isSignal(t)||signals.isComputed(t))return it(e,t.value);if(!t&&t!==0)return "";if(e==="style"){let r=rt(t);return r?shared.isString(r)?` style="${r}"`:` style="${En(r)}"`:""}if(e==="class"){let r=ot(t);return r?` class="${r}"`:""}return e.startsWith("on")?"":t===true?` ${e}`:` ${e}="${t}"`}function vn(e){return ()=>{let t=ge();return document.querySelector(`[data-hk="${t}"]`)||le(e)()}}function bn(e,t){let n=e.dataset.hk;if(!n)return se(e,t);let r=[],o=e.querySelectorAll(`[data-idx^="${n}"]`);o.length>0&&r.push(...Array.from(o).filter(c=>{let f=c.dataset.idx;return f!==null&&Z.test(f)}).map(c=>{let f=c.dataset.idx||"",[l,u]=f.split("-");return {hk:l,idx:u,node:c}}));let s=[],i=c=>{if(c.nodeType===Node.COMMENT_NODE&&c.textContent&&Z.test(c.textContent)){let[l,u]=c.textContent.split("-");s.push({hk:l,idx:u,node:c});}let f=c.firstChild;for(;f;)i(f),f=f.nextSibling;};i(e),r.push(...s);let a=[e];return t.forEach(c=>{let f=r.find(l=>l.idx===String(c));f&&a.push(f.node);}),a}function _n(e,t,n={}){Y();try{let r=shared.isString(t)?document.querySelector(t):t;if(!r){shared.error("Hydration error: Root element not found");return}let o=F(e,n);return o.mount(r),Se(),o}catch(r){shared.error("Hydration error:",r);return}}
|
|
7
|
-
Object.defineProperty(exports,"escapeHTML",{enumerable:true,get:function(){return shared.escapeHTML}});exports.Component=V;exports.Fragment=Zt;exports.Portal=tn;exports.Suspense=on;exports.SuspenseContext=he;exports.addEvent=Qt;exports.addEventListener=A;exports.bindElement=bt;exports.createApp=Mt;exports.createComponent=F;exports.createResource=Co;exports.createSSGComponent=dn;exports.delegateEvents=$t;exports.getHydrationKey=ge;exports.getRenderedElement=vn;exports.hydrate=_n;exports.inject=pe;exports.insert=ie;exports.isComponent=p;exports.isFragment=oo;exports.isPortal=po;exports.isSuspense=vo;exports.mapNodes=se;exports.mapSSRNodes=bn;exports.normalizeClass=G;exports.omitProps=St;exports.onDestroy=fe;exports.onMount=ae;exports.onUpdate=Tt;exports.patchAttr=Ye;exports.patchClass=Ot;exports.patchStyle=Gt;exports.provide=de;exports.render=ln;exports.renderToString=un;exports.setSSGAttr=it;exports.setStyle=j;exports.template=le;//# sourceMappingURL=template.cjs.js.map
|
|
1
|
+
'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');var bt=Object.defineProperty;var Le=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable;var Me=(e,t,n)=>t in e?bt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))_t.call(t,n)&&Me(e,n,t[n]);if(Le)for(var n of Le(t))Ct.call(t,n)&&Me(e,n,t[n]);return e};var re=(e,t,n)=>new Promise((o,r)=>{var s=a=>{try{c(n.next(a));}catch(u){r(u);}},i=a=>{try{c(n.throw(a));}catch(u){r(u);}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,i);c((n=n.apply(e,t)).next());});var Pt={mount:"mount",destroy:"destroy",update:"update"};function ie(e,t,n){let o=e[t];o||(o=e[t]=[]),o.includes(n)||o.push(n);}function se(e,t,n){let o=e.length;if(o===0)return;let r;for(let s=0;s<o;s++)try{let i=e[s]();if(shared.isPromise(i)){let c=i.catch(a=>{});(r!=null?r:r=[]).push(c);}}catch(i){}if(r)return Promise.all(r).then(()=>{})}function ce(e){let t=_();if(t){if(t.isMounted){try{let n=e();shared.isPromise(n)&&n.catch(o=>{});}catch(n){}return}ie(t,"onMount",e);}}function kt(e){let t=_();t&&ie(t,"onUpdate",e);}function ae(e){let t=_();t&&ie(t,"onDestroy",e);}function Ie(e){var o;if(e.isDestroyed||!((o=e.onMount)!=null&&o.length)){e.isMounted=true;return}let t=e.onMount,n=w(e,()=>se(t,e.id,Pt.mount));return t.length=0,e.isMounted=true,n}function ue(e){var o;if(e.isDestroyed||!((o=e.onUpdate)!=null&&o.length))return;let t=e.onUpdate,n=w(e,()=>se(t,e.id,"update"));return t.length=0,n}function He(e){var t;if(!(e.isDestroyed||!((t=e.onDestroy)!=null&&t.length)))return w(e,()=>se(e.onDestroy,e.id,"destroy"))}var L=null,Tt=0;function _(){return L}function K(e){L=e;}function U(e=L){let t={id:++Tt,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=[]),e.children.push(t)),t}function w(e,t){let n=L;L=e;try{return t()}finally{L=n;}}function V(e){var n,o,r;if(!e||e.isDestroyed)return;let t=e.parent;if(e.children){for(let s of e.children)V(s);e.children.length=0;}if((n=e.onDestroy)!=null&&n.length&&(He(e),e.onDestroy.length=0),(o=e.cleanup)!=null&&o.length){for(let s of e.cleanup)try{s();}catch(i){}e.cleanup.length=0;}if(t!=null&&t.children){let s=t.children.indexOf(e);s!==-1&&t.children.splice(s,1);}(r=e.provides)==null||r.clear(),e.onMount&&(e.onMount.length=0),e.onUpdate&&(e.onUpdate.length=0),e.parent=null,e.isDestroyed=true,L===e&&(L=t);}function I(e){let t=L;t&&(t.cleanup||(t.cleanup=[]),t.cleanup.push(e));}var Fe="_$spread$";var Ke="http://www.w3.org/2000/svg",fe="http://www.w3.org/2000/xlink",le="http://www.w3.org/2000/xmlns/";var de=Symbol(""),pe=Symbol(""),W=Symbol(""),me=Symbol(""),Oe=Symbol("");var Ve=1e3,$e=new WeakMap;function Ue(e){let t=$e.get(e);if(!t){let n=e.name||"anonymous",o=ze(e.toString()).toString(36);t=`${n}_${o}`,$e.set(e,t);}return t}function ze(e){let t=0,n=e.length<100?e.length:100;for(let o=0;o<n;o++)t=Math.trunc((t<<5)-t+e.charCodeAt(o));return t<0?-t:t}var Mt=0;function he(e){if(!shared.isFalsy(e)){if(shared.isString(e))return e.length<=Ve?e:`${e.slice(0,Ve-10)}_${ze(e).toString(36)}`;if(shared.isNumber(e))return String(e);if(shared.isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${Mt++}`}return String(e)}}var ye=Symbol("essor.key");function z(e,t){if(y(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=he(t);shared.isFalsy(n)?delete e[ye]:e[ye]=n;}function M(e){if(e)return y(e)?e.key:e[ye]}function R(e){if(shared.isHTMLElement(e))return e;if(shared.isPrimitive(e)){let t=shared.isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function D(e,t){let n=M(e),o=M(t);if(n!==o)return false;let r=y(e),s=y(t);if(r&&s)return e.component===t.component;if(r!==s)return false;if(shared.isPrimitive(e)||shared.isPrimitive(t))return e===t;let i=e,c=t;return i.nodeType!==c.nodeType?false:i.nodeType===Node.ELEMENT_NODE?i.tagName===c.tagName:true}function Ne(e,t){if(e===t)return true;if(shared.isNull(e)||shared.isNull(t)||!shared.isObject(e)||!shared.isObject(t)||shared.isArray(e)!==shared.isArray(t))return false;let n=e,o=t,r=Object.keys(n),s=Object.keys(o);if(r.length!==s.length)return false;for(let i of r)if(!(i in o)||n[i]!==o[i])return false;return true}function P(e){if(!e)return;if(y(e)){e.destroy();return}let t=e;t.parentElement&&t.remove();}function C(e,t,n){if(!e||!t)return;if(y(t)){let r=y(n)?n.firstChild:n;t.mount(e,r);return}let o=y(n)?n.firstChild:n;o?e.insertBefore(t,o):e.appendChild(t);}function X(e,t,n){if(!e||!t||!n||t===n)return;let o=y(n)?n.beforeNode:n.nextSibling;P(n),C(e,t,o);}function k(e){if(e){if(y(e))return e.firstChild;if(!shared.isPrimitive(e))return e}}function qe(e,t){if(y(e)||y(t))return;let n=M(e);n&&!M(t)&&z(t,n);}function H(e,t,n){if(n===t)return t;let o=shared.isHTMLElement(t);if(shared.isHTMLElement(n)&&o){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let c=t.attributes,a=n.attributes;for(let u=c.length-1;u>=0;u--){let p=c[u].name;n.hasAttribute(p)||t.removeAttribute(p);}for(let u=0,p=a.length;u<p;u++){let f=a[u];t.getAttribute(f.name)!==f.value&&t.setAttribute(f.name,f.value);}return qe(t,n),t}}if(shared.isTextNode(t)&&shared.isTextNode(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),qe(t,n),t;let s=y(t),i=y(n);return s&&i&&t.component===n.component?n.update(t):(X(e,n,t),n)}function Je(e,t,n,o){let r=t.length,s=n.length;if(r===0&&s===0)return [];if(r===0){for(let i=0;i<s;i++)C(e,n[i],o);return n}if(s===0){for(let i=0;i<r;i++)P(t[i]);return []}if(r===1&&s===1){let i=t[0],c=n[0];return D(i,c)?(H(e,i,c),n[0]=i):X(e,c,i),n}if(r===2&&s===2){let i=t[0],c=t[1],a=n[0],u=n[1];if(D(i,a)&&D(c,u))return H(e,i,a),H(e,c,u),n[0]=i,n[1]=c,n;if(D(i,u)&&D(c,a)){H(e,i,u),H(e,c,a);let p=k(c),f=k(i);return p&&f&&p.parentNode===e&&e.insertBefore(p,f),n[0]=c,n[1]=i,n}}return Ft(e,t,n,o)}function Ft(e,t,n,o){let r=0,s=0,i=t.length-1,c=n.length-1,a=t[0],u=t[i],p=n[0],f=n[c];for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(D(a,p))H(e,a,p),n[s]=a,a=t[++r],p=n[++s];else break;for(;r<=i&&s<=c;)if(!a)a=t[++r];else if(!u)u=t[--i];else if(D(u,f))H(e,u,f),n[c]=u,u=t[--i],f=n[--c];else break;if(r>i){if(s<=c){let l=c+1<n.length?k(n[c+1]):o;for(let m=s;m<=c;m++)C(e,n[m],l);}}else if(s>c)for(let l=r;l<=i;l++){let m=t[l];m&&P(m);}else Kt(e,t,n,r,i,s,c,o);return n}function Kt(e,t,n,o,r,s,i,c){let a=i-s+1,u;for(let N=s;N<=i;N++){let E=M(n[N]);E!==void 0&&(u||(u=Object.create(null)),u[E]=N);}let p=new Int32Array(a),f=false,l=0,m=0;for(let N=o;N<=r;N++){let E=t[N];if(!E)continue;if(m>=a){P(E);continue}let x,A=M(E);if(A!==void 0&&u&&A in u)x=u[A];else for(let d=s;d<=i;d++)if(p[d-s]===0&&A===void 0&&M(n[d])===void 0&&D(E,n[d])){x=d;break}x===void 0?P(E):(p[x-s]=N+1,x>=l?l=x:f=true,H(e,E,n[x]),n[x]=E,m++);}let S=f?Ot(p):[],v=S.length-1,h=c;for(let N=a-1;N>=0;N--){let E=s+N,x=n[E];if(p[N]===0)C(e,x,h),h=k(x)||h;else if(f)if(v<0||N!==S[v]){let A=k(x);A&&A.parentNode===e&&C(e,A,h),h=A||h;}else h=k(x)||h,v--;else h=k(x)||h;}}function Ot(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],o=new Int32Array(t),r,s,i,c,a;for(r=0;r<t;r++){let u=e[r];if(u!==0){if(s=n[n.length-1],n.length===0||e[s]<u){o[r]=s,n.push(r);continue}for(i=0,c=n.length-1;i<c;)a=i+c>>1,e[n[a]]<u?i=a+1:c=a;u<e[n[i]]&&(i>0&&(o[r]=n[i-1]),n[i]=r);}}for(i=n.length,c=n[i-1];i-- >0;)n[i]=c,c=o[c];return n}function T(e,t,n,o){e.addEventListener(t,n,o),I(()=>{e.removeEventListener(t,n,o);});}function Yt(e,t,n,o){shared.isHtmlInputElement(e)?Bt(e,o):shared.isHtmlSelectElement(e)?Gt(e,o):shared.isHtmlTextAreaElement(e)&&T(e,"input",()=>{o(e.value);});}function Bt(e,t){switch(e.type){case "checkbox":T(e,"change",()=>{t(!!e.checked);});break;case "radio":T(e,"change",()=>{t(e.checked?e.value:"");});break;case "file":T(e,"change",()=>{t(e.files);});break;case "number":case "range":T(e,"input",()=>{t(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":T(e,"change",()=>{t(e.value||"");});break;default:T(e,"input",()=>{t(e.value);});break}}function Gt(e,t){T(e,"change",()=>{if(e.multiple){let n=Array.from(e.options).filter(o=>o.selected).map(o=>o.value);t(n);}else t(e.value);});}function Se(e,t,n){if(!e)return;let o=[],r=_(),s=signals.effect(()=>{let i=()=>{let c=shared.isFunction(t)?t():t,a=shared.coerceArray(c).map(u=>shared.isFunction(u)?u():u).flatMap(R);o=Je(e,o,a,n);};r?w(r,i):i();});return I(()=>{s(),o.forEach(i=>P(i)),o.length=0;}),o}function Ee(e,t){let n=t.length,o=new Array(n),r=new Set(t),s=1,i=0,c=a=>{if(a.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(r.has(s)&&(o[i++]=a,i===n))return true;s++;}let u=a.firstChild;for(;u;){if(c(u))return true;u=u.nextSibling;}return false};return c(e),o}var nt;nt=de;var J=class{constructor(t,n={}){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this._propSnapshots={};this.state=0;this.parentScope=null;this[nt]=true;this.key=n.key?he(n.key):Ue(t),this.reactiveProps=signals.shallowReactive(O({},n)),this.parentScope=_();for(let o in n){let r=n[o];shared.isObject(r)&&(this._propSnapshots[o]=shared.isArray(r)?[...r]:O({},r));}}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=k(t);if(n)return n}}mount(t,n){var i,c;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let a of this.renderedNodes)C(t,a,n);return this.state=2,this.renderedNodes}let o=(i=this.parentScope)!=null?i:_();this.scope=U(o),K(this.scope);let r=this.component(this.reactiveProps);shared.isFunction(r)&&(r=r(this.reactiveProps)),(signals.isSignal(r)||signals.isComputed(r))&&(r=r.value);let s=(c=Se(t,r,n))!=null?c:[];return this.renderedNodes=s,this.applyProps(this.props),this.state=2,Ie(this.scope),this.renderedNodes}update(t){return this.key!==t.key?(this.mount(t.parentNode,t.beforeNode),this):(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.scope=t.scope,this.parentScope=t.parentScope,this.renderedNodes=t.renderedNodes,this.state=t.state,this.reactiveProps=t.reactiveProps,this._propSnapshots=t._propSnapshots,this._updateReactiveProps(this.props),!this.isConnected&&this.parentNode?(this.mount(this.parentNode,this.beforeNode),this):(this.scope&&(K(this.scope),this.applyProps(this.props),ue(this.scope)),this))}_updateReactiveProps(t){for(let n in t){if(n==="key")continue;let o=t[n],r=this.reactiveProps[n];if(o===r&&!this._propSnapshots[n])continue;if(shared.isObject(o)){let i=this._propSnapshots[n];if(i&&Ne(o,i))continue;let c=shared.isArray(o)?[...o]:O({},o);this.reactiveProps[n]=c,this._propSnapshots[n]=c;}else shared.hasChanged(o,r)&&(this.reactiveProps[n]=o,this._propSnapshots[n]&&delete this._propSnapshots[n]);}}unwrapRenderResult(t){return shared.isFunction(t)&&(t=t(this.reactiveProps)),(signals.isSignal(t)||signals.isComputed(t))&&(t=t.value),y(t)&&(t=t.mount(this.parentNode,this.beforeNode)),shared.isPromise(t)&&(t=t.then(n=>this.unwrapRenderResult(n))),t}forceUpdate(){if(this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{w(this.scope,()=>{let n=this.component(this.reactiveProps);shared.isFunction(n)&&(n=n(this.reactiveProps)),(signals.isSignal(n)||signals.isComputed(n))&&(n=n.value);let o=shared.coerceArray(n),r=this._getAnchorNode();if(this.parentNode){for(let s of this.renderedNodes)P(s);for(let s of o)C(this.parentNode,s,r);this.renderedNodes=o;}}),this.scope&&ue(this.scope);}catch(n){throw this.renderedNodes=t,n}}_getAnchorNode(){if(this.beforeNode)return this.beforeNode;if(this.renderedNodes.length>0){let t=this.renderedNodes[this.renderedNodes.length-1],n=k(t);if(n)return n.nextSibling}}destroy(){if(this.state===4||this.state===5)return;this.state=4;for(let n of this.renderedNodes)P(n);let t=this.scope;t&&(V(t),this.scope=null),this.renderedNodes=[],this.parentNode=void 0,this.beforeNode=void 0,this.parentScope=null,this.reactiveProps={},this.props={},this.state=5;}applyProps(t){if(!t)return;let n=this.firstChild;for(let[o,r]of Object.entries(t))if(shared.startsWith(o,"on")){if(!n||!shared.isHTMLElement(n))return;let s=o.slice("on".length).toLowerCase();T(n,s,r);}else o==="ref"&&signals.isSignal(r)&&(r.value=n);this.props=t;}};function y(e){return !!e&&!!e[de]}function Y(e,t){return y(e)?e:new J(e,t)}function Ae(e){let t,n=()=>{let o=document.createElement("template");o.innerHTML=e;let r=o.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=n())).cloneNode(true)}function nn(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n){shared.error(`Target element not found: ${t}`);return}n.innerHTML&&(shared.error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let r=y(e)?e:Y(e);return r.mount(n),r}function be(e,t){let n=_();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function _e(e,t){let n=_();if(!n)return t;let o=n;for(;o;){if(o.provides){let r=o.provides.get(e);if(r)return r}o=o.parent;}return t}function Ce(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function ct(e,t,n){let o=e[`_$${n}`];if(o&&shared.isFunction(o)&&!e.disabled){let r=e[`${n}Data`];if(r?o.call(e,r,t):o.call(e,t),t.cancelBubble)return false}return e.host&&!shared.isString(e.host)&&!e.host._$host&&shared.isFunction(e.contains)&&e.contains(t.target)&&Ce(t,e.host),true}function it(e,t,n){let o=e;for(;ct(o,t,n)&&(o=o._$host||o.parentNode||o.host););return o}function rn(e){let t=e.target,n=`${e.type}`,o=e.target,r=e.currentTarget;if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let s=e.composedPath();Ce(e,s[0]);for(let i=0;i<s.length-2&&(t=s[i],!!ct(t,e,n));i++){if(t._$host){t=t._$host,t=it(t,e,n);break}if(t.parentNode===r)break}}else t=it(t,e,n);Ce(e,o);}var st=Symbol("_$EVENTS");function sn(e,t=window.document){let n=t,o=n[st]||(n[st]=new Set);for(let r of e)o.has(r)||(o.add(r),t.addEventListener(r,rn));}function cn(e,t){let n=new Set(t);return new Proxy(e,{get(o,r){if(!n.has(r))return Reflect.get(o,r)},ownKeys(o){return Reflect.ownKeys(o).filter(r=>!n.has(r))},getOwnPropertyDescriptor(o,r){if(!n.has(r))return Reflect.getOwnPropertyDescriptor(o,r)},has(o,r){return n.has(r)?false:Reflect.has(o,r)}})}var Pe=false;function Q(){Pe=true;}function B(){Pe=false;}function F(){return Pe}var at=0;function Z(){return `${at++}`}function ee(){at=0;}var ft=/^\d+-\d+$/;function lt(e){return ()=>{if(!shared.isBrowser())return null;let t=Z(),n=document.querySelector(`[data-hk="${t}"]`);return n||Ae(e)()}}function dt(e,t){let n=e.dataset.hk;if(!n)return Ee(e,t);let o=[],r=e.querySelectorAll(`[data-idx^="${n}"]`);r.length>0&&o.push(...Array.from(r).filter(a=>{let u=a.dataset.idx;return u!==null&&ft.test(u)}).map(a=>{let u=a.dataset.idx||"",[p,f]=u.split("-");return {hk:p,idx:f,node:a}}));let s=[],i=a=>{if(a.nodeType===Node.COMMENT_NODE&&a.textContent&&ft.test(a.textContent)){let[p,f]=a.textContent.split("-");s.push({hk:p,idx:f,node:a});}let u=a.firstChild;for(;u;)i(u),u=u.nextSibling;};i(e),o.push(...s);let c=[e];return t.forEach(a=>{let u=o.find(p=>p.idx===String(a));u&&c.push(u.node);}),c}function pt(e,t){Q(),ee();try{let n=shared.isString(t)?document.querySelector(t):t;if(!n){shared.error("Hydration error: Root element not found");return}let o=Y(e);return o.mount(n),B(),o}catch(n){shared.error("Hydration error:",n),B();return}}function mt(e,t,n,o=false){if(t===n||F())return;let r=te(n),s=te(t);r&&s===r||(r?o?e.setAttribute("class",r):e.className=r:e.removeAttribute("class"));}function te(e){return shared.normalizeClassName(e)}var yt=/\s*!important$/,mn=["Webkit","Moz","ms"],ke={};function gt(e,t,n){let o=e.style,r=shared.isString(n);if(!F()){if(n&&r){t!==n&&(o.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t))for(let s in t)(!n||n[s]==null)&&j(o,s,"");else if(t&&shared.isString(t)){let s=t.split(";");for(let i of s){let c=i.indexOf(":");if(c>0){let a=i.slice(0,c).trim();n&&shared.isObject(n)&&n[a]==null&&j(o,a,"");}}}if(n&&!shared.isString(n))for(let s in n){let i=n[s];(!t||shared.isString(t)||t[s]!==i)&&i!=null&&j(o,s,i);}}}function j(e,t,n){if(shared.isArray(n)){for(let r of n)j(e,t,r);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let o=yn(e,t);shared.isString(n)&&yt.test(n)?e.setProperty(shared.camelCase(o),n.replace(yt,""),"important"):e[o]=n;}function yn(e,t){let n=ke[t];if(n)return n;let o=shared.camelCase(t);if(o!=="filter"&&o in e)return ke[t]=o;o=shared.capitalize(o);for(let r of mn){let s=r+o;if(s in e)return ke[t]=s}return t}function Te(e,t,n,o){if(t==="key"){o==null?z(e,void 0):z(e,String(o));return}if(t===Fe){Object.keys(o).forEach(f=>{Te(e,f,n==null?void 0:n[f],o==null?void 0:o[f]);});return}if(F())return;let r=(e==null?void 0:e.namespaceURI)===Ke,s=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(n===o)return;let a=t.toLowerCase();if(a.length>2&&a.charCodeAt(0)===111&&a.charCodeAt(1)===110||a==="innerhtml")return;if(o==null){if(s)e.removeAttributeNS(fe,t.slice(6));else if(i){let f=t.slice(6);e.removeAttributeNS(le,f);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(fe,t,String(o));return}if(i){e.setAttributeNS(le,t,String(o));return}if(c){shared.includeBooleanAttr(o)?e.setAttribute(t,""):e.removeAttribute(t);return}let u=shared.isSymbol(o)?String(o):o;if((a==="href"||a==="src"||a==="xlink:href")&&shared.isString(u)){let f=u.trim().toLowerCase();if(f.startsWith("javascript:")||f.startsWith("data:"))return}if(r)e.setAttribute(t,String(u));else if(t in e)try{e[t]=u;}catch(f){e.setAttribute(t,String(u));}else e.setAttribute(t,String(u));}function Nt(e,t,n,o){if(!(o!=null&&o.delegate))return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o);let r=o.delegate,s=c=>{let a=c.target;(a.matches(r)||a.closest(r))&&n.call(e,c);},i=O({},o);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function St(e){if(!(e!=null&&e.children))return shared.error("Fragment component requires children"),null;let{children:t}=e;return t}St[pe]=true;function An(e){return !!e&&!!e[pe]}function vt(e){let t=document.createComment("portal");t[W]=true;let n=e.children;if(n){let o=shared.isArray(n)?n:[n],r=[];ce(()=>{let s=shared.isString(e.target)?document.querySelector(e.target):e.target;s&&(o.forEach(i=>{if(i!=null){let c=R(i);c&&(C(s,c),r.push(c));}}),I(()=>{r.forEach(i=>{!shared.isString(i)&&i.parentNode===s&&s.removeChild(i);});}));});}return t}vt[W]=true;function _n(e){return !!e&&!!e[W]}var we=Symbol("SuspenseContext");function xt(e){if(shared.isUndefined(document)){let f=e.fallback;return f?String(f||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,s=null,i=()=>{if(!r){for(r=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let f=R(e.fallback);f&&C(t,f);}}},c=()=>{if(!(!r||!(s||e.children!=null&&!shared.isPromise(e.children)))){for(r=false;t.firstChild;)t.removeChild(t.firstChild);s?a(s):e.children!=null&&!shared.isPromise(e.children)&&a(e.children);}},a=f=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(f==null)return;let l=_();if((shared.isArray(f)?f:[f]).forEach(S=>{if(S!=null){y(S)&&(S.parentContext=l);let v=R(S);v&&C(t,v);}}),r){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let S=R(e.fallback);S&&C(t,S);}}},u={register:f=>{o++,i(),f.then(()=>{n&&(o--,o===0&&c());}).catch(l=>{n&&(o--,o===0&&c());});},increment:()=>{o++,i();},decrement:()=>{o--,o===0&&c();}};be(we,u);let p=e.children;return shared.isPromise(p)?(p.then(f=>{s=f;}).catch(()=>{}),u.register(p)):p!=null?a(p):i(),ae(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}xt[me]=true;function kn(e){return !!e&&!!e[me]}function Tn(e,t){let n=signals.signal(t==null?void 0:t.initialValue),o=signals.signal(true),r=signals.signal(null),s=signals.signal("pending"),i=0,c=null,a=()=>re(null,null,function*(){let f=++i;o.value=true,s.value="pending",r.value=null;try{let l=e();c=l.then(()=>{}).catch(()=>{});let m=yield l;f===i&&(n.value=m,s.value="ready",o.value=!1);}catch(l){f===i&&(r.value=l instanceof Error?l:new Error(String(l)),s.value="errored",o.value=false);}});a();let u=(()=>{if(o.value&&c){let f=_e(we,null);f&&f.register(c);}return n.value});return u.loading=o,u.error=r,u.state=s,[u,{mutate:f=>{n.value=f,s.value="ready",o.value=false,r.value=null;},refetch:()=>re(null,null,function*(){yield a();})}]}function At(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=null,s=e.keyFn,i=e.children,c=()=>{var m,S;let l=e.each;return signals.isSignal(l)?(m=l.value)!=null?m:[]:typeof l=="function"?(S=l())!=null?S:[]:l!=null?l:[]},a=l=>s?s(l):l,u=(l,m,S,v)=>{var x;let h=_(),N=U(h);K(N);let E;try{let A=i(l,m);y(A)?(A.mount(S,v),E=(x=A.firstChild)!=null?x:document.createComment("empty")):(E=A,E.parentNode||(v?S.insertBefore(E,v):S.appendChild(E)));}finally{K(h);}return {key:a(l),node:E,scope:N}},p=l=>{V(l.scope),l.node.parentNode&&l.node.parentNode.removeChild(l.node);};signals.memoEffect(({prev:l})=>{var v;let m=c();if(l===m)return {prev:m};let S=n.parentNode;if(!S){if(m.length===0){if(e.fallback){let h=e.fallback();y(h)?(h.mount(t,n),r=(v=h.firstChild)!=null?v:document.createComment("empty")):(r=h,t.insertBefore(r,n));}return {prev:m}}o=new Array(m.length);for(let[h,N]of m.entries())o[h]=u(N,h,t,n);return {prev:m}}return signals.untrack(()=>f(S,m)),{prev:m}},{prev:[]});function f(l,m){var A;let S=o.length,v=m.length;if(v===0){for(let d=0;d<S;d++)p(o[d]);if(o=[],e.fallback&&!r){let d=e.fallback();y(d)?(d.mount(l,n),r=(A=d.firstChild)!=null?A:document.createComment("empty")):(r=d,l.insertBefore(r,n));}return}if(S===0||r){r&&(r.parentNode&&r.parentNode.removeChild(r),r=null),o=new Array(v);let d=document.createDocumentFragment();for(let b=0;b<v;b++)o[b]=u(m[b],b,d,null);l.insertBefore(d,n);return}let h=new Map;for(let d=0;d<S;d++){let b=o[d],G=h.get(b.key);G?G.push(b):h.set(b.key,[b]);}let N=new Array(v),E=[],x=document.createDocumentFragment();for(let d=0;d<v;d++){let b=m[d],G=a(b),oe=h.get(G);oe&&oe.length>0?N[d]=oe.shift():N[d]=u(b,d,x,null);}for(let d of h.values())for(let b of d)E.push(b);for(let d of E)p(d);for(let d=0;d<v;d++){let b=N[d].node;l.insertBefore(b,n);}o=N;}return I(()=>{for(let l of o)p(l);r&&r.parentNode&&r.parentNode.removeChild(r),n.parentNode&&n.parentNode.removeChild(n);}),t}At[Oe]=true;
|
|
2
|
+
exports.Component=J;exports.For=At;exports.Fragment=St;exports.Portal=vt;exports.Suspense=xt;exports.addEvent=Nt;exports.addEventListener=T;exports.bindElement=Yt;exports.createApp=nn;exports.createComponent=Y;exports.createResource=Tn;exports.createScope=U;exports.delegateEvents=sn;exports.disposeScope=V;exports.endHydration=B;exports.getActiveScope=_;exports.getFirstDOMNode=k;exports.getHydrationKey=Z;exports.getRenderedElement=lt;exports.hydrate=pt;exports.inject=_e;exports.insert=Se;exports.insertNode=C;exports.isComponent=y;exports.isFragment=An;exports.isHydrating=F;exports.isPortal=_n;exports.isSameNode=D;exports.isSuspense=kn;exports.mapNodes=Ee;exports.mapSSRNodes=dt;exports.normalizeClass=te;exports.normalizeNode=R;exports.omitProps=cn;exports.onCleanup=I;exports.onDestroy=ae;exports.onMount=ce;exports.onUpdate=kt;exports.patchAttr=Te;exports.patchClass=mt;exports.patchStyle=gt;exports.provide=be;exports.removeNode=P;exports.replaceNode=X;exports.resetHydrationKey=ee;exports.runWithScope=w;exports.setActiveScope=K;exports.setStyle=j;exports.shallowCompare=Ne;exports.startHydration=Q;exports.template=Ae;//# sourceMappingURL=template.cjs.js.map
|
|
8
3
|
//# sourceMappingURL=template.cjs.js.map
|