solely 0.1.1 → 0.1.3
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 +154 -5
- package/dist/index.js +598 -564
- package/dist/index.umd.cjs +11 -11
- package/dist/runtime/component/base-element.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(f,
|
|
2
|
-
`);if(a>
|
|
3
|
-
`):[],
|
|
1
|
+
(function(f,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(f=typeof globalThis<"u"?globalThis:f||self,k(f.solely={}))})(this,function(f){"use strict";var sn=Object.defineProperty;var le=f=>{throw TypeError(f)};var rn=(f,k,N)=>k in f?sn(f,k,{enumerable:!0,configurable:!0,writable:!0,value:N}):f[k]=N;var L=(f,k,N)=>rn(f,typeof k!="symbol"?k+"":k,N),_t=(f,k,N)=>k.has(f)||le("Cannot "+N);var I=(f,k,N)=>(_t(f,k,"read from private field"),N?N.call(f):k.get(f)),W=(f,k,N)=>k.has(f)?le("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(f):k.set(f,N),F=(f,k,N,Et)=>(_t(f,k,"write to private field"),Et?Et.call(f,N):k.set(f,N),N),T=(f,k,N)=>(_t(f,k,"access private method"),N);var z,X,tt,ot,et,H,nt,st,Y,at,ct,J,C,ue,Nt,he,Tt,Wt,vt,fe,de,Ft,Mt;const D={dark:{gutter:"#858585",errorLineBg:"#3c1e1e",errorLineFg:"#f8f8f2",arrow:"#ff6b6b",badgeBg:"#ff6b6b",badgeFg:"#ffffff",exprLabel:"#a0a0a0",exprCode:"#5ddcff"}}.dark;function ht(s){let t=0;for(let e=0;e<s.length;){const n=s.codePointAt(e);if(s[e]===" "){t+=4,e++;continue}n>=9472&&n<=9599||n>255?t+=2:t+=1,e+=n>65535?2:1}return t}function jt(s,t={}){const{lineIndex:e=0,totalLines:n=1}=t,r=Math.max(1,Math.floor(s));return(n<=1||e===0?"^":"~").repeat(r)}function Dt(s,t="",e,n="component"){var P;const r=(s==null?void 0:s.message)??String(s),i=`%cTemplate Error%c in <${n}> → ${r}`,o=[`color:${D.badgeFg};background:${D.badgeBg};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${D.arrow};font-weight:bold;`];if(!t||!(e!=null&&e.loc)||e.loc.length<2){console.error(i,...o),e!=null&&e.expr&&console.log(`Expression: ${e.expr.trim()}`);return}const c=e.loc;let a=c[0]||0,l=c[1]||0;a|=0,l|=0,a<1&&(a=1),l<1&&(l=1);const h=t.split(`
|
|
2
|
+
`);if(a>h.length){console.error(`[Template Error] 行号 ${a} 超出范围`);return}const u=a-1,y=Math.max(0,u-3),$=Math.min(h.length-1,u+3),m=String($+1).length,p=((P=e.expr)==null?void 0:P.trim())??"",A=p?p.split(`
|
|
3
|
+
`):[],b=p?Math.max(...A.map(ht)):0,E=A.length>1,R=`color:${D.gutter};`,M=`color:${D.arrow};font-weight:bold;`,d=`color:${D.gutter};`,v=`color:${D.errorLineFg};background:${D.errorLineBg};padding:0 4px;`,x=`color:${D.gutter};`,w=`color:${D.arrow};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${i} %c(Line:${a}, Col:${l})`,...o,`color:${D.gutter};font-weight:normal;`);for(let S=y;S<=$;S++){const O=h[S],_=String(S+1).padStart(m," ");if(!(S===u)){console.log(`%c${_} │%c ${O}`,R,d);continue}const q=O.slice(0,Math.max(0,l-1)),K=ht(q),bt=" ".repeat(m+3),tn=_.padEnd(m," ");if(console.log(`%c${tn} │%c ${O}`,M,v),E)for(let G=0;G<A.length;G++){const Pt=A[G],lt=u+G;let Ot=0;if(G===0)Ot=K;else if(lt<h.length){const ut=h[lt],wt=ut.search(/\S/),nn=wt===-1?ut:ut.slice(0,wt);Ot=ht(nn)}const en=Math.max(1,ht(Pt.trim())),ae=jt(en,{lineIndex:G,totalLines:A.length}),ce=bt+" ".repeat(Ot);if(G===0)console.log(`%c${ce}%c${ae}`,x,w);else if(lt<h.length){const ut=String(lt+1).padEnd(m," "),wt=h[lt];console.log(`%c${ut} │%c ${wt}`,M,v),console.log(`%c${ce}%c${ae}`,x,w)}}else{const G=bt+" ".repeat(K),Pt=jt(b||1);console.log(`%c${G}%c${Pt}`,x,w)}}p&&console.log(`%cExpression:%c ${p}`,`color:${D.exprLabel};font-weight:bold;`,`color:${D.exprCode};font-family:monospace;`),console.groupEnd()}const $t={};function Vt(s){const t=s.map(e=>e.replace(/[',"]/g,"")).join(",");if(!$t[t]){const e=s[s.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(me(e))throw new Error("Input contains potentially dangerous code: "+e);$t[t]=new Function(...s)}return $t[t]}const pe=["eval","Function","process","require"];function me(s){return pe.some(t=>new RegExp(`\\b${t}\\b`,"g").test(s))}const ge=/\{\{\{\s*[\s\S]*?\s*\}\}\}/,ye=/\{\{\s*([\s\S]*?)\s*\}\}/g;function be(s,t){if(!(s!=null&&s.trim()))return"";if(ge.test(s))throw new Error("Illegal interpolation syntax: use {{ }} instead of {{{ }}}");return t==="template"?s.replace(ye,(e,n)=>`\${${n.trim()}}`):s}function we(s,t){const e=n=>n.endsWith(";")?n:n+";";switch(t){case"template":return`return \`${s}\`;`;case"expression":return`return (${s});`;case"handler":case"lifecycle":return e(s)}}function ve(s){if(!s.length)return{loopValues:"",loopIndices:""};const t=s.map(n=>n.item).join(", "),e=s.map(n=>n.index).join(", ");return{loopValues:`var [${t}] = loops.map(l => l.itmVal);`,loopIndices:`var [${e}] = loops.map(l => l.idxVal);`}}function Ee(s,t,e,n){const r=s==="lifecycle"?["el","loops"]:s==="handler"?["event","loops"]:["loops"],o=`
|
|
4
4
|
const { $data } = this;
|
|
5
|
-
${
|
|
5
|
+
${s==="handler"?"const { value, checked } = event?.target || {};":""}
|
|
6
6
|
${e}
|
|
7
|
-
${
|
|
7
|
+
${n}
|
|
8
8
|
${t}
|
|
9
|
-
`.replace(/^\s+|\s+$/gm,"");return r.push(o),r}function
|
|
9
|
+
`.replace(/^\s+|\s+$/gm,"");return r.push(o),r}function Bt(s,t,e){if(!(s!=null&&s.trim()))return()=>"";const n=be(s,t),r=we(n,t),{loopValues:i,loopIndices:o}=ve(e),c=Ee(t,r,i,o);return Vt(c)}const Kt=new Set(["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"]),U=s=>{if(s===null||typeof s!="object")return!1;const t=Object.prototype.toString.call(s);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function $e(s=window.location){let t;typeof s=="string"?t=new URL(s).hash:t=s.hash;const e=t.split("?");let n=e[0];const r=e[1],i={};return n=n.replace(/^#\/?/,""),r&&r.split("&").forEach(o=>{const[c,a]=o.split("=");c&&a&&(i[decodeURIComponent(c)]=decodeURIComponent(a))}),{path:n.split("/").filter(Boolean),query:i}}var g=(s=>(s[s.Element=0]="Element",s[s.Text=1]="Text",s[s.Comment=2]="Comment",s[s.If=3]="If",s[s.ElseIf=4]="ElseIf",s[s.Else=5]="Else",s[s.For=6]="For",s[s.Conditional=7]="Conditional",s[s.Other=99]="Other",s))(g||{});const qt={onMounted:"mounted",onUpdated:"updated",onUnmounted:"unmounted"};function Gt(s){return qt[s]??null}function zt(s){return s==="mounted"||s==="updated"||s==="unmounted"}const xt=Symbol.for("solely.irMeta"),Z=process.env.NODE_ENV!=="production",xe=/\{\{[\s\S]*?\}\}/;class Se{constructor(){L(this,"compilers",new Map)}get(t="anonymous"){let e=this.compilers.get(t);return e||(e=new ke,this.compilers.set(t,e)),e}clear(t){var e;if(t)(e=this.compilers.get(t))==null||e.clear(),this.compilers.delete(t);else{for(const n of this.compilers.values())n.clear();this.compilers.clear()}}}const Ut=new Se;class ke{constructor(){L(this,"cache",new Map);L(this,"functions",[])}makeCacheKey(t,e,n){if(n.length===0)return`${t}:${e}`;const r=n.map(i=>Object.keys(i).sort().join(",")).join(";");return`${t}:${e}:${r}`}compile(t,e,n){const r=e==null?void 0:e.trim();if(!r)return 0;const i=this.makeCacheKey(t,r,n),o=this.cache.get(i);if(o!==void 0)return o;let c;try{c=Bt(r,t,n)}catch(l){Z&&console.error(`[IR Compile Error] Type: ${t}, Expr: "${r}"`,l),c=()=>""}const a=this.functions.push(c);return this.cache.set(i,a),a}getFunctions(){return this.functions}getStats(){return{total:this.functions.length,cached:this.cache.size}}clear(){this.cache.clear(),this.functions=[]}}function Ht(s){const t=s[0];return t===":"?{isDynamic:!0,type:"expression"}:t==="@"?{isDynamic:!0,type:"handler"}:zt(s)?{isDynamic:!0,type:"lifecycle"}:{isDynamic:!1,type:null}}function Ce(s){return s?xe.test(s):!1}function St(s,t,e){Z&&(s[xt]={expr:t??"",loc:e??null})}function Yt(s){if(!s.attrs)return;const t=s.attrs.find(a=>a.key==="s-model");if(!t)return;const e="$data."+t.value.replace("this.","").replace("$data.",""),n=t.loc,r=(s.tag||"").toLowerCase(),i=s.attrs.find(a=>a.key==="type"),o=(i==null?void 0:i.value)??"text";s.attrs=s.attrs.filter(a=>a!==t);const c=(a,l,h)=>{var u;(u=s.attrs)==null||u.push({key:a,value:l,role:h,loc:n})};if(r==="input"){if(o==="checkbox"){const a=s.attrs.find(y=>y.key==="value"),l=a?JSON.stringify(a.value):'"on"',h=`Array.isArray(${e}) ? ${e}.includes(${l}) : ${e}`;c(":checked",h);const u=`
|
|
10
10
|
const _v = ${l};
|
|
11
11
|
if(Array.isArray(${e})) {
|
|
12
12
|
const _i = ${e}.indexOf(_v);
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
else if(!checked && _i > -1) ${e}.splice(_i,1);
|
|
15
15
|
} else {
|
|
16
16
|
${e} = checked;
|
|
17
|
-
}`;c("@change",
|
|
17
|
+
}`;c("@change",u,"model");return}if(o==="radio"){const a=s.attrs.find(h=>h.key==="value"),l=(a==null?void 0:a.value)??"null";c(":checked",`${e} == ${JSON.stringify(l)}`),c("@change",`if (checked) ${e} = ${JSON.stringify(l)}`,"model");return}c(":value",e),c("@input",`${e} = value`,"model");return}if(r==="textarea"){c(":value",e),c("@input",`${e} = value`,"model");return}if(r==="select"){s.attrs.some(l=>l.key==="multiple")?(c("updated",`
|
|
18
18
|
const values = Array.isArray(${e}) ? ${e} : ${e} != null ? [${e}] : [];
|
|
19
19
|
for (const opt of el.options) {
|
|
20
20
|
opt.selected = values.includes(opt.value);
|
|
21
|
-
}`),c("@change",`${e} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(c(":value",e),c("@change",`${e} = value`,"model"));return}c(":value",e),c("@input",`${e} = $event`,"model")}function ft(
|
|
22
|
-
`),p=t[0]+
|
|
23
|
-
`&&c.push(l+1);function a(l){let u=0;for(let h=1;h<c.length&&!(c[h]>l);h++)u=h;return[u+1,l-c[u]+1]}for(;i<o;){const l=n.indexOf("<",i);if(l===-1||l>i){const C=n.substring(i,l===-1?void 0:l),I=C.trim();if(I){const d=C.indexOf(I),E=i+d,$=a(E);r().push({type:m.Text,tag:"text",content:I,loc:$,children:[]})}if(l===-1)break;i=l}const u=Pe(n,i+1);if(u===-1){const C=n.substring(i);C.trim()&&r().push({type:m.Text,tag:"text",content:C.trim(),children:[],loc:a(i)});break}const h=n.substring(i,u+1),y=r(),v=a(i);if(h.startsWith("<!--")){y.push({type:m.Comment,tag:"comment",content:h.slice(4,-3),loc:v,children:[]}),i=u+1;continue}if(h.startsWith("<![CDATA[")){y.push({type:m.Text,tag:"text",content:h.slice(9,-3),loc:v,children:[]}),i=u+1;continue}if(h.startsWith("<!")&&!h.startsWith("<!--")){y.push({type:m.Comment,tag:"comment",content:h.slice(2,-1),loc:v,children:[]}),i=u+1;continue}if(h.startsWith("<?")){y.push({type:m.Comment,tag:"comment",content:h.slice(2,-2),loc:v,children:[]}),i=u+1;continue}if(h.startsWith("</")){const C=s.pop();for(;e.length>0;){if((e[e.length-1].tag||"").toLowerCase()===(C==null?void 0:C.toLowerCase())){e.pop();break}e.pop()}i=u+1;continue}const g=Me(h,v);y.push(g);const p=g.tag||"",A=p.toLowerCase().startsWith("script"),w=p.toLowerCase().startsWith("style"),k=h.endsWith("/>")||Le.has(p.toLowerCase());if((A||w)&&!k){const C=`</${p}>`,I=n.toLowerCase().indexOf(C,u+1);if(I!==-1){const d=n.substring(u+1,I);d.length&&g.children.push({type:m.Text,tag:"text",content:d,loc:a(u+1),children:[]}),i=I+C.length;continue}else{const d=n.substring(u+1);d.length&&g.children.push({type:m.Text,tag:"text",content:d,loc:a(u+1),children:[]}),i=o;continue}}!k&&g.type!==m.Text&&g.type!==m.Comment&&(e.push(g),s.push(p)),i=u+1}return t}const dt=Symbol("solely.raw");function Jt(n){const t=n&&n[dt];return t?Jt(t):n}function Oe(n){return!!(n&&n[dt])}const Ct=(n,t,e=new WeakMap)=>{if(n===t)return!0;if(n==null||t==null||typeof n!="object"||typeof t!="object")return n===t;if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return!1;if(e.has(n))return e.get(n)===t;e.set(n,t);for(let r=0;r<n.length;r++)if(!Ct(n[r],t[r],e))return!1;return!0}if(Array.isArray(n)!==Array.isArray(t))return!1;if(e.has(n))return e.get(n)===t;e.set(n,t);const s=Reflect.ownKeys(n);if(s.length!==Reflect.ownKeys(t).length)return!1;for(const r of s)if(!Reflect.has(t,r)||!Ct(n[r],t[r],e))return!1;return!0};function Qt(n,t,e={}){const{throttle:s=0,onBatch:r,immediate:i=!1,deepCompare:o=!1}=e;let c=!0,a=null,l=[],u=0;const h=new WeakMap,y=new WeakMap,v=new WeakMap,g=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[],p=d=>{if(g.length===0)return!0;const E=d.map(String).join(".");return g.some($=>{if($==="")return!0;const b=$.replace(/\./g,"\\.").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+").replace(/\[\d+\]/g,"\\[\\d+\\]");return new RegExp(`^${b}$`).test(E)})},A=d=>{const E=[];let $=d;for(;$;){const b=y.get($);if(!b||b.key==null)break;E.unshift(b.key),$=b.parent}return E},w=(d,E)=>{if(!c)return;const $=A(d);if(!p($))return;const b={...E,path:$};s>0?(l.push(b),a||(a=setTimeout(()=>{const P=[...l];l=[],a=null,c&&(r==null||r(P),P.forEach(t))},s))):(r==null||r([b]),t(b))},k=(d,E)=>{const $={};return["push","pop","shift","unshift","splice"].forEach(b=>{$[b]=function(...P){u++;const x=d[b].apply(d,P);if(u--,b==="push")w(E,{type:"array-push",index:d.length-P.length,values:P});else if(b==="unshift")w(E,{type:"array-push",index:0,values:P});else if(b==="pop")w(E,{type:"array-splice",index:d.length,deleteCount:1,insert:[]});else if(b==="shift")w(E,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if(b==="splice"){const[O,N,...F]=P;w(E,{type:"array-splice",index:O,deleteCount:N,insert:F})}return x}}),["sort","reverse","fill","copyWithin"].forEach(b=>{$[b]=function(...P){u++;const x=d[b].apply(d,P);return u--,w(E,{type:"array-reset",method:b}),x}}),["indexOf","lastIndexOf","includes"].forEach(b=>{$[b]=function(P,...x){let O=d[b].apply(d,[P,...x]);return(O===-1||O===!1)&&Oe(P)&&(O=d[b].apply(d,[Jt(P),...x])),O}}),$},C=(d,E,$)=>{if(!Object.isExtensible(d)||d[dt])return d;const b=h.get(d);if(b)return y.set(b,{parent:E,key:$}),b;const P={get(O,N,F){if(N===dt)return O;if(Array.isArray(O)){const V=v.get(x);if(V&&Object.prototype.hasOwnProperty.call(V,N))return Reflect.get(V,N,F)}const K=Reflect.get(O,N,F);return typeof N=="symbol"?K:U(K)?C(K,x,N):K},set(O,N,F,K){const V=O[N];if(o?Ct(V,F):V===F)return!0;const wt=Reflect.set(O,N,F,K);return u===0&&(Array.isArray(V)&&Array.isArray(F)?w(x,{type:"array-replace",oldValue:V,newValue:F}):w(x,{type:"set",key:N,newValue:F,oldValue:V})),wt},deleteProperty(O,N){if(!Reflect.has(O,N))return!1;const F=O[N],K=Reflect.deleteProperty(O,N);return K&&u===0&&w(x,{type:"delete",key:N,oldValue:F}),K}},x=new Proxy(d,P);return h.set(d,x),y.set(x,{parent:E,key:$}),Array.isArray(d)&&v.set(x,k(d,x)),x},I=C(n,null,null);if(i){const d=(E,$,b=new WeakSet)=>{!U(E)||b.has(E)||(b.add(E),Reflect.ownKeys(E).forEach(P=>{const x=E[P];w($,{type:"set",key:P,newValue:x,oldValue:void 0}),U(x)&&d(x,C(x,$,P),b)}))};d(n,I)}return{proxy:I,unobserve:()=>{c=!1,l=[],a&&clearTimeout(a)},resume:()=>{c=!0}}}const Xt=Symbol.for("solely.manifest"),B=class B extends HTMLElement{constructor(e={}){var r;super();T(this,L);T(this,G);T(this,X);T(this,tt);T(this,ot);T(this,et);T(this,Y);T(this,nt,!1);T(this,st,!1);T(this,H,!1);T(this,at,!1);W(this,G,this.constructor[Xt]||{});const s=R(this,G);W(this,et,(r=s.shadowDOM)!=null&&r.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this),D(this,L,Nt).call(this,e),D(this,L,he).call(this,s),queueMicrotask(()=>D(this,L,Wt).call(this))}static get observedAttributes(){if(R(B,Z).has(this))return R(B,Z).get(this);const e=this[Xt];if(!(e!=null&&e.props))return R(B,Z).set(this,[]),[];const s=e.props.map(r=>(typeof r=="string"?r:r.name).replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase());return R(B,Z).set(this,s),s}get $data(){return R(this,ot)}set $data(e){var s;U(e)||(e={}),(s=R(this,Y))==null||s.call(this),D(this,L,Nt).call(this,e),D(this,L,vt).call(this)}refresh(){D(this,L,vt).call(this)}connectedCallback(){var r;D(this,L,Wt).call(this);const e=R(this,G);if((e.className||e.tagName||"").split(" ").forEach(i=>i&&this.classList.add(i)),D(this,L,de).call(this),e.props&&U(this.$data))for(const i of e.props){const o=typeof i=="string"?i:i.name,c=D(this,L,_t).call(this,o),a=o.replace(/-([a-z])/g,(l,u)=>u.toUpperCase());if(this.hasAttribute(o)){const l=this.getAttribute(o),u=D(this,L,Tt).call(this,l,c==null?void 0:c.default,c==null?void 0:c.type);this.$data[a]=u}else c&&"default"in c&&(this.$data[a]=c.default)}R(this,tt)&&W(this,X,ie(R(this,tt),R(this,et),this)),this.mounted(),(r=this.onInit)==null||r.call(this)}disconnectedCallback(){var e;this.unmounted(),(e=R(this,Y))==null||e.call(this),W(this,Y,void 0)}attributeChangedCallback(e,s,r){if(s===r||!U(this.$data))return;const i=D(this,L,_t).call(this,e),o=e.replace(/-([a-z])/g,(l,u)=>u.toUpperCase()),c=this.$data[o],a=D(this,L,Tt).call(this,r,(i==null?void 0:i.default)??c,i==null?void 0:i.type);this.$data[o]=a,W(this,H,!0),this.attributeChanged(e,c,a),this.emit("change",{source:"attribute",name:e,oldValue:c,newValue:a})}emit(e,s,r){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:s,...r}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(e,s,r){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};G=new WeakMap,X=new WeakMap,tt=new WeakMap,ot=new WeakMap,et=new WeakMap,Y=new WeakMap,nt=new WeakMap,st=new WeakMap,H=new WeakMap,at=new WeakMap,ct=new WeakMap,Z=new WeakMap,L=new WeakSet,Nt=function(e){const{proxy:s,unobserve:r}=Qt(e,i=>{this.emit("change",{source:"state",...i}),D(this,L,vt).call(this)});W(this,ot,s),W(this,Y,r)},he=function(e){const s=e.template;if(typeof s=="string"){const r=Zt(s);W(this,tt,Ht(r,{source:s,filename:e.tagName}))}},_t=function(e){const s=R(this,G).props;if(!s)return;const r=e.replace(/-([a-z])/g,(o,c)=>c.toUpperCase()),i=s.find(o=>typeof o=="string"?o===r:o.name===r);if(i)return typeof i=="string"?{name:i}:i},Tt=function(e,s,r){if(e===null)return s;switch(r){case"number":{const i=Number(e);return isNaN(i)?s:i}case"boolean":return e!==null&&e!=="false";case"object":try{return JSON.parse(e)}catch{return s}default:return e}},vt=function(){R(this,st)||!R(this,X)||(W(this,st,!0),queueMicrotask(()=>{W(this,st,!1),D(this,L,fe).call(this)}))},fe=function(){R(this,nt)||!this.isConnected||(W(this,nt,!0),R(this,H)&&this.beforeAttributesUpdate(),this.beforeUpdate(),R(this,X).update(),this.updated(),R(this,H)&&(this.afterAttributesUpdate(),W(this,H,!1)),W(this,nt,!1))},de=function(){const s=R(this,G).styles;if(!s)return;const r=R(this,et);if("adoptedStyleSheets"in r){if(r._styleInjected)return;let o=R(B,ct).get(s);o||(o=new CSSStyleSheet,o.replaceSync(s),R(B,ct).set(s,o)),r.adoptedStyleSheets=[...r.adoptedStyleSheets,o],r._styleInjected=!0;return}if(r.querySelector("style[data-manifest-style]"))return;const i=document.createElement("style");i.dataset.manifestStyle="true",i.textContent=s,r.appendChild(i)},Wt=function(){R(this,at)||(W(this,at,!0),this.created())},It=new WeakMap,T(B,ct,new Map),T(B,Z,new WeakMap),T(B,It,!1);let it=B;const Ne=Symbol.for("solely.manifest"),Rt=n=>t=>{if(customElements.get(n.tagName))return console.warn(`标签名称 "${n.tagName}" 已经被注册`),t;class e extends t{}return e[Ne]=n,customElements.define(n.tagName,e),e},pt=Symbol("solely.isSVG"),mt=Symbol("solely.irCtx"),yt=Symbol("solely.irEvents"),q=Symbol.for("solely.irMeta"),te=Symbol("solely.lastDynamicClass"),ee=Symbol("solely.dynamicStyleLast"),_e={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},Te={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},We=new Set(["data-","aria-","role","form"]),De=new Set(["value","selectedIndex"]);function Fe(n,t){var i;const e=n,s=(i=t.attrs)==null?void 0:i.find(o=>o.key==="class"&&!o.dynamic),r=s?s.value:"";r&&(e[pt]?e.className.baseVal=r:e.className=r)}function je(n,t){var r;const e=(r=t.attrs)==null?void 0:r.find(i=>i.key==="style"&&!i.dynamic),s=e?ne(e.value):{};for(const i in s){const o=s[i];i.startsWith("--")?n.style.setProperty(i,o):n.style[i]=o}}const Ve=(n,t)=>{const e=n,s=ne(t),r=e[ee]||{};for(const i in r)i in s||(i.startsWith("--")?n.style.removeProperty(i):n.style[i]="");for(const i in s){const o=s[i];i.startsWith("--")?n.style.setProperty(i,o):n.style[i]=o}e[ee]=s},Be=(n,t)=>{const e=n,s=e[te]||{},r=Ke(t);for(const i in s)s[i]&&!r[i]&&(e[pt]?e.className.baseVal=e.className.baseVal.replace(new RegExp(`\\b${i}\\b`,"g"),"").trim():e.classList.remove(i));for(const i in r)if(r[i])if(e[pt]){const o=e.className.baseVal.split(/\s+/);o.includes(i)||(o.push(i),e.className.baseVal=o.join(" "))}else e.classList.add(i);e[te]=r};function ne(n){const t={},e=[[n]];for(;e.length;){const[s,r]=e.pop();if(typeof s=="string"){s.split(";").forEach(i=>{const[o,c]=i.split(":").map(a=>a.trim());o&&c&&(t[o]=c)});continue}if(Array.isArray(s)){s.forEach(i=>e.push([i]));continue}if(s&&typeof s=="object")for(const[i,o]of Object.entries(s)){const c=r?`${r}-${i}`:i;o&&typeof o=="object"&&!Array.isArray(o)?e.push([o,c]):t[c]=String(o??"")}}return t}function Ke(n){const t={},e=[n];for(;e.length;){const s=e.pop();if(s){if(typeof s=="string")s.split(/\s+/).forEach(r=>r&&(t[r]=!0));else if(Array.isArray(s))e.push(...s);else if(typeof s=="object")for(const[r,i]of Object.entries(s))t[r]=!!i}}return t}function qe(n,t,e){const s=t.indexOf(":");if(s>0){const r=t.slice(0,s),i=_e[r];if(i)return n.setAttributeNS(i,t,e)}n.setAttribute(t,e)}function se(n,t,e){if(t.startsWith("data-")||t.startsWith("aria-")||We.has(t)){n.setAttribute(t,e);return}const s=Te[t]||t;n[s]=e}class re{constructor(t,e,s={}){M(this,"nodeMap",new Map);M(this,"marker",!1);this.ir=t,this.container=e,this.scope=s}evalIR(t,e,s){var i;const r=this.ir.functions[t-1];try{return r?r.apply(this.scope,e):""}catch(o){return Ft(o.message||o.toString(),((i=this.ir.metadata)==null?void 0:i.source)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.tag,r=e instanceof SVGElement||s==="svg",i=r?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s);return i[pt]=r,i}createText(t,e){const s=t.dynamic?this.evalIR(t.fid,[e],t[q]):t.txt||"";return document.createTextNode(s)}createComment(t,e){const s=t.dynamic?this.evalIR(t.fid,[e],t[q]):t.txt||"";return document.createComment(s)}applyAttrs(t,e,s,r=!1){const i=[],o=t;o[mt]||(o[mt]={loops:null}),o[mt].loops=s,o[yt]||(o[yt]=Object.create(null));let c,a=!1,l,u=!1;for(const h of e){const{key:y,fid:v,dynamic:g,value:p}=h;if(y===":class"){c=this.evalIR(v,[s]),a=!0;continue}if(y===":style"){l=this.evalIR(v,[s]),u=!0;continue}if(y==="class"||y==="style")continue;const A=y[0];if(A==="@"){const k=y.slice(1),C=h.role??"user";let I=o[yt][k];if(I||(I=o[yt][k]={model:[],user:[]},t.addEventListener(k,d=>{for(const E of I.model)E(d);for(const E of I.user)E(d)})),!r){const d=E=>this.evalIR(v,[E,o[mt].loops],h[q]);I[C].push(d)}continue}if(y==="mounted"){r||requestAnimationFrame(()=>this.evalIR(v,[t,s],h[q]));continue}if(y==="updated"){r&&requestAnimationFrame(()=>this.evalIR(v,[t,s],h[q]));continue}if(y==="ref"&&p){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[p]=t;continue}const w=g?this.evalIR(v,[s],h[q]):p??"";if(A===":"){const k=y.slice(1);t.tagName==="SELECT"&&De.has(k)?i.push(()=>se(t,k,w)):se(t,k,w)}else qe(t,y,String(w))}return(a||!r)&&Be(t,c),(u||!r)&&Ve(t,l),i}updateNode(t,e,s){const r=e.dynamic?this.evalIR(e.fid,[s],e[q]):e.txt||"";e.dynamic&&t.textContent!==r&&(t.textContent=r)}irToNode(t,e,s,r,i){var l,u,h,y;const o=s+"-"+e,c=this.nodeMap.get(o);let a;if(c){a=c.node,c.marker=this.marker;let v=[];t.dynamic&&(t.type===m.Element?v=this.applyAttrs(a,t.attrs??[],i,!0):this.updateNode(a,t,i)),(l=t.children)==null||l.forEach((g,p)=>{this.irToNode(g,p,o,a,i)}),v.forEach(g=>g())}else switch(t.type){case m.Element:a=this.createElement(t,r),Fe(a,t),je(a,t);const v=this.applyAttrs(a,t.attrs??[],i);r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker}),(u=t.children)==null||u.forEach((g,p)=>{this.irToNode(g,p,o,a,i)}),v.forEach(g=>g());break;case m.Text:a=this.createText(t,i),r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker});break;case m.Comment:a=this.createComment(t,i),r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker});break;case m.For:{const g=`${o}-end`;let p=(h=this.nodeMap.get(g))==null?void 0:h.node;p?this.nodeMap.get(g).marker=this.marker:(p=document.createComment(`for:${o}`),r.appendChild(p),this.nodeMap.set(g,{irNode:{type:m.Comment},node:p,loops:i,marker:this.marker}));const A=this.evalIR(t.fid,[i],t[q])||[],w=document.createDocumentFragment();A.forEach((k,C)=>{var d;const I=[...i,{itmVal:k,idxVal:C}];(d=t.children)==null||d.forEach((E,$)=>{this.irToNode(E,$,`${o}-for-${C}`,w,I)})}),p.parentNode.insertBefore(w,p);break}case m.Conditional:{const g=`${o}-end`;let p=(y=this.nodeMap.get(g))==null?void 0:y.node;p?this.nodeMap.get(g).marker=this.marker:(p=document.createComment(`if:${o}`),r.appendChild(p),this.nodeMap.set(g,{irNode:{},node:p,loops:i,marker:this.marker}));for(let A=0;A<(t.branches||[]).length;A++){const w=t.branches[A];if(w.condFid===null||this.evalIR(w.condFid,[i],w[q])){const C=document.createDocumentFragment();w.children.forEach((I,d)=>{this.irToNode(I,d,`${o}-if-${A}`,C,i)}),p.parentNode.insertBefore(C,p);break}}break}}}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:r,loops:i}=e;if(s.attrs){const o=s.attrs.find(a=>a.key==="unmounted");o&&requestAnimationFrame(()=>{this.evalIR(o.fid,[r,i],o[q])});const c=s.attrs.find(a=>a.key==="ref");c&&c.value&&delete this.scope.$refs[c.value]}r==null||r.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.nodes.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.nodes.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear()}}const ie=(n,t,e={})=>{const s=new re(n,t,e);return s.mount(),{update:()=>s.update(),destroy:()=>s.destroy()}};let Q=null,oe;const Lt=new Promise(n=>{oe=n});function Ge(n){return Q||(Q=new ae(n),oe(Q),Q)}function gt(){return Q}class ae{constructor(t){M(this,"routes");M(this,"base");M(this,"mode");M(this,"beforeEachGuard");M(this,"afterEachGuard");M(this,"currentRoute",null);M(this,"listeners",new Set);M(this,"isStarted",!1);this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const e=t.startsWith("/")?t:"/"+t,[s,r]=e.split("?"),i=s.split("/").filter(Boolean),o=this.parseQuery(r),c=this.recursiveMatch(this.routes,i);if(c){const a=c.matched[c.matched.length-1];return a.config.redirect?this.matchRoute(a.config.redirect):{matched:c.matched,params:c.params,query:o,fullPath:e,meta:c.matched.reduce((l,u)=>({...l,...u.config.meta||{}}),{})}}return null}recursiveMatch(t,e){const s=[...t].sort((r,i)=>this.calculateScore(i.path)-this.calculateScore(r.path));for(const r of s){const i=r.path.split("/").filter(Boolean),o={};let c=!0;if(i.length===0&&e.length===0)return{matched:[{config:r,params:{}}],params:{}};for(let a=0;a<i.length;a++){const l=i[a],u=e[a];if(l.startsWith(":")){if(!u){c=!1;break}o[l.slice(1)]=u}else if(l==="*"){c=!0;break}else if(l!==u){c=!1;break}}if(c){const a=i.length,l=e.slice(a),u={config:r,params:o};if(l.length>0&&r.children){const h=this.recursiveMatch(r.children,l);if(h)return{matched:[u,...h.matched],params:{...o,...h.params}}}else if(l.length===0||i.includes("*"))return{matched:[u],params:o}}}return null}calculateScore(t="/"){const e=t.split("/").filter(Boolean);return e.length===0?1:e.reduce((s,r)=>r.startsWith(":")?s+5:r==="*"?s+0:s+10,0)}parseQuery(t){const e={};return t&&new URLSearchParams(t).forEach((r,i)=>{e[i]=r}),e}normalizePath(t="/"){let e=t&&typeof t=="string"?t:"/";return e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}getPath(){let t;try{t=this.mode==="hash"?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const e=this.base||"/";return e!=="/"&&t.startsWith(e)&&(t=t.slice(e.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",e){const s=this.normalizePath(t),r=this.base||"/";if(this.mode==="hash")e?window.location.replace(`#${s}`):window.location.hash=s;else{const i=r.endsWith("/")?r.slice(0,-1):r,o=i==="/"?s:i+s;e?window.history.replaceState({path:o},"",o):window.history.pushState({path:o},"",o)}}async navigate(t="/",e=!1,s=!1){const r=this.normalizePath(t),i=this.currentRoute,o=this.matchRoute(r);if(!o)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===o.fullPath)return{success:!0};if(this.beforeEachGuard)try{const c=await this.beforeEachGuard(o,i);if(c===!1)return{success:!1,cancelled:!0};if(typeof c=="string")return this.navigate(c,e)}catch(c){return{success:!1,error:c instanceof Error?c.message:"Guard Error"}}return this.currentRoute=o,s||this.updateBrowserHistory(r,e),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(o,i),{success:!0}}resolve(t="/"){const e=this.normalizePath(t);if(this.mode==="hash")return`#${e}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return s==="/"?e:s+e}get modeType(){return this.mode}pushWithQuery(t="/",e){const s=new URLSearchParams(e).toString(),r=t.includes("?")?"&":"?";return this.push(t+(s?r+s:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){if(this.isStarted)return;const t=()=>{this.navigate(this.getPath(),!0,!0)};window.addEventListener("popstate",t),this.mode==="hash"&&!window.location.hash&&(window.location.hash="/"),this.navigate(this.getPath(),!0)}getCurrentRoute(){return this.currentRoute}}var ze=Object.getOwnPropertyDescriptor,Ue=(n,t,e,s)=>{for(var r=s>1?void 0:s?ze(t,e):t,i=n.length-1,o;i>=0;i--)(o=n[i])&&(r=o(r)||r);return r};let bt=class extends it{constructor(){super(...arguments);M(this,"unsubscribe");M(this,"level",0);M(this,"currentElement",null);M(this,"currentTagName",null);M(this,"routerAttrs",new Set);M(this,"prevPropKeys",new Set);M(this,"scheduled",!1);M(this,"cache",new Map);M(this,"latestLoadId",0)}async mounted(){this.detectLevel();const t=await Lt;this.unsubscribe=t.listen(()=>{this.scheduleLoad(t.getCurrentRoute())}),this.loadRoute(t.getCurrentRoute())}unmounted(){var t;(t=this.unsubscribe)==null||t.call(this),this.cache.forEach(e=>e.remove()),this.cache.clear()}scheduleLoad(t){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t)}))}detectLevel(){let t=0,e=this.parentElement;for(;e;)e instanceof bt&&t++,e=e.parentElement;this.level=t}async loadRoute(t){const e=++this.latestLoadId,s=t==null?void 0:t.matched[this.level];if(!s){this.handleEmptyRoute();return}const{config:r}=s;let i=r.tagName;if(!i&&typeof r.component=="function"){this.renderLoading();try{const c=await r.component();i=typeof c=="string"?c:c.tagName}catch(c){this.renderError(`Load Error: ${c}`);return}}if(e!==this.latestLoadId)return;if(!i){this.clear();return}if(!r.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase()){this.syncState(this.currentElement,t==null?void 0:t.params,(t==null?void 0:t.query)||{},r.props);return}this.clear(r.keepAlive);const o=this.getOrCreateComponent(i,r);this.syncState(o,t==null?void 0:t.params,(t==null?void 0:t.query)||{},r.props),this.appendChild(o),this.currentElement=o,this.currentTagName=i.toLowerCase()}getOrCreateComponent(t,e){const s=t.toLowerCase();if(e.keepAlive&&this.cache.has(s))return this.cache.get(s);const r=document.createElement(t);return e.keepAlive&&this.cache.set(s,r),r}syncState(t,e,s,r={}){const i=a=>a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=new Map;Object.entries(e).forEach(([a,l])=>o.set(i(a),String(l))),Object.entries(s).forEach(([a,l])=>o.set(`query-${i(a)}`,String(l))),this.routerAttrs.forEach(a=>{o.has(a)||(t.removeAttribute(a),this.routerAttrs.delete(a))}),o.forEach((a,l)=>{t.getAttribute(l)!==a&&t.setAttribute(l,a),this.routerAttrs.add(l)});const c=new Set(Object.keys(r));this.prevPropKeys.forEach(a=>{c.has(a)||(t[a]=void 0)}),Object.entries(r).forEach(([a,l])=>{t[a]!==l&&(t[a]=l)}),this.prevPropKeys=c}handleEmptyRoute(){this.clear(),this.level===0&&this.renderError("404 Not Found")}renderLoading(){this.innerHTML='<div style="padding:20px; color:#999;">Loading...</div>'}renderError(t){this.innerHTML=`<div style="padding:20px; color:#ff4d4f;">${t}</div>`}clear(t=!1){this.currentElement?this.contains(this.currentElement)&&this.removeChild(this.currentElement):t||(this.innerHTML=""),this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};bt=Ue([Rt({tagName:"router-view"})],bt);const Ye=bt;var He=Object.getOwnPropertyDescriptor,Ze=(n,t,e,s)=>{for(var r=s>1?void 0:s?He(t,e):t,i=n.length-1,o;i>=0;i--)(o=n[i])&&(r=o(r)||r);return r};let At=class extends it{constructor(){super(...arguments);M(this,"_prefetched",!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await Lt).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",e=>{var r,i;e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.button!==0||(r=e.target.closest("a"))!=null&&r.getAttribute("target")||(e.preventDefault(),(i=gt())==null||i.push(this.$data.to))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=gt();if(!t)return;this.$data.href=t.resolve(this.$data.to);let e=!1;if(this.$data.active)e=!0;else{const r=t.getCurrentRoute();if(r){const i=r.fullPath;this.hasAttribute("exact")?e=i===this.$data.to:e=i===this.$data.to||i.startsWith(this.$data.to+"/")}}this.$data.isActive=e;const s=this.$data.activeClass||"active";this.classList.toggle(s,e)}prefetchRoute(){if(this._prefetched||!this.hasAttribute("prefetch"))return;const t=gt();t&&typeof t.prefetch=="function"&&(t.prefetch(this.$data.to),this._prefetched=!0)}};At=Ze([Rt({tagName:"router-link",template:`
|
|
21
|
+
}`),c("@change",`${e} = Array.from(event.target.selectedOptions).map(o => o.value)`,"model")):(c(":value",e),c("@change",`${e} = value`,"model"));return}c(":value",e),c("@input",`${e} = $event`,"model")}function ft(s,t,e,n=null){if(!s.attrs||s.attrs.length===0)return[];const r=[];for(const i of s.attrs){if(n&&n.has(i.key))continue;const{key:o,value:c,role:a}=i,{isDynamic:l,type:h}=Ht(o);if(l&&h){const u=e.compile(h,c??"",t),y={key:o,fid:u,dynamic:1,role:a};St(y,c,i.loc??s.loc),r.push(y)}else r.push({key:o,value:c,dynamic:0,role:a})}return r}function Re(s,t,e){var i,o,c,a,l,h;const n={type:s.type,dynamic:0};let r=!1;switch(s.type===g.Text?Ce(s.content)&&(r=!0):((i=s.attrs)!=null&&i.some(u=>u.key==="s-model"||Ht(u.key).isDynamic)&&(r=!0),s.type===g.For&&(r=!0)),n.dynamic=r?1:0,s.type){case g.Text:{const u=s.content??"";r?(n.fid=e.compile("template",u,t),St(n,u,s.loc)):n.txt=u;break}case g.Element:{n.tag=s.tag,Yt(s),n.attrs=ft(s,t,e),s.children&&(n.children=rt(s.children,t,e));break}case g.For:{const u=(o=s.attrs)==null?void 0:o.find(p=>p.key==="each"),y=(u==null?void 0:u.value)??"";n.fid=e.compile("expression",y,t),n.item=((a=(c=s.attrs)==null?void 0:c.find(p=>p.key==="item"))==null?void 0:a.value)??"item",n.index=((h=(l=s.attrs)==null?void 0:l.find(p=>p.key==="index"))==null?void 0:h.value)??"index",St(n,y,(u==null?void 0:u.loc)??s.loc);const $=new Set(["each","item","index"]);n.attrs=ft(s,t,e,$);const m=[...t,{item:n.item,index:n.index}];s.children&&(n.children=rt(s.children,m,e));break}case g.If:case g.ElseIf:case g.Else:{Z&&console.warn(`[IR] Orphaned conditional node found: ${g[s.type]}`),n.attrs=ft(s,t,e),s.children&&(n.children=rt(s.children,t,e));break}case g.Comment:{n.txt=s.content??"";break}}return n}function rt(s,t,e){var i;const n=[];let r=0;for(;r<s.length;){const o=s[r];if(o.type===g.If){const c=[];let a=r;for(;a<s.length;){const l=s[a],h=l.type;if(h!==g.If&&h!==g.ElseIf&&h!==g.Else)break;let u=null,y="",$=null;if(h!==g.Else){const b=(i=l.attrs)==null?void 0:i.find(E=>E.key==="test"||E.key==="condition");y=(b==null?void 0:b.value)??"false",u=e.compile("expression",y,t),$=(b==null?void 0:b.loc)??l.loc}const m=l.children?rt(l.children,t,e):[],A=ft(l,t,e,new Set(["test","condition"]));if(c.push({condFid:u,children:m,attrs:A.length>0?A:void 0,[xt]:Z?{expr:y,loc:$}:void 0}),a++,h===g.Else)break}n.push({type:g.Conditional,dynamic:1,branches:c,...Z&&{[xt]:{loc:o.loc}}}),r=a}else n.push(Re(o,t,e)),r++}return n}function Jt(s,t={}){const{filename:e="anonymous",source:n}=t,r=Ut.get(e);r.clear();const i=performance.now(),o=rt(s,[],r),c=performance.now(),a=r.getStats(),l=o.filter(u=>u.dynamic===1).length,h={type:"root",version:"1.1.0",functions:r.getFunctions(),nodes:o,stats:{totalFunctions:a.total,cachedFunctions:a.cached,dynamicNodes:l,totalNodes:o.length},metadata:{compiledAt:new Date().toISOString(),astSize:s.length,filename:e,...n&&{source:n}}};return Z&&console.log(`[IRBuilder] ${e} | ${(c-i).toFixed(2)}ms | Nodes: ${o.length} | Fns: ${a.total}`),h}function Le(s){Ut.clear(s)}const Ie=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,Ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Me=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function Pe(s,t){const e=[];let n;const r=s.replace(/^\s*[^\s"'/>]+/,""),i=s.length-r.length;for(;(n=Me.exec(r))!==null;){const o=n[1];if(!o)continue;const c=n[2]??n[3]??n[4]??"";let a=o;Kt.has(o)&&(a=a.replace(/^on/,"@")),a!=="s-model"&&(a=a.replace(/^on-/,"@").replace(/^s-/,":")),a=Gt(a)||a;const l=n[0],h=l.indexOf("=");let u;if(h===-1)u=l.indexOf(o)+o.length;else{let b=h+1;for(;b<l.length&&/\s/.test(l[b]);)b++;if(l[b]==='"'||l[b]==="'"){let E=b+1;for(;E<l.length&&/\s/.test(l[E]);)E++;u=E}else{let E=b;for(;E<l.length&&/\s/.test(l[E]);)E++;u=E}}let y=n.index+u+i;const m=s.slice(0,y).split(`
|
|
22
|
+
`),p=t[0]+m.length-1,A=m.length>1?m[m.length-1].length+1:t[1]+y;e.push({key:a,value:c,loc:[p,A]})}return e}function Oe(s,t){var o;const e=((o=(s.match(Ie)||[])[1])==null?void 0:o.toLowerCase())??"",n=Pe(s,t);return{type:{for:g.For,if:g.If,elseif:g.ElseIf,else:g.Else}[e]??g.Element,tag:e,loc:t,children:[],attrs:n}}function _e(s,t){const e=s.length;if(s.startsWith("!--",t)){const o=s.indexOf("-->",t+3);return o===-1?-1:o+2}if(s.startsWith("![CDATA[",t)){const o=s.indexOf("]]>",t+8);return o===-1?-1:o+2}if(s[t]==="!")return s.indexOf(">",t+1);if(s[t]==="?"){const o=s.indexOf("?>",t+1);return o===-1?-1:o+1}let n=!1,r=!1,i=t;for(;i<e;){const o=s[i];if(o==="'"&&!r)n=!n;else if(o==='"'&&!n)r=!r;else if(o===">"&&!n&&!r)return i;i++}return-1}function Zt(s){const t=[];if(!s)return[];const e=[],n=[],r=()=>{var l;return e.length===0?t:(l=e[e.length-1]).children||(l.children=[])};let i=0;const o=s.length,c=[0];for(let l=0;l<o;l++)s[l]===`
|
|
23
|
+
`&&c.push(l+1);function a(l){let h=0;for(let u=1;u<c.length&&!(c[u]>l);u++)h=u;return[h+1,l-c[h]+1]}for(;i<o;){const l=s.indexOf("<",i);if(l===-1||l>i){const R=s.substring(i,l===-1?void 0:l),M=R.trim();if(M){const d=R.indexOf(M),v=i+d,x=a(v);r().push({type:g.Text,tag:"text",content:M,loc:x,children:[]})}if(l===-1)break;i=l}const h=_e(s,i+1);if(h===-1){const R=s.substring(i);R.trim()&&r().push({type:g.Text,tag:"text",content:R.trim(),children:[],loc:a(i)});break}const u=s.substring(i,h+1),y=r(),$=a(i);if(u.startsWith("<!--")){y.push({type:g.Comment,tag:"comment",content:u.slice(4,-3),loc:$,children:[]}),i=h+1;continue}if(u.startsWith("<![CDATA[")){y.push({type:g.Text,tag:"text",content:u.slice(9,-3),loc:$,children:[]}),i=h+1;continue}if(u.startsWith("<!")&&!u.startsWith("<!--")){y.push({type:g.Comment,tag:"comment",content:u.slice(2,-1),loc:$,children:[]}),i=h+1;continue}if(u.startsWith("<?")){y.push({type:g.Comment,tag:"comment",content:u.slice(2,-2),loc:$,children:[]}),i=h+1;continue}if(u.startsWith("</")){const R=n.pop();for(;e.length>0;){if((e[e.length-1].tag||"").toLowerCase()===(R==null?void 0:R.toLowerCase())){e.pop();break}e.pop()}i=h+1;continue}const m=Oe(u,$);y.push(m);const p=m.tag||"",A=p.toLowerCase().startsWith("script"),b=p.toLowerCase().startsWith("style"),E=u.endsWith("/>")||Ae.has(p.toLowerCase());if((A||b)&&!E){const R=`</${p}>`,M=s.toLowerCase().indexOf(R,h+1);if(M!==-1){const d=s.substring(h+1,M);d.length&&m.children.push({type:g.Text,tag:"text",content:d,loc:a(h+1),children:[]}),i=M+R.length;continue}else{const d=s.substring(h+1);d.length&&m.children.push({type:g.Text,tag:"text",content:d,loc:a(h+1),children:[]}),i=o;continue}}!E&&m.type!==g.Text&&m.type!==g.Comment&&(e.push(m),n.push(p)),i=h+1}return t}const dt=Symbol("solely.raw");function Qt(s){const t=s&&s[dt];return t?Qt(t):s}function Ne(s){return!!(s&&s[dt])}const kt=(s,t,e=new WeakMap)=>{if(s===t)return!0;if(s==null||t==null||typeof s!="object"||typeof t!="object")return s===t;if(Array.isArray(s)&&Array.isArray(t)){if(s.length!==t.length)return!1;if(e.has(s))return e.get(s)===t;e.set(s,t);for(let r=0;r<s.length;r++)if(!kt(s[r],t[r],e))return!1;return!0}if(Array.isArray(s)!==Array.isArray(t))return!1;if(e.has(s))return e.get(s)===t;e.set(s,t);const n=Reflect.ownKeys(s);if(n.length!==Reflect.ownKeys(t).length)return!1;for(const r of n)if(!Reflect.has(t,r)||!kt(s[r],t[r],e))return!1;return!0};function Xt(s,t,e={}){const{throttle:n=0,onBatch:r,immediate:i=!1,deepCompare:o=!1}=e;let c=!0,a=null,l=[],h=0;const u=new WeakMap,y=new WeakMap,$=new WeakMap,m=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[],p=d=>{if(m.length===0)return!0;const v=d.map(String).join(".");return m.some(x=>{if(x==="")return!0;const w=x.replace(/\./g,"\\.").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+").replace(/\[\d+\]/g,"\\[\\d+\\]");return new RegExp(`^${w}$`).test(v)})},A=d=>{const v=[];let x=d;for(;x;){const w=y.get(x);if(!w||w.key==null)break;v.unshift(w.key),x=w.parent}return v},b=(d,v)=>{if(!c)return;const x=A(d);if(!p(x))return;const w={...v,path:x};n>0?(l.push(w),a||(a=setTimeout(()=>{const P=[...l];l=[],a=null,c&&(r==null||r(P),P.forEach(t))},n))):(r==null||r([w]),t(w))},E=(d,v)=>{const x={};return["push","pop","shift","unshift","splice"].forEach(w=>{x[w]=function(...P){h++;const S=d[w].apply(d,P);if(h--,w==="push")b(v,{type:"array-push",index:d.length-P.length,values:P});else if(w==="unshift")b(v,{type:"array-push",index:0,values:P});else if(w==="pop")b(v,{type:"array-splice",index:d.length,deleteCount:1,insert:[]});else if(w==="shift")b(v,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if(w==="splice"){const[O,_,...j]=P;b(v,{type:"array-splice",index:O,deleteCount:_,insert:j})}return S}}),["sort","reverse","fill","copyWithin"].forEach(w=>{x[w]=function(...P){h++;const S=d[w].apply(d,P);return h--,b(v,{type:"array-reset",method:w}),S}}),["indexOf","lastIndexOf","includes"].forEach(w=>{x[w]=function(P,...S){let O=d[w].apply(d,[P,...S]);return(O===-1||O===!1)&&Ne(P)&&(O=d[w].apply(d,[Qt(P),...S])),O}}),x},R=(d,v,x)=>{if(!Object.isExtensible(d)||d[dt])return d;const w=u.get(d);if(w)return y.set(w,{parent:v,key:x}),w;const P={get(O,_,j){if(_===dt)return O;if(Array.isArray(O)){const K=$.get(S);if(K&&Object.prototype.hasOwnProperty.call(K,_))return Reflect.get(K,_,j)}const q=Reflect.get(O,_,j);return typeof _=="symbol"?q:U(q)?R(q,S,_):q},set(O,_,j,q){const K=O[_];if(o?kt(K,j):K===j)return!0;const bt=Reflect.set(O,_,j,q);return h===0&&(Array.isArray(K)&&Array.isArray(j)?b(S,{type:"array-replace",oldValue:K,newValue:j}):b(S,{type:"set",key:_,newValue:j,oldValue:K})),bt},deleteProperty(O,_){if(!Reflect.has(O,_))return!1;const j=O[_],q=Reflect.deleteProperty(O,_);return q&&h===0&&b(S,{type:"delete",key:_,oldValue:j}),q}},S=new Proxy(d,P);return u.set(d,S),y.set(S,{parent:v,key:x}),Array.isArray(d)&&$.set(S,E(d,S)),S},M=R(s,null,null);if(i){const d=(v,x,w=new WeakSet)=>{!U(v)||w.has(v)||(w.add(v),Reflect.ownKeys(v).forEach(P=>{const S=v[P];b(x,{type:"set",key:P,newValue:S,oldValue:void 0}),U(S)&&d(S,R(S,x,P),w)}))};d(s,M)}return{proxy:M,unobserve:()=>{c=!1,l=[],a&&clearTimeout(a)},resume:()=>{c=!0}}}const te=Symbol.for("solely.manifest"),B=class B extends HTMLElement{constructor(e={}){var i;super();W(this,C);W(this,z);W(this,X);W(this,tt);W(this,ot);W(this,et);W(this,H);W(this,nt,!1);W(this,st,!1);W(this,Y,!1);W(this,at,!1);const n=this.constructor;F(this,z,n[te]||{tagName:"base-element"});const r=I(this,z);F(this,et,(i=r.shadowDOM)!=null&&i.use?this.attachShadow({mode:r.shadowDOM.mode||"open"}):this),T(this,C,Nt).call(this,e),T(this,C,he).call(this,r),queueMicrotask(()=>T(this,C,Ft).call(this))}static get observedAttributes(){if(I(B,J).has(this))return I(B,J).get(this);const e=this[te];if(!(e!=null&&e.props))return I(B,J).set(this,[]),[];const n=e.props.map(r=>(typeof r=="string"?r:r.name).replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase());return I(B,J).set(this,n),n}get $data(){return I(this,ot)}set $data(e){var n;U(e)||(e={}),(n=I(this,H))==null||n.call(this),T(this,C,Nt).call(this,e),T(this,C,vt).call(this)}refresh(){T(this,C,vt).call(this)}connectedCallback(){var i;const e=this.constructor;Array.isArray(e.upgradeProps)&&T(this,C,ue).call(this,e.upgradeProps),T(this,C,Ft).call(this);const n=I(this,z);if((n.className||n.tagName||"").split(" ").forEach(o=>o&&this.classList.add(o)),T(this,C,de).call(this),n.props&&U(this.$data))for(const o of n.props){const c=typeof o=="string"?o:o.name,a=T(this,C,Tt).call(this,c),l=c.replace(/-([a-z])/g,(h,u)=>u.toUpperCase());if(this.hasAttribute(c)){const h=this.getAttribute(c),u=T(this,C,Wt).call(this,h,a==null?void 0:a.default,a==null?void 0:a.type);this.$data[l]=u}else a&&"default"in a&&(this.$data[l]=a.default)}I(this,tt)&&F(this,X,re(I(this,tt),I(this,et),this)),this.mounted(),(i=this.onInit)==null||i.call(this)}disconnectedCallback(){var e;this.unmounted(),(e=I(this,H))==null||e.call(this),F(this,H,void 0)}attributeChangedCallback(e,n,r){if(n===r||!U(this.$data))return;const i=T(this,C,Tt).call(this,e),o=e.replace(/-([a-z])/g,(l,h)=>h.toUpperCase()),c=this.$data[o],a=T(this,C,Wt).call(this,r,(i==null?void 0:i.default)??c,i==null?void 0:i.type);this.$data[o]=a,F(this,Y,!0),this.attributeChanged(e,c,a),this.emit("change",{source:"attribute",name:e,oldValue:c,newValue:a})}emit(e,n,r){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:n,...r}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(e,n,r){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};z=new WeakMap,X=new WeakMap,tt=new WeakMap,ot=new WeakMap,et=new WeakMap,H=new WeakMap,nt=new WeakMap,st=new WeakMap,Y=new WeakMap,at=new WeakMap,ct=new WeakMap,J=new WeakMap,C=new WeakSet,ue=function(e){for(const n of e)if(this.hasOwnProperty(n)){const r=this[n];delete this[n],this[n]=r}},Nt=function(e){const{proxy:n,unobserve:r}=Xt(e,i=>{this.emit("change",{source:"state",...i}),T(this,C,vt).call(this)});F(this,ot,n),F(this,H,r)},he=function(e){const n=e.template;if(typeof n=="string"){const r=Zt(n);F(this,tt,Jt(r,{source:n,filename:e.tagName}))}},Tt=function(e){const n=I(this,z).props;if(!n)return;const r=e.replace(/-([a-z])/g,(o,c)=>c.toUpperCase()),i=n.find(o=>typeof o=="string"?o===r:o.name===r);if(i)return typeof i=="string"?{name:i}:i},Wt=function(e,n,r){if(e===null)return n;switch(r){case"number":{const i=Number(e);return isNaN(i)?n:i}case"boolean":return e!==null&&e!=="false";case"object":try{return JSON.parse(e)}catch{return n}default:return e}},vt=function(){I(this,st)||!I(this,X)||(F(this,st,!0),queueMicrotask(()=>{F(this,st,!1),T(this,C,fe).call(this)}))},fe=function(){I(this,nt)||!this.isConnected||(F(this,nt,!0),I(this,Y)&&this.beforeAttributesUpdate(),this.beforeUpdate(),I(this,X).update(),this.updated(),I(this,Y)&&(this.afterAttributesUpdate(),F(this,Y,!1)),F(this,nt,!1))},de=function(){const n=I(this,z).styles;if(!n)return;const r=I(this,et);if("adoptedStyleSheets"in r){if(r._styleInjected)return;let o=I(B,ct).get(n);o||(o=new CSSStyleSheet,o.replaceSync(n),I(B,ct).set(n,o)),r.adoptedStyleSheets=[...r.adoptedStyleSheets,o],r._styleInjected=!0;return}if(r.querySelector("style[data-manifest-style]"))return;const i=document.createElement("style");i.dataset.manifestStyle="true",i.textContent=n,r.appendChild(i)},Ft=function(){I(this,at)||(F(this,at,!0),this.created())},Mt=new WeakMap,L(B,"upgradeProps"),W(B,ct,new Map),W(B,J,new WeakMap),W(B,Mt,!1);let it=B;const Te=Symbol.for("solely.manifest"),Ct=s=>t=>{if(customElements.get(s.tagName))return console.warn(`标签名称 "${s.tagName}" 已经被注册`),t;class e extends t{}return e[Te]=s,customElements.define(s.tagName,e),e},pt=Symbol("solely.irCtx"),mt=Symbol("solely.irEvents"),V=Symbol.for("solely.irMeta"),Rt=Symbol("solely.prevClassObj"),Lt=Symbol("solely.prevStyleObj"),We={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},Fe={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},je=new Set(["data-","aria-","role","form"]),De=new Set(["value","selectedIndex"]);function Ve(s,t){var n;const e=(n=t.attrs)==null?void 0:n.find(r=>r.key==="class"&&!r.dynamic);e!=null&&e.value&&s.setAttribute("class",e.value)}function Be(s,t){var r;const e=(r=t.attrs)==null?void 0:r.find(i=>i.key==="style"&&!i.dynamic),n=e?ee(e.value):{};for(const i in n){const o=n[i];i.startsWith("--")?s.style.setProperty(i,o):s.style[i]=o}}const Ke=(s,t)=>{const e=s,n=ee(t),r=e[Lt];if(!r){for(const o in n){const c=n[o];o.startsWith("--")?s.style.setProperty(o,c):s.style[o]=c}e[Lt]=n;return}let i=!1;for(const o in r)o in n||(o.startsWith("--")?s.style.removeProperty(o):s.style[o]="",i=!0);for(const o in n){const c=n[o],a=r[o];c!==a&&(o.startsWith("--")?s.style.setProperty(o,c):s.style[o]=c,i=!0)}i&&(e[Lt]=n)},qe=(s,t)=>{const e=s,n=e[Rt],r=Ge(t);if(!n){for(const o in r)s.classList.add(o);e[Rt]=r;return}let i=!1;for(const o in n)r[o]||(s.classList.remove(o),i=!0);for(const o in r)n[o]||(s.classList.add(o),i=!0);i&&(e[Rt]=r)};function ee(s){const t={},e=[[s]];for(;e.length;){const[n,r]=e.pop();if(n){if(typeof n=="string"){const i=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;(o=i.exec(n))!==null;){const c=o[1].trim(),a=o[2].trim();c&&a&&(t[c]=a)}continue}if(Array.isArray(n)){for(let i=n.length-1;i>=0;i--)e.push([n[i]]);continue}if(typeof n=="object")for(const i in n){const o=n[i];if(o==null)continue;const c=r?`${r}-${i}`:i;typeof o=="object"&&!Array.isArray(o)?e.push([o,c]):t[c]=String(o)}}}return t}function Ge(s){const t={},e=[s];for(;e.length;){const n=e.pop();if(n){if(typeof n=="string"){const r=n.split(" ");for(let i=0;i<r.length;i++){const o=r[i].trim();o&&(t[o]=!0)}}else if(Array.isArray(n))for(let r=n.length-1;r>=0;r--)e.push(n[r]);else if(typeof n=="object")for(const r in n)n[r]&&(t[r]=!0)}}return t}function ze(s,t,e){const n=t.indexOf(":");if(n>0){const r=t.slice(0,n),i=We[r];if(i)return s.setAttributeNS(i,t,e)}s.setAttribute(t,e)}function ne(s,t,e){if(t.startsWith("data-")||t.startsWith("aria-")||je.has(t)){s.setAttribute(t,e);return}const n=Fe[t]||t;s[n]=e}class se{constructor(t,e,n={}){L(this,"nodeMap",new Map);L(this,"marker",!1);this.ir=t,this.container=e,this.scope=n}evalIR(t,e,n){var i;const r=this.ir.functions[t-1];try{return r?r.apply(this.scope,e):""}catch(o){return Dt(o.message||o.toString(),((i=this.ir.metadata)==null?void 0:i.source)||"",n,this.scope.tagName),""}}createElement(t,e){const n=t.tag;return e instanceof SVGElement||n==="svg"?document.createElementNS("http://www.w3.org/2000/svg",n):document.createElement(n)}createText(t,e){const n=t.dynamic?this.evalIR(t.fid,[e],t[V]):t.txt||"";return document.createTextNode(n)}createComment(t,e){const n=t.dynamic?this.evalIR(t.fid,[e],t[V]):t.txt||"";return document.createComment(n)}applyAttrs(t,e,n,r=!1){const i=[],o=t;o[pt]||(o[pt]={loops:null}),o[pt].loops=n,o[mt]||(o[mt]=Object.create(null));let c,a=!1,l,h=!1;for(const u of e){const{key:y,fid:$,dynamic:m,value:p}=u;if(y===":class"){c=this.evalIR($,[n],u[V]),a=!0;continue}if(y===":style"){l=this.evalIR($,[n],u[V]),h=!0;continue}if(y==="class"||y==="style")continue;const A=y[0];if(A==="@"){const E=y.slice(1),R=u.role??"user";let M=o[mt][E];if(M||(M=o[mt][E]={model:[],user:[]},t.addEventListener(E,d=>{for(const v of M.model)v(d);for(const v of M.user)v(d)})),!r){const d=v=>this.evalIR($,[v,o[pt].loops],u[V]);M[R].push(d)}continue}if(y==="mounted"){r||requestAnimationFrame(()=>this.evalIR($,[t,n],u[V]));continue}if(y==="updated"){r&&requestAnimationFrame(()=>this.evalIR($,[t,n],u[V]));continue}if(y==="ref"&&p){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[p]=t;continue}const b=m?this.evalIR($,[n],u[V]):p??"";if(A===":"){const E=y.slice(1);t.tagName==="SELECT"&&De.has(E)?i.push(()=>ne(t,E,b)):ne(t,E,b)}else r||ze(t,y,String(b))}return a&&qe(t,c),h&&Ke(t,l),i}updateNode(t,e,n){const r=e.dynamic?this.evalIR(e.fid,[n],e[V]):e.txt||"";e.dynamic&&t.textContent!==r&&(t.textContent=r)}irToNode(t,e,n,r,i){var l,h,u,y;const o=n+"-"+e,c=this.nodeMap.get(o);let a;if(c){a=c.node,c.marker=this.marker;let $=[];t.dynamic&&(t.type===g.Element?$=this.applyAttrs(a,t.attrs??[],i,!0):this.updateNode(a,t,i)),(l=t.children)==null||l.forEach((m,p)=>{this.irToNode(m,p,o,a,i)}),$.forEach(m=>m())}else switch(t.type){case g.Element:a=this.createElement(t,r),Ve(a,t),Be(a,t);const $=this.applyAttrs(a,t.attrs??[],i);r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker}),(h=t.children)==null||h.forEach((m,p)=>{this.irToNode(m,p,o,a,i)}),$.forEach(m=>m());break;case g.Text:a=this.createText(t,i),r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker});break;case g.Comment:a=this.createComment(t,i),r.appendChild(a),this.nodeMap.set(o,{irNode:t,node:a,loops:i,marker:this.marker});break;case g.For:{const m=`${o}-end`;let p=(u=this.nodeMap.get(m))==null?void 0:u.node;p?this.nodeMap.get(m).marker=this.marker:(p=document.createComment(`for:${o}`),r.appendChild(p),this.nodeMap.set(m,{irNode:{type:g.Comment},node:p,loops:i,marker:this.marker}));const A=this.evalIR(t.fid,[i],t[V])||[],b=document.createDocumentFragment();A.forEach((E,R)=>{var d;const M=[...i,{itmVal:E,idxVal:R}];(d=t.children)==null||d.forEach((v,x)=>{this.irToNode(v,x,`${o}-for-${R}`,b,M)})}),p.parentNode.insertBefore(b,p);break}case g.Conditional:{const m=`${o}-end`;let p=(y=this.nodeMap.get(m))==null?void 0:y.node;p?this.nodeMap.get(m).marker=this.marker:(p=document.createComment(`if:${o}`),r.appendChild(p),this.nodeMap.set(m,{irNode:{},node:p,loops:i,marker:this.marker}));for(let A=0;A<(t.branches||[]).length;A++){const b=t.branches[A];if(b.condFid===null||this.evalIR(b.condFid,[i],b[V])){const R=document.createDocumentFragment();b.children.forEach((M,d)=>{this.irToNode(M,d,`${o}-if-${A}`,R,i)}),p.parentNode.insertBefore(R,p);break}}break}}}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:n,node:r,loops:i}=e;if(n.attrs){const o=n.attrs.find(a=>a.key==="unmounted");o&&requestAnimationFrame(()=>{this.evalIR(o.fid,[r,i],o[V])});const c=n.attrs.find(a=>a.key==="ref");c&&c.value&&delete this.scope.$refs[c.value]}r==null||r.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.nodes.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.nodes.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear()}}const re=(s,t,e={})=>{const n=new se(s,t,e);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};let Q=null,ie;const It=new Promise(s=>{ie=s});function Ue(s){return Q||(Q=new oe(s),ie(Q),Q)}function gt(){return Q}class oe{constructor(t){L(this,"routes");L(this,"base");L(this,"mode");L(this,"beforeEachGuard");L(this,"afterEachGuard");L(this,"currentRoute",null);L(this,"listeners",new Set);L(this,"isStarted",!1);this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const e=t.startsWith("/")?t:"/"+t,[n,r]=e.split("?"),i=n.split("/").filter(Boolean),o=this.parseQuery(r),c=this.recursiveMatch(this.routes,i);if(c){const a=c.matched[c.matched.length-1];return a.config.redirect?this.matchRoute(a.config.redirect):{matched:c.matched,params:c.params,query:o,fullPath:e,meta:c.matched.reduce((l,h)=>({...l,...h.config.meta||{}}),{})}}return null}recursiveMatch(t,e){const n=[...t].sort((r,i)=>this.calculateScore(i.path)-this.calculateScore(r.path));for(const r of n){const i=r.path.split("/").filter(Boolean),o={};let c=!0;if(i.length===0&&e.length===0)return{matched:[{config:r,params:{}}],params:{}};for(let a=0;a<i.length;a++){const l=i[a],h=e[a];if(l.startsWith(":")){if(!h){c=!1;break}o[l.slice(1)]=h}else if(l==="*"){c=!0;break}else if(l!==h){c=!1;break}}if(c){const a=i.length,l=e.slice(a),h={config:r,params:o};if(l.length>0&&r.children){const u=this.recursiveMatch(r.children,l);if(u)return{matched:[h,...u.matched],params:{...o,...u.params}}}else if(l.length===0||i.includes("*"))return{matched:[h],params:o}}}return null}calculateScore(t="/"){const e=t.split("/").filter(Boolean);return e.length===0?1:e.reduce((n,r)=>r.startsWith(":")?n+5:r==="*"?n+0:n+10,0)}parseQuery(t){const e={};return t&&new URLSearchParams(t).forEach((r,i)=>{e[i]=r}),e}normalizePath(t="/"){let e=t&&typeof t=="string"?t:"/";return e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}getPath(){let t;try{t=this.mode==="hash"?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const e=this.base||"/";return e!=="/"&&t.startsWith(e)&&(t=t.slice(e.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",e){const n=this.normalizePath(t),r=this.base||"/";if(this.mode==="hash")e?window.location.replace(`#${n}`):window.location.hash=n;else{const i=r.endsWith("/")?r.slice(0,-1):r,o=i==="/"?n:i+n;e?window.history.replaceState({path:o},"",o):window.history.pushState({path:o},"",o)}}async navigate(t="/",e=!1,n=!1){const r=this.normalizePath(t),i=this.currentRoute,o=this.matchRoute(r);if(!o)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===o.fullPath)return{success:!0};if(this.beforeEachGuard)try{const c=await this.beforeEachGuard(o,i);if(c===!1)return{success:!1,cancelled:!0};if(typeof c=="string")return this.navigate(c,e)}catch(c){return{success:!1,error:c instanceof Error?c.message:"Guard Error"}}return this.currentRoute=o,n||this.updateBrowserHistory(r,e),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(o,i),{success:!0}}resolve(t="/"){const e=this.normalizePath(t);if(this.mode==="hash")return`#${e}`;const n=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return n==="/"?e:n+e}get modeType(){return this.mode}pushWithQuery(t="/",e){const n=new URLSearchParams(e).toString(),r=t.includes("?")?"&":"?";return this.push(t+(n?r+n:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){if(this.isStarted)return;const t=()=>{this.navigate(this.getPath(),!0,!0)};window.addEventListener("popstate",t),this.mode==="hash"&&!window.location.hash&&(window.location.hash="/"),this.navigate(this.getPath(),!0)}getCurrentRoute(){return this.currentRoute}}var He=Object.getOwnPropertyDescriptor,Ye=(s,t,e,n)=>{for(var r=n>1?void 0:n?He(t,e):t,i=s.length-1,o;i>=0;i--)(o=s[i])&&(r=o(r)||r);return r};let yt=class extends it{constructor(){super(...arguments);L(this,"unsubscribe");L(this,"level",0);L(this,"currentElement",null);L(this,"currentTagName",null);L(this,"routerAttrs",new Set);L(this,"prevPropKeys",new Set);L(this,"scheduled",!1);L(this,"cache",new Map);L(this,"latestLoadId",0)}async mounted(){this.detectLevel();const t=await It;this.unsubscribe=t.listen(()=>{this.scheduleLoad(t.getCurrentRoute())}),this.loadRoute(t.getCurrentRoute())}unmounted(){var t;(t=this.unsubscribe)==null||t.call(this),this.cache.forEach(e=>e.remove()),this.cache.clear()}scheduleLoad(t){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t)}))}detectLevel(){let t=0,e=this.parentElement;for(;e;)e instanceof yt&&t++,e=e.parentElement;this.level=t}async loadRoute(t){const e=++this.latestLoadId,n=t==null?void 0:t.matched[this.level];if(!n){this.handleEmptyRoute();return}const{config:r}=n;let i=r.tagName;if(!i&&typeof r.component=="function"){this.renderLoading();try{const c=await r.component();i=typeof c=="string"?c:c.tagName}catch(c){this.renderError(`Load Error: ${c}`);return}}if(e!==this.latestLoadId)return;if(!i){this.clear();return}if(!r.forceReload&&this.currentElement&&this.currentTagName===i.toLowerCase()){this.syncState(this.currentElement,t==null?void 0:t.params,(t==null?void 0:t.query)||{},r.props);return}this.clear(r.keepAlive);const o=this.getOrCreateComponent(i,r);this.syncState(o,t==null?void 0:t.params,(t==null?void 0:t.query)||{},r.props),this.appendChild(o),this.currentElement=o,this.currentTagName=i.toLowerCase()}getOrCreateComponent(t,e){const n=t.toLowerCase();if(e.keepAlive&&this.cache.has(n))return this.cache.get(n);const r=document.createElement(t);return e.keepAlive&&this.cache.set(n,r),r}syncState(t,e,n,r={}){const i=a=>a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=new Map;Object.entries(e).forEach(([a,l])=>o.set(i(a),String(l))),Object.entries(n).forEach(([a,l])=>o.set(`query-${i(a)}`,String(l))),this.routerAttrs.forEach(a=>{o.has(a)||(t.removeAttribute(a),this.routerAttrs.delete(a))}),o.forEach((a,l)=>{t.getAttribute(l)!==a&&t.setAttribute(l,a),this.routerAttrs.add(l)});const c=new Set(Object.keys(r));this.prevPropKeys.forEach(a=>{c.has(a)||(t[a]=void 0)}),Object.entries(r).forEach(([a,l])=>{t[a]!==l&&(t[a]=l)}),this.prevPropKeys=c}handleEmptyRoute(){this.clear(),this.level===0&&this.renderError("404 Not Found")}renderLoading(){this.innerHTML='<div style="padding:20px; color:#999;">Loading...</div>'}renderError(t){this.innerHTML=`<div style="padding:20px; color:#ff4d4f;">${t}</div>`}clear(t=!1){this.currentElement?this.contains(this.currentElement)&&this.removeChild(this.currentElement):t||(this.innerHTML=""),this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};yt=Ye([Ct({tagName:"router-view"})],yt);const Je=yt;var Ze=Object.getOwnPropertyDescriptor,Qe=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ze(t,e):t,i=s.length-1,o;i>=0;i--)(o=s[i])&&(r=o(r)||r);return r};let At=class extends it{constructor(){super(...arguments);L(this,"_prefetched",!1)}set to(t){this.$data.to=t,this.updateState()}get to(){return this.$data.to}async mounted(){(await It).listen(()=>this.updateState()),this.updateState(),this.addEventListener("click",e=>{var r,i;e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.button!==0||(r=e.target.closest("a"))!=null&&r.getAttribute("target")||(e.preventDefault(),(i=gt())==null||i.push(this.$data.to))}),this.addEventListener("mouseenter",()=>{this.prefetchRoute()},{once:!0})}updateState(){const t=gt();if(!t)return;this.$data.href=t.resolve(this.$data.to);let e=!1;if(this.$data.active)e=!0;else{const r=t.getCurrentRoute();if(r){const i=r.fullPath;this.hasAttribute("exact")?e=i===this.$data.to:e=i===this.$data.to||i.startsWith(this.$data.to+"/")}}this.$data.isActive=e;const n=this.$data.activeClass||"active";this.classList.toggle(n,e)}prefetchRoute(){if(this._prefetched||!this.hasAttribute("prefetch"))return;const t=gt();t&&typeof t.prefetch=="function"&&(t.prefetch(this.$data.to),this._prefetched=!0)}};At=Qe([Ct({tagName:"router-link",template:`
|
|
24
24
|
<a part="link" :href="$data.href" :class="{active: $data.isActive}">
|
|
25
25
|
<slot>{{$data.label || ''}}</slot>
|
|
26
26
|
</a>
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
:host([custom]) a {
|
|
44
44
|
display: contents;
|
|
45
45
|
}
|
|
46
|
-
`,shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],At);const
|
|
46
|
+
`,shadowDOM:{use:!0,mode:"open"},props:["to","active","exact","label","custom","activeClass","prefetch"]})],At);const Xe=At;f.ASTType=g,f.BaseElement=it,f.CustomElement=Ct,f.IRRenderer=se,f.LIFECYCLE_ATTRS_MAP=qt,f.Router=oe,f.RouterLink=Xe,f.RouterView=Je,f.buildIR=Jt,f.clearIRCache=Le,f.createFunction=Vt,f.createRender=re,f.createRouter=Ue,f.genFunction=Bt,f.getRouter=gt,f.isLifecycleKind=zt,f.isObject=U,f.listeners=Kt,f.mapAttrKeyToLifecycleKind=Gt,f.observe=Xt,f.parseHashUrl=$e,f.parseHtml=Zt,f.routerReady=It,f.showTemplateError=Dt,f.transformModel=Yt,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
declare interface BaseElement<TData = any> {
|
|
2
|
+
/**
|
|
3
|
+
* 通过 ref 属性获取的 DOM 元素引用集合
|
|
4
|
+
* - 键:模板中写的 ref="xxx" 的名字
|
|
5
|
+
* - 值:对应的 DOM 元素(通常是 HTMLElement 或 SVGElement)
|
|
6
|
+
*/
|
|
7
|
+
$refs: Record<string, HTMLElement | SVGElement | any>;
|
|
2
8
|
}
|
|
3
9
|
declare class BaseElement<TData extends object = any> extends HTMLElement {
|
|
4
10
|
#private;
|
|
11
|
+
static upgradeProps?: readonly string[];
|
|
5
12
|
static get observedAttributes(): string[];
|
|
6
13
|
constructor(initialData?: TData);
|
|
7
14
|
get $data(): TData;
|