@kupola/kupola 1.4.5 → 1.4.7
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/css/components-ext.css +8 -8
- package/css/components.css +1 -0
- package/css/table.css +35 -34
- package/css/theme-dark.css +12 -12
- package/css/theme-light.css +2 -2
- package/dist/css/components-ext.css +8 -8
- package/dist/css/components.css +1 -0
- package/dist/css/table.css +35 -34
- package/dist/css/theme-dark.css +12 -12
- package/dist/css/theme-light.css +16 -16
- package/dist/kupola.cjs.js +1 -1
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.css +58 -56
- package/dist/kupola.esm.js +8 -5
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.min.css +1 -1
- package/dist/kupola.umd.js +1 -1
- package/dist/kupola.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/kupola.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Q{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const o of s){await this._resolveDepends(o.depends,t);const l=performance.now();let c,h;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){h=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const d=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:d,status:h?"error":"success",error:h?h.message:null,timestamp:Date.now()})}const a=performance.now()-r;console.debug(`[KupolaLifecycle] ${t} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Is=new Q("app");function As(i="app"){return new Q(i)}const zs=new Set(["__proto__","prototype","constructor"]);function tt(i){return zs.has(i)}function Ps(i){return i?i.trim():""}function $s(i){return i?i.replace(/^\s+/,""):""}function qs(i){return i?i.replace(/\s+$/,""):""}function Bs(i){return i?i.toUpperCase():""}function Fs(i){return i?i.toLowerCase():""}function Ns(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Os(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Rs(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Vs(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Ks(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Ws(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Us(i,t,e){return i?i.split(t).join(e):""}function Ys(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Xs(i,t){return(i||"").startsWith(t)}function js(i,t){return(i||"").endsWith(t)}function Js(i,t){return(i||"").includes(t)}function Gs(i,t){return(i||"").repeat(t)}function Zs(i){return(i||"").split("").reverse().join("")}function Qs(i,t){return!i||!t?0:i.split(t).length-1}function ti(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function ei(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function si(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function ii(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Xt={trim:Ps,trimLeft:$s,trimRight:qs,toUpperCase:Bs,toLowerCase:Fs,capitalize:Ns,camelize:Os,hyphenate:Rs,padStart:Vs,padEnd:Ks,truncate:Ws,replaceAll:Us,format:Ys,startsWith:Xs,endsWith:js,includes:Js,repeat:Gs,reverse:Zs,countOccurrences:Qs,escapeHtml:ti,unescapeHtml:ei,generateRandom:si,generateUUID:ii};function ni(i){return Array.isArray(i)}function ri(i){return!i||i.length===0}function ai(i){return i?i.length:0}function oi(i,t){return i&&i.length>0?i[0]:t}function li(i,t){return i&&i.length>0?i[i.length-1]:t}function ci(i,t,e){return i&&i[t]!==void 0?i[t]:e}function hi(i,t,e){return i?i.slice(t,e):[]}function di(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function ui(i,t=","){return i?i.join(t):""}function pi(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function fi(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function mi(i,t){return i?i.includes(t):!1}function gi(i,...t){return i&&i.push(...t),i}function _i(i){return i?i.pop():void 0}function yi(i){return i?i.shift():void 0}function vi(i,...t){return i&&i.unshift(...t),i}function bi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function xi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function Ei(i,t,e){return i&&(i.splice(t,0,e),i)}function ki(i){return i?i.slice().reverse():[]}function wi(i,t){return i?i.slice().sort(t):[]}function Ci(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function Si(i,t){return i?i.filter(t):[]}function Li(i,t){return i?i.map(t):[]}function Di(i,t,e){return i?i.reduce(t,e):e}function Hi(i,t){i&&i.forEach(t)}function Mi(i,t){return i?i.every(t):!0}function Ti(i,t){return i?i.some(t):!1}function Ii(i,t){return i?i.find(t):void 0}function Ai(i,t){return i?i.findIndex(t):-1}function zi(i,t=1){return i?i.flat(t):[]}function jt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(jt(e)):t.concat(e),[]):[]}function Pi(i){return i?[...new Set(i)]:[]}function $i(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function qi(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function Bi(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Jt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function Fi(i){return!i||i.length===0?0:Jt(i)/i.length}function Ni(i){return i&&i.length>0?Math.max(...i):-1/0}function Oi(i){return i&&i.length>0?Math.min(...i):1/0}function Ri(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Vi(...i){return[...new Set(i.flat().filter(Boolean))]}function Ki(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Wi(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Gt={isArray:ni,isEmpty:ri,size:ai,first:oi,last:li,get:ci,slice:hi,concat:di,join:ui,indexOf:pi,lastIndexOf:fi,includes:mi,push:gi,pop:_i,shift:yi,unshift:vi,remove:bi,removeAt:xi,insert:Ei,reverse:ki,sort:wi,sortBy:Ci,filter:Si,map:Li,reduce:Di,forEach:Hi,every:Mi,some:Ti,find:Ii,findIndex:Ai,flat:zi,flattenDeep:jt,unique:Pi,uniqueBy:$i,chunk:qi,shuffle:Bi,sum:Jt,average:Fi,max:Ni,min:Oi,intersection:Ri,union:Vi,difference:Ki,zip:Wi};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Ui(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Yi(i){return i?Object.keys(i):[]}function Xi(i){return i?Object.values(i):[]}function ji(i){return i?Object.entries(i):[]}function Ji(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function Gi(i,t,e){if(!i)return e;const s=t.split(".");return s.some(tt)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Zi(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(tt))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Qi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function tn(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Zt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{tt(s)||(rt(e[s])&&rt(t[s])?t[s]=Zt(t[s],e[s]):t[s]=e[s])}),t),{})}function en(i){return i&&JSON.parse(JSON.stringify(i))}function W(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,W(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(W(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(W(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{tt(s)||(e[s]=W(i[s],t))}),e}function sn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function nn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function rn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function an(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function on(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function ln(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function cn(i){return i?Object.keys(i).length:0}function hn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Qt(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Qt(i[n],t[n]))}function te(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&te(i[t])}),i)}function dn(i){return i&&Object.seal(i)}const ee={isObject:rt,isEmpty:Ui,keys:Yi,values:Xi,entries:ji,has:Ji,get:Gi,set:Zi,pick:Qi,omit:tn,merge:Zt,clone:en,deepClone:W,forEach:sn,map:nn,filter:rn,reduce:an,toArray:on,fromArray:ln,size:cn,invert:hn,isEqual:Qt,freeze:te,seal:dn};function L(i){return typeof i=="number"&&!isNaN(i)}function un(i){return Number.isInteger(i)}function pn(i){return L(i)&&!Number.isInteger(i)}function fn(i){return L(i)&&i>0}function mn(i){return L(i)&&i<0}function gn(i){return L(i)&&i===0}function _n(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function yn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function vn(i){return L(i)?Math.floor(i):i}function bn(i){return L(i)?Math.ceil(i):i}function xn(i){return L(i)?Math.abs(i):i}function En(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function kn(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function se(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function wn(...i){const t=i.flat().filter(L);return t.length>0?se(t)/t.length:0}function ie(i=0,t=1){return Math.random()*(t-i)+i}function Cn(i,t){return Math.floor(ie(i,t+1))}function Sn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Ln(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Dn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Hn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Mn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Tn(i){return Number.isNaN(i)}function In(i){return Number.isFinite(i)}function An(i,t=10){return Number.parseInt(i,t)}function zn(i){return Number.parseFloat(i)}function Pn(i,t=0){const e=Number(i);return isNaN(e)?t:e}function $n(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function qn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const ne={isNumber:L,isInteger:un,isFloat:pn,isPositive:fn,isNegative:mn,isZero:gn,clamp:_n,round:yn,floor:vn,ceil:bn,abs:xn,min:En,max:kn,sum:se,average:wn,random:ie,randomInt:Cn,format:Sn,formatCurrency:Ln,formatPercent:Dn,toFixed:Hn,toPrecision:Mn,isNaN:Tn,isFinite:In,parseInt:An,parseFloat:zn,toNumber:Pn,safeDivide:$n,safeMultiply:qn};function et(){return Date.now()}function K(){const i=new Date;return i.setHours(0,0,0,0),i}function Bn(){const i=K();return i.setDate(i.getDate()+1),i}function Fn(){const i=K();return i.setDate(i.getDate()-1),i}function k(i){return i instanceof Date&&!isNaN(i.getTime())}function re(i){return k(i)}function Nn(i){const t=new Date(i);return re(t)?t:null}function On(i,t="YYYY-MM-DD HH:mm:ss"){if(!k(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),o=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",h)}function Rn(i){return k(i)?i.toISOString():""}function Vn(i){return k(i)?new Date(i.toUTCString()):null}function Kn(i,t){if(!k(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Wn(i,t){if(!k(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Un(i,t){if(!k(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Yn(i,t){if(!k(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function st(i,t){if(!k(i)||!k(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Xn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function jn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function Jn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function Gn(i){return k(i)?st(i,K())===0:!1}function Zn(i){return k(i)?st(i,K())===-1:!1}function Qn(i){return k(i)?st(i,K())===1:!1}function tr(i){return k(i)?i.getTime()>et():!1}function er(i){return k(i)?i.getTime()<et():!1}function sr(i){if(!k(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function ir(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function nr(i){if(!k(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function rr(i){return k(i)?Math.ceil((i.getMonth()+1)/3):0}function ar(i){if(!k(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function or(i){if(!k(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function lr(i){return k(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function cr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function ae(i,t=1){if(!k(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function hr(i,t=1){if(!k(i))return i;const e=ae(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function dr(i){if(!k(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function ur(i){if(!k(i))return"";const e=et()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,o=30*r,l=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}const oe={now:et,today:K,tomorrow:Bn,yesterday:Fn,isDate:k,isValid:re,parse:Nn,format:On,toISO:Rn,toUTC:Vn,addDays:Kn,addHours:Wn,addMinutes:Un,addSeconds:Yn,diffDays:st,diffHours:Xn,diffMinutes:jn,diffSeconds:Jn,isToday:Gn,isYesterday:Zn,isTomorrow:Qn,isFuture:tr,isPast:er,isLeapYear:sr,getDaysInMonth:ir,getWeekOfYear:nr,getQuarter:rr,startOfDay:ar,endOfDay:or,startOfMonth:lr,endOfMonth:cr,startOfWeek:ae,endOfWeek:hr,getAge:dr,fromNow:ur};function le(i,t,e={}){let s=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(r,n)}function h(){a=Date.now(),o?(s=setTimeout(d,t),c()):s=setTimeout(d,t)}function d(){s=null,l&&n&&c(),n=null,r=null}function u(){return Math.max(0,t-(Date.now()-a))}return function(...f){n=f,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(d,u())):h()}}function ce(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function o(){i.apply(a,r),r=null,a=null}return function(...l){s?n&&(r=l,a=this):(s=!0,r=l,a=this,o(),setTimeout(()=>{s=!1,n&&r&&o()},t))}}function pr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function fr(i){return/^1[3-9]\d{9}$/.test(i||"")}function mr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function he(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function de(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function gr(i){return he(i)||de(i)}function _r(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function yr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function vr(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function ue(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function pe(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function fe(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function br(i){return ue(i)||pe(i)||fe(i)}function xr(i){return!isNaN(new Date(i).getTime())}function Er(i){try{return JSON.parse(i),!0}catch{return!1}}function kr(i){return!i||i.trim()===""}function wr(i){return/^\s+$/.test(i||"")}function Cr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Sr(i){return/^-?\d+$/.test(i||"")}function Lr(i){return/^-?\d+\.\d+$/.test(i||"")}function Dr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Hr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Mr(i){return/^[a-zA-Z]+$/.test(i||"")}function Tr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Ir(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Ar(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function zr(i,t){return(i||"").length>=t}function Pr(i,t){return(i||"").length<=t}function $r(i,t){return t instanceof RegExp?t.test(i||""):!1}function qr(i,t){return String(i)===String(t)}function me(i,t){return(i||"").includes(t)}function Br(i,t){return!me(i,t)}function Fr(i){return Array.isArray(i)}function Nr(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Or(i,t){return i?i.length>=t:!1}function Rr(i,t){return i?i.length<=t:!1}function Vr(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Kr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Wr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");ct[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,i);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const ct={isEmail:pr,isPhone:fr,isURL:mr,isIPv4:he,isIPv6:de,isIP:gr,isIDCard:_r,isPassport:yr,isCreditCard:vr,isHexColor:ue,isRGB:pe,isRGBA:fe,isColor:br,isDate:xr,isJSON:Er,isEmpty:kr,isWhitespace:wr,isNumber:Cr,isInteger:Sr,isFloat:Lr,isPositive:Dr,isNegative:Hr,isAlpha:Mr,isAlphaNumeric:Tr,isChinese:Ir,isLength:Ar,minLength:zr,maxLength:Pr,matches:$r,equals:qr,contains:me,notContains:Br,isArray:Fr,arrayLength:Nr,arrayMinLength:Or,arrayMaxLength:Rr,isObject:Vr,hasKeys:Kr,validate:Wr};function Ur(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(d,u){return d<<u|d>>>32-u}function a(d){const u=d.length*8;for(d+="";d.length%64!==56;)d+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)d+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)d+=String.fromCharCode(p>>>8*m&255);return d}function o(d,u){const[f,p,m,y]=u,_=[];for(let S=0;S<16;S++)_[S]=d.charCodeAt(S*4)&255|(d.charCodeAt(S*4+1)&255)<<8|(d.charCodeAt(S*4+2)&255)<<16|(d.charCodeAt(S*4+3)&255)<<24;let x=f,b=p,v=m,w=y;for(let S=0;S<64;S++){let C,D;const T=Math.floor(S/16),z=S%16;T===0?(C=b&v|~b&w,D=z):T===1?(C=w&b|~w&v,D=(5*z+1)%16):T===2?(C=b^v^w,D=(3*z+5)%16):(C=v^(b|~w),D=7*z%16);const q=w;w=v,v=b,b=b+r(x+C+s[S]+_[D]&4294967295,n[T][S%4]),x=q}return[f+x&4294967295,p+b&4294967295,m+v&4294967295,y+w&4294967295]}const l=a(t);let c=[...e];for(let d=0;d<l.length;d+=64)c=o(l.substring(d,d+64),c);let h="";return c.forEach(d=>{for(let u=0;u<4;u++)h+=(d>>>8*u&255).toString(16).padStart(2,"0")}),h}function Yr(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,h){return c>>>h|c<<32-h}function n(c){const h=c.length*8;for(c+="";c.length%64!==56;)c+="\0";const d=h&4294967295,u=h>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(d>>>8*f&255);return c}function r(c,h){const d=[];for(let v=0;v<16;v++)d[v]=c.charCodeAt(v*4)&255|(c.charCodeAt(v*4+1)&255)<<8|(c.charCodeAt(v*4+2)&255)<<16|(c.charCodeAt(v*4+3)&255)<<24;for(let v=16;v<64;v++){const w=s(d[v-15],7)^s(d[v-15],18)^d[v-15]>>>3,S=s(d[v-2],17)^s(d[v-2],19)^d[v-2]>>>10;d[v]=d[v-16]+w+d[v-7]+S&4294967295}let[u,f,p,m,y,_,x,b]=h;for(let v=0;v<64;v++){const w=s(y,6)^s(y,11)^s(y,25),S=y&_^~y&x,C=b+w+S+e[v]+d[v]&4294967295,D=s(u,2)^s(u,13)^s(u,22),T=u&f^u&p^f&p,z=D+T&4294967295;b=x,x=_,_=y,y=m+C&4294967295,m=p,p=f,f=u,u=C+z&4294967295}return[h[0]+u&4294967295,h[1]+f&4294967295,h[2]+p&4294967295,h[3]+m&4294967295,h[4]+y&4294967295,h[5]+_&4294967295,h[6]+x&4294967295,h[7]+b&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let h=3;h>=0;h--)l+=(c>>>8*h&255).toString(16).padStart(2,"0")}),l}function Xr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,o=n[s++]||0,l=r>>2,c=(r&3)<<4|a>>4,h=(a&15)<<2|o>>6,d=o&63;e+=t[l]+t[c]+(s>n.length+1?"=":t[h])+(s>n.length?"=":t[d])}return e}function jr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),o=t.indexOf(i.charAt(s++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,h=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(h))}return e}function Jr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ge={md5:Ur,sha256:Yr,base64Encode:Xr,base64Decode:jr,uuid:Jr},P=new Map;async function X(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function Gr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>X(n,t)));const s=[];for(const n of i)s.push(await X(n,t));return s}async function _e(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=s,o.defer=n,o.onload=()=>{P.set(i,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${i}`))},o.src=i,document.head.appendChild(o)})}async function ye(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Zr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Qr(i,t="image"){switch(t){case"image":return X(i);case"script":return _e(i);case"stylesheet":case"style":return ye(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function ta(i){return P.has(i)}function ea(){P.clear()}function sa(i){P.delete(i)}const ve={loadImage:X,loadImages:Gr,loadScript:_e,loadStylesheet:ye,loadFont:Zr,preload:Qr,isLoaded:ta,clearCache:ea,clearCacheByUrl:sa},ia={string:Xt,array:Gt,object:ee,number:ne,date:oe,debounce:le,throttle:ce,validator:ct,crypto:ge,preload:ve};function na(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class Ot{constructor(){this.children={},this.keys=[]}}class nt{constructor(){this.root=new Ot}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new Ot),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class be{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),o=Reflect.set(e,s,n,r),l=this.resolvePath(e,s);return this.notify(l,n,a),this.queueUpdate(l,n),o},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[g.path]?`${t[g.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((o,l)=>(o[l]||(o[l]={}),o[l]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=na(e);t.innerHTML!==c&&(t.innerHTML=c);break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const h=e?"none":"";t.style.display!==h&&(t.style.display=h);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:o=null}=e,l=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,h=>{const d=this.persistedKeys.get(t);d&&(d.debounce>0?(d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(()=>{this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey})},d.debounce)):this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=localStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(t=>{if(!this._isObserving){this._isObserving=!0;try{t.forEach(e=>{e.addedNodes.forEach(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue.clear(),this.snapshots=[]}}class at{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},$?($.set(this._stateKey,s),this.state=$.data?.[this._stateKey]||$.createReactive(s,this._stateKey),$.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),$&&$.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class xe{constructor(){this.stores=new Map}createStore(t,e){const s=new at(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof at&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Ee{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function M(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const $=new be,ra=new Ee,ht=new xe;function aa(i,t){return ht.createStore(i,t)}function oa(i){return ht.getStore(i)}const ke="kupola-theme",we="kupola-brand",O=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function R(){return localStorage.getItem(ke)||"dark"}function j(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(ke,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function U(){return localStorage.getItem(we)||"zengqing"}function J(i){const t=O.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(we,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function Ce(){const i=R();j(i);const t=U();J(t);const e=document.querySelector("[data-theme-toggle]");e&&(e.onclick=function(o){o.preventDefault();const c=R()==="dark"?"light":"dark";j(c)});let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",O.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=o.name,s.appendChild(l)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(o){o.stopPropagation()});function r(o){s&&n&&!s.contains(o.target)&&!n.contains(o.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");J(c),s&&(s.style.display="none")})})}function la(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",R()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=R()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const o=R()==="dark"?"light":"dark";j(o)},i}function ca(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",O.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=a.name,i.appendChild(o)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",U()),t.className="ds-btn ds-btn--ghost ds-btn--sm",t.style.position="fixed",t.style.top="16px",t.style.right="56px",t.style.zIndex="9999",t.style.display="flex",t.style.alignItems="center",t.style.gap="6px";const e=document.createElement("span");e.className="brand-icon",e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.backgroundColor=O.find(a=>a.id===U()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=O.find(a=>a.id===U()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");J(l),i.style.display="none"})}),{toggleBtn:t,container:i}}class Se{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const E=new Se,ha=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of ha)i.attr&&!E._dataAttrs.includes(i.attr)&&E._dataAttrs.push(i.attr),i.cls&&!E._cssClasses.includes(i.cls)&&E._cssClasses.push(i.cls);class Y{constructor(t){this.element=t,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new Q,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Q{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const o of s){await this._resolveDepends(o.depends,t);const l=performance.now();let c,h;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){h=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const d=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:d,status:h?"error":"success",error:h?h.message:null,timestamp:Date.now()})}const a=performance.now()-r;console.debug(`[KupolaLifecycle] ${t} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Is=new Q("app");function As(i="app"){return new Q(i)}const zs=new Set(["__proto__","prototype","constructor"]);function tt(i){return zs.has(i)}function Ps(i){return i?i.trim():""}function $s(i){return i?i.replace(/^\s+/,""):""}function qs(i){return i?i.replace(/\s+$/,""):""}function Bs(i){return i?i.toUpperCase():""}function Fs(i){return i?i.toLowerCase():""}function Ns(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Os(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Rs(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Vs(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Ks(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Ws(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Us(i,t,e){return i?i.split(t).join(e):""}function Ys(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Xs(i,t){return(i||"").startsWith(t)}function js(i,t){return(i||"").endsWith(t)}function Js(i,t){return(i||"").includes(t)}function Gs(i,t){return(i||"").repeat(t)}function Zs(i){return(i||"").split("").reverse().join("")}function Qs(i,t){return!i||!t?0:i.split(t).length-1}function ti(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function ei(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function si(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function ii(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Xt={trim:Ps,trimLeft:$s,trimRight:qs,toUpperCase:Bs,toLowerCase:Fs,capitalize:Ns,camelize:Os,hyphenate:Rs,padStart:Vs,padEnd:Ks,truncate:Ws,replaceAll:Us,format:Ys,startsWith:Xs,endsWith:js,includes:Js,repeat:Gs,reverse:Zs,countOccurrences:Qs,escapeHtml:ti,unescapeHtml:ei,generateRandom:si,generateUUID:ii};function ni(i){return Array.isArray(i)}function ri(i){return!i||i.length===0}function ai(i){return i?i.length:0}function oi(i,t){return i&&i.length>0?i[0]:t}function li(i,t){return i&&i.length>0?i[i.length-1]:t}function ci(i,t,e){return i&&i[t]!==void 0?i[t]:e}function hi(i,t,e){return i?i.slice(t,e):[]}function di(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function ui(i,t=","){return i?i.join(t):""}function pi(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function fi(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function mi(i,t){return i?i.includes(t):!1}function gi(i,...t){return i&&i.push(...t),i}function _i(i){return i?i.pop():void 0}function yi(i){return i?i.shift():void 0}function vi(i,...t){return i&&i.unshift(...t),i}function bi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function xi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function Ei(i,t,e){return i&&(i.splice(t,0,e),i)}function ki(i){return i?i.slice().reverse():[]}function wi(i,t){return i?i.slice().sort(t):[]}function Ci(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function Si(i,t){return i?i.filter(t):[]}function Li(i,t){return i?i.map(t):[]}function Di(i,t,e){return i?i.reduce(t,e):e}function Hi(i,t){i&&i.forEach(t)}function Mi(i,t){return i?i.every(t):!0}function Ti(i,t){return i?i.some(t):!1}function Ii(i,t){return i?i.find(t):void 0}function Ai(i,t){return i?i.findIndex(t):-1}function zi(i,t=1){return i?i.flat(t):[]}function jt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(jt(e)):t.concat(e),[]):[]}function Pi(i){return i?[...new Set(i)]:[]}function $i(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function qi(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function Bi(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Jt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function Fi(i){return!i||i.length===0?0:Jt(i)/i.length}function Ni(i){return i&&i.length>0?Math.max(...i):-1/0}function Oi(i){return i&&i.length>0?Math.min(...i):1/0}function Ri(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Vi(...i){return[...new Set(i.flat().filter(Boolean))]}function Ki(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Wi(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Gt={isArray:ni,isEmpty:ri,size:ai,first:oi,last:li,get:ci,slice:hi,concat:di,join:ui,indexOf:pi,lastIndexOf:fi,includes:mi,push:gi,pop:_i,shift:yi,unshift:vi,remove:bi,removeAt:xi,insert:Ei,reverse:ki,sort:wi,sortBy:Ci,filter:Si,map:Li,reduce:Di,forEach:Hi,every:Mi,some:Ti,find:Ii,findIndex:Ai,flat:zi,flattenDeep:jt,unique:Pi,uniqueBy:$i,chunk:qi,shuffle:Bi,sum:Jt,average:Fi,max:Ni,min:Oi,intersection:Ri,union:Vi,difference:Ki,zip:Wi};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Ui(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Yi(i){return i?Object.keys(i):[]}function Xi(i){return i?Object.values(i):[]}function ji(i){return i?Object.entries(i):[]}function Ji(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function Gi(i,t,e){if(!i)return e;const s=t.split(".");return s.some(tt)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Zi(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(tt))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Qi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function tn(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Zt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{tt(s)||(rt(e[s])&&rt(t[s])?t[s]=Zt(t[s],e[s]):t[s]=e[s])}),t),{})}function en(i){return i&&JSON.parse(JSON.stringify(i))}function W(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,W(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(W(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(W(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{tt(s)||(e[s]=W(i[s],t))}),e}function sn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function nn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function rn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function an(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function on(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function ln(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function cn(i){return i?Object.keys(i).length:0}function hn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Qt(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Qt(i[n],t[n]))}function te(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&te(i[t])}),i)}function dn(i){return i&&Object.seal(i)}const ee={isObject:rt,isEmpty:Ui,keys:Yi,values:Xi,entries:ji,has:Ji,get:Gi,set:Zi,pick:Qi,omit:tn,merge:Zt,clone:en,deepClone:W,forEach:sn,map:nn,filter:rn,reduce:an,toArray:on,fromArray:ln,size:cn,invert:hn,isEqual:Qt,freeze:te,seal:dn};function L(i){return typeof i=="number"&&!isNaN(i)}function un(i){return Number.isInteger(i)}function pn(i){return L(i)&&!Number.isInteger(i)}function fn(i){return L(i)&&i>0}function mn(i){return L(i)&&i<0}function gn(i){return L(i)&&i===0}function _n(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function yn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function vn(i){return L(i)?Math.floor(i):i}function bn(i){return L(i)?Math.ceil(i):i}function xn(i){return L(i)?Math.abs(i):i}function En(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function kn(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function se(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function wn(...i){const t=i.flat().filter(L);return t.length>0?se(t)/t.length:0}function ie(i=0,t=1){return Math.random()*(t-i)+i}function Cn(i,t){return Math.floor(ie(i,t+1))}function Sn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Ln(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Dn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Hn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Mn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Tn(i){return Number.isNaN(i)}function In(i){return Number.isFinite(i)}function An(i,t=10){return Number.parseInt(i,t)}function zn(i){return Number.parseFloat(i)}function Pn(i,t=0){const e=Number(i);return isNaN(e)?t:e}function $n(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function qn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const ne={isNumber:L,isInteger:un,isFloat:pn,isPositive:fn,isNegative:mn,isZero:gn,clamp:_n,round:yn,floor:vn,ceil:bn,abs:xn,min:En,max:kn,sum:se,average:wn,random:ie,randomInt:Cn,format:Sn,formatCurrency:Ln,formatPercent:Dn,toFixed:Hn,toPrecision:Mn,isNaN:Tn,isFinite:In,parseInt:An,parseFloat:zn,toNumber:Pn,safeDivide:$n,safeMultiply:qn};function et(){return Date.now()}function K(){const i=new Date;return i.setHours(0,0,0,0),i}function Bn(){const i=K();return i.setDate(i.getDate()+1),i}function Fn(){const i=K();return i.setDate(i.getDate()-1),i}function k(i){return i instanceof Date&&!isNaN(i.getTime())}function re(i){return k(i)}function Nn(i){const t=new Date(i);return re(t)?t:null}function On(i,t="YYYY-MM-DD HH:mm:ss"){if(!k(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),o=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",h)}function Rn(i){return k(i)?i.toISOString():""}function Vn(i){return k(i)?new Date(i.toUTCString()):null}function Kn(i,t){if(!k(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Wn(i,t){if(!k(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Un(i,t){if(!k(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Yn(i,t){if(!k(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function st(i,t){if(!k(i)||!k(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Xn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function jn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function Jn(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function Gn(i){return k(i)?st(i,K())===0:!1}function Zn(i){return k(i)?st(i,K())===-1:!1}function Qn(i){return k(i)?st(i,K())===1:!1}function tr(i){return k(i)?i.getTime()>et():!1}function er(i){return k(i)?i.getTime()<et():!1}function sr(i){if(!k(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function ir(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function nr(i){if(!k(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function rr(i){return k(i)?Math.ceil((i.getMonth()+1)/3):0}function ar(i){if(!k(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function or(i){if(!k(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function lr(i){return k(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function cr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function ae(i,t=1){if(!k(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function hr(i,t=1){if(!k(i))return i;const e=ae(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function dr(i){if(!k(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function ur(i){if(!k(i))return"";const e=et()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,o=30*r,l=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}const oe={now:et,today:K,tomorrow:Bn,yesterday:Fn,isDate:k,isValid:re,parse:Nn,format:On,toISO:Rn,toUTC:Vn,addDays:Kn,addHours:Wn,addMinutes:Un,addSeconds:Yn,diffDays:st,diffHours:Xn,diffMinutes:jn,diffSeconds:Jn,isToday:Gn,isYesterday:Zn,isTomorrow:Qn,isFuture:tr,isPast:er,isLeapYear:sr,getDaysInMonth:ir,getWeekOfYear:nr,getQuarter:rr,startOfDay:ar,endOfDay:or,startOfMonth:lr,endOfMonth:cr,startOfWeek:ae,endOfWeek:hr,getAge:dr,fromNow:ur};function le(i,t,e={}){let s=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(r,n)}function h(){a=Date.now(),o?(s=setTimeout(d,t),c()):s=setTimeout(d,t)}function d(){s=null,l&&n&&c(),n=null,r=null}function u(){return Math.max(0,t-(Date.now()-a))}return function(...f){n=f,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(d,u())):h()}}function ce(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function o(){i.apply(a,r),r=null,a=null}return function(...l){s?n&&(r=l,a=this):(s=!0,r=l,a=this,o(),setTimeout(()=>{s=!1,n&&r&&o()},t))}}function pr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function fr(i){return/^1[3-9]\d{9}$/.test(i||"")}function mr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function he(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function de(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function gr(i){return he(i)||de(i)}function _r(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function yr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function vr(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function ue(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function pe(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function fe(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function br(i){return ue(i)||pe(i)||fe(i)}function xr(i){return!isNaN(new Date(i).getTime())}function Er(i){try{return JSON.parse(i),!0}catch{return!1}}function kr(i){return!i||i.trim()===""}function wr(i){return/^\s+$/.test(i||"")}function Cr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Sr(i){return/^-?\d+$/.test(i||"")}function Lr(i){return/^-?\d+\.\d+$/.test(i||"")}function Dr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Hr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Mr(i){return/^[a-zA-Z]+$/.test(i||"")}function Tr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Ir(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Ar(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function zr(i,t){return(i||"").length>=t}function Pr(i,t){return(i||"").length<=t}function $r(i,t){return t instanceof RegExp?t.test(i||""):!1}function qr(i,t){return String(i)===String(t)}function me(i,t){return(i||"").includes(t)}function Br(i,t){return!me(i,t)}function Fr(i){return Array.isArray(i)}function Nr(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Or(i,t){return i?i.length>=t:!1}function Rr(i,t){return i?i.length<=t:!1}function Vr(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Kr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Wr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");ct[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,i);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const ct={isEmail:pr,isPhone:fr,isURL:mr,isIPv4:he,isIPv6:de,isIP:gr,isIDCard:_r,isPassport:yr,isCreditCard:vr,isHexColor:ue,isRGB:pe,isRGBA:fe,isColor:br,isDate:xr,isJSON:Er,isEmpty:kr,isWhitespace:wr,isNumber:Cr,isInteger:Sr,isFloat:Lr,isPositive:Dr,isNegative:Hr,isAlpha:Mr,isAlphaNumeric:Tr,isChinese:Ir,isLength:Ar,minLength:zr,maxLength:Pr,matches:$r,equals:qr,contains:me,notContains:Br,isArray:Fr,arrayLength:Nr,arrayMinLength:Or,arrayMaxLength:Rr,isObject:Vr,hasKeys:Kr,validate:Wr};function Ur(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(d,u){return d<<u|d>>>32-u}function a(d){const u=d.length*8;for(d+="";d.length%64!==56;)d+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)d+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)d+=String.fromCharCode(p>>>8*m&255);return d}function o(d,u){const[f,p,m,y]=u,_=[];for(let S=0;S<16;S++)_[S]=d.charCodeAt(S*4)&255|(d.charCodeAt(S*4+1)&255)<<8|(d.charCodeAt(S*4+2)&255)<<16|(d.charCodeAt(S*4+3)&255)<<24;let x=f,b=p,v=m,w=y;for(let S=0;S<64;S++){let C,D;const T=Math.floor(S/16),z=S%16;T===0?(C=b&v|~b&w,D=z):T===1?(C=w&b|~w&v,D=(5*z+1)%16):T===2?(C=b^v^w,D=(3*z+5)%16):(C=v^(b|~w),D=7*z%16);const q=w;w=v,v=b,b=b+r(x+C+s[S]+_[D]&4294967295,n[T][S%4]),x=q}return[f+x&4294967295,p+b&4294967295,m+v&4294967295,y+w&4294967295]}const l=a(t);let c=[...e];for(let d=0;d<l.length;d+=64)c=o(l.substring(d,d+64),c);let h="";return c.forEach(d=>{for(let u=0;u<4;u++)h+=(d>>>8*u&255).toString(16).padStart(2,"0")}),h}function Yr(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,h){return c>>>h|c<<32-h}function n(c){const h=c.length*8;for(c+="";c.length%64!==56;)c+="\0";const d=h&4294967295,u=h>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(d>>>8*f&255);return c}function r(c,h){const d=[];for(let v=0;v<16;v++)d[v]=c.charCodeAt(v*4)&255|(c.charCodeAt(v*4+1)&255)<<8|(c.charCodeAt(v*4+2)&255)<<16|(c.charCodeAt(v*4+3)&255)<<24;for(let v=16;v<64;v++){const w=s(d[v-15],7)^s(d[v-15],18)^d[v-15]>>>3,S=s(d[v-2],17)^s(d[v-2],19)^d[v-2]>>>10;d[v]=d[v-16]+w+d[v-7]+S&4294967295}let[u,f,p,m,y,_,x,b]=h;for(let v=0;v<64;v++){const w=s(y,6)^s(y,11)^s(y,25),S=y&_^~y&x,C=b+w+S+e[v]+d[v]&4294967295,D=s(u,2)^s(u,13)^s(u,22),T=u&f^u&p^f&p,z=D+T&4294967295;b=x,x=_,_=y,y=m+C&4294967295,m=p,p=f,f=u,u=C+z&4294967295}return[h[0]+u&4294967295,h[1]+f&4294967295,h[2]+p&4294967295,h[3]+m&4294967295,h[4]+y&4294967295,h[5]+_&4294967295,h[6]+x&4294967295,h[7]+b&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let h=3;h>=0;h--)l+=(c>>>8*h&255).toString(16).padStart(2,"0")}),l}function Xr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,o=n[s++]||0,l=r>>2,c=(r&3)<<4|a>>4,h=(a&15)<<2|o>>6,d=o&63;e+=t[l]+t[c]+(s>n.length+1?"=":t[h])+(s>n.length?"=":t[d])}return e}function jr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),o=t.indexOf(i.charAt(s++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,h=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(h))}return e}function Jr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ge={md5:Ur,sha256:Yr,base64Encode:Xr,base64Decode:jr,uuid:Jr},P=new Map;async function X(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function Gr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>X(n,t)));const s=[];for(const n of i)s.push(await X(n,t));return s}async function _e(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=s,o.defer=n,o.onload=()=>{P.set(i,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${i}`))},o.src=i,document.head.appendChild(o)})}async function ye(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Zr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Qr(i,t="image"){switch(t){case"image":return X(i);case"script":return _e(i);case"stylesheet":case"style":return ye(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function ta(i){return P.has(i)}function ea(){P.clear()}function sa(i){P.delete(i)}const ve={loadImage:X,loadImages:Gr,loadScript:_e,loadStylesheet:ye,loadFont:Zr,preload:Qr,isLoaded:ta,clearCache:ea,clearCacheByUrl:sa},ia={string:Xt,array:Gt,object:ee,number:ne,date:oe,debounce:le,throttle:ce,validator:ct,crypto:ge,preload:ve};function na(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class Ot{constructor(){this.children={},this.keys=[]}}class nt{constructor(){this.root=new Ot}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new Ot),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class be{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),o=Reflect.set(e,s,n,r),l=this.resolvePath(e,s);return this.notify(l,n,a),this.queueUpdate(l,n),o},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[g.path]?`${t[g.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((o,l)=>(o[l]||(o[l]={}),o[l]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=na(e);t.innerHTML!==c&&(t.innerHTML=c);break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const h=e?"none":"";t.style.display!==h&&(t.style.display=h);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:o=null}=e,l=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,h=>{const d=this.persistedKeys.get(t);d&&(d.debounce>0?(d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(()=>{this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey})},d.debounce)):this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=localStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(t=>{if(!this._isObserving){this._isObserving=!0;try{t.forEach(e=>{e.addedNodes.forEach(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new nt,this.updateQueue.clear(),this.snapshots=[]}}class at{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},$?($.set(this._stateKey,s),this.state=$.data?.[this._stateKey]||$.createReactive(s,this._stateKey),$.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),$&&$.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class xe{constructor(){this.stores=new Map}createStore(t,e){const s=new at(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof at&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Ee{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function M(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const $=new be,ra=new Ee,ht=new xe;function aa(i,t){return ht.createStore(i,t)}function oa(i){return ht.getStore(i)}const ke="kupola-theme",we="kupola-brand",O=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function R(){return localStorage.getItem(ke)||"dark"}function j(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(ke,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function U(){return localStorage.getItem(we)||"zengqing"}function J(i){const t=O.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(we,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function Ce(){const i=R();j(i);const t=U();J(t);const e=document.querySelector("[data-theme-toggle]");if(e){const o=e.onclick;e.onclick=function(l){l.preventDefault();const h=R()==="dark"?"light":"dark";j(h),typeof o=="function"&&o.call(this,l)}}let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",O.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=o.name,s.appendChild(l)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(o){o.stopPropagation()});function r(o){s&&n&&!s.contains(o.target)&&!n.contains(o.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");J(c),s&&(s.style.display="none")})})}function la(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",R()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=R()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const o=R()==="dark"?"light":"dark";j(o)},i}function ca(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",O.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=a.name,i.appendChild(o)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",U()),t.className="ds-btn ds-btn--ghost ds-btn--sm",t.style.position="fixed",t.style.top="16px",t.style.right="56px",t.style.zIndex="9999",t.style.display="flex",t.style.alignItems="center",t.style.gap="6px";const e=document.createElement("span");e.className="brand-icon",e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.backgroundColor=O.find(a=>a.id===U()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=O.find(a=>a.id===U()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");J(l),i.style.display="none"})}),{toggleBtn:t,container:i}}class Se{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const E=new Se,ha=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of ha)i.attr&&!E._dataAttrs.includes(i.attr)&&E._dataAttrs.push(i.attr),i.cls&&!E._cssClasses.includes(i.cls)&&E._cssClasses.push(i.cls);class Y{constructor(t){this.element=t,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new Q,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
|
|
2
2
|
<div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">
|
|
3
3
|
<div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>
|
|
4
4
|
<div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>
|