@kupola/kupola 1.7.8 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/colors-and-type.css +242 -287
- package/css/scaffold.css +9 -3
- package/css/theme-dark.css +2 -0
- package/css/theme-light.css +2 -0
- package/dist/core-Dfj-u6qC.cjs +1 -0
- package/dist/core-LA_QgrQO.js +4955 -0
- package/dist/core.cjs.js +1 -0
- package/dist/core.esm.js +1 -0
- package/dist/core.umd.js +1 -0
- package/dist/css/colors-and-type.css +242 -287
- package/dist/css/scaffold.css +9 -3
- package/dist/css/theme-dark.css +2 -0
- package/dist/css/theme-light.css +2 -0
- package/dist/kupola-lite.cjs.js +1 -0
- package/dist/kupola-lite.esm.js +1 -0
- package/dist/kupola.cjs.js +1 -215
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +1 -8586
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.min.js +1 -0
- package/dist/kupola.umd.js +1 -215
- package/dist/kupola.umd.js.map +1 -1
- package/dist/plugins/vite-plugin-kupola.js +110 -99
- package/dist/plugins/webpack-plugin-kupola.js +58 -0
- package/dist/react-theme.js +111 -0
- package/dist/theme-preload.js +28 -0
- package/dist/theme-standalone.js +98 -0
- package/dist/vue-theme.js +78 -0
- package/js/icons.js +153 -81
- package/js/react-theme.js +111 -0
- package/js/theme-preload.js +28 -0
- package/js/theme-standalone.js +15 -5
- package/js/theme.js +17 -1
- package/js/vue-theme.js +78 -0
- package/package.json +32 -1
- package/plugins/vite-plugin-kupola.js +110 -99
- package/plugins/webpack-plugin-kupola.js +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class e{constructor(e="app"){this.scope=e,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(e){const t=this.transitions.get(this.state);if(!t||!t.includes(e))throw new Error(`Invalid state transition: ${this.state} -> ${e}`);return!0}_updateState(e){this._validateTransition(e),this.state=e,this.stateHistory.push(e)}_resetResolved(e){const t=this.hooks.get(e);t&&t.forEach(e=>{e.resolved=!1})}on(e,t,r={}){if(!this.allPhases.includes(e))throw new Error(`Unknown lifecycle phase: ${e}`);const n=this.hooks.get(e);return n.push({handler:t,priority:r.priority||0,depends:r.depends||[],name:r.name||t.name||`anonymous_${n.length}`}),n.sort((e,t)=>t.priority-e.priority),()=>{const e=n.findIndex(e=>e.handler===t);e>-1&&n.splice(e,1)}}async _resolveDepends(e,t){if(e&&0!==e.length)for(const r of e){const e=this.hooks.get(t).find(e=>e.name===r);e&&!e.resolved&&(await e.handler(),e.resolved=!0)}}async emit(e,...t){if("destroyed"===this.state&&"error"!==e)return;const r=this.hooks.get(e);if(!r||0===r.length)return;const n=`${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const s=performance.now();try{for(const s of r){await this._resolveDepends(s.depends,e);const r=performance.now();let i,a;try{i=s.handler(...t),i instanceof Promise&&await i,s.resolved=!0}catch(o){a=o,console.error(`[KupolaLifecycle] Error in ${e} hook "${s.name}":`,o),"error"!==e&&await this._handleError({phase:e,hook:s.name,error:o,args:t})}const c=performance.now()-r;this.trace.push({emitId:n,phase:e,hookName:s.name,duration:c,status:a?"error":"success",error:a?a.message:null,timestamp:Date.now()})}const i=performance.now()-s;console.debug(`[KupolaLifecycle] ${e} completed in ${i.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(e,...t){if(!this.basePhases.includes(e))throw new Error(`Unknown base phase: ${e}`);const r=this.phaseStateMap[e];if(r)if(Array.isArray(r.from)){if(!r.from.includes(this.state))throw new Error(`Cannot ${e} from state ${this.state}, expected one of: ${r.from.join(", ")}`)}else if(this.state!==r.from)throw new Error(`Cannot ${e} from state ${this.state}, expected ${r.from}`);const n=`before${e.charAt(0).toUpperCase()+e.slice(1)}`,s=`after${e.charAt(0).toUpperCase()+e.slice(1)}`;this._resetResolved(n),this._resetResolved(e),this._resetResolved(s),this.allPhases.includes(n)&&await this.emit(n,...t),await this.emit(e,...t),r&&this._updateState(r.to),this.allPhases.includes(s)&&await this.emit(s,...t)}async bootstrap(...e){await this.runPhase("bootstrap",...e)}async _waitForDOMReady(){return new Promise(e=>{if("complete"===document.readyState||"interactive"===document.readyState)return void e();const t=()=>{document.removeEventListener("DOMContentLoaded",t),window.removeEventListener("load",t),e()};document.addEventListener("DOMContentLoaded",t),window.addEventListener("load",t)})}async mount(...e){await this.runPhase("mount",...e)}async mountWithDOMReady(...e){await this._waitForDOMReady(),await this.runPhase("mount",...e)}async update(...e){await this.runPhase("update",...e)}async unmount(...e){await this.runPhase("unmount",...e)}async destroy(...e){await this.runPhase("destroy",...e),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(e){return this.hooks.get(e)||[]}hasHandlers(e){const t=this.hooks.get(e);return t&&t.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(e){return this.state===e}onError(e){return this._onErrorCallback=e,this.on("error",e)}setErrorBoundary(e){return this.errorBoundary=e,this.on("errorBoundary",t=>"function"==typeof e?e(t):null)}setMaxErrors(e){this.maxErrors=e}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(e){if(this.errorCount++,this.lastError=e.error,this.errorCount>=this.maxErrors)return void console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);if(await this.emit("error",e),"function"==typeof this._onErrorCallback)try{await this._onErrorCallback(e)}catch(r){console.error("[KupolaLifecycle] Error in onError callback:",r)}const t=this.hooks.get("errorBoundary");if(t&&t.length>0)for(const n of t)try{const t=n.handler(e);if(t instanceof Promise&&await t,"handled"===t)return void console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${n.name}"`)}catch(r){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${n.name}":`,r)}console.error(`[KupolaLifecycle] Unhandled error in ${e.phase}:`,e.error)}}const t=new e("app");const r=new Set(["__proto__","prototype","constructor"]);function n(e){return r.has(e)}const s={trim:function(e){return e?e.trim():""},trimLeft:function(e){return e?e.replace(/^\s+/,""):""},trimRight:function(e){return e?e.replace(/\s+$/,""):""},toUpperCase:function(e){return e?e.toUpperCase():""},toLowerCase:function(e){return e?e.toLowerCase():""},capitalize:function(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""},camelize:function(e){return e?e.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():""):""},hyphenate:function(e){return e?e.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart:function(e,t,r=" "){return(String(e)||"").padStart(t,r)},padEnd:function(e,t,r=" "){return(String(e)||"").padEnd(t,r)},truncate:function(e,t,r="..."){return!e||e.length<=t?e||"":e.slice(0,t)+r},replaceAll:function(e,t,r){return e?e.split(t).join(r):""},format:function(e,t){return e?e.replace(/\{\{(\w+)\}\}/g,(e,r)=>void 0!==t[r]?t[r]:`{{${r}}}`):""},startsWith:function(e,t){return(e||"").startsWith(t)},endsWith:function(e,t){return(e||"").endsWith(t)},includes:function(e,t){return(e||"").includes(t)},repeat:function(e,t){return(e||"").repeat(t)},reverse:function(e){return(e||"").split("").reverse().join("")},countOccurrences:function(e,t){return e&&t?e.split(t).length-1:0},escapeHtml:function(e){if(!e)return"";const t=document.createElement("div");return t.textContent=e,t.innerHTML},unescapeHtml:function(e){if(!e)return"";const t=document.createElement("div");return t.innerHTML=e,t.textContent},generateRandom:function(e=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let n=0;n<e;n++)r+=t.charAt(Math.floor(62*Math.random()));return r},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}};function o(e){return e?e.reduce((e,t)=>e+(Number(t)||0),0):0}const i={isArray:function(e){return Array.isArray(e)},isEmpty:function(e){return!e||0===e.length},size:function(e){return e?e.length:0},first:function(e,t){return e&&e.length>0?e[0]:t},last:function(e,t){return e&&e.length>0?e[e.length-1]:t},get:function(e,t,r){return e&&void 0!==e[t]?e[t]:r},slice:function(e,t,r){return e?e.slice(t,r):[]},concat:function(...e){return e.reduce((e,t)=>e.concat(t||[]),[])},join:function(e,t=","){return e?e.join(t):""},indexOf:function(e,t,r=0){if(!e)return-1;if(Number.isNaN(t)){for(let t=r;t<e.length;t++)if(Number.isNaN(e[t]))return t;return-1}return e.indexOf(t,r)},lastIndexOf:function(e,t,r){if(!e)return-1;if(Number.isNaN(t)){for(let t=void 0!==r?r:e.length-1;t>=0;t--)if(Number.isNaN(e[t]))return t;return-1}return e.lastIndexOf(t,r)},includes:function(e,t){return!!e&&e.includes(t)},push:function(e,...t){return e&&e.push(...t),e},pop:function(e){return e?e.pop():void 0},shift:function(e){return e?e.shift():void 0},unshift:function(e,...t){return e&&e.unshift(...t),e},remove:function(e,t){if(!e)return e;const r=Number.isNaN(t)?e.findIndex(e=>Number.isNaN(e)):e.indexOf(t);return r>-1&&e.splice(r,1),e},removeAt:function(e,t){return!e||t<0||t>=e.length||e.splice(t,1),e},insert:function(e,t,r){return e?(e.splice(t,0,r),e):e},reverse:function(e){return e?e.slice().reverse():[]},sort:function(e,t){return e?e.slice().sort(t):[]},sortBy:function(e,t,r="asc"){return e?e.slice().sort((e,n)=>{const s="object"==typeof e?e[t]:e,o="object"==typeof n?n[t]:n;return s<o?"asc"===r?-1:1:s>o?"asc"===r?1:-1:0}):[]},filter:function(e,t){return e?e.filter(t):[]},map:function(e,t){return e?e.map(t):[]},reduce:function(e,t,r){return e?e.reduce(t,r):r},forEach:function(e,t){e&&e.forEach(t)},every:function(e,t){return!e||e.every(t)},some:function(e,t){return!!e&&e.some(t)},find:function(e,t){return e?e.find(t):void 0},findIndex:function(e,t){return e?e.findIndex(t):-1},flat:function(e,t=1){return e?e.flat(t):[]},flattenDeep:function e(t){return t?t.reduce((t,r)=>Array.isArray(r)?t.concat(e(r)):t.concat(r),[]):[]},unique:function(e){return e?[...new Set(e)]:[]},uniqueBy:function(e,t){if(!e)return[];const r=new Set;return e.filter(e=>{const n="object"==typeof e?e[t]:e;return!r.has(n)&&(r.add(n),!0)})},chunk:function(e,t){if(!e||t<=0)return[];const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r},shuffle:function(e){if(!e)return[];const t=e.slice();for(let r=t.length-1;r>0;r--){const e=Math.floor(Math.random()*(r+1));[t[r],t[e]]=[t[e],t[r]]}return t},sum:o,average:function(e){return e&&0!==e.length?o(e)/e.length:0},max:function(e){return e&&e.length>0?Math.max(...e):-1/0},min:function(e){return e&&e.length>0?Math.min(...e):1/0},intersection:function(...e){return 0===e.length?[]:e.reduce((e,t)=>e.filter(e=>t&&t.includes(e)))},union:function(...e){return[...new Set(e.flat().filter(Boolean))]},difference:function(e,t){return e?e.filter(e=>!t||!t.includes(e)):[]},zip:function(...e){if(0===e.length)return[];const t=Math.max(...e.map(e=>e?e.length:0));return Array.from({length:t},(t,r)=>e.map(e=>e&&e[r]))}};function a(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const c={isObject:a,isEmpty:function(e){return!e||"object"!=typeof e||0===Object.keys(e).length},keys:function(e){return e?Object.keys(e):[]},values:function(e){return e?Object.values(e):[]},entries:function(e){return e?Object.entries(e):[]},has:function(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)},get:function(e,t,r){if(!e)return r;const s=t.split(".");return s.some(n)?r:s.reduce((e,t)=>e&&e[t],e)??r},set:function(e,t,r){if(!e||"object"!=typeof e)return e;const s=t.split(".");if(s.some(n))return e;const o=s.pop();let i=e;return s.forEach(e=>{i[e]&&"object"==typeof i[e]||(i[e]={}),i=i[e]}),i[o]=r,e},pick:function(e,t){return e?t.reduce((t,r)=>(void 0!==e[r]&&(t[r]=e[r]),t),{}):{}},omit:function(e,t){return e?Object.keys(e).reduce((r,n)=>(t.includes(n)||(r[n]=e[n]),r),{}):{}},merge:function e(...t){return t.reduce((t,r)=>(r&&"object"==typeof r&&Object.keys(r).forEach(s=>{n(s)||(a(r[s])&&a(t[s])?t[s]=e(t[s],r[s]):t[s]=r[s])}),t),{})},clone:function(e){return e?JSON.parse(JSON.stringify(e)):e},deepClone:function e(t,r=new WeakMap){if(!t||"object"!=typeof t)return t;if(r.has(t))return r.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const n=new Map;return r.set(t,n),t.forEach((t,s)=>n.set(s,e(t,r))),n}if(t instanceof Set){const n=new Set;return r.set(t,n),t.forEach(t=>n.add(e(t,r))),n}if(Array.isArray(t)){const n=[];return r.set(t,n),t.forEach(t=>n.push(e(t,r))),n}const s={};return r.set(t,s),Object.keys(t).forEach(o=>{n(o)||(s[o]=e(t[o],r))}),s},forEach:function(e,t){e&&Object.keys(e).forEach(r=>t(e[r],r,e))},map:function(e,t){if(!e)return{};const r={};return Object.keys(e).forEach(n=>{r[n]=t(e[n],n,e)}),r},filter:function(e,t){if(!e)return{};const r={};return Object.keys(e).forEach(n=>{t(e[n],n,e)&&(r[n]=e[n])}),r},reduce:function(e,t,r){return e?Object.keys(e).reduce((r,n)=>t(r,e[n],n,e),r):r},toArray:function(e){return e?Object.keys(e).map(t=>({key:t,value:e[t]})):[]},fromArray:function(e,t,r){return e?e.reduce((e,n)=>{const s="object"==typeof n?n[t]:n,o=r?n[r]:n;return void 0!==s&&(e[s]=o),e},{}):{}},size:function(e){return e?Object.keys(e).length:0},invert:function(e){if(!e)return{};const t={};return Object.keys(e).forEach(r=>{t[e[r]]=r}),t},isEqual:function e(t,r){if(t===r)return!0;if(!t||!r||"object"!=typeof t||"object"!=typeof r)return!1;const n=Object.keys(t),s=Object.keys(r);return n.length===s.length&&n.every(n=>e(t[n],r[n]))},freeze:function e(t){return t?(Object.freeze(t),Object.keys(t).forEach(r=>{"object"==typeof t[r]&&e(t[r])}),t):t},seal:function(e){return e?Object.seal(e):e}};function l(e){return"number"==typeof e&&!isNaN(e)}function u(...e){return e.flat().filter(l).reduce((e,t)=>e+t,0)}function h(e=0,t=1){return Math.random()*(t-e)+e}const d={isNumber:l,isInteger:function(e){return Number.isInteger(e)},isFloat:function(e){return l(e)&&!Number.isInteger(e)},isPositive:function(e){return l(e)&&e>0},isNegative:function(e){return l(e)&&e<0},isZero:function(e){return l(e)&&0===e},clamp:function(e,t,r){return l(e)?Math.min(Math.max(e,t),r):e},round:function(e,t=0){if(!l(e))return e;const r=Math.pow(10,t);return Math.round(e*r)/r},floor:function(e){return l(e)?Math.floor(e):e},ceil:function(e){return l(e)?Math.ceil(e):e},abs:function(e){return l(e)?Math.abs(e):e},min:function(...e){const t=e.filter(l);return t.length>0?Math.min(...t):void 0},max:function(...e){const t=e.filter(l);return t.length>0?Math.max(...t):void 0},sum:u,average:function(...e){const t=e.flat().filter(l);return t.length>0?u(t)/t.length:0},random:h,randomInt:function(e,t){return Math.floor(h(e,t+1))},format:function(e,t=2){return l(e)?e.toFixed(t):String(e)},formatCurrency:function(e,t="CNY",r=2){return l(e)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:r,maximumFractionDigits:r}).format(e):String(e)},formatPercent:function(e,t=0){return l(e)?`${(100*e).toFixed(t)}%`:String(e)},toFixed:function(e,t=0){return l(e)?e.toFixed(t):String(e)},toPrecision:function(e,t=6){return l(e)?e.toPrecision(t):String(e)},isNaN:function(e){return Number.isNaN(e)},isFinite:function(e){return Number.isFinite(e)},parseInt:function(e,t=10){return Number.parseInt(e,t)},parseFloat:function(e){return Number.parseFloat(e)},toNumber:function(e,t=0){const r=Number(e);return isNaN(r)?t:r},safeDivide:function(e,t,r=0){return l(e)&&l(t)&&0!==t?e/t:r},safeMultiply:function(...e){return e.reduce((e,t)=>l(e)&&l(t)?e*t:0,1)}};function p(){return Date.now()}function f(){const e=new Date;return e.setHours(0,0,0,0),e}function m(e){return e instanceof Date&&!isNaN(e.getTime())}function y(e){return m(e)}function g(e,t){if(!m(e)||!m(t))return 0;const r=new Date(e);r.setHours(0,0,0,0);const n=new Date(t);return n.setHours(0,0,0,0),Math.floor((r.getTime()-n.getTime())/864e5)}function b(e,t=1){if(!m(e))return e;const r=new Date(e),n=r.getDay(),s=n>=t?n-t:n+(7-t);return r.setDate(r.getDate()-s),r.setHours(0,0,0,0),r}const w={now:p,today:f,tomorrow:function(){const e=f();return e.setDate(e.getDate()+1),e},yesterday:function(){const e=f();return e.setDate(e.getDate()-1),e},isDate:m,isValid:y,parse:function(e){const t=new Date(e);return y(t)?t:null},format:function(e,t="YYYY-MM-DD HH:mm:ss"){if(!m(e))return"";const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0"),l=["日","一","二","三","四","五","六"][e.getDay()];return t.replace("YYYY",r).replace("MM",n).replace("DD",s).replace("HH",o).replace("mm",i).replace("ss",a).replace("SSS",c).replace("D",e.getDate()).replace("M",e.getMonth()+1).replace("H",e.getHours()).replace("m",e.getMinutes()).replace("s",e.getSeconds()).replace("W",l)},toISO:function(e){return m(e)?e.toISOString():""},toUTC:function(e){return m(e)?new Date(e.toUTCString()):null},addDays:function(e,t){if(!m(e))return e;const r=new Date(e);return r.setDate(r.getDate()+t),r},addHours:function(e,t){if(!m(e))return e;const r=new Date(e);return r.setHours(r.getHours()+t),r},addMinutes:function(e,t){if(!m(e))return e;const r=new Date(e);return r.setMinutes(r.getMinutes()+t),r},addSeconds:function(e,t){if(!m(e))return e;const r=new Date(e);return r.setSeconds(r.getSeconds()+t),r},diffDays:g,diffHours:function(e,t){return m(e)&&m(t)?Math.floor((e.getTime()-t.getTime())/36e5):0},diffMinutes:function(e,t){return m(e)&&m(t)?Math.floor((e.getTime()-t.getTime())/6e4):0},diffSeconds:function(e,t){return m(e)&&m(t)?Math.floor((e.getTime()-t.getTime())/1e3):0},isToday:function(e){return!!m(e)&&0===g(e,f())},isYesterday:function(e){return!!m(e)&&-1===g(e,f())},isTomorrow:function(e){return!!m(e)&&1===g(e,f())},isFuture:function(e){return!!m(e)&&e.getTime()>p()},isPast:function(e){return!!m(e)&&e.getTime()<p()},isLeapYear:function(e){if(!m(e))return!1;const t=e.getFullYear();return t%4==0&&(t%100!=0||t%400==0)},getDaysInMonth:function(e){return m(e)?new Date(e.getFullYear(),e.getMonth()+1,0).getDate():0},getWeekOfYear:function(e){if(!m(e))return 0;const t=new Date(e.getFullYear(),0,1),r=e.getTime()-t.getTime();return Math.ceil(r/6048e5)},getQuarter:function(e){return m(e)?Math.ceil((e.getMonth()+1)/3):0},startOfDay:function(e){if(!m(e))return e;const t=new Date(e);return t.setHours(0,0,0,0),t},endOfDay:function(e){if(!m(e))return e;const t=new Date(e);return t.setHours(23,59,59,999),t},startOfMonth:function(e){return m(e)?new Date(e.getFullYear(),e.getMonth(),1):e},endOfMonth:function(e){return m(e)?new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999):e},startOfWeek:b,endOfWeek:function(e,t=1){if(!m(e))return e;const r=b(e,t),n=new Date(r);return n.setDate(n.getDate()+6),n.setHours(23,59,59,999),n},getAge:function(e){if(!m(e))return 0;const t=new Date;let r=t.getFullYear()-e.getFullYear();return(t.getMonth()<e.getMonth()||t.getMonth()===e.getMonth()&&t.getDate()<e.getDate())&&r--,Math.max(0,r)},fromNow:function(e){if(!m(e))return"";const t=p()-e.getTime(),r=6e4,n=36e5,s=24*n,o=7*s,i=30*s,a=365*s;return t<r?"刚刚":t<n?`${Math.floor(t/r)}分钟前`:t<s?`${Math.floor(t/n)}小时前`:t<o?`${Math.floor(t/s)}天前`:t<i?`${Math.floor(t/o)}周前`:t<a?`${Math.floor(t/i)}个月前`:`${Math.floor(t/a)}年前`}};function v(e,t,r={}){let n=null,s=null,o=null,i=0;const a=r.leading||!1,c=!1!==r.trailing;function l(){e.apply(o,s)}function u(){n=null,c&&s&&l(),s=null,o=null}return function(...e){s=e,o=this,i=Date.now(),n?(clearTimeout(n),n=setTimeout(u,Math.max(0,t-(Date.now()-i)))):(i=Date.now(),a?(n=setTimeout(u,t),l()):n=setTimeout(u,t))}}function _(e,t,r={}){let n=!1;const s=r.trailing||!1;let o=null,i=null;function a(){e.apply(i,o),o=null,i=null}return function(...e){n?s&&(o=e,i=this):(n=!0,o=e,i=this,a(),setTimeout(()=>{n=!1,s&&o&&a()},t))}}function x(e){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(e||"")}function E(e){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(e||"")}function S(e){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e||"")}function C(e){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(e||"");return!!t&&t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255)}function k(e){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(e||"");if(!t)return!1;const[,r,n,s,o]=t;return parseInt(r)>=0&&parseInt(r)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseFloat(o)>=0&&parseFloat(o)<=1}function A(e,t){return(e||"").includes(t)}const D={isEmail:function(e){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e||"")},isPhone:function(e){return/^1[3-9]\d{9}$/.test(e||"")},isURL:function(e){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(e||"")},isIPv4:x,isIPv6:E,isIP:function(e){return x(e)||E(e)},isIDCard:function(e){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(e||"")},isPassport:function(e){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(e||"")},isCreditCard:function(e){const t=e.replace(/\s/g,"");if(!/^(?: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})$/.test(t))return!1;let r=0,n=!1;for(let s=t.length-1;s>=0;s--){let e=parseInt(t[s],10);n&&(e*=2,e>9&&(e-=9)),r+=e,n=!n}return r%10==0},isHexColor:S,isRGB:C,isRGBA:k,isColor:function(e){return S(e)||C(e)||k(e)},isDate:function(e){return!isNaN(new Date(e).getTime())},isJSON:function(e){try{return JSON.parse(e),!0}catch{return!1}},isEmpty:function(e){return!e||""===e.trim()},isWhitespace:function(e){return/^\s+$/.test(e||"")},isNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isInteger:function(e){return/^-?\d+$/.test(e||"")},isFloat:function(e){return/^-?\d+\.\d+$/.test(e||"")},isPositive:function(e){const t=parseFloat(e);return!isNaN(t)&&t>0},isNegative:function(e){const t=parseFloat(e);return!isNaN(t)&&t<0},isAlpha:function(e){return/^[a-zA-Z]+$/.test(e||"")},isAlphaNumeric:function(e){return/^[a-zA-Z0-9]+$/.test(e||"")},isChinese:function(e){return/^[\u4e00-\u9fa5]+$/.test(e||"")},isLength:function(e,t,r){const n=(e||"").length;return n>=t&&(void 0===r||n<=r)},minLength:function(e,t){return(e||"").length>=t},maxLength:function(e,t){return(e||"").length<=t},matches:function(e,t){return t instanceof RegExp&&t.test(e||"")},equals:function(e,t){return String(e)===String(t)},contains:A,notContains:function(e,t){return!A(e,t)},isArray:function(e){return Array.isArray(e)},arrayLength:function(e,t,r){const n=e?e.length:0;return n>=t&&(void 0===r||n<=r)},arrayMinLength:function(e,t){return!!e&&e.length>=t},arrayMaxLength:function(e,t){return!!e&&e.length<=t},isObject:function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},hasKeys:function(e,t){return!!(e&&t&&Array.isArray(t))&&t.every(t=>Object.prototype.hasOwnProperty.call(e,t))},validate:function(e,t){const r={};return Object.keys(t).forEach(n=>{const s=e[n],o=t[n],i=[];o.forEach(t=>{if("string"==typeof t){const[e,...r]=t.split(":");D[e](s,...r)||i.push(e)}else if("function"==typeof t){const r=t(s,e);!0!==r&&i.push(r||"validation_failed")}}),i.length>0&&(r[n]=i)}),{valid:0===Object.keys(r).length,errors:r}}};const $={md5:function(e){const t=e?String(e):"",r=[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 s(e,t){return e<<t|e>>>32-t}function o(e,t){const[o,i,a,c]=t,l=[];for(let r=0;r<16;r++)l[r]=255&e.charCodeAt(4*r)|(255&e.charCodeAt(4*r+1))<<8|(255&e.charCodeAt(4*r+2))<<16|(255&e.charCodeAt(4*r+3))<<24;let u=o,h=i,d=a,p=c;for(let f=0;f<64;f++){let e,t;const o=Math.floor(f/16),i=f%16;0===o?(e=h&d|~h&p,t=i):1===o?(e=p&h|~p&d,t=(5*i+1)%16):2===o?(e=h^d^p,t=(3*i+5)%16):(e=d^(h|~p),t=7*i%16);const a=p;p=d,d=h,h+=s(u+e+r[f]+l[t]&4294967295,n[o][f%4]),u=a}return[o+u&4294967295,i+h&4294967295,a+d&4294967295,c+p&4294967295]}const i=function(e){const t=8*e.length;for(e+="";e.length%64!=56;)e+="\0";const r=4294967295&t,n=t>>>32&4294967295;for(let s=0;s<4;s++)e+=String.fromCharCode(r>>>8*s&255);for(let s=0;s<4;s++)e+=String.fromCharCode(n>>>8*s&255);return e}(t);let a=[1732584193,4023233417,2562383102,271733878];for(let l=0;l<i.length;l+=64)a=o(i.substring(l,l+64),a);let c="";return a.forEach(e=>{for(let t=0;t<4;t++)c+=(e>>>8*t&255).toString(16).padStart(2,"0")}),c},sha256:function(e){const t=e?String(e):"",r=[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 n(e,t){return e>>>t|e<<32-t}function s(e,t){const s=[];for(let r=0;r<16;r++)s[r]=255&e.charCodeAt(4*r)|(255&e.charCodeAt(4*r+1))<<8|(255&e.charCodeAt(4*r+2))<<16|(255&e.charCodeAt(4*r+3))<<24;for(let r=16;r<64;r++){const e=n(s[r-15],7)^n(s[r-15],18)^s[r-15]>>>3,t=n(s[r-2],17)^n(s[r-2],19)^s[r-2]>>>10;s[r]=s[r-16]+e+s[r-7]+t&4294967295}let[o,i,a,c,l,u,h,d]=t;for(let p=0;p<64;p++){const e=d+(n(l,6)^n(l,11)^n(l,25))+(l&u^~l&h)+r[p]+s[p]&4294967295,t=o&i^o&a^i&a;d=h,h=u,u=l,l=c+e&4294967295,c=a,a=i,i=o,o=e+((n(o,2)^n(o,13)^n(o,22))+t&4294967295)&4294967295}return[t[0]+o&4294967295,t[1]+i&4294967295,t[2]+a&4294967295,t[3]+c&4294967295,t[4]+l&4294967295,t[5]+u&4294967295,t[6]+h&4294967295,t[7]+d&4294967295]}const o=function(e){const t=8*e.length;for(e+="";e.length%64!=56;)e+="\0";const r=4294967295&t,n=t>>>32&4294967295;for(let s=0;s<4;s++)e+=String.fromCharCode(n>>>8*s&255);for(let s=0;s<4;s++)e+=String.fromCharCode(r>>>8*s&255);return e}(t);let i=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<o.length;c+=64)i=s(o.substring(c,c+64),i);let a="";return i.forEach(e=>{for(let t=3;t>=0;t--)a+=(e>>>8*t&255).toString(16).padStart(2,"0")}),a},base64Encode:function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let r="",n=0;const s=e?e.split("").map(e=>e.charCodeAt(0)):[];for(;n<s.length;){const e=s[n++],o=s[n++]||0,i=s[n++]||0,a=(15&o)<<2|i>>6,c=63&i;r+=t[e>>2]+t[(3&e)<<4|o>>4]+(n>s.length+1?"=":t[a])+(n>s.length?"=":t[c])}return r},base64Decode:function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let r="",n=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");n<e.length;){const s=t.indexOf(e.charAt(n++)),o=t.indexOf(e.charAt(n++)),i=t.indexOf(e.charAt(n++)),a=t.indexOf(e.charAt(n++)),c=s<<2|o>>4,l=(15&o)<<4|i>>2,u=(3&i)<<6|a;r+=String.fromCharCode(c),64!==i&&(r+=String.fromCharCode(l)),64!==a&&(r+=String.fromCharCode(u))}return r},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},L=new Map;async function O(e,t={}){const{crossOrigin:r="anonymous"}=t;return L.has(e)?L.get(e):new Promise((t,n)=>{const s=new Image;s.crossOrigin=r,s.onload=()=>{L.set(e,s),t(s)},s.onerror=()=>{n(new Error(`Failed to load image: ${e}`))},s.src=e})}async function M(e,t={}){const{type:r="text/javascript",async:n=!0,defer:s=!1}=t;return L.has(e)?L.get(e):new Promise((t,o)=>{const i=document.createElement("script");i.type=r,i.async=n,i.defer=s,i.onload=()=>{L.set(e,i),t(i)},i.onerror=()=>{i.remove(),o(new Error(`Failed to load script: ${e}`))},i.src=e,document.head.appendChild(i)})}async function N(e,t={}){const{media:r="all"}=t;return L.has(e)?L.get(e):new Promise((t,n)=>{const s=document.createElement("link");s.rel="stylesheet",s.href=e,s.media=r,s.onload=()=>{L.set(e,s),t(s)},s.onerror=()=>{s.remove(),n(new Error(`Failed to load stylesheet: ${e}`))},document.head.appendChild(s)})}const P={loadImage:O,loadImages:async function(e,t={}){const{parallel:r=!0}=t;if(r)return Promise.all(e.map(e=>O(e,t)));const n=[];for(const s of e)n.push(await O(s,t));return n},loadScript:M,loadStylesheet:N,loadFont:async function(e,t,r={}){const{weight:n="normal",style:s="normal"}=r,o=new FontFace(e,`url(${t})`,{weight:n,style:s});try{return await o.load(),document.fonts.add(o),o}catch(i){throw new Error(`Failed to load font: ${e}`)}},preload:async function(e,t="image"){switch(t){case"image":return O(e);case"script":return M(e);case"stylesheet":case"style":return N(e);default:throw new Error(`Unsupported preload type: ${t}`)}},isLoaded:function(e){return L.has(e)},clearCache:function(){L.clear()},clearCacheByUrl:function(e){L.delete(e)}},R={string:s,array:i,object:c,number:d,date:w,debounce:v,throttle:_,validator:D,crypto:$,preload:P};class T{constructor(){this.children={},this.keys=[]}}class I{constructor(){this.root=new T}insert(e){let t=this.root;const r=e.split(".");r.forEach((n,s)=>{t.children[n]||(t.children[n]=new T),t=t.children[n],s===r.length-1&&t.keys.push(e)})}getSubKeys(e){let t=this.root;const r=e.split("."),n=[];for(let s=0;s<r.length;s++){const e=r[s];if(!t.children[e])break;t=t.children[e];const o=e=>{e.keys.length>0&&n.push(...e.keys),Object.values(e.children).forEach(e=>o(e))};o(t)}return[...new Set(n)]}getParentKeys(e){const t=e.split("."),r=[];for(let n=1;n<=t.length;n++){const e=t.slice(0,n).join(".");r.push(e)}return r}}const j=Symbol("reactive_parent"),F=Symbol("reactive_path"),H=Symbol("reactive_is_reactive");class K{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new I,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 e={get:(e,t,r)=>{if("__raw__"===t)return e;const n=Reflect.get(e,t,r);return n&&"object"==typeof n&&!Array.isArray(n)?this.wrapReactive(n,t):n},set:(e,t,r,n)=>{const s=Reflect.get(e,t,n),o=Reflect.set(e,t,r,n),i=this.resolvePath(e,t);return this.notify(i,r,s),this.queueUpdate(i,r),o},deleteProperty:(e,t)=>{const r=Reflect.get(e,t,receiver),n=Reflect.deleteProperty(e,t),s=this.resolvePath(e,t);return this.notify(s,void 0,r),this.queueUpdate(s,void 0),n}};this.data=new Proxy(this.rawData,e),this.data.__parent__=null,this.data.__path__=""}wrapReactive(e,t){if(e[H])return e;if(this._proxyCache.has(e))return this._proxyCache.get(e);const r=new Proxy(e,{get:(e,t,r)=>{if("__raw__"===t)return e;if(t===j||"__parent__"===t)return e[j];if(t===F||"__path__"===t)return e[F];if(t===H||"__isReactive__"===t)return!0;const n=Reflect.get(e,t,r);return n&&"object"==typeof n&&!Array.isArray(n)?this.wrapReactive(n,`${e[F]}${e[F]?".":""}${t}`):n},set:(e,t,r,n)=>{if(t===j||t===F||t===H||"__parent__"===t||"__path__"===t||"__isReactive__"===t)return!0;const s=Reflect.get(e,t,n),o=Reflect.set(e,t,r,n),i=`${e[F]}${e[F]?".":""}${t}`;return this.notify(i,r,s),this.queueUpdate(i,r),o},deleteProperty:(e,t)=>{if(t===j||t===F||t===H)return!1;const r=Reflect.get(e,t),n=Reflect.deleteProperty(e,t),s=`${e[F]}${e[F]?".":""}${t}`;return this.notify(s,void 0,r),this.queueUpdate(s,void 0),n},has:(e,t)=>"__raw__"===t||t===j||t===F||t===H||"__parent__"===t||"__path__"===t||"__isReactive__"===t||t in e,ownKeys:e=>Reflect.ownKeys(e).filter(e=>e!==j&&e!==F&&e!==H),getOwnPropertyDescriptor:(e,t)=>t===j||t===F||t===H?{configurable:!1,enumerable:!1,writable:!1,value:e[t]}:Reflect.getOwnPropertyDescriptor(e,t)});return e[j]=e,e[F]=t,e[H]=!0,this._proxyCache.set(e,r),Object.keys(e).forEach(r=>{e[r]&&"object"==typeof e[r]&&!Array.isArray(e[r])&&(e[r]=this.wrapReactive(e[r],`${t}${t?".":""}${r}`))}),r}resolvePath(e,t){return e[F]?`${e[F]}.${t}`:t}queueUpdate(e,t){this.updateQueue.set(e,t),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const e=new Set;this.updateQueue.forEach((t,r)=>{e.add(r),this.updateElementsDirect(r,t);this.pathTrie.getSubKeys(r).forEach(t=>{if(!e.has(t)){const r=this.get(t);this.updateElementsDirect(t,r),e.add(t)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(e,t){this.elements[e]&&this.elements[e].forEach(e=>{this.updateElement(e,t)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(e=>this.updateQueue.has(e)||this.pathTrie.getSubKeys(e).some(e=>this.updateQueue.has(e)))&&this.updateComputedProperty(e)})}set(e,t,r=!1){const n=this.get(e);"object"==typeof e?(Object.assign(this.rawData,e),Object.keys(e).forEach(t=>{r||(this.notify(t,e[t],n?.[t]),this.queueUpdate(t,e[t]))})):(e.includes(".")?this.setNested(e,t):this.rawData[e]=t,r||(this.notify(e,t,n),this.queueUpdate(e,t))),r||this.processComputed()}get(e){if(e)return e.includes(".")?this.getNested(e):this.rawData[e]}getNested(e){if(e)return e.split(".").reduce((e,t)=>e?.[t],this.rawData)}setNested(e,t){const r=e.split("."),n=r.pop(),s=r.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),this.rawData),o=s[n];s[n]=t,this.notify(e,t,o),this.queueUpdate(e,t)}observe(e,t){this.observers[e]||(this.observers[e]=[]),this.observers[e].push(t)}unobserve(e,t){this.observers[e]&&(this.observers[e]=this.observers[e].filter(e=>e!==t))}notify(e,t,r){this.observers[e]&&this.observers[e].forEach(n=>{try{n(t,r)}catch(s){console.error(`Observer error for ${e}:`,s)}}),this.observers["*"]?.forEach(n=>{try{n(e,t,r)}catch(s){console.error("Wildcard observer error:",s)}})}updateElement(e,t){const r=e.getAttribute("data-bind");if(!r)return;r.split("|").forEach(r=>{const n=r.split(":"),s=n[0].trim(),o=n[1]?.trim();switch(s){case"text":e.textContent!==String(t??"")&&(e.textContent=t??"");break;case"html":const r=function(e){if(!e)return"";let t=String(e);const r=/<\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 n;do{n=t,t=t.replace(r,"")}while(t!==n);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}(t);e.innerHTML!==r&&(e.innerHTML=r);break;case"value":"checkbox"===e.type?e.checked!==!!t&&(e.checked=!!t):e.value!==String(t??"")&&(e.value=t??"");break;case"checked":e.checked!==!!t&&(e.checked=!!t);break;case"disabled":e.disabled!==!!t&&(e.disabled=!!t);break;case"hidden":const n=t?"none":"";e.style.display!==n&&(e.style.display=n);break;case"class":o&&(t?e.classList.add(o):e.classList.remove(o));break;case"style":o&&e.style[o]!==String(t??"")&&(e.style[o]=t??"");break;case"attr":if(o){e.getAttribute(o)!==String(t??"")&&e.setAttribute(o,t??"")}break;case"src":e.src!==String(t??"")&&(e.src=t??"");break;case"href":e.href!==String(t??"")&&(e.href=t??"");break;case"placeholder":e.placeholder!==String(t??"")&&(e.placeholder=t??"")}})}computed(e,t,r){this.computedProperties[e]={deps:t,callback:r},t.forEach(e=>{this.pathTrie.insert(e)}),this.updateComputedProperty(e)}updateComputedProperty(e){const t=this.computedProperties[e];if(t)try{const r=t.deps.map(e=>this.get(e)),n=t.callback(...r);this.set(e,n,!0)}catch(r){console.error(`Computed error for ${e}:`,r)}}load(e){Object.keys(e).forEach(t=>{e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])?this.rawData[t]=this.wrapReactive(e[t],t):this.rawData[t]=e[t],this.queueUpdate(t,this.rawData[t])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new I,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(e,t={}){const{storage:r="local",debounce:n=0,version:s=1,encrypt:o=!1,encryptionKey:i=null}=t,a="session"===r?sessionStorage:localStorage;this.persistedKeys.set(e,{storage:a,debounce:n,timeout:null,version:s,encrypt:o,encryptionKey:i});const c=this.get(e);void 0!==c&&this._persistSave(e,c,a,{version:s,encrypt:o,encryptionKey:i}),this.observe(e,t=>{const r=this.persistedKeys.get(e);r&&(r.debounce>0?(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(()=>{this._persistSave(e,t,r.storage,{version:r.version,encrypt:r.encrypt,encryptionKey:r.encryptionKey})},r.debounce)):this._persistSave(e,t,r.storage,{version:r.version,encrypt:r.encrypt,encryptionKey:r.encryptionKey}))})}_persistSave(e,t,r,n={}){try{const{version:s=1,encrypt:o=!1,encryptionKey:i=null}=n,a={value:t,version:s,timestamp:Date.now()};let c=JSON.stringify(a);o&&i&&(c=this._encrypt(c,i)),this._ensureStorageCapacity(r),r.setItem(`kupola:${e}`,c)}catch(s){if(console.warn(`Failed to persist key ${e}:`,s),"QuotaExceededError"===s.name&&r===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${e}`);try{sessionStorage.setItem(`kupola:${e}`,JSON.stringify({value:t,version:1}))}catch(o){console.warn(`sessionStorage also failed for key ${e}:`,o)}}}}_ensureStorageCapacity(e){try{const t="kupola:__storage_test__";e.setItem(t,"test"),e.removeItem(t)}catch(t){"QuotaExceededError"===t.name&&this._cleanupOldStorage(e)}}_cleanupOldStorage(e){const t=Date.now();for(let n=0;n<e.length;n++){const s=e.key(n);if(s?.startsWith("kupola:"))try{const r=JSON.parse(e.getItem(s));r.timestamp&&t-r.timestamp>2592e6&&e.removeItem(s)}catch(r){e.removeItem(s)}}}_encrypt(e,t){return window.CryptoJS?window.CryptoJS.AES.encrypt(e,t).toString():(console.warn("CryptoJS not available, encryption skipped"),e)}_decrypt(e,t){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),e;try{return window.CryptoJS.AES.decrypt(e,t).toString(window.CryptoJS.enc.Utf8)}catch(r){return console.warn("Decryption failed:",r),e}}unpersist(e){const t=this.persistedKeys.get(e);t&&(t.timeout&&clearTimeout(t.timeout),t.storage.removeItem(`kupola:${e}`),this.persistedKeys.delete(e))}loadPersisted(e={}){const t={},{encryptionKey:r=null}=e;for(let s=0;s<localStorage.length;s++){const o=localStorage.key(s);if(o?.startsWith("kupola:")){const s=o.replace("kupola:","");try{const n=localStorage.getItem(o);let i;if(r){const e=this._decrypt(n,r);i=JSON.parse(e)}else i=JSON.parse(n);if(void 0!==i.version&&i.version!==e.version){console.debug(`Skipping outdated data for ${s} (version ${i.version})`);continue}t[s]=void 0!==i.value?i.value:i}catch(n){console.warn(`Failed to load persisted key ${s}:`,n)}}}for(let s=0;s<sessionStorage.length;s++){const o=sessionStorage.key(s);if(o?.startsWith("kupola:")){const s=o.replace("kupola:","");try{const n=sessionStorage.getItem(o);let i;if(r){const e=this._decrypt(n,r);i=JSON.parse(e)}else i=JSON.parse(n);if(void 0!==i.version&&i.version!==e.version){console.debug(`Skipping outdated data for ${s} (version ${i.version})`);continue}t[s]=void 0!==i.value?i.value:i}catch(n){}}}return Object.keys(t).length>0&&this.load(t),t}_clone(e){if("function"==typeof structuredClone)try{return structuredClone(e)}catch(t){console.warn("structuredClone failed, falling back to JSON:",t)}return JSON.parse(JSON.stringify(e))}snapshot(){const e=this._clone(this.rawData);return this.snapshots.push(e),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(e=-1){if(0===this.snapshots.length)return!1;const t=e>=0?e:this.snapshots.length-1,r=this.snapshots[t];return!!r&&(this.rawData=this._clone(r),this.createReactiveData(),Object.keys(this.rawData).forEach(e=>{this.queueUpdate(e,this.rawData[e])}),this.processComputed(),!0)}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(e=>{const r=e.getAttribute("data-bind");if(!r)return;const n=r.split(":"),s=n[1]?.trim();s&&("checkbox"===e.type?(t[s]||(t[s]=[]),e.checked&&t[s].push(e.value)):"radio"===e.type?e.checked&&(t[s]=e.value):t[s]=e.value)}),t}fillForm(e,t){Object.keys(t).forEach(r=>{e.querySelectorAll('[data-bind*=":'+r+'"]').forEach(e=>{"checkbox"===e.type?e.checked=Array.isArray(t[r])?t[r].includes(e.value):!!t[r]:"radio"===e.type?e.checked=e.value===t[r]:e.value=t[r]??""})})}createReactive(e,t=""){if(e[H])return e;if(this._proxyCache.has(e))return this._proxyCache.get(e);const r=new Proxy(e,{get:(e,t,r)=>{if("__raw__"===t)return e;if(t===j||"__parent__"===t)return e[j];if(t===F||"__path__"===t)return e[F];if(t===H||"__isReactive__"===t)return!0;const n=Reflect.get(e,t,r);return n&&"object"==typeof n&&!Array.isArray(n)?this.wrapReactive(n,`${e[F]}${e[F]?".":""}${t}`):n},set:(e,t,r,n)=>{if(t===j||t===F||t===H||"__parent__"===t||"__path__"===t||"__isReactive__"===t)return!0;const s=Reflect.get(e,t,n),o=Reflect.set(e,t,r,n),i=`${e[F]}${e[F]?".":""}${t}`;return this.notify(i,r,s),this.queueUpdate(i,r),o},deleteProperty:(e,t)=>{if(t===j||t===F||t===H)return!1;const r=Reflect.get(e,t),n=Reflect.deleteProperty(e,t),s=`${e[F]}${e[F]?".":""}${t}`;return this.notify(s,void 0,r),this.queueUpdate(s,void 0),n},has:(e,t)=>"__raw__"===t||t===j||t===F||t===H||"__parent__"===t||"__path__"===t||"__isReactive__"===t||t in e,ownKeys:e=>Reflect.ownKeys(e).filter(e=>e!==j&&e!==F&&e!==H),getOwnPropertyDescriptor:(e,t)=>t===j||t===F||t===H?{configurable:!1,enumerable:!1,writable:!1,value:e[t]}:Reflect.getOwnPropertyDescriptor(e,t)});return e[j]=e,e[F]=t,e[H]=!0,this._proxyCache.set(e,r),Object.keys(e).forEach(r=>{e[r]&&"object"==typeof e[r]&&!Array.isArray(e[r])&&(e[r]=this.wrapReactive(e[r],`${t}${t?".":""}${r}`))}),r}bind(){document.querySelectorAll("[data-bind]").forEach(e=>{this._bindElement(e)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(e=>{if(!this._isObserving){this._isObserving=!0;try{e.forEach(e=>{e.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){e.querySelectorAll("[data-bind]").forEach(e=>this._bindElement(e)),e.hasAttribute&&e.hasAttribute("data-bind")&&this._bindElement(e)}})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(e){const t=e.getAttribute("data-bind").split(":");t[0].split("|")[0].trim();const r=t[1]?.trim();if(r){if(this.pathTrie.insert(r),this.elements[r]||(this.elements[r]=[]),this.elements[r].includes(e)||this.elements[r].push(e),"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName){const t=e.__kupolaBindHandler;t&&e.removeEventListener("input",t);const n=()=>{const t="checkbox"===e.type?e.checked:e.value;r.includes(".")?this.setNested(r,t):this.set(r,t)};e.__kupolaBindHandler=n,e.addEventListener("input",n)}void 0!==this.rawData[r]&&this.updateElement(e,this.rawData[r])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(e=>{e.forEach(e=>{const t=e.__kupolaBindHandler;t&&(e.removeEventListener("input",t),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((e,t)=>{e.timeout&&clearTimeout(e.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new I,this.updateQueue.clear(),this.snapshots=[]}}class U{constructor(e,t={}){this.name=e,this._stateKey=`__store_${e}__`;const r=t.state?t.state():{};this.getters=t.getters||{},this.actions=t.actions||{},this.mutations=t.mutations||{},this.observers={},W?(W.set(this._stateKey,r),this.state=W.data?.[this._stateKey]||W.createReactive(r,this._stateKey),W.observe(this._stateKey,e=>{this.notify(e)})):this.state=r,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(e=>{Object.defineProperty(this,e,{get:()=>this.getters[e](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(e=>{this[e]=(...t)=>this.actions[e]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...t)})}commit(e,t){const r=this.mutations[e];r?r(this.state,t):console.warn(`Mutation ${e} not found in store ${this.name}`)}dispatch(e,t){const r=this.actions[e];if(r)return r({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},t);console.warn(`Action ${e} not found in store ${this.name}`)}observe(e){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(e),e}unobserve(e){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(t=>t!==e))}notify(e){this.observers["*"]&&this.observers["*"].forEach(t=>{try{t(e)}catch(r){console.error(`Observer error for store ${this.name}:`,r)}}),W&&W.set(this.name,e)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((e,t)=>(e[t]=this[t],e),{})}}}class z{constructor(){this.stores=new Map}createStore(e,t){const r=new U(e,t);return this.stores.set(e,r),r}getStore(e){return this.stores.get(e)}registerStore(e){e instanceof U&&this.stores.set(e.name,e)}dispose(){this.stores.clear()}}class q{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),t}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(e=>e!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(r=>{try{r(t)}catch(n){console.error(`Error in event handler for ${e}:`,n)}}),this.events["*"]?.forEach(r=>{try{r(e,t)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(e,t){const r=n=>{t(n),this.off(e,r)};return this.on(e,r),r}delegate(e,t,r){if(!this.delegatedEvents[t]){this.delegatedEvents[t]=[];const e=e=>{this.delegatedEvents[t].forEach(({selector:t,cb:r})=>{(e.target.matches(t)||e.target.closest(t))&&r(e)})};document.addEventListener(t,e),this.eventListeners[t]=e}return this.delegatedEvents[t].push({selector:e,cb:r}),r}undelegate(e,t){if(this.delegatedEvents[t]&&(this.delegatedEvents[t]=this.delegatedEvents[t].filter(t=>t.selector!==e),0===this.delegatedEvents[t].length)){const e=this.eventListeners[t];e&&(document.removeEventListener(t,e),delete this.eventListeners[t]),delete this.delegatedEvents[t]}}destroy(){Object.entries(this.eventListeners).forEach(([e,t])=>{document.removeEventListener(e,t)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function B(e=null){const t={_value:e,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get:()=>t._value,set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(t=>t(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const W=new K,J=new q,Y=new z;const Q={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}},V=[];function Z(){if("undefined"!=typeof window&&window.kupolaConfig)try{oe(Q,window.kupolaConfig),G()}catch(e){console.warn("[Kupola] Failed to parse window.kupolaConfig:",e)}}function G(){V.forEach(e=>{try{e(Q)}catch(t){console.warn("[Kupola] Error in config change listener:",t)}})}function X(e){"function"==typeof e&&V.push(e)}function ee(e){return e?function(e,t){return t.split(".").reduce((e,t)=>void 0!==(e&&e[t])?e[t]:void 0,e)}(Q,e):Q}function te(){return Q.paths.base+Q.paths.icons.replace(/^\//,"")}function re(){return Q.theme.default}function ne(){return Q.theme.brand}function se(){return Q.security}function oe(e,t){for(const r in t)t[r]instanceof Object&&r in e&&e[r]instanceof Object?oe(e[r],t[r]):e[r]=t[r];return e}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Z):Z());const ie="kupola-theme",ae="kupola-brand";X(e=>{const t=document.querySelector("[data-theme-toggle]");if(t){const e=le();pe(t),ue(e)}});const ce=[{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 le(){return localStorage.getItem(ie)||re()}function ue(e){if("dark"!==e&&"light"!==e)return;var t=document.documentElement;t.hasAttribute("data-kupola-theme-preloaded")&&(t.style.removeProperty("--bg-base-default"),t.style.removeProperty("--text-default"),t.removeAttribute("data-kupola-theme-preloaded")),t.setAttribute("data-theme",e),localStorage.setItem(ie,e);const r=document.querySelector("[data-theme-toggle]");r&&(r.setAttribute("data-current-theme",e),pe(r))}function he(){return localStorage.getItem(ae)||ne()}function de(e){const t=ce.find(t=>t.id===e);if(!t)return;document.documentElement.setAttribute("data-brand",e),localStorage.setItem(ae,e);const r=document.querySelector("[data-brand-toggle]");if(r){r.setAttribute("data-current-brand",e);const n=r.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const s=r.querySelector(".brand-name");s&&(s.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.getAttribute("data-brand-btn")===e?t.classList.add("is-active"):t.classList.remove("is-active")})}function pe(e){const t=e.querySelector(".theme-icon");if(t){const e=le(),r=te();t.src="dark"===e?r+"sun.svg":r+"moon.svg"}}function fe(e){e.preventDefault();ue("dark"===le()?"light":"dark")}function me(){var e=document.documentElement;e.hasAttribute("data-kupola-theme-preloaded")&&(e.style.removeProperty("--bg-base-default"),e.style.removeProperty("--text-default"),e.removeAttribute("data-kupola-theme-preloaded"));const t=document.querySelector("[data-theme-toggle]");ue(le());de(he()),t&&(pe(t),t.removeEventListener("click",fe),t.addEventListener("click",fe));let r=document.getElementById("brand-picker");r||(r=document.createElement("div"),r.id="brand-picker",r.style.position="fixed",r.style.top="64px",r.style.right="16px",r.style.zIndex="9998",r.style.display="none",r.style.padding="12px",r.style.width="200px",r.style.gridTemplateColumns="repeat(3, 1fr)",r.style.gap="6px",r.style.backgroundColor="var(--bg-base-secondary)",r.style.border="1px solid var(--border-neutral-l1)",r.style.borderRadius="8px",r.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",r.style.overflow="hidden",ce.forEach(e=>{const t=document.createElement("button");t.setAttribute("data-brand-btn",e.id),t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.height="60px",t.style.backgroundColor=e.color,t.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(e.color)?"#0C0C0D":"#FFFFFF",t.style.fontWeight="500",t.style.borderRadius="4px",t.style.border="none",t.style.cursor="pointer",t.style.margin="0",t.style.padding="0",t.textContent=e.name,r.appendChild(t)}),document.body.appendChild(r));const n=document.querySelector("[data-brand-toggle]");function s(e){r&&n&&(r.contains(e.target)||n.contains(e.target)||(r.style.display="none",document.removeEventListener("click",s,!0)))}n&&r&&(n.onclick=function(e){e.stopPropagation(),e.preventDefault();const t="none"===r.style.display;r.style.display=t?"grid":"none",t?setTimeout(()=>{document.addEventListener("click",s,!0)},0):document.removeEventListener("click",s,!0)},r.onclick=function(e){e.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(e=>{e.addEventListener("click",t=>{t.stopPropagation();de(e.getAttribute("data-brand-btn")),r&&(r.style.display="none")})})}class ye{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(e,t,r=null,n={}){this.initializers.set(e,t),r&&this.cleanupFunctions.set(e,r),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(e){this.initializers.delete(e),this.cleanupFunctions.delete(e)}has(e){return this.initializers.has(e)}get(e){return this.initializers.get(e)}_buildSelector(){if(null!==this._cachedSelector)return this._cachedSelector;const e=this._dataAttrs.map(e=>`[${e}]`);for(const t of this._cssClasses)e.push(`.${t}`);return this._cachedSelector=e.join(", "),this._cachedSelector}async initialize(e){if(this.processedElements.has(e))return;for(const n of this._dataAttrs){const t=e.getAttribute(n);if(null!==t){const s=t||n.replace("data-",""),o=this.initializers.get(s)||this.initializers.get(n.replace("data-",""));if(o){try{await o(e),this.processedElements.add(e)}catch(r){console.error(`[ComponentInitializerRegistry] Error initializing "${s}":`,r)}return}}}const t=e.className;if("string"==typeof t)for(const n of this._cssClasses){if(new RegExp(`(^|\\s)${n}(\\s|$)`).test(t)){const t=n.replace("ds-",""),s=this.initializers.get(t)||this.initializers.get(n);if(s){try{await s(e),this.processedElements.add(e)}catch(r){console.error(`[ComponentInitializerRegistry] Error initializing "${t}":`,r)}return}}}}cleanup(e){for(const n of this._dataAttrs){const t=e.getAttribute(n);if(null!==t){const s=t||n.replace("data-",""),o=this.cleanupFunctions.get(s)||this.cleanupFunctions.get(n.replace("data-",""));if(o){try{o(e)}catch(r){console.error(`[ComponentInitializerRegistry] Error cleaning up "${s}":`,r)}return void this.processedElements.delete(e)}}}const t=e.className;if("string"==typeof t)for(const n of this._cssClasses){if(new RegExp(`(^|\\s)${n}(\\s|$)`).test(t)){const t=n.replace("ds-",""),s=this.cleanupFunctions.get(t)||this.cleanupFunctions.get(n);if(s){try{s(e)}catch(r){console.error(`[ComponentInitializerRegistry] Error cleaning up "${t}":`,r)}return void this.processedElements.delete(e)}}}}async initializeAll(e=document){const t=this._buildSelector();if(!t)return;const r=e.querySelectorAll(t),n=[];r.forEach(e=>{this.processedElements.has(e)||n.push(this.initialize(e))}),await Promise.all(n)}}const ge=new ye,be=[{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 Ue of be)Ue.attr&&!ge._dataAttrs.includes(Ue.attr)&&ge._dataAttrs.push(Ue.attr),Ue.cls&&!ge._cssClasses.includes(Ue.cls)&&ge._cssClasses.push(Ue.cls);class we{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 e,this.setupContext=null}_parseProps(){const e={};for(const r of this.element.attributes)if(r.name.startsWith("data-prop-")){const n=r.name.replace("data-prop-","");let s=r.value;try{s=JSON.parse(s)}catch(t){}e[n]=s}return e}_parseSlots(){const e={};return this.element.querySelectorAll("[data-slot]").forEach(t=>{const r=t.getAttribute("data-slot")||"default";e[r]=t.innerHTML.trim(),t.remove()}),!e.default&&this.element.children.length>0&&(e.default=this.element.innerHTML.trim()),e}$slot(e="default"){return this.slots[e]||""}$emit(e,t){if((this._eventListeners[e]||[]).forEach(r=>{try{r(t)}catch(n){console.error(`Error in event handler for ${e}:`,n)}}),this.element){const r=new CustomEvent(`kupola:${e}`,{detail:t,bubbles:!0,cancelable:!0});this.element.dispatchEvent(r)}}$on(e,t){return this._eventListeners[e]||(this._eventListeners[e]=[]),this._eventListeners[e].push(t),t}$off(e,t){this._eventListeners[e]&&(this._eventListeners[e]=this._eventListeners[e].filter(e=>e!==t))}async setProps(e){try{this.props={...this.props,...e},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(t){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,t),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:t,args:[e]})}}async setState(e){try{this.state={...this.state,...e},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(t){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,t),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:t,args:[e]})}}async mount(){if(!this.isMounted&&!this.isDestroyed)try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),"function"==typeof this.setup){const e=this.setup();e instanceof Promise&&await e}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(e){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,e),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:e,args:[]}),"function"==typeof this.renderError)try{this.renderError(e)}catch(t){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,t)}else this.element.innerHTML=`\n <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">\n <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>\n <div style="font-size: 12px; white-space: pre-wrap;">${e.message}</div>\n </div>\n `}}_bindLifecycleHooks(){if(this._hooksBound)return;const e={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let t=Object.getPrototypeOf(this);const r=new Set;for(;t&&t.constructor!==Object&&t.constructor!==we;){for(const[n,s]of Object.entries(e))r.has(n)||t.hasOwnProperty(n)&&(Array.isArray(s)?s.forEach(e=>{"render"===n&&this.lifecycle.on(e,()=>this.render?.())}):"renderError"===n?this.lifecycle.on(s,e=>(this.renderError(e.error),"handled")):this.lifecycle.on(s,()=>this[n]?.()),r.add(n));t=Object.getPrototypeOf(t)}this._hooksBound=!0}async unmount(){if(this.isMounted&&!this.isDestroyed)try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(e){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,e),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:e,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(e){}updated(){}setup(){}}function ve(e,t){Object.keys(t).forEach(r=>{if("constructor"!==r)if("function"==typeof t[r]){const n=e.prototype[r];e.prototype[r]=n?function(...e){return t[r].apply(this,e),n.apply(this,e)}:t[r]}else e.prototype[r]=t[r]})}class _e{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(e,t){if(!(t.prototype instanceof we))throw new Error(`Component ${e} must extend KupolaComponent`);this.components.set(e,t)}registerLazy(e,t){this.lazyComponents.set(e,t)}unregister(e){this.components.delete(e),this.lazyComponents.delete(e),this.loadedComponents.delete(e),this.loadingPromises.delete(e)}get(e){return this.components.get(e)||this.loadedComponents.get(e)}async getAsync(e){const t=this.components.get(e)||this.loadedComponents.get(e);if(t)return t;if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const r=this.lazyComponents.get(e);if(!r)throw new Error(`Component ${e} not found`);const n=(async()=>{try{const t=await r(),n=t.default||t;if(!(n.prototype instanceof we))throw new Error(`Component ${e} must extend KupolaComponent`);return this.loadedComponents.set(e,n),n}catch(t){throw this.loadingPromises.delete(e),t}})();return this.loadingPromises.set(e,n),n}defineMixin(e,t){this.mixins.set(e,t)}useMixin(e,...t){t.forEach(t=>{const r=this.mixins.get(t);r&&ve(e,r)})}async bootstrap(e=document){await this._upgradeElements(e),this._startObserver(e)}async _upgradeElements(e){const t=e.querySelectorAll("[data-component]"),r=[];t.forEach(e=>{r.push(this._upgradeElement(e))}),await Promise.all(r)}async _upgradeElement(e){if(!e.__kupolaInstance&&!e.__kupolaUpgrading){e.__kupolaUpgrading=!0;try{const r=e.getAttribute("data-component");if(r){const n=ge.get(r);if(n)try{return void(await n(e))}catch(t){console.warn(`[KupolaComponentRegistry] Initializer for "${r}" failed, trying component class:`,t)}}let n=this.components.get(r);if(!n){try{n=await this.getAsync(r)}catch(t){return void console.error(`Failed to load component ${r}:`,t)}if(!e.isConnected)return}const s=e.getAttribute("data-mixins"),o=n;s&&s.split(",").forEach(e=>{const t=this.mixins.get(e.trim());t&&ve(o,t)});const i=new o(e);e.__kupolaInstance=i,this.instances.set(e,i),i.mount()}finally{e.__kupolaUpgrading=!1}}}_startObserver(e){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){e.hasAttribute("data-component")&&this._upgradeElement(e).catch(e=>console.error(e)),this._upgradeElements(e).catch(e=>console.error(e)),ge.initialize(e).catch(()=>{});const t=ge._buildSelector();t&&e.querySelectorAll?.(t).forEach(e=>{ge.initialize(e).catch(()=>{})})}}),e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=this.instances.get(e);t&&(t.unmount(),this.instances.delete(e)),e.querySelectorAll("[data-component]").forEach(e=>{const t=this.instances.get(e);t&&(t.unmount(),this.instances.delete(e))}),ge.cleanup(e),e.querySelectorAll?.("*").forEach(e=>{ge.cleanup(e)})}})})}),this.observer.observe(e,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(e=>{e.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}async function xe(){if("undefined"!=typeof window){!function(){if(se().xssProtection&&"undefined"!=typeof document){let e=document.querySelector('meta[http-equiv="X-XSS-Protection"]');e||(e=document.createElement("meta"),e.setAttribute("http-equiv","X-XSS-Protection"),e.setAttribute("content","1; mode=block"),document.head.insertBefore(e,document.head.firstChild)),e=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),e||(e=document.createElement("meta"),e.setAttribute("http-equiv","X-Content-Type-Options"),e.setAttribute("content","nosniff"),document.head.insertBefore(e,document.head.firstChild))}}();const e=ee();W.loadPersisted(),W.bind(),me(),!1!==e.components?.autoInit&&(await ge.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}exports.kupolaRegistry=null,"undefined"!=typeof window&&(exports.kupolaRegistry=new _e),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",xe):"undefined"!=typeof window&&setTimeout(xe,0);class Ee{constructor(e={}){const t=ee();this.locales=e.locales||{},this.currentLocale=e.defaultLocale||t.i18n?.locale||"zh-CN",this.fallbackLocale=e.fallbackLocale||t.i18n?.fallbackLocale||"en-US",this.delimiter=e.delimiter||".",this.missingHandler=e.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(e=>{const t=e.dataset.kupolaI18n;if(t)try{const r=JSON.parse(e.textContent);this.addLocale(t,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(e,t){this.locales[e]||(this.locales[e]={}),this._mergeDeep(this.locales[e],t)}_mergeDeep(e,t){for(const r of Object.keys(t))t[r]instanceof Object&&r in e?this._mergeDeep(e[r],t[r]):e[r]=t[r]}setLocale(e){return!!this.locales[e]&&(this.currentLocale=e,document.documentElement.lang=e,this._emitChange(),!0)}getLocale(){return this.currentLocale}t(e,t={}){let r=this._getTranslation(e,this.currentLocale);return r||(r=this._getTranslation(e,this.fallbackLocale)),r?this._interpolate(r,t):this.missingHandler(e)}_getTranslation(e,t){if(!this.locales[t])return null;const r=e.split(this.delimiter);let n=this.locales[t];for(const s of r){if(!n||"object"!=typeof n||!(s in n))return null;n=n[s]}return"string"==typeof n?n:null}_interpolate(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>void 0!==t[r]?t[r]:e)}n(e,t,r={}){const n=this.t(e,{...r,count:t});if(!n)return n;const s=n.split("|");return 1===s.length?n.replace("{count}",t):2===s.length?1===t?s[0]:s[1]:s.length>=3?0===t?s[0]:1===t?s[1]:s[2]:n}_emitChange(){const e=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(e)}async loadLocale(e,t){try{const r=await fetch(t),n=await r.json();return this.addLocale(e,n),!0}catch(r){return console.error("Failed to load locale:",r),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(e){return!!this.locales[e]}formatDate(e,t={}){const r=t.locale||this.currentLocale,n="string"==typeof e?new Date(e):e;return new Intl.DateTimeFormat(r,t).format(n)}formatNumber(e,t={}){const r=t.locale||this.currentLocale;return new Intl.NumberFormat(r,t).format(e)}formatCurrency(e,t,r={}){const n=r.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:t,...r}).format(e)}formatRelativeTime(e,t,r={}){const n=r.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,r).format(e,t)}}const Se=new Ee;class Ce{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(e,t,r,n={}){const{scope:s=null,once:o=!1,passive:i=!1,capture:a=!1}=n,c=this._generateId(),l={id:c,target:e,eventName:t,handler:r,scope:s,once:o,wrappedHandler:null};l.wrappedHandler=t=>{o&&this.offById(c),r.call(e,t)};const u=this._getEventKey(e,t);return this._listeners.has(u)||this._listeners.set(u,[]),this._listeners.get(u).push(l),s&&(this._scopeListeners.has(s)||this._scopeListeners.set(s,[]),this._scopeListeners.get(s).push(c)),e.addEventListener(t,l.wrappedHandler,{passive:i,capture:a}),{unsubscribe:()=>this.offById(c)}}once(e,t,r,n={}){return this.on(e,t,r,{...n,once:!0})}off(e,t,r){const n=this._getEventKey(e,t);if(!this._listeners.has(n))return;const s=this._listeners.get(n),o=s.filter(e=>e.handler!==r);s.forEach(n=>{n.handler===r&&(e.removeEventListener(t,n.wrappedHandler),this._removeFromScope(n))}),0===o.length?this._listeners.delete(n):this._listeners.set(n,o)}offById(e){for(const[t,r]of this._listeners){const n=r.findIndex(t=>t.id===e);if(-1!==n){const e=r[n];return e.target.removeEventListener(e.eventName,e.wrappedHandler),r.splice(n,1),0===r.length&&this._listeners.delete(t),this._removeFromScope(e),!0}}return!1}offByScope(e){if(!this._scopeListeners.has(e))return;this._scopeListeners.get(e).forEach(e=>{this.offById(e)}),this._scopeListeners.delete(e)}offAll(e,t=null){if(t){const r=this._getEventKey(e,t);if(!this._listeners.has(r))return;this._listeners.get(r).forEach(r=>{e.removeEventListener(t,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(r)}else for(const[r,n]of this._listeners){const[t]=r.split(":");this._getTargetId(e)===t&&(n.forEach(t=>{e.removeEventListener(t.eventName,t.wrappedHandler),this._removeFromScope(t)}),this._listeners.delete(r))}}emit(e,t,r={}){const n=new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0});return e.dispatchEvent(n),n}emitGlobal(e,t={}){return this.emit(document,e,t)}emitToScope(e,t,r={}){if(!this._scopeListeners.has(e))return;const n=this._scopeListeners.get(e),s=new Set;for(const[o,i]of this._listeners)i.forEach(e=>{n.includes(e.id)&&s.add(e.target)});s.forEach(e=>{this.emit(e,t,r)})}getListenerCount(e,t=null){if(t){const r=this._getEventKey(e,t);return this._listeners.has(r)?this._listeners.get(r).length:0}let r=0;const n=this._getTargetId(e);for(const[s,o]of this._listeners){const[e]=s.split(":");e===n&&(r+=o.length)}return r}getScopeListenerCount(e){return this._scopeListeners.has(e)?this._scopeListeners.get(e).length:0}hasListeners(e,t=null){return this.getListenerCount(e,t)>0}_getEventKey(e,t){return`${this._getTargetId(e)}:${t}`}_getTargetId(e){return e===document?"document":e===window?"window":e===document.body?"body":(e._kupolaId||(e._kupolaId=this._generateId()),e._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(e){if(!e.scope||!this._scopeListeners.has(e.scope))return;const t=this._scopeListeners.get(e.scope),r=t.indexOf(e.id);-1!==r&&(t.splice(r,1),0===t.length&&this._scopeListeners.delete(e.scope))}destroy(){for(const[e,t]of this._listeners)t.forEach(e=>{e.target.removeEventListener(e.eventName,e.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const ke=new Ce;class Ae{constructor(){this._queue=new Set,this._scheduled=!1,this._flushDepth=0,this._maxDepth=10}schedule(e){this._queue.add(e),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){if(this._flushDepth>=this._maxDepth)return console.warn("[Kupola Scheduler] Max flush depth reached, possible infinite loop detected"),this._queue.clear(),void(this._scheduled=!1);const e=Array.from(this._queue);this._queue.clear(),this._scheduled=!1,this._flushDepth++;const t=new Set;for(const n of e)if(!t.has(n)){t.add(n);try{n()}catch(r){console.error("[DependsScheduler]",r)}}this._flushDepth--}}const De=new Ae;class $e{constructor(e,t){this.data=e,this.createdAt=Date.now(),this.ttl=t}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class Le{constructor(){this._store=new Map}get(e){const t=this._store.get(e);return t||null}set(e,t,r=6e4){this._store.set(e,new $e(t,r))}has(e){return this._store.has(e)}delete(e){this._store.delete(e)}clear(){this._store.clear()}getStale(e){const t=this._store.get(e);return t?t.data:null}}class Oe extends Error{constructor(e,t,r){super(e),this.name="DependsError",this.code=t,this.cause=r,this.timestamp=Date.now()}}let Me="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;class Ne{constructor(e,t){this.config=e,this.cacheKey=e.cacheKey||String(e.source),this.staleTime=e.staleTime??6e4,this.cache=t,this.subscribers=[],this.pending=null,this.retryCount=e.retry??0,this.retryDelay=e.retryDelay??1e3,this.onError=e.onError||null}subscribe(e){return this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);t>-1&&this.subscribers.splice(t,1)}}notify(){De.schedule(()=>{this.subscribers.forEach(e=>{try{e()}catch(t){console.error("[DependsSource.notify]",t)}})})}async fetch(e){throw new Oe("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(e){const t=this.cache.get(this.cacheKey);return t&&t.isFresh?t.data:t&&t.isStale?(this._revalidate(e),t.data):this._fetchWithRetry(e)}async _fetchWithRetry(e,t=0){try{const t=await this.fetch(e);return this.cache.set(this.cacheKey,t,this.staleTime),this.notify(),t}catch(r){if(t<this.retryCount){const r=this.retryDelay*Math.pow(2,t),n=r+Math.random()*r*.5;return await new Promise(e=>setTimeout(e,n)),this._fetchWithRetry(e,t+1)}const s=r instanceof Oe?r:new Oe(r.message||"Fetch failed","FETCH_ERROR",r);if(this.onError)try{this.onError(s)}catch(n){}throw s}}async _revalidate(e){try{await this._fetchWithRetry(e)}catch(t){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class Pe extends Ne{constructor(e,t){super(e,t),this.method=e.method||"GET",this.headers=e.headers||{},this.queryParams=e.query||{}}async fetch(e){let t=this.config.source;const r=ee("http");!r?.baseURL||t.startsWith("http://")||t.startsWith("https://")||(t=r.baseURL+t.replace(/^\//,""));for(const u in e)t=t.replace(`:${u}`,encodeURIComponent(e[u]));const n=[];for(const[u,h]of Object.entries(this.queryParams||{}))n.push(`${encodeURIComponent(u)}=${encodeURIComponent(h)}`);for(const u in e)this.config.source.includes(`:${u}`)||n.push(`${encodeURIComponent(u)}=${encodeURIComponent(e[u])}`);n.length>0&&(t+=(t.includes("?")?"&":"?")+n.join("&"));const s=r?.headers||{},o={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...s,...this.headers}};r?.withCredentials&&(o.credentials="include"),["POST","PUT","PATCH"].includes(o.method)&&(o.body=JSON.stringify(e));const i=Me;if(!i)throw new Oe("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const a=await i(t,o),c="boolean"==typeof a.ok?a.ok:a.status>=200&&a.status<300,l="number"==typeof a.status?a.status:0;if(!c)throw new Oe(`HTTP ${l}`,"HTTP_ERROR");return"function"==typeof a.json?await a.json():void 0!==a.data?a.data:a}}class Re extends Ne{constructor(e,t){super(e,t),this.storageKey=e.source.replace("localStorage:",""),this.defaultValue=e.default,this.sync=!1!==e.sync,this.sync&&"undefined"!=typeof window&&(this._storageHandler=e=>{e.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(null===t)return this.defaultValue;try{return JSON.parse(t)}catch(e){return t}}catch(t){return this.defaultValue}}setValue(e){const t="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(this.storageKey,t),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class Te extends Ne{constructor(e,t){super(e,t),this.paramName=e.source.replace("route:","")}async fetch(){if("undefined"==typeof window)return"";const e=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));if(e)return decodeURIComponent(e[1]);return new URLSearchParams(location.search).get(this.paramName)||""}}class Ie extends Ne{async fetch(e){return await this.config.source(e)}}class je extends Ne{async fetch(){return this.config.source}}class Fe extends Ne{constructor(e,t){super(e,t),this.ws=null,this.reconnect=!1!==e.reconnect,this.reconnectDelay=e.reconnectDelay||3e3,this._reconnectAttempt=0,this._maxReconnectDelay=e.maxReconnectDelay||3e4,this.messageHandler=null,this._connected=!1,this._destroyed=!1}async fetch(){return new Promise((e,t)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,this._reconnectAttempt=0,e(this.cache.getStale(this.cacheKey))},this.messageHandler=e=>{let t;try{t=JSON.parse(e.data)}catch(r){t=e.data}this.cache.set(this.cacheKey,t,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=e=>{this._connected||t(new Oe("WebSocket connection failed","WS_ERROR",e))},this.ws.onclose=()=>{if(this._connected=!1,this.reconnect&&!this._destroyed){const e=this.reconnectDelay*Math.pow(2,this._reconnectAttempt),t=Math.random()*e*.3,r=Math.min(e+t,this._maxReconnectDelay);this._reconnectAttempt++,setTimeout(()=>{this._destroyed||this.fetch().catch(()=>{})},r)}}}catch(r){t(new Oe("WebSocket creation failed","WS_ERROR",r))}})}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("string"==typeof e?e:JSON.stringify(e))}destroy(){this._destroyed=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function He(e,t){const r=e.source;return"function"==typeof r?new Ie(e,t):"string"==typeof r&&(r.startsWith("ws://")||r.startsWith("wss://"))?new Fe(e,t):"string"==typeof r&&(r.startsWith("/")||r.startsWith("http"))?new Pe(e,t):"string"==typeof r&&r.startsWith("localStorage:")?new Re(e,t):"string"==typeof r&&r.startsWith("route:")?new Te(e,t):new je(e,t)}function Ke(e){const t={};for(const r in e){const n=e[r];t[r]=n&&"object"==typeof n&&"value"in n?n.value:n}return t}exports.BRAND_OPTIONS=ce,exports.CacheEntry=$e,exports.CacheManager=Le,exports.ComponentInitializerRegistry=ye,exports.DependsError=Oe,exports.DependsSource=Ne,exports.FetchedSource=Pe,exports.FunctionSource=Ie,exports.GlobalEvents=Ce,exports.KupolaComponent=we,exports.KupolaComponentRegistry=_e,exports.KupolaDataBind=K,exports.KupolaEventBus=q,exports.KupolaI18n=Ee,exports.KupolaLifecycle=e,exports.KupolaStore=U,exports.KupolaStoreManager=z,exports.KupolaUtils=R,exports.RouteSource=Te,exports.Scheduler=Ae,exports.StaticSource=je,exports.StorageSource=Re,exports.WebSocketSource=Fe,exports.applyMixin=ve,exports.arrayUtils=i,exports.bootstrapComponents=function(e){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(e):Promise.resolve()},exports.clearCache=function(){},exports.configureHttpClient=function(e){if(!e||"function"!=typeof e.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");Me=e.fetch.bind(e)},exports.createBrandPicker=function(){const e=document.createElement("div");e.id="brand-picker-auto",e.style.position="fixed",e.style.top="56px",e.style.right="16px",e.style.zIndex="9998",e.style.display="none",e.style.padding="12px",e.style.width="200px",e.style.gridTemplateColumns="repeat(3, 1fr)",e.style.gap="6px",e.style.backgroundColor="var(--bg-base-secondary)",e.style.border="1px solid var(--border-neutral-l1)",e.style.borderRadius="8px",e.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",e.style.overflow="hidden",ce.forEach(t=>{const r=document.createElement("button");r.setAttribute("data-brand-btn",t.id),r.style.display="flex",r.style.justifyContent="center",r.style.alignItems="center",r.style.height="60px",r.style.backgroundColor=t.color,r.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.color)?"#0C0C0D":"#FFFFFF",r.style.fontWeight="500",r.style.borderRadius="4px",r.style.border="none",r.style.cursor="pointer",r.style.margin="0",r.style.padding="0",r.textContent=t.name,e.appendChild(r)}),document.body.appendChild(e);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",he()),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 r=document.createElement("span");r.className="brand-icon",r.style.width="12px",r.style.height="12px",r.style.borderRadius="50%",r.style.backgroundColor=ce.find(e=>e.id===he()).color;const n=document.createElement("span");function s(r){e.contains(r.target)||t.contains(r.target)||(e.style.display="none",document.removeEventListener("click",s,!0))}return n.className="brand-name",n.style.fontSize="11px",n.textContent=ce.find(e=>e.id===he()).name,t.appendChild(r),t.appendChild(n),document.body.appendChild(t),t.onclick=function(t){t.stopPropagation(),t.preventDefault();const r="none"===e.style.display;e.style.display=r?"grid":"none",r?setTimeout(()=>{document.addEventListener("click",s,!0)},0):document.removeEventListener("click",s,!0)},e.onclick=function(e){e.stopPropagation()},e.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",r=>{r.stopPropagation();de(t.getAttribute("data-brand-btn")),e.style.display="none"})}),{toggleBtn:t,container:e}},exports.createI18n=function(e){return new Ee(e)},exports.createLifecycle=function(t="app"){return new e(t)},exports.createSource=He,exports.createStore=function(e,t){return Y.createStore(e,t)},exports.createThemeToggle=function(){const e=document.createElement("button");e.setAttribute("data-theme-toggle",""),e.setAttribute("data-current-theme",le()),e.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",e.style.position="fixed",e.style.top="16px",e.style.right="16px",e.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const r=te();return t.src="dark"===le()?r+"sun.svg":r+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",e.appendChild(t),document.body.appendChild(e),e.onclick=function(e){e.preventDefault();ue("dark"===le()?"light":"dark")},e},exports.cryptoUtils=$,exports.dateUtils=w,exports.debounce=v,exports.defineComponent=function(e,t){if(!t||"object"!=typeof t)throw new Error(`defineComponent("${e}"): options must be an object`);t.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(e,t.componentClass):t.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(e,t.lazy),t.init?ge.register(e,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&ge.register(e,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})},exports.defineMixin=function(e,t){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(e,t)},exports.emit=function(e,t,r){return ke.emit(e,t,r)},exports.emitGlobal=function(e,t){return ke.emitGlobal(e,t)},exports.escapeHtml=function(e){if("string"!=typeof e)return e;const t=document.createElement("div");return t.textContent=e,t.innerHTML},exports.formatCurrency=function(e,t,r={}){return Se.formatCurrency(e,t,r)},exports.formatDate=function(e,t={}){return Se.formatDate(e,t)},exports.formatNumber=function(e,t={}){return Se.formatNumber(e,t)},exports.generateSecureId=function(e,t){const r=se(),n=r?.secureId||{},s=e||n.length||16,o=n.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if("undefined"==typeof crypto||!crypto.getRandomValues){let e="";for(let t=0;t<s;t++)e+=o[Math.floor(Math.random()*o.length)];return t?`${t}_${e}`:e}const i=new Uint32Array(s);crypto.getRandomValues(i);let a="";for(let c=0;c<s;c++)a+=o[i[c]%o.length];return t?`${t}_${a}`:a},exports.getBasePath=function(){return Q.paths.base},exports.getBrand=he,exports.getConfig=ee,exports.getDefaultBrand=ne,exports.getDefaultTheme=re,exports.getHttpClient=function(){return Me},exports.getHttpConfig=function(){return Q.http},exports.getIconsPath=te,exports.getListenerCount=function(e,t){return ke.getListenerCount(e,t)},exports.getLocale=function(){return Se.getLocale()},exports.getMessageConfig=function(){return Q.message},exports.getNotificationConfig=function(){return Q.notification},exports.getPerformanceConfig=function(){return Q.performance},exports.getSecurityConfig=se,exports.getStore=function(e){return Y.getStore(e)},exports.getTheme=le,exports.getUiConfig=function(){return Q.ui},exports.getValidationConfig=function(){return Q.validation},exports.getZIndexConfig=function(){return Q.zIndex},exports.globalEvents=ke,exports.initTheme=me,exports.kupolaBootstrap=xe,exports.kupolaData=W,exports.kupolaEvents=J,exports.kupolaI18n=Se,exports.kupolaInitializer=ge,exports.kupolaLifecycle=t,exports.kupolaStoreManager=Y,exports.maskData=function(e,t,r={}){const n=se(),s=n?.maskData||{};if(!s.enabled&&!r.force)return e;if(null==e)return e;const o=(r.patterns||s.patterns||{})[t];if(!o)return e;const i="string"==typeof o.regex?new RegExp(o.regex):o.regex;return String(e).replace(i,o.replace)},exports.n=function(e,t,r={}){return Se.n(e,t,r)},exports.numberUtils=d,exports.objectUtils=c,exports.off=function(e,t,r){ke.off(e,t,r)},exports.offAll=function(e,t){ke.offAll(e,t)},exports.offByScope=function(e){ke.offByScope(e)},exports.offConfigChange=function(e){const t=V.indexOf(e);t>-1&&V.splice(t,1)},exports.on=function(e,t,r,n){return ke.on(e,t,r,n)},exports.onConfigChange=X,exports.once=function(e,t,r,n){return ke.once(e,t,r,n)},exports.preloadUtils=P,exports.ref=B,exports.registerComponent=function(e,t){exports.kupolaRegistry&&exports.kupolaRegistry.register(e,t)},exports.registerLazyComponent=function(e,t){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(e,t)},exports.resetHttpClient=function(){Me="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null},exports.sanitizeHtml=function(e,t={}){const r=se(),n=r?.sanitizeHtml||{};if(!n.enabled&&!t.force)return e;const s=t.allowedTags||n.allowedTags||[],o=t.allowedAttributes||n.allowedAttributes||{};if("string"!=typeof e)return e;const i=(new DOMParser).parseFromString(e,"text/html");return i.body.querySelectorAll("*").forEach(e=>{const t=e.tagName.toLowerCase();s.includes(t)?Array.from(e.attributes).forEach(r=>{const n=r.name.toLowerCase();(o[t]||[]).includes(n)||e.removeAttribute(r.name)}):e.remove()}),i.body.innerHTML},exports.setBrand=de,exports.setConfig=function(e){oe(Q,e),G()},exports.setLocale=function(e){return Se.setLocale(e)},exports.setTheme=ue,exports.stringUtils=s,exports.stripHtml=function(e){return"string"!=typeof e?e:(new DOMParser).parseFromString(e,"text/html").body.textContent||""},exports.t=function(e,t={}){return Se.t(e,t)},exports.throttle=_,exports.useDeps=function(e,t){const r={},n=new Le,s=[];for(const o in t){let i=function(){return Ke(e)},a=t[o];"string"==typeof a&&(a={source:a});const c=He({...a,cacheKey:a.cacheKey||`${o}-${JSON.stringify(Ke(e))}`},n),l=B(null),u=B(!0),h=B(null),d=B(null);let p=0;async function f(){const e=++p;u.value=!0,h.value=null;try{const t=await c.getValue(i());if(e!==p)return;l.value=t,d.value=Date.now()}catch(t){if(e!==p)return;h.value=t.message||"Unknown error"}finally{e===p&&(u.value=!1)}}f();const m=c.subscribe(()=>{const e=n.getStale(c.cacheKey);null!=e&&(l.value=e,d.value=Date.now())});s.push(m);const y=Object.keys(e);y.length>0&&y.forEach(t=>{const r=e[t];if(r&&"object"==typeof r&&"value"in r&&r._subscribers){const e=()=>{c.invalidate(),f()};r._subscribers.add(e),s.push(()=>r._subscribers.delete(e))}}),r[o]={data:l,loading:u,error:h,lastUpdated:d,refresh:()=>(c.invalidate(),f()),setValue(e){c instanceof Re&&(c.setValue(e),l.value=e)},send(e){c instanceof Fe&&c.send(e)},_source:c}}return r._dispose=()=>{if(s.forEach(e=>e()),window.__kupolaDepInstances){const e=window.__kupolaDepInstances.indexOf(r);-1!==e&&window.__kupolaDepInstances.splice(e,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(r),r},exports.useMixin=function(e,...t){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(e,...t)},exports.useQuery=function(e){const t=new Le,r=He(e,t),n=B(null),s=B(!0),o=B(null);let i=0;async function a(){const t=++i;s.value=!0,o.value=null;try{const s=await r.getValue(e.params||{});if(t!==i)return;n.value=s}catch(a){if(t!==i)return;o.value=a.message||"Unknown error"}finally{t===i&&(s.value=!1)}}return a(),r.subscribe(()=>{const e=t.getStale(r.cacheKey);null!=e&&(n.value=e)}),{data:n,loading:s,error:o,refresh:()=>(r.invalidate(),a())}},exports.validatorUtils=D;
|