@kupola/kupola 1.6.3 → 1.6.4

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.
@@ -1,9 +1,9 @@
1
- (function(h,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(h=typeof globalThis<"u"?globalThis:h||self,F(h.Kupola={}))})(this,function(h){"use strict";class F{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(i=>{i.resolved=!1})}on(t,e,i={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:i.priority||0,depends:i.depends||[],name:i.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 i of t){const r=this.hooks.get(e).find(a=>a.name===i);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const i=this.hooks.get(t);if(!i||i.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 l of i){await this._resolveDepends(l.depends,t);const o=performance.now();let c,d;try{c=l.handler(...e),c instanceof Promise&&await c,l.resolved=!0}catch(p){d=p,console.error(`[KupolaLifecycle] Error in ${t} hook "${l.name}":`,p),t!=="error"&&await this._handleError({phase:t,hook:l.name,error:p,args:e})}const u=performance.now()-o;this.trace.push({emitId:n,phase:t,hookName:l.name,duration:u,status:d?"error":"success",error:d?d.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 i=this.phaseStateMap[t];if(i){if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${i.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),i&&this._updateState(i.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(i){console.error("[KupolaLifecycle] Error in onError callback:",i)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const i of e)try{const n=i.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${i.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${i.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ui=new F("app");function Yi(s="app"){return new F(s)}const Xi=new Set(["__proto__","prototype","constructor"]);function tt(s){return Xi.has(s)}function ji(s){return s?s.trim():""}function Ji(s){return s?s.replace(/^\s+/,""):""}function Zi(s){return s?s.replace(/\s+$/,""):""}function Gi(s){return s?s.toUpperCase():""}function Qi(s){return s?s.toLowerCase():""}function ts(s){return s?s.charAt(0).toUpperCase()+s.slice(1):""}function es(s){return s?s.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function is(s){return s?s.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function ss(s,t,e=" "){return(String(s)||"").padStart(t,e)}function ns(s,t,e=" "){return(String(s)||"").padEnd(t,e)}function rs(s,t,e="..."){return!s||s.length<=t?s||"":s.slice(0,t)+e}function as(s,t,e){return s?s.split(t).join(e):""}function ls(s,t){return s?s.replace(/\{\{(\w+)\}\}/g,(e,i)=>t[i]!==void 0?t[i]:`{{${i}}}`):""}function os(s,t){return(s||"").startsWith(t)}function cs(s,t){return(s||"").endsWith(t)}function hs(s,t){return(s||"").includes(t)}function ds(s,t){return(s||"").repeat(t)}function us(s){return(s||"").split("").reverse().join("")}function ps(s,t){return!s||!t?0:s.split(t).length-1}function fs(s){if(!s)return"";const t=document.createElement("div");return t.textContent=s,t.innerHTML}function ms(s){if(!s)return"";const t=document.createElement("div");return t.innerHTML=s,t.textContent}function gs(s=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let i=0;i<s;i++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function _s(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}const Yt={trim:ji,trimLeft:Ji,trimRight:Zi,toUpperCase:Gi,toLowerCase:Qi,capitalize:ts,camelize:es,hyphenate:is,padStart:ss,padEnd:ns,truncate:rs,replaceAll:as,format:ls,startsWith:os,endsWith:cs,includes:hs,repeat:ds,reverse:us,countOccurrences:ps,escapeHtml:fs,unescapeHtml:ms,generateRandom:gs,generateUUID:_s};function ys(s){return Array.isArray(s)}function vs(s){return!s||s.length===0}function bs(s){return s?s.length:0}function Es(s,t){return s&&s.length>0?s[0]:t}function ks(s,t){return s&&s.length>0?s[s.length-1]:t}function ws(s,t,e){return s&&s[t]!==void 0?s[t]:e}function xs(s,t,e){return s?s.slice(t,e):[]}function Cs(...s){return s.reduce((t,e)=>t.concat(e||[]),[])}function Ss(s,t=","){return s?s.join(t):""}function Ls(s,t,e=0){if(!s)return-1;if(Number.isNaN(t)){for(let i=e;i<s.length;i++)if(Number.isNaN(s[i]))return i;return-1}return s.indexOf(t,e)}function Ds(s,t,e){if(!s)return-1;if(Number.isNaN(t)){const i=e!==void 0?e:s.length-1;for(let n=i;n>=0;n--)if(Number.isNaN(s[n]))return n;return-1}return s.lastIndexOf(t,e)}function Hs(s,t){return s?s.includes(t):!1}function Ms(s,...t){return s&&s.push(...t),s}function Ts(s){return s?s.pop():void 0}function Is(s){return s?s.shift():void 0}function As(s,...t){return s&&s.unshift(...t),s}function zs(s,t){if(!s)return s;const e=Number.isNaN(t)?s.findIndex(i=>Number.isNaN(i)):s.indexOf(t);return e>-1&&s.splice(e,1),s}function Ps(s,t){return!s||t<0||t>=s.length||s.splice(t,1),s}function $s(s,t,e){return s&&(s.splice(t,0,e),s)}function Bs(s){return s?s.slice().reverse():[]}function qs(s,t){return s?s.slice().sort(t):[]}function Os(s,t,e="asc"){return s?s.slice().sort((i,n)=>{const r=typeof i=="object"?i[t]:i,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function Fs(s,t){return s?s.filter(t):[]}function Ns(s,t){return s?s.map(t):[]}function Rs(s,t,e){return s?s.reduce(t,e):e}function Vs(s,t){s&&s.forEach(t)}function Ks(s,t){return s?s.every(t):!0}function Ws(s,t){return s?s.some(t):!1}function Us(s,t){return s?s.find(t):void 0}function Ys(s,t){return s?s.findIndex(t):-1}function Xs(s,t=1){return s?s.flat(t):[]}function Xt(s){return s?s.reduce((t,e)=>Array.isArray(e)?t.concat(Xt(e)):t.concat(e),[]):[]}function js(s){return s?[...new Set(s)]:[]}function Js(s,t){if(!s)return[];const e=new Set;return s.filter(i=>{const n=typeof i=="object"?i[t]:i;return e.has(n)?!1:(e.add(n),!0)})}function Zs(s,t){if(!s||t<=0)return[];const e=[];for(let i=0;i<s.length;i+=t)e.push(s.slice(i,i+t));return e}function Gs(s){if(!s)return[];const t=s.slice();for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t}function jt(s){return s?s.reduce((t,e)=>t+(Number(e)||0),0):0}function Qs(s){return!s||s.length===0?0:jt(s)/s.length}function tn(s){return s&&s.length>0?Math.max(...s):-1/0}function en(s){return s&&s.length>0?Math.min(...s):1/0}function sn(...s){return s.length===0?[]:s.reduce((t,e)=>t.filter(i=>e&&e.includes(i)))}function nn(...s){return[...new Set(s.flat().filter(Boolean))]}function rn(s,t){return s?s.filter(e=>!t||!t.includes(e)):[]}function an(...s){if(s.length===0)return[];const t=Math.max(...s.map(e=>e?e.length:0));return Array.from({length:t},(e,i)=>s.map(n=>n&&n[i]))}const Jt={isArray:ys,isEmpty:vs,size:bs,first:Es,last:ks,get:ws,slice:xs,concat:Cs,join:Ss,indexOf:Ls,lastIndexOf:Ds,includes:Hs,push:Ms,pop:Ts,shift:Is,unshift:As,remove:zs,removeAt:Ps,insert:$s,reverse:Bs,sort:qs,sortBy:Os,filter:Fs,map:Ns,reduce:Rs,forEach:Vs,every:Ks,some:Ws,find:Us,findIndex:Ys,flat:Xs,flattenDeep:Xt,unique:js,uniqueBy:Js,chunk:Zs,shuffle:Gs,sum:jt,average:Qs,max:tn,min:en,intersection:sn,union:nn,difference:rn,zip:an};function ht(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function ln(s){return!s||typeof s!="object"?!0:Object.keys(s).length===0}function on(s){return s?Object.keys(s):[]}function cn(s){return s?Object.values(s):[]}function hn(s){return s?Object.entries(s):[]}function dn(s,t){return s?Object.prototype.hasOwnProperty.call(s,t):!1}function un(s,t,e){if(!s)return e;const i=t.split(".");return i.some(tt)?e:i.reduce((n,r)=>n&&n[r],s)??e}function pn(s,t,e){if(!s||typeof s!="object")return s;const i=t.split(".");if(i.some(tt))return s;const n=i.pop();let r=s;return i.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,s}function fn(s,t){return s?t.reduce((e,i)=>(s[i]!==void 0&&(e[i]=s[i]),e),{}):{}}function mn(s,t){return s?Object.keys(s).reduce((e,i)=>(t.includes(i)||(e[i]=s[i]),e),{}):{}}function Zt(...s){return s.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(i=>{tt(i)||(ht(e[i])&&ht(t[i])?t[i]=Zt(t[i],e[i]):t[i]=e[i])}),t),{})}function gn(s){return s&&JSON.parse(JSON.stringify(s))}function J(s,t=new WeakMap){if(!s||typeof s!="object")return s;if(t.has(s))return t.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const i=new Map;return t.set(s,i),s.forEach((n,r)=>i.set(r,J(n,t))),i}if(s instanceof Set){const i=new Set;return t.set(s,i),s.forEach(n=>i.add(J(n,t))),i}if(Array.isArray(s)){const i=[];return t.set(s,i),s.forEach(n=>i.push(J(n,t))),i}const e={};return t.set(s,e),Object.keys(s).forEach(i=>{tt(i)||(e[i]=J(s[i],t))}),e}function _n(s,t){s&&Object.keys(s).forEach(e=>t(s[e],e,s))}function yn(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{e[i]=t(s[i],i,s)}),e}function vn(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{t(s[i],i,s)&&(e[i]=s[i])}),e}function bn(s,t,e){return s?Object.keys(s).reduce((i,n)=>t(i,s[n],n,s),e):e}function En(s){return s?Object.keys(s).map(t=>({key:t,value:s[t]})):[]}function kn(s,t,e){return s?s.reduce((i,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(i[r]=a),i},{}):{}}function wn(s){return s?Object.keys(s).length:0}function xn(s){if(!s)return{};const t={};return Object.keys(s).forEach(e=>{t[s[e]]=e}),t}function Gt(s,t){if(s===t)return!0;if(!s||!t||typeof s!="object"||typeof t!="object")return!1;const e=Object.keys(s),i=Object.keys(t);return e.length!==i.length?!1:e.every(n=>Gt(s[n],t[n]))}function Qt(s){return s&&(Object.freeze(s),Object.keys(s).forEach(t=>{typeof s[t]=="object"&&Qt(s[t])}),s)}function Cn(s){return s&&Object.seal(s)}const te={isObject:ht,isEmpty:ln,keys:on,values:cn,entries:hn,has:dn,get:un,set:pn,pick:fn,omit:mn,merge:Zt,clone:gn,deepClone:J,forEach:_n,map:yn,filter:vn,reduce:bn,toArray:En,fromArray:kn,size:wn,invert:xn,isEqual:Gt,freeze:Qt,seal:Cn};function D(s){return typeof s=="number"&&!isNaN(s)}function Sn(s){return Number.isInteger(s)}function Ln(s){return D(s)&&!Number.isInteger(s)}function Dn(s){return D(s)&&s>0}function Hn(s){return D(s)&&s<0}function Mn(s){return D(s)&&s===0}function Tn(s,t,e){return D(s)?Math.min(Math.max(s,t),e):s}function In(s,t=0){if(!D(s))return s;const e=Math.pow(10,t);return Math.round(s*e)/e}function An(s){return D(s)?Math.floor(s):s}function zn(s){return D(s)?Math.ceil(s):s}function Pn(s){return D(s)?Math.abs(s):s}function $n(...s){const t=s.filter(D);return t.length>0?Math.min(...t):void 0}function Bn(...s){const t=s.filter(D);return t.length>0?Math.max(...t):void 0}function ee(...s){return s.flat().filter(D).reduce((e,i)=>e+i,0)}function qn(...s){const t=s.flat().filter(D);return t.length>0?ee(t)/t.length:0}function ie(s=0,t=1){return Math.random()*(t-s)+s}function On(s,t){return Math.floor(ie(s,t+1))}function Fn(s,t=2){return D(s)?s.toFixed(t):String(s)}function Nn(s,t="CNY",e=2){return D(s)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(s):String(s)}function Rn(s,t=0){return D(s)?`${(s*100).toFixed(t)}%`:String(s)}function Vn(s,t=0){return D(s)?s.toFixed(t):String(s)}function Kn(s,t=6){return D(s)?s.toPrecision(t):String(s)}function Wn(s){return Number.isNaN(s)}function Un(s){return Number.isFinite(s)}function Yn(s,t=10){return Number.parseInt(s,t)}function Xn(s){return Number.parseFloat(s)}function jn(s,t=0){const e=Number(s);return isNaN(e)?t:e}function Jn(s,t,e=0){return!D(s)||!D(t)||t===0?e:s/t}function Zn(...s){return s.reduce((t,e)=>!D(t)||!D(e)?0:t*e,1)}const se={isNumber:D,isInteger:Sn,isFloat:Ln,isPositive:Dn,isNegative:Hn,isZero:Mn,clamp:Tn,round:In,floor:An,ceil:zn,abs:Pn,min:$n,max:Bn,sum:ee,average:qn,random:ie,randomInt:On,format:Fn,formatCurrency:Nn,formatPercent:Rn,toFixed:Vn,toPrecision:Kn,isNaN:Wn,isFinite:Un,parseInt:Yn,parseFloat:Xn,toNumber:jn,safeDivide:Jn,safeMultiply:Zn};function et(){return Date.now()}function W(){const s=new Date;return s.setHours(0,0,0,0),s}function Gn(){const s=W();return s.setDate(s.getDate()+1),s}function Qn(){const s=W();return s.setDate(s.getDate()-1),s}function x(s){return s instanceof Date&&!isNaN(s.getTime())}function ne(s){return x(s)}function tr(s){const t=new Date(s);return ne(t)?t:null}function er(s,t="YYYY-MM-DD HH:mm:ss"){if(!x(s))return"";const e=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),r=String(s.getHours()).padStart(2,"0"),a=String(s.getMinutes()).padStart(2,"0"),l=String(s.getSeconds()).padStart(2,"0"),o=String(s.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][s.getDay()];return t.replace("YYYY",e).replace("MM",i).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",s.getDate()).replace("M",s.getMonth()+1).replace("H",s.getHours()).replace("m",s.getMinutes()).replace("s",s.getSeconds()).replace("W",d)}function ir(s){return x(s)?s.toISOString():""}function sr(s){return x(s)?new Date(s.toUTCString()):null}function nr(s,t){if(!x(s))return s;const e=new Date(s);return e.setDate(e.getDate()+t),e}function rr(s,t){if(!x(s))return s;const e=new Date(s);return e.setHours(e.getHours()+t),e}function ar(s,t){if(!x(s))return s;const e=new Date(s);return e.setMinutes(e.getMinutes()+t),e}function lr(s,t){if(!x(s))return s;const e=new Date(s);return e.setSeconds(e.getSeconds()+t),e}function it(s,t){if(!x(s)||!x(t))return 0;const e=new Date(s);e.setHours(0,0,0,0);const i=new Date(t);return i.setHours(0,0,0,0),Math.floor((e.getTime()-i.getTime())/(1e3*60*60*24))}function or(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60*60))}function cr(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60))}function hr(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/1e3)}function dr(s){return x(s)?it(s,W())===0:!1}function ur(s){return x(s)?it(s,W())===-1:!1}function pr(s){return x(s)?it(s,W())===1:!1}function fr(s){return x(s)?s.getTime()>et():!1}function mr(s){return x(s)?s.getTime()<et():!1}function gr(s){if(!x(s))return!1;const t=s.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function _r(s){return x(s)?new Date(s.getFullYear(),s.getMonth()+1,0).getDate():0}function yr(s){if(!x(s))return 0;const t=new Date(s.getFullYear(),0,1),e=s.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function vr(s){return x(s)?Math.ceil((s.getMonth()+1)/3):0}function br(s){if(!x(s))return s;const t=new Date(s);return t.setHours(0,0,0,0),t}function Er(s){if(!x(s))return s;const t=new Date(s);return t.setHours(23,59,59,999),t}function kr(s){return x(s)?new Date(s.getFullYear(),s.getMonth(),1):s}function wr(s){return x(s)?new Date(s.getFullYear(),s.getMonth()+1,0,23,59,59,999):s}function re(s,t=1){if(!x(s))return s;const e=new Date(s),i=e.getDay(),n=i>=t?i-t:i+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function xr(s,t=1){if(!x(s))return s;const e=re(s,t),i=new Date(e);return i.setDate(i.getDate()+6),i.setHours(23,59,59,999),i}function Cr(s){if(!x(s))return 0;const t=new Date;let e=t.getFullYear()-s.getFullYear();return(t.getMonth()<s.getMonth()||t.getMonth()===s.getMonth()&&t.getDate()<s.getDate())&&e--,Math.max(0,e)}function Sr(s){if(!x(s))return"";const e=et()-s.getTime(),i=60*1e3,n=60*i,r=24*n,a=7*r,l=30*r,o=365*r;return e<i?"刚刚":e<n?`${Math.floor(e/i)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<l?`${Math.floor(e/a)}周前`:e<o?`${Math.floor(e/l)}个月前`:`${Math.floor(e/o)}年前`}const ae={now:et,today:W,tomorrow:Gn,yesterday:Qn,isDate:x,isValid:ne,parse:tr,format:er,toISO:ir,toUTC:sr,addDays:nr,addHours:rr,addMinutes:ar,addSeconds:lr,diffDays:it,diffHours:or,diffMinutes:cr,diffSeconds:hr,isToday:dr,isYesterday:ur,isTomorrow:pr,isFuture:fr,isPast:mr,isLeapYear:gr,getDaysInMonth:_r,getWeekOfYear:yr,getQuarter:vr,startOfDay:br,endOfDay:Er,startOfMonth:kr,endOfMonth:wr,startOfWeek:re,endOfWeek:xr,getAge:Cr,fromNow:Sr};function le(s,t,e={}){let i=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){s.apply(r,n)}function d(){a=Date.now(),l?(i=setTimeout(u,t),c()):i=setTimeout(u,t)}function u(){i=null,o&&n&&c(),n=null,r=null}function p(){return Math.max(0,t-(Date.now()-a))}return function(...m){n=m,r=this,a=Date.now(),i?(clearTimeout(i),i=setTimeout(u,p())):d()}}function oe(s,t,e={}){let i=!1;const n=e.trailing||!1;let r=null,a=null;function l(){s.apply(a,r),r=null,a=null}return function(...o){i?n&&(r=o,a=this):(i=!0,r=o,a=this,l(),setTimeout(()=>{i=!1,n&&r&&l()},t))}}function Lr(s){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s||"")}function Dr(s){return/^1[3-9]\d{9}$/.test(s||"")}function Hr(s){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(s||"")}function ce(s){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(s||"")}function he(s){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(s||"")}function Mr(s){return ce(s)||he(s)}function Tr(s){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(s||"")}function Ir(s){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(s||"")}function Ar(s){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=s.replace(/\s/g,"");if(!t.test(e))return!1;let i=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)),i+=a,n=!n}return i%10===0}function de(s){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(s||"")}function ue(s){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function pe(s){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(s||"");if(!t)return!1;const[,e,i,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(i)>=0&&parseInt(i)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function zr(s){return de(s)||ue(s)||pe(s)}function Pr(s){return!isNaN(new Date(s).getTime())}function $r(s){try{return JSON.parse(s),!0}catch{return!1}}function Br(s){return!s||s.trim()===""}function qr(s){return/^\s+$/.test(s||"")}function Or(s){return!isNaN(parseFloat(s))&&isFinite(s)}function Fr(s){return/^-?\d+$/.test(s||"")}function Nr(s){return/^-?\d+\.\d+$/.test(s||"")}function Rr(s){const t=parseFloat(s);return!isNaN(t)&&t>0}function Vr(s){const t=parseFloat(s);return!isNaN(t)&&t<0}function Kr(s){return/^[a-zA-Z]+$/.test(s||"")}function Wr(s){return/^[a-zA-Z0-9]+$/.test(s||"")}function Ur(s){return/^[\u4e00-\u9fa5]+$/.test(s||"")}function Yr(s,t,e){const i=(s||"").length;return i>=t&&(e===void 0||i<=e)}function Xr(s,t){return(s||"").length>=t}function jr(s,t){return(s||"").length<=t}function Jr(s,t){return t instanceof RegExp?t.test(s||""):!1}function Zr(s,t){return String(s)===String(t)}function fe(s,t){return(s||"").includes(t)}function Gr(s,t){return!fe(s,t)}function Qr(s){return Array.isArray(s)}function ta(s,t,e){const i=s?s.length:0;return i>=t&&(e===void 0||i<=e)}function ea(s,t){return s?s.length>=t:!1}function ia(s,t){return s?s.length<=t:!1}function sa(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function na(s,t){return!s||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(s,e))}function ra(s,t){const e={};return Object.keys(t).forEach(i=>{const n=s[i],r=t[i],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");dt[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,s);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[i]=a)}),{valid:Object.keys(e).length===0,errors:e}}const dt={isEmail:Lr,isPhone:Dr,isURL:Hr,isIPv4:ce,isIPv6:he,isIP:Mr,isIDCard:Tr,isPassport:Ir,isCreditCard:Ar,isHexColor:de,isRGB:ue,isRGBA:pe,isColor:zr,isDate:Pr,isJSON:$r,isEmpty:Br,isWhitespace:qr,isNumber:Or,isInteger:Fr,isFloat:Nr,isPositive:Rr,isNegative:Vr,isAlpha:Kr,isAlphaNumeric:Wr,isChinese:Ur,isLength:Yr,minLength:Xr,maxLength:jr,matches:Jr,equals:Zr,contains:fe,notContains:Gr,isArray:Qr,arrayLength:ta,arrayMinLength:ea,arrayMaxLength:ia,isObject:sa,hasKeys:na,validate:ra};function aa(s){const t=s?String(s):"",e=[1732584193,4023233417,2562383102,271733878],i=[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(u,p){return u<<p|u>>>32-p}function a(u){const p=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const m=p&4294967295,f=p>>>32&4294967295;for(let g=0;g<4;g++)u+=String.fromCharCode(m>>>8*g&255);for(let g=0;g<4;g++)u+=String.fromCharCode(f>>>8*g&255);return u}function l(u,p){const[m,f,g,v]=p,y=[];for(let L=0;L<16;L++)y[L]=u.charCodeAt(L*4)&255|(u.charCodeAt(L*4+1)&255)<<8|(u.charCodeAt(L*4+2)&255)<<16|(u.charCodeAt(L*4+3)&255)<<24;let E=m,k=f,b=g,S=v;for(let L=0;L<64;L++){let C,P;const $=Math.floor(L/16),M=L%16;$===0?(C=k&b|~k&S,P=M):$===1?(C=S&k|~S&b,P=(5*M+1)%16):$===2?(C=k^b^S,P=(3*M+5)%16):(C=b^(k|~S),P=7*M%16);const O=S;S=b,b=k,k=k+r(E+C+i[L]+y[P]&4294967295,n[$][L%4]),E=O}return[m+E&4294967295,f+k&4294967295,g+b&4294967295,v+S&4294967295]}const o=a(t);let c=[...e];for(let u=0;u<o.length;u+=64)c=l(o.substring(u,u+64),c);let d="";return c.forEach(u=>{for(let p=0;p<4;p++)d+=(u>>>8*p&255).toString(16).padStart(2,"0")}),d}function la(s){const t=s?String(s):"",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 i(c,d){return c>>>d|c<<32-d}function n(c){const d=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=d&4294967295,p=d>>>32&4294967295;for(let m=0;m<4;m++)c+=String.fromCharCode(p>>>8*m&255);for(let m=0;m<4;m++)c+=String.fromCharCode(u>>>8*m&255);return c}function r(c,d){const u=[];for(let b=0;b<16;b++)u[b]=c.charCodeAt(b*4)&255|(c.charCodeAt(b*4+1)&255)<<8|(c.charCodeAt(b*4+2)&255)<<16|(c.charCodeAt(b*4+3)&255)<<24;for(let b=16;b<64;b++){const S=i(u[b-15],7)^i(u[b-15],18)^u[b-15]>>>3,L=i(u[b-2],17)^i(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+S+u[b-7]+L&4294967295}let[p,m,f,g,v,y,E,k]=d;for(let b=0;b<64;b++){const S=i(v,6)^i(v,11)^i(v,25),L=v&y^~v&E,C=k+S+L+e[b]+u[b]&4294967295,P=i(p,2)^i(p,13)^i(p,22),$=p&m^p&f^m&f,M=P+$&4294967295;k=E,E=y,y=v,v=g+C&4294967295,g=f,f=m,m=p,p=C+M&4294967295}return[d[0]+p&4294967295,d[1]+m&4294967295,d[2]+f&4294967295,d[3]+g&4294967295,d[4]+v&4294967295,d[5]+y&4294967295,d[6]+E&4294967295,d[7]+k&4294967295]}const a=n(t);let l=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)l=r(a.substring(c,c+64),l);let o="";return l.forEach(c=>{for(let d=3;d>=0;d--)o+=(c>>>8*d&255).toString(16).padStart(2,"0")}),o}function oa(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;const n=s?s.split("").map(r=>r.charCodeAt(0)):[];for(;i<n.length;){const r=n[i++],a=n[i++]||0,l=n[i++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(i>n.length+1?"=":t[d])+(i>n.length?"=":t[u])}return e}function ca(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;for(s=s.replace(/[^A-Za-z0-9+/=]/g,"");i<s.length;){const n=t.indexOf(s.charAt(i++)),r=t.indexOf(s.charAt(i++)),a=t.indexOf(s.charAt(i++)),l=t.indexOf(s.charAt(i++)),o=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|l;e+=String.fromCharCode(o),a!==64&&(e+=String.fromCharCode(c)),l!==64&&(e+=String.fromCharCode(d))}return e}function ha(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}const me={md5:aa,sha256:la,base64Encode:oa,base64Decode:ca,uuid:ha},B=new Map;async function st(s,t={}){const{crossOrigin:e="anonymous"}=t;return B.has(s)?B.get(s):new Promise((i,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{B.set(s,r),i(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${s}`))},r.src=s})}async function da(s,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(s.map(n=>st(n,t)));const i=[];for(const n of s)i.push(await st(n,t));return i}async function ge(s,t={}){const{type:e="text/javascript",async:i=!0,defer:n=!1}=t;return B.has(s)?B.get(s):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=i,l.defer=n,l.onload=()=>{B.set(s,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${s}`))},l.src=s,document.head.appendChild(l)})}async function _e(s,t={}){const{media:e="all"}=t;return B.has(s)?B.get(s):new Promise((i,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=s,r.media=e,r.onload=()=>{B.set(s,r),i(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${s}`))},document.head.appendChild(r)})}async function ua(s,t,e={}){const{weight:i="normal",style:n="normal"}=e,r=new FontFace(s,`url(${t})`,{weight:i,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${s}`)}}async function pa(s,t="image"){switch(t){case"image":return st(s);case"script":return ge(s);case"stylesheet":case"style":return _e(s);default:throw new Error(`Unsupported preload type: ${t}`)}}function fa(s){return B.has(s)}function ma(){B.clear()}function ga(s){B.delete(s)}const ye={loadImage:st,loadImages:da,loadScript:ge,loadStylesheet:_e,loadFont:ua,preload:pa,isLoaded:fa,clearCache:ma,clearCacheByUrl:ga},_a={string:Yt,array:Jt,object:te,number:se,date:ae,debounce:le,throttle:oe,validator:dt,crypto:me,preload:ye};function ya(s){if(!s)return"";let t=String(s);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 i;do i=t,t=t.replace(e,"");while(t!==i);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 ve{constructor(){this.children={},this.keys=[]}}class ut{constructor(){this.root=new ve}insert(t){let e=this.root;const i=t.split(".");i.forEach((n,r)=>{e.children[n]||(e.children[n]=new ve),e=e.children[n],r===i.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const i=t.split("."),n=[];for(let r=0;r<i.length;r++){const a=i[r];if(!e.children[a])break;e=e.children[a];const l=o=>{o.keys.length>0&&n.push(...o.keys),Object.values(o.children).forEach(c=>l(c))};l(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),i=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");i.push(r)}return i}}const _={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 ut,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,i,n)=>{if(i==="__raw__")return e;const r=Reflect.get(e,i,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,i):r},set:(e,i,n,r)=>{const a=Reflect.get(e,i,r),l=Reflect.set(e,i,n,r),o=this.resolvePath(e,i);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,i)=>{const n=Reflect.get(e,i,receiver),r=Reflect.deleteProperty(e,i),a=this.resolvePath(e,i);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[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.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[_.path]?`${t[_.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,i)=>{t.add(i),this.updateElementsDirect(i,e),this.pathTrie.getSubKeys(i).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(i=>{this.updateElement(i,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,i=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{i||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,i||(this.notify(t,e,n),this.queueUpdate(t,e))),i||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,i)=>e?.[i],this.rawData)}setNested(t,e){const i=t.split("."),n=i.pop(),r=i.reduce((l,o)=>(l[o]||(l[o]={}),l[o]),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(i=>i!==e))}notify(t,e,i){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,i)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,i)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ya(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 d=e?"none":"";t.style.display!==d&&(t.style.display=d);break;case"class":o&&(e?t.classList.add(o):t.classList.remove(o));break;case"style":o&&t.style[o]!==String(e??"")&&(t.style[o]=e??"");break;case"attr":o&&t.getAttribute(o)!==String(e??"")&&t.setAttribute(o,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,i){this.computedProperties[t]={deps:e,callback:i},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const i=e.deps.map(r=>this.get(r)),n=e.callback(...i);this.set(t,n,!0)}catch(i){console.error(`Computed error for ${t}:`,i)}}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 ut,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:i="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=i==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:l});const c=this.get(t);c!==void 0&&this._persistSave(t,c,o,{version:r,encrypt:a,encryptionKey:l}),this.observe(t,d=>{const u=this.persistedKeys.get(t);u&&(u.debounce>0?(u.timeout&&clearTimeout(u.timeout),u.timeout=setTimeout(()=>{this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey})},u.debounce)):this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey}))})}_persistSave(t,e,i,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:l=null}=n,o={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(o);a&&l&&(c=this._encrypt(c,l)),this._ensureStorageCapacity(i),i.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&i===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(),i=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>i&&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(i){return console.warn("Decryption failed:",i),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:i=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 l=localStorage.getItem(r);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch(l){console.warn(`Failed to load persisted key ${a}:`,l)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=sessionStorage.getItem(r);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}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,i=this.snapshots[e];return i?(this.rawData=this._clone(i),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(i=>{const n=i.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(i.type==="checkbox"?(e[a]||(e[a]=[]),i.checked&&e[a].push(i.value)):i.type==="radio"?i.checked&&(e[a]=i.value):e[a]=i.value)}),e}fillForm(t,e){Object.keys(e).forEach(i=>{t.querySelectorAll('[data-bind*=":'+i+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[i])?e[i].includes(n.value):!!e[i]:n.type==="radio"?n.checked=n.value===e[i]:n.value=e[i]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.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(i=>{i.nodeType===Node.ELEMENT_NODE&&(i.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),i.hasAttribute&&i.hasAttribute("data-bind")&&this._bindElement(i))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const i=t.getAttribute("data-bind").split(":");i[0].split("|")[0].trim();const n=i[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 l=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,l):this.set(n,l)};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 i=e.__kupolaBindHandler;i&&(e.removeEventListener("input",i),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 ut,this.updateQueue.clear(),this.snapshots=[]}}class pt{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const i=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,i),this.state=q.data?.[this._stateKey]||q.createReactive(i,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=i,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 i=this.mutations[t];if(!i){console.warn(`Mutation ${t} not found in store ${this.name}`);return}i(this.state,e)}dispatch(t,e){const i=this.actions[t];if(!i){console.warn(`Action ${t} not found in store ${this.name}`);return}return i({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(i){console.error(`Observer error for store ${this.name}:`,i)}}),q&&q.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 Ee{constructor(){this.stores=new Map}createStore(t,e){const i=new pt(t,e);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof pt&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ke{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(i=>i!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(i=>{try{i(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(i=>{try{i(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const i=n=>{e(n),this.off(t,i)};return this.on(t,i),i}delegate(t,e,i){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:l})=>{(r.target.matches(a)||r.target.closest(a))&&l(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:i}),i}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(i=>i.selector!==t),this.delegatedEvents[e].length===0)){const i=this.eventListeners[e];i&&(document.removeEventListener(e,i),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 I(s=null){const t={_value:s,_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(i=>i(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new be,va=new ke,ft=new Ee;function ba(s,t){return ft.createStore(s,t)}function Ea(s){return ft.getStore(s)}const T={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}};function ka(s){He(T,s)}function nt(s){return s?Ca(T,s):T}function mt(){return T.paths.base+T.paths.icons.replace(/^\//,"")}function wa(){return T.paths.base}function we(){return T.theme.default}function xe(){return T.theme.brand}function xa(){return T.http}function U(){return T.ui}function Y(){return T.zIndex}function Z(){return T.security}function Ce(){return T.performance}function Se(){return T.message}function Le(){return T.notification}function De(){return T.validation}function He(s,t){for(const e in t)t[e]instanceof Object&&e in s&&s[e]instanceof Object?He(s[e],t[e]):s[e]=t[e];return s}function Ca(s,t){return t.split(".").reduce((e,i)=>(e&&e[i])!==void 0?e[i]:void 0,s)}const Me="kupola-theme",Te="kupola-brand",X=[{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 V(){return localStorage.getItem(Me)||we()}function rt(s){if(s!=="dark"&&s!=="light")return;document.documentElement.setAttribute("data-theme",s),localStorage.setItem(Me,s);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",s);const e=t.querySelector(".theme-icon");if(e){const i=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=s==="dark"?i+"sun.svg":i+"moon.svg"}}}function G(){return localStorage.getItem(Te)||xe()}function at(s){const t=X.find(n=>n.id===s);if(!t)return;document.documentElement.setAttribute("data-brand",s),localStorage.setItem(Te,s);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",s);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")===s?n.classList.add("is-active"):n.classList.remove("is-active")})}function Ie(s){const t=s.querySelector(".theme-icon");if(t){const e=V(),i=mt();t.src=e==="dark"?i+"sun.svg":i+"moon.svg"}}function Ae(){const s=V();rt(s);const t=G();at(t);const e=document.querySelector("[data-theme-toggle]");if(e){Ie(e);const l=e.onclick;e.onclick=function(o){o.preventDefault();const d=V()==="dark"?"light":"dark";rt(d),Ie(e),typeof l=="function"&&l.call(this,o)}}let i=document.getElementById("brand-picker");i||(i=document.createElement("div"),i.id="brand-picker",i.style.position="fixed",i.style.top="64px",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",X.forEach(l=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",l.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=l.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(l.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=l.name,i.appendChild(o)}),document.body.appendChild(i));const n=document.querySelector("[data-brand-toggle]");n&&i&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},i.onclick=function(l){l.stopPropagation()});function r(l){i&&n&&!i.contains(l.target)&&!n.contains(l.target)&&(i.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(l=>{l.addEventListener("click",o=>{o.stopPropagation();const c=l.getAttribute("data-brand-btn");at(c),i&&(i.style.display="none")})})}function Sa(){const s=document.createElement("button");s.setAttribute("data-theme-toggle",""),s.setAttribute("data-current-theme",V()),s.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",s.style.position="fixed",s.style.top="16px",s.style.right="16px",s.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=mt();return t.src=V()==="dark"?e+"sun.svg":e+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",s.appendChild(t),document.body.appendChild(s),s.onclick=function(i){i.preventDefault();const r=V()==="dark"?"light":"dark";rt(r)},s}function La(){const s=document.createElement("div");s.id="brand-picker-auto",s.style.position="fixed",s.style.top="56px",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",X.forEach(a=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",a.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=a.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.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=a.name,s.appendChild(l)}),document.body.appendChild(s);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",G()),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=X.find(a=>a.id===G()).color;const i=document.createElement("span");i.className="brand-name",i.style.fontSize="11px",i.textContent=X.find(a=>a.id===G()).name,t.appendChild(e),t.appendChild(i),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},s.onclick=function(a){a.stopPropagation()};function n(a){!s.contains(a.target)&&!t.contains(a.target)&&(s.style.display="none",document.removeEventListener("click",n,!0))}return s.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");at(o),s.style.display="none"})}),{toggleBtn:t,container:s}}function Da(s,t={}){const i=Z()?.sanitizeHtml||{};if(!i.enabled&&!t.force)return s;const n=t.allowedTags||i.allowedTags||[],r=t.allowedAttributes||i.allowedAttributes||{};if(typeof s!="string")return s;const l=new DOMParser().parseFromString(s,"text/html");return l.body.querySelectorAll("*").forEach(c=>{const d=c.tagName.toLowerCase();if(!n.includes(d)){c.remove();return}Array.from(c.attributes).forEach(u=>{const p=u.name.toLowerCase();(r[d]||[]).includes(p)||c.removeAttribute(u.name)})}),l.body.innerHTML}function Ha(s){if(typeof s!="string")return s;const t=document.createElement("div");return t.textContent=s,t.innerHTML}function Ma(s){return typeof s!="string"?s:new DOMParser().parseFromString(s,"text/html").body.textContent||""}function Ta(s,t,e={}){const n=Z()?.maskData||{};if(!n.enabled&&!e.force||s==null)return s;const a=(e.patterns||n.patterns||{})[t];if(!a)return s;const l=typeof a.regex=="string"?new RegExp(a.regex):a.regex;return String(s).replace(l,a.replace)}function Ia(s,t){const i=Z()?.secureId||{},n=s||i.length||16,r=i.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(typeof crypto>"u"||!crypto.getRandomValues){let o="";for(let c=0;c<n;c++)o+=r[Math.floor(Math.random()*r.length)];return t?`${t}_${o}`:o}const a=new Uint32Array(n);crypto.getRandomValues(a);let l="";for(let o=0;o<n;o++)l+=r[a[o]%r.length];return t?`${t}_${l}`:l}class ze{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,i=null,n={}){this.initializers.set(t,e),i&&this.cleanupFunctions.set(t,i),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 i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(i.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(e.includes(i)){const n=i.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(i);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(i.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(e.includes(i)){const n=i.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(i);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 i=t.querySelectorAll(e),n=[];i.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new ze,Aa=[{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 s of Aa)s.attr&&!w._dataAttrs.includes(s.attr)&&w._dataAttrs.push(s.attr),s.cls&&!w._cssClasses.includes(s.cls)&&w._cssClasses.push(s.cls);class Q{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 F,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const i=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[i]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(i=>{const n=i.getAttribute("data-slot")||"default";t[n]=i.innerHTML.trim(),i.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(i=>i!==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
+ (function(h,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(h=typeof globalThis<"u"?globalThis:h||self,F(h.Kupola={}))})(this,function(h){"use strict";class F{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(i=>{i.resolved=!1})}on(t,e,i={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:i.priority||0,depends:i.depends||[],name:i.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 i of t){const r=this.hooks.get(e).find(a=>a.name===i);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const i=this.hooks.get(t);if(!i||i.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 l of i){await this._resolveDepends(l.depends,t);const o=performance.now();let c,d;try{c=l.handler(...e),c instanceof Promise&&await c,l.resolved=!0}catch(p){d=p,console.error(`[KupolaLifecycle] Error in ${t} hook "${l.name}":`,p),t!=="error"&&await this._handleError({phase:t,hook:l.name,error:p,args:e})}const u=performance.now()-o;this.trace.push({emitId:n,phase:t,hookName:l.name,duration:u,status:d?"error":"success",error:d?d.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 i=this.phaseStateMap[t];if(i){if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${i.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),i&&this._updateState(i.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(i){console.error("[KupolaLifecycle] Error in onError callback:",i)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const i of e)try{const n=i.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${i.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${i.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ui=new F("app");function Yi(s="app"){return new F(s)}const Xi=new Set(["__proto__","prototype","constructor"]);function tt(s){return Xi.has(s)}function ji(s){return s?s.trim():""}function Ji(s){return s?s.replace(/^\s+/,""):""}function Zi(s){return s?s.replace(/\s+$/,""):""}function Gi(s){return s?s.toUpperCase():""}function Qi(s){return s?s.toLowerCase():""}function ts(s){return s?s.charAt(0).toUpperCase()+s.slice(1):""}function es(s){return s?s.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function is(s){return s?s.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function ss(s,t,e=" "){return(String(s)||"").padStart(t,e)}function ns(s,t,e=" "){return(String(s)||"").padEnd(t,e)}function rs(s,t,e="..."){return!s||s.length<=t?s||"":s.slice(0,t)+e}function as(s,t,e){return s?s.split(t).join(e):""}function ls(s,t){return s?s.replace(/\{\{(\w+)\}\}/g,(e,i)=>t[i]!==void 0?t[i]:`{{${i}}}`):""}function os(s,t){return(s||"").startsWith(t)}function cs(s,t){return(s||"").endsWith(t)}function hs(s,t){return(s||"").includes(t)}function ds(s,t){return(s||"").repeat(t)}function us(s){return(s||"").split("").reverse().join("")}function ps(s,t){return!s||!t?0:s.split(t).length-1}function fs(s){if(!s)return"";const t=document.createElement("div");return t.textContent=s,t.innerHTML}function ms(s){if(!s)return"";const t=document.createElement("div");return t.innerHTML=s,t.textContent}function gs(s=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let i=0;i<s;i++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function _s(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}const Yt={trim:ji,trimLeft:Ji,trimRight:Zi,toUpperCase:Gi,toLowerCase:Qi,capitalize:ts,camelize:es,hyphenate:is,padStart:ss,padEnd:ns,truncate:rs,replaceAll:as,format:ls,startsWith:os,endsWith:cs,includes:hs,repeat:ds,reverse:us,countOccurrences:ps,escapeHtml:fs,unescapeHtml:ms,generateRandom:gs,generateUUID:_s};function ys(s){return Array.isArray(s)}function vs(s){return!s||s.length===0}function bs(s){return s?s.length:0}function Es(s,t){return s&&s.length>0?s[0]:t}function ks(s,t){return s&&s.length>0?s[s.length-1]:t}function ws(s,t,e){return s&&s[t]!==void 0?s[t]:e}function xs(s,t,e){return s?s.slice(t,e):[]}function Cs(...s){return s.reduce((t,e)=>t.concat(e||[]),[])}function Ss(s,t=","){return s?s.join(t):""}function Ls(s,t,e=0){if(!s)return-1;if(Number.isNaN(t)){for(let i=e;i<s.length;i++)if(Number.isNaN(s[i]))return i;return-1}return s.indexOf(t,e)}function Ds(s,t,e){if(!s)return-1;if(Number.isNaN(t)){const i=e!==void 0?e:s.length-1;for(let n=i;n>=0;n--)if(Number.isNaN(s[n]))return n;return-1}return s.lastIndexOf(t,e)}function Hs(s,t){return s?s.includes(t):!1}function Ms(s,...t){return s&&s.push(...t),s}function Ts(s){return s?s.pop():void 0}function Is(s){return s?s.shift():void 0}function As(s,...t){return s&&s.unshift(...t),s}function zs(s,t){if(!s)return s;const e=Number.isNaN(t)?s.findIndex(i=>Number.isNaN(i)):s.indexOf(t);return e>-1&&s.splice(e,1),s}function Ps(s,t){return!s||t<0||t>=s.length||s.splice(t,1),s}function $s(s,t,e){return s&&(s.splice(t,0,e),s)}function Bs(s){return s?s.slice().reverse():[]}function qs(s,t){return s?s.slice().sort(t):[]}function Os(s,t,e="asc"){return s?s.slice().sort((i,n)=>{const r=typeof i=="object"?i[t]:i,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function Fs(s,t){return s?s.filter(t):[]}function Ns(s,t){return s?s.map(t):[]}function Rs(s,t,e){return s?s.reduce(t,e):e}function Vs(s,t){s&&s.forEach(t)}function Ks(s,t){return s?s.every(t):!0}function Ws(s,t){return s?s.some(t):!1}function Us(s,t){return s?s.find(t):void 0}function Ys(s,t){return s?s.findIndex(t):-1}function Xs(s,t=1){return s?s.flat(t):[]}function Xt(s){return s?s.reduce((t,e)=>Array.isArray(e)?t.concat(Xt(e)):t.concat(e),[]):[]}function js(s){return s?[...new Set(s)]:[]}function Js(s,t){if(!s)return[];const e=new Set;return s.filter(i=>{const n=typeof i=="object"?i[t]:i;return e.has(n)?!1:(e.add(n),!0)})}function Zs(s,t){if(!s||t<=0)return[];const e=[];for(let i=0;i<s.length;i+=t)e.push(s.slice(i,i+t));return e}function Gs(s){if(!s)return[];const t=s.slice();for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t}function jt(s){return s?s.reduce((t,e)=>t+(Number(e)||0),0):0}function Qs(s){return!s||s.length===0?0:jt(s)/s.length}function tn(s){return s&&s.length>0?Math.max(...s):-1/0}function en(s){return s&&s.length>0?Math.min(...s):1/0}function sn(...s){return s.length===0?[]:s.reduce((t,e)=>t.filter(i=>e&&e.includes(i)))}function nn(...s){return[...new Set(s.flat().filter(Boolean))]}function rn(s,t){return s?s.filter(e=>!t||!t.includes(e)):[]}function an(...s){if(s.length===0)return[];const t=Math.max(...s.map(e=>e?e.length:0));return Array.from({length:t},(e,i)=>s.map(n=>n&&n[i]))}const Jt={isArray:ys,isEmpty:vs,size:bs,first:Es,last:ks,get:ws,slice:xs,concat:Cs,join:Ss,indexOf:Ls,lastIndexOf:Ds,includes:Hs,push:Ms,pop:Ts,shift:Is,unshift:As,remove:zs,removeAt:Ps,insert:$s,reverse:Bs,sort:qs,sortBy:Os,filter:Fs,map:Ns,reduce:Rs,forEach:Vs,every:Ks,some:Ws,find:Us,findIndex:Ys,flat:Xs,flattenDeep:Xt,unique:js,uniqueBy:Js,chunk:Zs,shuffle:Gs,sum:jt,average:Qs,max:tn,min:en,intersection:sn,union:nn,difference:rn,zip:an};function ht(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function ln(s){return!s||typeof s!="object"?!0:Object.keys(s).length===0}function on(s){return s?Object.keys(s):[]}function cn(s){return s?Object.values(s):[]}function hn(s){return s?Object.entries(s):[]}function dn(s,t){return s?Object.prototype.hasOwnProperty.call(s,t):!1}function un(s,t,e){if(!s)return e;const i=t.split(".");return i.some(tt)?e:i.reduce((n,r)=>n&&n[r],s)??e}function pn(s,t,e){if(!s||typeof s!="object")return s;const i=t.split(".");if(i.some(tt))return s;const n=i.pop();let r=s;return i.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,s}function fn(s,t){return s?t.reduce((e,i)=>(s[i]!==void 0&&(e[i]=s[i]),e),{}):{}}function mn(s,t){return s?Object.keys(s).reduce((e,i)=>(t.includes(i)||(e[i]=s[i]),e),{}):{}}function Zt(...s){return s.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(i=>{tt(i)||(ht(e[i])&&ht(t[i])?t[i]=Zt(t[i],e[i]):t[i]=e[i])}),t),{})}function gn(s){return s&&JSON.parse(JSON.stringify(s))}function J(s,t=new WeakMap){if(!s||typeof s!="object")return s;if(t.has(s))return t.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const i=new Map;return t.set(s,i),s.forEach((n,r)=>i.set(r,J(n,t))),i}if(s instanceof Set){const i=new Set;return t.set(s,i),s.forEach(n=>i.add(J(n,t))),i}if(Array.isArray(s)){const i=[];return t.set(s,i),s.forEach(n=>i.push(J(n,t))),i}const e={};return t.set(s,e),Object.keys(s).forEach(i=>{tt(i)||(e[i]=J(s[i],t))}),e}function _n(s,t){s&&Object.keys(s).forEach(e=>t(s[e],e,s))}function yn(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{e[i]=t(s[i],i,s)}),e}function vn(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{t(s[i],i,s)&&(e[i]=s[i])}),e}function bn(s,t,e){return s?Object.keys(s).reduce((i,n)=>t(i,s[n],n,s),e):e}function En(s){return s?Object.keys(s).map(t=>({key:t,value:s[t]})):[]}function kn(s,t,e){return s?s.reduce((i,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(i[r]=a),i},{}):{}}function wn(s){return s?Object.keys(s).length:0}function xn(s){if(!s)return{};const t={};return Object.keys(s).forEach(e=>{t[s[e]]=e}),t}function Gt(s,t){if(s===t)return!0;if(!s||!t||typeof s!="object"||typeof t!="object")return!1;const e=Object.keys(s),i=Object.keys(t);return e.length!==i.length?!1:e.every(n=>Gt(s[n],t[n]))}function Qt(s){return s&&(Object.freeze(s),Object.keys(s).forEach(t=>{typeof s[t]=="object"&&Qt(s[t])}),s)}function Cn(s){return s&&Object.seal(s)}const te={isObject:ht,isEmpty:ln,keys:on,values:cn,entries:hn,has:dn,get:un,set:pn,pick:fn,omit:mn,merge:Zt,clone:gn,deepClone:J,forEach:_n,map:yn,filter:vn,reduce:bn,toArray:En,fromArray:kn,size:wn,invert:xn,isEqual:Gt,freeze:Qt,seal:Cn};function D(s){return typeof s=="number"&&!isNaN(s)}function Sn(s){return Number.isInteger(s)}function Ln(s){return D(s)&&!Number.isInteger(s)}function Dn(s){return D(s)&&s>0}function Hn(s){return D(s)&&s<0}function Mn(s){return D(s)&&s===0}function Tn(s,t,e){return D(s)?Math.min(Math.max(s,t),e):s}function In(s,t=0){if(!D(s))return s;const e=Math.pow(10,t);return Math.round(s*e)/e}function An(s){return D(s)?Math.floor(s):s}function zn(s){return D(s)?Math.ceil(s):s}function Pn(s){return D(s)?Math.abs(s):s}function $n(...s){const t=s.filter(D);return t.length>0?Math.min(...t):void 0}function Bn(...s){const t=s.filter(D);return t.length>0?Math.max(...t):void 0}function ee(...s){return s.flat().filter(D).reduce((e,i)=>e+i,0)}function qn(...s){const t=s.flat().filter(D);return t.length>0?ee(t)/t.length:0}function ie(s=0,t=1){return Math.random()*(t-s)+s}function On(s,t){return Math.floor(ie(s,t+1))}function Fn(s,t=2){return D(s)?s.toFixed(t):String(s)}function Nn(s,t="CNY",e=2){return D(s)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(s):String(s)}function Rn(s,t=0){return D(s)?`${(s*100).toFixed(t)}%`:String(s)}function Vn(s,t=0){return D(s)?s.toFixed(t):String(s)}function Kn(s,t=6){return D(s)?s.toPrecision(t):String(s)}function Wn(s){return Number.isNaN(s)}function Un(s){return Number.isFinite(s)}function Yn(s,t=10){return Number.parseInt(s,t)}function Xn(s){return Number.parseFloat(s)}function jn(s,t=0){const e=Number(s);return isNaN(e)?t:e}function Jn(s,t,e=0){return!D(s)||!D(t)||t===0?e:s/t}function Zn(...s){return s.reduce((t,e)=>!D(t)||!D(e)?0:t*e,1)}const se={isNumber:D,isInteger:Sn,isFloat:Ln,isPositive:Dn,isNegative:Hn,isZero:Mn,clamp:Tn,round:In,floor:An,ceil:zn,abs:Pn,min:$n,max:Bn,sum:ee,average:qn,random:ie,randomInt:On,format:Fn,formatCurrency:Nn,formatPercent:Rn,toFixed:Vn,toPrecision:Kn,isNaN:Wn,isFinite:Un,parseInt:Yn,parseFloat:Xn,toNumber:jn,safeDivide:Jn,safeMultiply:Zn};function et(){return Date.now()}function W(){const s=new Date;return s.setHours(0,0,0,0),s}function Gn(){const s=W();return s.setDate(s.getDate()+1),s}function Qn(){const s=W();return s.setDate(s.getDate()-1),s}function x(s){return s instanceof Date&&!isNaN(s.getTime())}function ne(s){return x(s)}function tr(s){const t=new Date(s);return ne(t)?t:null}function er(s,t="YYYY-MM-DD HH:mm:ss"){if(!x(s))return"";const e=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),r=String(s.getHours()).padStart(2,"0"),a=String(s.getMinutes()).padStart(2,"0"),l=String(s.getSeconds()).padStart(2,"0"),o=String(s.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][s.getDay()];return t.replace("YYYY",e).replace("MM",i).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",s.getDate()).replace("M",s.getMonth()+1).replace("H",s.getHours()).replace("m",s.getMinutes()).replace("s",s.getSeconds()).replace("W",d)}function ir(s){return x(s)?s.toISOString():""}function sr(s){return x(s)?new Date(s.toUTCString()):null}function nr(s,t){if(!x(s))return s;const e=new Date(s);return e.setDate(e.getDate()+t),e}function rr(s,t){if(!x(s))return s;const e=new Date(s);return e.setHours(e.getHours()+t),e}function ar(s,t){if(!x(s))return s;const e=new Date(s);return e.setMinutes(e.getMinutes()+t),e}function lr(s,t){if(!x(s))return s;const e=new Date(s);return e.setSeconds(e.getSeconds()+t),e}function it(s,t){if(!x(s)||!x(t))return 0;const e=new Date(s);e.setHours(0,0,0,0);const i=new Date(t);return i.setHours(0,0,0,0),Math.floor((e.getTime()-i.getTime())/(1e3*60*60*24))}function or(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60*60))}function cr(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60))}function hr(s,t){return!x(s)||!x(t)?0:Math.floor((s.getTime()-t.getTime())/1e3)}function dr(s){return x(s)?it(s,W())===0:!1}function ur(s){return x(s)?it(s,W())===-1:!1}function pr(s){return x(s)?it(s,W())===1:!1}function fr(s){return x(s)?s.getTime()>et():!1}function mr(s){return x(s)?s.getTime()<et():!1}function gr(s){if(!x(s))return!1;const t=s.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function _r(s){return x(s)?new Date(s.getFullYear(),s.getMonth()+1,0).getDate():0}function yr(s){if(!x(s))return 0;const t=new Date(s.getFullYear(),0,1),e=s.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function vr(s){return x(s)?Math.ceil((s.getMonth()+1)/3):0}function br(s){if(!x(s))return s;const t=new Date(s);return t.setHours(0,0,0,0),t}function Er(s){if(!x(s))return s;const t=new Date(s);return t.setHours(23,59,59,999),t}function kr(s){return x(s)?new Date(s.getFullYear(),s.getMonth(),1):s}function wr(s){return x(s)?new Date(s.getFullYear(),s.getMonth()+1,0,23,59,59,999):s}function re(s,t=1){if(!x(s))return s;const e=new Date(s),i=e.getDay(),n=i>=t?i-t:i+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function xr(s,t=1){if(!x(s))return s;const e=re(s,t),i=new Date(e);return i.setDate(i.getDate()+6),i.setHours(23,59,59,999),i}function Cr(s){if(!x(s))return 0;const t=new Date;let e=t.getFullYear()-s.getFullYear();return(t.getMonth()<s.getMonth()||t.getMonth()===s.getMonth()&&t.getDate()<s.getDate())&&e--,Math.max(0,e)}function Sr(s){if(!x(s))return"";const e=et()-s.getTime(),i=60*1e3,n=60*i,r=24*n,a=7*r,l=30*r,o=365*r;return e<i?"刚刚":e<n?`${Math.floor(e/i)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<l?`${Math.floor(e/a)}周前`:e<o?`${Math.floor(e/l)}个月前`:`${Math.floor(e/o)}年前`}const ae={now:et,today:W,tomorrow:Gn,yesterday:Qn,isDate:x,isValid:ne,parse:tr,format:er,toISO:ir,toUTC:sr,addDays:nr,addHours:rr,addMinutes:ar,addSeconds:lr,diffDays:it,diffHours:or,diffMinutes:cr,diffSeconds:hr,isToday:dr,isYesterday:ur,isTomorrow:pr,isFuture:fr,isPast:mr,isLeapYear:gr,getDaysInMonth:_r,getWeekOfYear:yr,getQuarter:vr,startOfDay:br,endOfDay:Er,startOfMonth:kr,endOfMonth:wr,startOfWeek:re,endOfWeek:xr,getAge:Cr,fromNow:Sr};function le(s,t,e={}){let i=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){s.apply(r,n)}function d(){a=Date.now(),l?(i=setTimeout(u,t),c()):i=setTimeout(u,t)}function u(){i=null,o&&n&&c(),n=null,r=null}function p(){return Math.max(0,t-(Date.now()-a))}return function(...m){n=m,r=this,a=Date.now(),i?(clearTimeout(i),i=setTimeout(u,p())):d()}}function oe(s,t,e={}){let i=!1;const n=e.trailing||!1;let r=null,a=null;function l(){s.apply(a,r),r=null,a=null}return function(...o){i?n&&(r=o,a=this):(i=!0,r=o,a=this,l(),setTimeout(()=>{i=!1,n&&r&&l()},t))}}function Lr(s){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s||"")}function Dr(s){return/^1[3-9]\d{9}$/.test(s||"")}function Hr(s){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(s||"")}function ce(s){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(s||"")}function he(s){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(s||"")}function Mr(s){return ce(s)||he(s)}function Tr(s){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(s||"")}function Ir(s){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(s||"")}function Ar(s){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=s.replace(/\s/g,"");if(!t.test(e))return!1;let i=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)),i+=a,n=!n}return i%10===0}function de(s){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(s||"")}function ue(s){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function pe(s){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(s||"");if(!t)return!1;const[,e,i,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(i)>=0&&parseInt(i)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function zr(s){return de(s)||ue(s)||pe(s)}function Pr(s){return!isNaN(new Date(s).getTime())}function $r(s){try{return JSON.parse(s),!0}catch{return!1}}function Br(s){return!s||s.trim()===""}function qr(s){return/^\s+$/.test(s||"")}function Or(s){return!isNaN(parseFloat(s))&&isFinite(s)}function Fr(s){return/^-?\d+$/.test(s||"")}function Nr(s){return/^-?\d+\.\d+$/.test(s||"")}function Rr(s){const t=parseFloat(s);return!isNaN(t)&&t>0}function Vr(s){const t=parseFloat(s);return!isNaN(t)&&t<0}function Kr(s){return/^[a-zA-Z]+$/.test(s||"")}function Wr(s){return/^[a-zA-Z0-9]+$/.test(s||"")}function Ur(s){return/^[\u4e00-\u9fa5]+$/.test(s||"")}function Yr(s,t,e){const i=(s||"").length;return i>=t&&(e===void 0||i<=e)}function Xr(s,t){return(s||"").length>=t}function jr(s,t){return(s||"").length<=t}function Jr(s,t){return t instanceof RegExp?t.test(s||""):!1}function Zr(s,t){return String(s)===String(t)}function fe(s,t){return(s||"").includes(t)}function Gr(s,t){return!fe(s,t)}function Qr(s){return Array.isArray(s)}function ta(s,t,e){const i=s?s.length:0;return i>=t&&(e===void 0||i<=e)}function ea(s,t){return s?s.length>=t:!1}function ia(s,t){return s?s.length<=t:!1}function sa(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function na(s,t){return!s||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(s,e))}function ra(s,t){const e={};return Object.keys(t).forEach(i=>{const n=s[i],r=t[i],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");dt[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,s);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[i]=a)}),{valid:Object.keys(e).length===0,errors:e}}const dt={isEmail:Lr,isPhone:Dr,isURL:Hr,isIPv4:ce,isIPv6:he,isIP:Mr,isIDCard:Tr,isPassport:Ir,isCreditCard:Ar,isHexColor:de,isRGB:ue,isRGBA:pe,isColor:zr,isDate:Pr,isJSON:$r,isEmpty:Br,isWhitespace:qr,isNumber:Or,isInteger:Fr,isFloat:Nr,isPositive:Rr,isNegative:Vr,isAlpha:Kr,isAlphaNumeric:Wr,isChinese:Ur,isLength:Yr,minLength:Xr,maxLength:jr,matches:Jr,equals:Zr,contains:fe,notContains:Gr,isArray:Qr,arrayLength:ta,arrayMinLength:ea,arrayMaxLength:ia,isObject:sa,hasKeys:na,validate:ra};function aa(s){const t=s?String(s):"",e=[1732584193,4023233417,2562383102,271733878],i=[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(u,p){return u<<p|u>>>32-p}function a(u){const p=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const m=p&4294967295,f=p>>>32&4294967295;for(let g=0;g<4;g++)u+=String.fromCharCode(m>>>8*g&255);for(let g=0;g<4;g++)u+=String.fromCharCode(f>>>8*g&255);return u}function l(u,p){const[m,f,g,v]=p,y=[];for(let L=0;L<16;L++)y[L]=u.charCodeAt(L*4)&255|(u.charCodeAt(L*4+1)&255)<<8|(u.charCodeAt(L*4+2)&255)<<16|(u.charCodeAt(L*4+3)&255)<<24;let E=m,k=f,b=g,S=v;for(let L=0;L<64;L++){let C,P;const $=Math.floor(L/16),M=L%16;$===0?(C=k&b|~k&S,P=M):$===1?(C=S&k|~S&b,P=(5*M+1)%16):$===2?(C=k^b^S,P=(3*M+5)%16):(C=b^(k|~S),P=7*M%16);const O=S;S=b,b=k,k=k+r(E+C+i[L]+y[P]&4294967295,n[$][L%4]),E=O}return[m+E&4294967295,f+k&4294967295,g+b&4294967295,v+S&4294967295]}const o=a(t);let c=[...e];for(let u=0;u<o.length;u+=64)c=l(o.substring(u,u+64),c);let d="";return c.forEach(u=>{for(let p=0;p<4;p++)d+=(u>>>8*p&255).toString(16).padStart(2,"0")}),d}function la(s){const t=s?String(s):"",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 i(c,d){return c>>>d|c<<32-d}function n(c){const d=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=d&4294967295,p=d>>>32&4294967295;for(let m=0;m<4;m++)c+=String.fromCharCode(p>>>8*m&255);for(let m=0;m<4;m++)c+=String.fromCharCode(u>>>8*m&255);return c}function r(c,d){const u=[];for(let b=0;b<16;b++)u[b]=c.charCodeAt(b*4)&255|(c.charCodeAt(b*4+1)&255)<<8|(c.charCodeAt(b*4+2)&255)<<16|(c.charCodeAt(b*4+3)&255)<<24;for(let b=16;b<64;b++){const S=i(u[b-15],7)^i(u[b-15],18)^u[b-15]>>>3,L=i(u[b-2],17)^i(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+S+u[b-7]+L&4294967295}let[p,m,f,g,v,y,E,k]=d;for(let b=0;b<64;b++){const S=i(v,6)^i(v,11)^i(v,25),L=v&y^~v&E,C=k+S+L+e[b]+u[b]&4294967295,P=i(p,2)^i(p,13)^i(p,22),$=p&m^p&f^m&f,M=P+$&4294967295;k=E,E=y,y=v,v=g+C&4294967295,g=f,f=m,m=p,p=C+M&4294967295}return[d[0]+p&4294967295,d[1]+m&4294967295,d[2]+f&4294967295,d[3]+g&4294967295,d[4]+v&4294967295,d[5]+y&4294967295,d[6]+E&4294967295,d[7]+k&4294967295]}const a=n(t);let l=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)l=r(a.substring(c,c+64),l);let o="";return l.forEach(c=>{for(let d=3;d>=0;d--)o+=(c>>>8*d&255).toString(16).padStart(2,"0")}),o}function oa(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;const n=s?s.split("").map(r=>r.charCodeAt(0)):[];for(;i<n.length;){const r=n[i++],a=n[i++]||0,l=n[i++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(i>n.length+1?"=":t[d])+(i>n.length?"=":t[u])}return e}function ca(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;for(s=s.replace(/[^A-Za-z0-9+/=]/g,"");i<s.length;){const n=t.indexOf(s.charAt(i++)),r=t.indexOf(s.charAt(i++)),a=t.indexOf(s.charAt(i++)),l=t.indexOf(s.charAt(i++)),o=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|l;e+=String.fromCharCode(o),a!==64&&(e+=String.fromCharCode(c)),l!==64&&(e+=String.fromCharCode(d))}return e}function ha(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}const me={md5:aa,sha256:la,base64Encode:oa,base64Decode:ca,uuid:ha},B=new Map;async function st(s,t={}){const{crossOrigin:e="anonymous"}=t;return B.has(s)?B.get(s):new Promise((i,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{B.set(s,r),i(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${s}`))},r.src=s})}async function da(s,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(s.map(n=>st(n,t)));const i=[];for(const n of s)i.push(await st(n,t));return i}async function ge(s,t={}){const{type:e="text/javascript",async:i=!0,defer:n=!1}=t;return B.has(s)?B.get(s):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=i,l.defer=n,l.onload=()=>{B.set(s,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${s}`))},l.src=s,document.head.appendChild(l)})}async function _e(s,t={}){const{media:e="all"}=t;return B.has(s)?B.get(s):new Promise((i,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=s,r.media=e,r.onload=()=>{B.set(s,r),i(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${s}`))},document.head.appendChild(r)})}async function ua(s,t,e={}){const{weight:i="normal",style:n="normal"}=e,r=new FontFace(s,`url(${t})`,{weight:i,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${s}`)}}async function pa(s,t="image"){switch(t){case"image":return st(s);case"script":return ge(s);case"stylesheet":case"style":return _e(s);default:throw new Error(`Unsupported preload type: ${t}`)}}function fa(s){return B.has(s)}function ma(){B.clear()}function ga(s){B.delete(s)}const ye={loadImage:st,loadImages:da,loadScript:ge,loadStylesheet:_e,loadFont:ua,preload:pa,isLoaded:fa,clearCache:ma,clearCacheByUrl:ga},_a={string:Yt,array:Jt,object:te,number:se,date:ae,debounce:le,throttle:oe,validator:dt,crypto:me,preload:ye};function ya(s){if(!s)return"";let t=String(s);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 i;do i=t,t=t.replace(e,"");while(t!==i);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 ve{constructor(){this.children={},this.keys=[]}}class ut{constructor(){this.root=new ve}insert(t){let e=this.root;const i=t.split(".");i.forEach((n,r)=>{e.children[n]||(e.children[n]=new ve),e=e.children[n],r===i.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const i=t.split("."),n=[];for(let r=0;r<i.length;r++){const a=i[r];if(!e.children[a])break;e=e.children[a];const l=o=>{o.keys.length>0&&n.push(...o.keys),Object.values(o.children).forEach(c=>l(c))};l(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),i=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");i.push(r)}return i}}const _={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 ut,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,i,n)=>{if(i==="__raw__")return e;const r=Reflect.get(e,i,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,i):r},set:(e,i,n,r)=>{const a=Reflect.get(e,i,r),l=Reflect.set(e,i,n,r),o=this.resolvePath(e,i);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,i)=>{const n=Reflect.get(e,i,receiver),r=Reflect.deleteProperty(e,i),a=this.resolvePath(e,i);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[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.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[_.path]?`${t[_.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,i)=>{t.add(i),this.updateElementsDirect(i,e),this.pathTrie.getSubKeys(i).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(i=>{this.updateElement(i,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,i=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{i||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,i||(this.notify(t,e,n),this.queueUpdate(t,e))),i||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,i)=>e?.[i],this.rawData)}setNested(t,e){const i=t.split("."),n=i.pop(),r=i.reduce((l,o)=>(l[o]||(l[o]={}),l[o]),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(i=>i!==e))}notify(t,e,i){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,i)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,i)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ya(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 d=e?"none":"";t.style.display!==d&&(t.style.display=d);break;case"class":o&&(e?t.classList.add(o):t.classList.remove(o));break;case"style":o&&t.style[o]!==String(e??"")&&(t.style[o]=e??"");break;case"attr":o&&t.getAttribute(o)!==String(e??"")&&t.setAttribute(o,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,i){this.computedProperties[t]={deps:e,callback:i},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const i=e.deps.map(r=>this.get(r)),n=e.callback(...i);this.set(t,n,!0)}catch(i){console.error(`Computed error for ${t}:`,i)}}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 ut,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:i="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=i==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:l});const c=this.get(t);c!==void 0&&this._persistSave(t,c,o,{version:r,encrypt:a,encryptionKey:l}),this.observe(t,d=>{const u=this.persistedKeys.get(t);u&&(u.debounce>0?(u.timeout&&clearTimeout(u.timeout),u.timeout=setTimeout(()=>{this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey})},u.debounce)):this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey}))})}_persistSave(t,e,i,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:l=null}=n,o={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(o);a&&l&&(c=this._encrypt(c,l)),this._ensureStorageCapacity(i),i.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&i===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(),i=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>i&&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(i){return console.warn("Decryption failed:",i),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:i=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 l=localStorage.getItem(r);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch(l){console.warn(`Failed to load persisted key ${a}:`,l)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=sessionStorage.getItem(r);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}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,i=this.snapshots[e];return i?(this.rawData=this._clone(i),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(i=>{const n=i.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(i.type==="checkbox"?(e[a]||(e[a]=[]),i.checked&&e[a].push(i.value)):i.type==="radio"?i.checked&&(e[a]=i.value):e[a]=i.value)}),e}fillForm(t,e){Object.keys(e).forEach(i=>{t.querySelectorAll('[data-bind*=":'+i+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[i])?e[i].includes(n.value):!!e[i]:n.type==="radio"?n.checked=n.value===e[i]:n.value=e[i]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.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(i=>{i.nodeType===Node.ELEMENT_NODE&&(i.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),i.hasAttribute&&i.hasAttribute("data-bind")&&this._bindElement(i))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const i=t.getAttribute("data-bind").split(":");i[0].split("|")[0].trim();const n=i[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 l=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,l):this.set(n,l)};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 i=e.__kupolaBindHandler;i&&(e.removeEventListener("input",i),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 ut,this.updateQueue.clear(),this.snapshots=[]}}class pt{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const i=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,i),this.state=q.data?.[this._stateKey]||q.createReactive(i,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=i,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 i=this.mutations[t];if(!i){console.warn(`Mutation ${t} not found in store ${this.name}`);return}i(this.state,e)}dispatch(t,e){const i=this.actions[t];if(!i){console.warn(`Action ${t} not found in store ${this.name}`);return}return i({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(i){console.error(`Observer error for store ${this.name}:`,i)}}),q&&q.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 Ee{constructor(){this.stores=new Map}createStore(t,e){const i=new pt(t,e);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof pt&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ke{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(i=>i!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(i=>{try{i(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(i=>{try{i(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const i=n=>{e(n),this.off(t,i)};return this.on(t,i),i}delegate(t,e,i){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:l})=>{(r.target.matches(a)||r.target.closest(a))&&l(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:i}),i}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(i=>i.selector!==t),this.delegatedEvents[e].length===0)){const i=this.eventListeners[e];i&&(document.removeEventListener(e,i),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 I(s=null){const t={_value:s,_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(i=>i(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new be,va=new ke,ft=new Ee;function ba(s,t){return ft.createStore(s,t)}function Ea(s){return ft.getStore(s)}const T={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}};function ka(s){He(T,s)}function nt(s){return s?Ca(T,s):T}function mt(){return T.paths.base+T.paths.icons.replace(/^\//,"")}function wa(){return T.paths.base}function we(){return T.theme.default}function xe(){return T.theme.brand}function xa(){return T.http}function U(){return T.ui}function Y(){return T.zIndex}function Z(){return T.security}function Ce(){return T.performance}function Se(){return T.message}function Le(){return T.notification}function De(){return T.validation}function He(s,t){for(const e in t)t[e]instanceof Object&&e in s&&s[e]instanceof Object?He(s[e],t[e]):s[e]=t[e];return s}function Ca(s,t){return t.split(".").reduce((e,i)=>(e&&e[i])!==void 0?e[i]:void 0,s)}const Me="kupola-theme",Te="kupola-brand",X=[{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 V(){return localStorage.getItem(Me)||we()}function rt(s){if(s!=="dark"&&s!=="light")return;document.documentElement.setAttribute("data-theme",s),localStorage.setItem(Me,s);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",s);const e=t.querySelector(".theme-icon");if(e){const i=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=s==="dark"?i+"sun.svg":i+"moon.svg"}}}function G(){return localStorage.getItem(Te)||xe()}function at(s){const t=X.find(n=>n.id===s);if(!t)return;document.documentElement.setAttribute("data-brand",s),localStorage.setItem(Te,s);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",s);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")===s?n.classList.add("is-active"):n.classList.remove("is-active")})}function Ie(s){const t=s.querySelector(".theme-icon");if(t){const e=V(),i=mt();t.src=e==="dark"?i+"sun.svg":i+"moon.svg"}}function Ae(){const s=V();rt(s);const t=G();at(t);const e=document.querySelector("[data-theme-toggle]");if(e){Ie(e);const l=e.onclick;e.onclick=function(o){o.preventDefault();const d=V()==="dark"?"light":"dark";rt(d),Ie(e),typeof l=="function"&&l.call(this,o)}}let i=document.getElementById("brand-picker");i||(i=document.createElement("div"),i.id="brand-picker",i.style.position="fixed",i.style.top="64px",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",X.forEach(l=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",l.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=l.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(l.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=l.name,i.appendChild(o)}),document.body.appendChild(i));const n=document.querySelector("[data-brand-toggle]");n&&i&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},i.onclick=function(l){l.stopPropagation()});function r(l){i&&n&&!i.contains(l.target)&&!n.contains(l.target)&&(i.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(l=>{l.addEventListener("click",o=>{o.stopPropagation();const c=l.getAttribute("data-brand-btn");at(c),i&&(i.style.display="none")})})}function Sa(){const s=document.createElement("button");s.setAttribute("data-theme-toggle",""),s.setAttribute("data-current-theme",V()),s.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",s.style.position="fixed",s.style.top="16px",s.style.right="16px",s.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=mt();return t.src=V()==="dark"?e+"sun.svg":e+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",s.appendChild(t),document.body.appendChild(s),s.onclick=function(i){i.preventDefault();const r=V()==="dark"?"light":"dark";rt(r)},s}function La(){const s=document.createElement("div");s.id="brand-picker-auto",s.style.position="fixed",s.style.top="56px",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",X.forEach(a=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",a.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=a.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.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=a.name,s.appendChild(l)}),document.body.appendChild(s);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",G()),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=X.find(a=>a.id===G()).color;const i=document.createElement("span");i.className="brand-name",i.style.fontSize="11px",i.textContent=X.find(a=>a.id===G()).name,t.appendChild(e),t.appendChild(i),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},s.onclick=function(a){a.stopPropagation()};function n(a){!s.contains(a.target)&&!t.contains(a.target)&&(s.style.display="none",document.removeEventListener("click",n,!0))}return s.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");at(o),s.style.display="none"})}),{toggleBtn:t,container:s}}function Da(s,t={}){const i=Z()?.sanitizeHtml||{};if(!i.enabled&&!t.force)return s;const n=t.allowedTags||i.allowedTags||[],r=t.allowedAttributes||i.allowedAttributes||{};if(typeof s!="string")return s;const l=new DOMParser().parseFromString(s,"text/html");return l.body.querySelectorAll("*").forEach(c=>{const d=c.tagName.toLowerCase();if(!n.includes(d)){c.remove();return}Array.from(c.attributes).forEach(u=>{const p=u.name.toLowerCase();(r[d]||[]).includes(p)||c.removeAttribute(u.name)})}),l.body.innerHTML}function Ha(s){if(typeof s!="string")return s;const t=document.createElement("div");return t.textContent=s,t.innerHTML}function Ma(s){return typeof s!="string"?s:new DOMParser().parseFromString(s,"text/html").body.textContent||""}function Ta(s,t,e={}){const n=Z()?.maskData||{};if(!n.enabled&&!e.force||s==null)return s;const a=(e.patterns||n.patterns||{})[t];if(!a)return s;const l=typeof a.regex=="string"?new RegExp(a.regex):a.regex;return String(s).replace(l,a.replace)}function Ia(s,t){const i=Z()?.secureId||{},n=s||i.length||16,r=i.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(typeof crypto>"u"||!crypto.getRandomValues){let o="";for(let c=0;c<n;c++)o+=r[Math.floor(Math.random()*r.length)];return t?`${t}_${o}`:o}const a=new Uint32Array(n);crypto.getRandomValues(a);let l="";for(let o=0;o<n;o++)l+=r[a[o]%r.length];return t?`${t}_${l}`:l}class ze{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,i=null,n={}){this.initializers.set(t,e),i&&this.cleanupFunctions.set(t,i),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 i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(i.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(e)){const r=i.replace("ds-",""),a=this.initializers.get(r)||this.initializers.get(i);if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}}cleanup(t){for(const i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(i.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(e)){const r=i.replace("ds-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(i);if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const i=t.querySelectorAll(e),n=[];i.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new ze,Aa=[{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 s of Aa)s.attr&&!w._dataAttrs.includes(s.attr)&&w._dataAttrs.push(s.attr),s.cls&&!w._cssClasses.includes(s.cls)&&w._cssClasses.push(s.cls);class Q{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 F,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const i=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[i]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(i=>{const n=i.getAttribute("data-slot")||"default";t[n]=i.innerHTML.trim(),i.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(i=>i!==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>
5
5
  </div>
6
- `}}_bindLifecycleHooks(){if(this._hooksBound)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let e=Object.getPrototypeOf(this);const i=new Set;for(;e&&e.constructor!==Object&&e.constructor!==Q;){for(const[n,r]of Object.entries(t))i.has(n)||e.hasOwnProperty(n)&&(Array.isArray(r)?r.forEach(a=>{n==="render"&&this.lifecycle.on(a,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(r,a=>(this.renderError(a.error),"handled")):this.lifecycle.on(r,()=>this[n]?.()),i.add(n));e=Object.getPrototypeOf(e)}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(t){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function gt(s,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const i=s.prototype[e];i?s.prototype[e]=function(...n){return t[e].apply(this,n),i.apply(this,n)}:s.prototype[e]=t[e]}else s.prototype[e]=t[e]})}class Pe{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(t,e){if(!(e.prototype instanceof Q))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,e)}registerLazy(t,e){this.lazyComponents.set(t,e)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const e=this.components.get(t)||this.loadedComponents.get(t);if(e)return e;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const i=this.lazyComponents.get(t);if(!i)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await i(),a=r.default||r;if(!(a.prototype instanceof Q))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,a),a}catch(r){throw this.loadingPromises.delete(t),r}})();return this.loadingPromises.set(t,n),n}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(i=>{const n=this.mixins.get(i);n&&gt(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),i=[];e.forEach(n=>{i.push(this._upgradeElement(n))}),await Promise.all(i)}async _upgradeElement(t){if(!(t.__kupolaInstance||t.__kupolaUpgrading)){t.__kupolaUpgrading=!0;try{const e=t.getAttribute("data-component");if(e){const l=w.get(e);if(l)try{await l(t);return}catch(o){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,o)}}let i=this.components.get(e);if(!i){try{i=await this.getAsync(e)}catch(l){console.error(`Failed to load component ${e}:`,l);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=i;n&&n.split(",").forEach(l=>{const o=this.mixins.get(l.trim());o&&gt(r,o)});const a=new r(t);t.__kupolaInstance=a,this.instances.set(t,a),a.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(i=>{i.addedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){n.hasAttribute("data-component")&&this._upgradeElement(n).catch(a=>console.error(a)),this._upgradeElements(n).catch(a=>console.error(a)),w.initialize(n).catch(()=>{});const r=w._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{w.initialize(a).catch(()=>{})})}}),i.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=this.instances.get(n);r&&(r.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(a=>{const l=this.instances.get(a);l&&(l.unmount(),this.instances.delete(a))}),w.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{w.cleanup(a)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}h.kupolaRegistry=null,typeof window<"u"&&(h.kupolaRegistry=new Pe);function za(){if(Z().xssProtection&&typeof document<"u"){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Frame-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Frame-Options"),t.setAttribute("content","SAMEORIGIN"),document.head.insertBefore(t,document.head.firstChild))}}async function _t(){if(typeof window<"u"){za();const s=nt();q.loadPersisted(),q.bind(),Ae(),s.components?.autoInit!==!1&&(await w.initializeAll(),h.kupolaRegistry&&await h.kupolaRegistry.bootstrap())}}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_t):typeof window<"u"&&setTimeout(_t,0);function Pa(s,t){h.kupolaRegistry&&h.kupolaRegistry.register(s,t)}function $a(s,t){h.kupolaRegistry&&h.kupolaRegistry.registerLazy(s,t)}function Ba(s){return h.kupolaRegistry?h.kupolaRegistry.bootstrap(s):Promise.resolve()}function qa(s,t){h.kupolaRegistry&&h.kupolaRegistry.defineMixin(s,t)}function Oa(s,...t){h.kupolaRegistry&&h.kupolaRegistry.useMixin(s,...t)}function Fa(s,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${s}"): options must be an object`);t.componentClass?h.kupolaRegistry&&h.kupolaRegistry.register(s,t.componentClass):t.lazy&&h.kupolaRegistry&&h.kupolaRegistry.registerLazy(s,t.lazy),t.init?w.register(s,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&w.register(s,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class yt{constructor(t={}){const e=nt();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||e.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||e.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(i=>(console.warn(`Missing translation: ${i}`),i)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(i=>{const n=i.dataset.kupolaI18n;if(n)try{const r=JSON.parse(i.textContent);this.addLocale(n,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const i of Object.keys(e))e[i]instanceof Object&&i in t?this._mergeDeep(t[i],e[i]):t[i]=e[i]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let i=this._getTranslation(t,this.currentLocale);return i||(i=this._getTranslation(t,this.fallbackLocale)),i?this._interpolate(i,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const i=t.split(this.delimiter);let n=this.locales[e];for(const r of i)if(n&&typeof n=="object"&&r in n)n=n[r];else return null;return typeof n=="string"?n:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(i,n)=>e[n]!==void 0?e[n]:i)}n(t,e,i={}){const n=this.t(t,{...i,count:e});if(!n)return n;const r=n.split("|");return r.length===1?n.replace("{count}",e):r.length===2?e===1?r[0]:r[1]:r.length>=3?e===0?r[0]:e===1?r[1]:r[2]:n}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const n=await(await fetch(e)).json();return this.addLocale(t,n),!0}catch(i){return console.error("Failed to load locale:",i),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const i=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(i,e).format(n)}formatNumber(t,e={}){const i=e.locale||this.currentLocale;return new Intl.NumberFormat(i,e).format(t)}formatCurrency(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...i}).format(t)}formatRelativeTime(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,i).format(t,e)}}const N=new yt;function Na(s){return new yt(s)}function Ra(s,t={}){return N.t(s,t)}function Va(s,t,e={}){return N.n(s,t,e)}function Ka(s){return N.setLocale(s)}function Wa(){return N.getLocale()}function Ua(s,t={}){return N.formatDate(s,t)}function Ya(s,t={}){return N.formatNumber(s,t)}function Xa(s,t,e={}){return N.formatCurrency(s,t,e)}class $e{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,i,n={}){const{scope:r=null,once:a=!1,passive:l=!1,capture:o=!1}=n,c=this._generateId(),d={id:c,target:t,eventName:e,handler:i,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=p=>{a&&this.offById(c),i.call(t,p)};const u=this._getEventKey(t,e);return this._listeners.has(u)||this._listeners.set(u,[]),this._listeners.get(u).push(d),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,d.wrappedHandler,{passive:l,capture:o}),{unsubscribe:()=>this.offById(c)}}once(t,e,i,n={}){return this.on(t,e,i,{...n,once:!0})}off(t,e,i){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(l=>l.handler!==i);r.forEach(l=>{l.handler===i&&(t.removeEventListener(e,l.wrappedHandler),this._removeFromScope(l))}),a.length===0?this._listeners.delete(n):this._listeners.set(n,a)}offById(t){for(const[e,i]of this._listeners){const n=i.findIndex(r=>r.id===t);if(n!==-1){const r=i[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),i.splice(n,1),i.length===0&&this._listeners.delete(e),this._removeFromScope(r),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(i=>{this.offById(i)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const i=this._getEventKey(t,e);if(!this._listeners.has(i))return;this._listeners.get(i).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(i)}else for(const[i,n]of this._listeners){const[r]=i.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(i))}}emit(t,e,i={}){const n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,i={}){if(!this._scopeListeners.has(t))return;const n=this._scopeListeners.get(t),r=new Set;for(const[a,l]of this._listeners)l.forEach(o=>{n.includes(o.id)&&r.add(o.target)});r.forEach(a=>{this.emit(a,e,i)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let i=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[l]=r.split(":");l===n&&(i+=a.length)}return i}getScopeListenerCount(t){return this._scopeListeners.has(t)?this._scopeListeners.get(t).length:0}hasListeners(t,e=null){return this.getListenerCount(t,e)>0}_getEventKey(t,e){return`${this._getTargetId(t)}:${e}`}_getTargetId(t){return t===document?"document":t===window?"window":t===document.body?"body":(t._kupolaId||(t._kupolaId=this._generateId()),t._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(t){if(!t.scope||!this._scopeListeners.has(t.scope))return;const e=this._scopeListeners.get(t.scope),i=e.indexOf(t.id);i!==-1&&(e.splice(i,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(i=>{i.target.removeEventListener(i.eventName,i.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const H=new $e;function ja(s,t,e,i){return H.on(s,t,e,i)}function Ja(s,t,e,i){return H.once(s,t,e,i)}function Za(s,t,e){H.off(s,t,e)}function Ga(s,t,e){return H.emit(s,t,e)}function Qa(s,t){return H.emitGlobal(s,t)}function tl(s){H.offByScope(s)}function el(s,t){H.offAll(s,t)}function il(s,t){return H.getListenerCount(s,t)}class Be{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const i=U();this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.closeOnClick=e.closeOnClick!==void 0?e.closeOnClick:i.dropdown?.closeOnClick!==void 0?i.dropdown.closeOnClick:!0,this.appendToBody=e.appendToBody!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(i=>i.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.closeOnClick&&(this.hideMenu(),this.trigger.focus()))},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this._triggerKeydownHandler=t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);!e&&!i&&this.hideMenu()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=e=>this._itemClickHandler(e),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=this.menu.getBoundingClientRect(),i=window.innerHeight,n=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${Math.max(t.width,e.width)}px`;const r=i-t.bottom,a=t.top;r<e.height&&a>r?(this.menu.style.top=`${t.top-e.height-4}px`,this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+e.width>n?(this.menu.style.left=`${t.right-Math.max(t.width,e.width)}px`,this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const r=i-t.bottom,a=t.top;r<e.height&&a>r?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+e.width>n?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex;const t=Y().dropdown;this.menu.style.position="fixed",this.menu.style.zIndex=t,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){!this.menu||!this._originalParent||(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this._originalParent=null)}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach(e=>{if(e.type==="divider"){const i=document.createElement("div");i.className="ds-dropdown__divider",this.menu.appendChild(i)}else{const i=document.createElement("div");i.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),i.textContent=e.text||e.label||"",e.value!==void 0&&i.setAttribute("data-value",e.value),e.icon&&(i.innerHTML=e.icon+i.innerHTML),e.disabled&&i.classList.add("is-disabled"),i._dropdownItemClickHandler=n=>this._itemClickHandler(n),i.addEventListener("click",i._dropdownItemClickHandler),this.menu.appendChild(i)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function vt(s,t){const e=new Be(s,t);e.init(),s._kupolaDropdown=e}function sl(s=document){s.querySelectorAll(".ds-dropdown").forEach(t=>{vt(t)})}function bt(s){s._kupolaDropdown&&(s._kupolaDropdown.destroy(),s._kupolaDropdown=null)}function nl(){document.querySelectorAll(".ds-dropdown").forEach(s=>{bt(s)})}w.register("dropdown",vt,bt);class qe{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=e.appendToBody!==!1,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,e)},this._bindOptionClicks(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getVisibleOptions();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusOption(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(e);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus();break}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);!e&&!i&&this.hideOptions()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const i=this.filteredOptions.includes(e);e.el.style.display=i?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const i=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===i);e.style.display=n?"":"none"}),this.focusIndex=-1}_renderRemoteOptions(t){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),t.forEach(e=>{const i=document.createElement("div");i.className="ds-select__option",i.setAttribute("data-value",e.value),i.textContent=e.text||e.label,e.disabled&&i.classList.add("is-disabled"),this.selectedValues.has(e.value)&&i.classList.add("is-selected"),i._selectOptionClickHandler=n=>this._optionClickHandler(n),i.addEventListener("click",i._selectOptionClickHandler),this.optionsEl.appendChild(i)}),this.allOptions=t.map(e=>({el:this.optionsEl.querySelector(`[data-value="${e.value}"]`),value:e.value,text:e.text||e.label,group:"",disabled:!!e.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(i=>i.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(e.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(t,e){if(this.selectedValues.has(t))this.selectedValues.delete(t),e.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),e.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const e=this.allOptions.find(r=>r.value===t);if(!e)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=e.text;const n=document.createElement("button");n.className="ds-select__tag-close",n.type="button",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this.selectedValues.delete(t);const a=this.optionsEl.querySelector(`[data-value="${t}"]`);a&&a.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(n),this.tagsWrap.appendChild(i)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;t===0?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else this.selectedValues.size===0&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}_updateClearBtn(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}_syncNativeSelect(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect){if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const e=this.optionsEl.querySelector(`[data-value="${t.value}"]`);e&&e.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler=e=>this._optionClickHandler(e),t.addEventListener("click",t._selectOptionClickHandler)})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const t=Y().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.zIndex=t,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){!this.optionsEl||!this._originalParent||(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=this.optionsEl.getBoundingClientRect(),i=window.innerHeight,n=window.innerWidth;this.optionsEl.style.width=`${Math.max(t.width,e.width)}px`;const r=i-t.bottom,a=t.top;r<e.height&&a>r?this.optionsEl.style.top=`${t.top-e.height-4}px`:this.optionsEl.style.top=`${t.bottom+4}px`,t.left+e.width>n?this.optionsEl.style.left=`${t.right-Math.max(t.width,e.width)}px`:this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(i=>i.value===t);return e?{value:e.value,text:e.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(e=>this.selectedValues.add(e)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.classList.toggle("is-selected",this.selectedValues.has(e.getAttribute("data-value")))}),this._updateTags(),this._updateValueDisplay()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{const i=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",i),i&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function Et(s,t){const e=new qe(s,t);e.init(),s._kupolaSelect=e}function rl(s=document){s.querySelectorAll(".ds-select").forEach(t=>{Et(t)})}function Oe(s){s._kupolaSelect&&(s._kupolaSelect.destroy(),s._kupolaSelect=null)}w.register("select",Et,Oe);class Fe{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const i=U(),n=i.datepicker?.weekStart!==void 0?i.datepicker.weekStart:1;this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart!==void 0?e.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=e.appendToBody!==!1,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&(this._endInputClickHandler=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this._endInputClickHandler)),this._documentClickListener=H.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",i).replace("DD",n)}_isDateDisabled(t){if(this.minDate){const e=typeof this.minDate=="string"?this._parseDate(this.minDate):this.minDate;if(t<e)return!0}if(this.maxDate){const e=typeof this.maxDate=="string"?this._parseDate(this.maxDate):this.maxDate;if(t>e)return!0}return this.disabledDate?this.disabledDate(t):!1}_isToday(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isSameDay(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isInRange(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const e=t.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=i&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,n>=a?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top=`${t.top-a-4}px`,this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(i=>{i!==this.calendarEl&&(i.style.display="none",i.setAttribute("hidden",""))}),e||(this.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){!this.element.contains(t.target)&&!this.calendarEl.contains(t.target)&&(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const t=Y().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){!this.calendarEl||!this._originalParent||(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(f=>{f._dayClickHandler&&f.removeEventListener("click",f._dayClickHandler)}),this.viewMode==="years"){this._renderYearsView();return}if(this.viewMode==="months"){this._renderMonthsView();return}const e=this.currentDate.getFullYear(),i=this.currentDate.getMonth();t.innerHTML="";const n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",f=>{f.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[i]}`,a.addEventListener("click",f=>{f.stopPropagation(),this.viewMode="months",this._renderCalendar()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',l.addEventListener("click",f=>{f.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(f=>{const g=document.createElement("span");g.className="ds-datepicker__weekday",g.textContent=f,o.appendChild(g)}),t.appendChild(o);const d=document.createElement("div");d.className="ds-datepicker__days";const u=new Date(e,i,1).getDay(),p=new Date(e,i+1,0).getDate(),m=(u-this.weekStart+7)%7;for(let f=0;f<m;f++){const g=document.createElement("span");g.className="ds-datepicker__day ds-datepicker__day--empty",d.appendChild(g)}for(let f=1;f<=p;f++){const g=new Date(e,i,f),v=document.createElement("button");v.className="ds-datepicker__day",v.type="button",v.textContent=f,this._formatDate(g),this._isToday(g)&&v.classList.add("is-today"),this.range?((this._isSameDay(g,this.rangeStart)||this._isSameDay(g,this.rangeEnd))&&v.classList.add("is-selected"),this._isInRange(g)&&v.classList.add("is-in-range")):this._isSameDay(g,this.selectedDate)&&v.classList.add("is-selected"),this._isDateDisabled(g)&&(v.classList.add("is-disabled"),v.disabled=!0);const y=()=>this._selectDate(g);v.addEventListener("click",y),v._dayClickHandler=y,d.appendChild(v)}if(t.appendChild(d),this.showToday){const f=document.createElement("div");f.className="ds-datepicker__footer";const g=document.createElement("button");g.className="ds-datepicker__today-btn",g.type="button",g.textContent=this.todayText,g.addEventListener("click",y=>{y.stopPropagation(),this._goToToday()});const v=document.createElement("button");v.className="ds-datepicker__clear-btn",v.type="button",v.textContent=this.clearText,v.addEventListener("click",y=>{y.stopPropagation(),this._clearDate()}),f.appendChild(g),f.appendChild(v),t.appendChild(f)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=e-6,n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",c=>{c.stopPropagation()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',l.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const d=i+c,u=document.createElement("button");u.className="ds-datepicker__year-cell",u.type="button",u.textContent=d,d===e&&u.classList.add("is-selected"),u.addEventListener("click",p=>{p.stopPropagation(),this.currentDate.setFullYear(d),this.viewMode="months",this._renderCalendar()}),o.appendChild(u)}t.appendChild(o)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=e,r.addEventListener("click",o=>{o.stopPropagation(),this.viewMode="years",this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--next",a.type="button",a.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',a.addEventListener("click",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),i.appendChild(n),i.appendChild(r),i.appendChild(a),t.appendChild(i);const l=document.createElement("div");l.className="ds-datepicker__months-grid",this.months.forEach((o,c)=>{const d=document.createElement("button");d.className="ds-datepicker__month-cell",d.type="button",d.textContent=o,c===this.currentDate.getMonth()&&d.classList.add("is-selected"),d.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),l.appendChild(d)}),t.appendChild(l)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this.endInput&&this._endInputClickHandler&&this.endInput.removeEventListener("click",this._endInputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function kt(s,t){const e=new Fe(s,t);e.init(),s._kupolaDatepicker=e}function al(s=document){s.querySelectorAll(".ds-datepicker").forEach(t=>{kt(t)})}function Ne(s){s._kupolaDatepicker&&(s._kupolaDatepicker.destroy(),s._kupolaDatepicker=null)}w.register("datepicker",kt,Ne);class Re{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=H.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(t,e,i){if(this.disabledTime)return this.disabledTime(t,e,i);const n=t*3600+e*60+i;if(this.minTime){const r=this.minTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n<a)return!0}if(this.maxTime){const r=this.maxTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n>a)return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const n=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")} ${n}`:`${t}:${String(e).padStart(2,"0")} ${n}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):r>=a?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this._syncPanelSelection(),this.calculatePosition();return}this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+=`<div class="ds-timepicker__section">
6
+ `}}_bindLifecycleHooks(){if(this._hooksBound)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let e=Object.getPrototypeOf(this);const i=new Set;for(;e&&e.constructor!==Object&&e.constructor!==Q;){for(const[n,r]of Object.entries(t))i.has(n)||e.hasOwnProperty(n)&&(Array.isArray(r)?r.forEach(a=>{n==="render"&&this.lifecycle.on(a,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(r,a=>(this.renderError(a.error),"handled")):this.lifecycle.on(r,()=>this[n]?.()),i.add(n));e=Object.getPrototypeOf(e)}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(t){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function gt(s,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const i=s.prototype[e];i?s.prototype[e]=function(...n){return t[e].apply(this,n),i.apply(this,n)}:s.prototype[e]=t[e]}else s.prototype[e]=t[e]})}class Pe{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(t,e){if(!(e.prototype instanceof Q))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,e)}registerLazy(t,e){this.lazyComponents.set(t,e)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const e=this.components.get(t)||this.loadedComponents.get(t);if(e)return e;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const i=this.lazyComponents.get(t);if(!i)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await i(),a=r.default||r;if(!(a.prototype instanceof Q))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,a),a}catch(r){throw this.loadingPromises.delete(t),r}})();return this.loadingPromises.set(t,n),n}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(i=>{const n=this.mixins.get(i);n&&gt(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),i=[];e.forEach(n=>{i.push(this._upgradeElement(n))}),await Promise.all(i)}async _upgradeElement(t){if(!(t.__kupolaInstance||t.__kupolaUpgrading)){t.__kupolaUpgrading=!0;try{const e=t.getAttribute("data-component");if(e){const l=w.get(e);if(l)try{await l(t);return}catch(o){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,o)}}let i=this.components.get(e);if(!i){try{i=await this.getAsync(e)}catch(l){console.error(`Failed to load component ${e}:`,l);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=i;n&&n.split(",").forEach(l=>{const o=this.mixins.get(l.trim());o&&gt(r,o)});const a=new r(t);t.__kupolaInstance=a,this.instances.set(t,a),a.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(i=>{i.addedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){n.hasAttribute("data-component")&&this._upgradeElement(n).catch(a=>console.error(a)),this._upgradeElements(n).catch(a=>console.error(a)),w.initialize(n).catch(()=>{});const r=w._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{w.initialize(a).catch(()=>{})})}}),i.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=this.instances.get(n);r&&(r.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(a=>{const l=this.instances.get(a);l&&(l.unmount(),this.instances.delete(a))}),w.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{w.cleanup(a)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}h.kupolaRegistry=null,typeof window<"u"&&(h.kupolaRegistry=new Pe);function za(){if(Z().xssProtection&&typeof document<"u"){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Frame-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Frame-Options"),t.setAttribute("content","SAMEORIGIN"),document.head.insertBefore(t,document.head.firstChild))}}async function _t(){if(typeof window<"u"){za();const s=nt();q.loadPersisted(),q.bind(),Ae(),s.components?.autoInit!==!1&&(await w.initializeAll(),h.kupolaRegistry&&await h.kupolaRegistry.bootstrap())}}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_t):typeof window<"u"&&setTimeout(_t,0);function Pa(s,t){h.kupolaRegistry&&h.kupolaRegistry.register(s,t)}function $a(s,t){h.kupolaRegistry&&h.kupolaRegistry.registerLazy(s,t)}function Ba(s){return h.kupolaRegistry?h.kupolaRegistry.bootstrap(s):Promise.resolve()}function qa(s,t){h.kupolaRegistry&&h.kupolaRegistry.defineMixin(s,t)}function Oa(s,...t){h.kupolaRegistry&&h.kupolaRegistry.useMixin(s,...t)}function Fa(s,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${s}"): options must be an object`);t.componentClass?h.kupolaRegistry&&h.kupolaRegistry.register(s,t.componentClass):t.lazy&&h.kupolaRegistry&&h.kupolaRegistry.registerLazy(s,t.lazy),t.init?w.register(s,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&w.register(s,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class yt{constructor(t={}){const e=nt();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||e.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||e.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(i=>(console.warn(`Missing translation: ${i}`),i)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(i=>{const n=i.dataset.kupolaI18n;if(n)try{const r=JSON.parse(i.textContent);this.addLocale(n,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const i of Object.keys(e))e[i]instanceof Object&&i in t?this._mergeDeep(t[i],e[i]):t[i]=e[i]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let i=this._getTranslation(t,this.currentLocale);return i||(i=this._getTranslation(t,this.fallbackLocale)),i?this._interpolate(i,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const i=t.split(this.delimiter);let n=this.locales[e];for(const r of i)if(n&&typeof n=="object"&&r in n)n=n[r];else return null;return typeof n=="string"?n:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(i,n)=>e[n]!==void 0?e[n]:i)}n(t,e,i={}){const n=this.t(t,{...i,count:e});if(!n)return n;const r=n.split("|");return r.length===1?n.replace("{count}",e):r.length===2?e===1?r[0]:r[1]:r.length>=3?e===0?r[0]:e===1?r[1]:r[2]:n}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const n=await(await fetch(e)).json();return this.addLocale(t,n),!0}catch(i){return console.error("Failed to load locale:",i),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const i=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(i,e).format(n)}formatNumber(t,e={}){const i=e.locale||this.currentLocale;return new Intl.NumberFormat(i,e).format(t)}formatCurrency(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...i}).format(t)}formatRelativeTime(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,i).format(t,e)}}const N=new yt;function Na(s){return new yt(s)}function Ra(s,t={}){return N.t(s,t)}function Va(s,t,e={}){return N.n(s,t,e)}function Ka(s){return N.setLocale(s)}function Wa(){return N.getLocale()}function Ua(s,t={}){return N.formatDate(s,t)}function Ya(s,t={}){return N.formatNumber(s,t)}function Xa(s,t,e={}){return N.formatCurrency(s,t,e)}class $e{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,i,n={}){const{scope:r=null,once:a=!1,passive:l=!1,capture:o=!1}=n,c=this._generateId(),d={id:c,target:t,eventName:e,handler:i,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=p=>{a&&this.offById(c),i.call(t,p)};const u=this._getEventKey(t,e);return this._listeners.has(u)||this._listeners.set(u,[]),this._listeners.get(u).push(d),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,d.wrappedHandler,{passive:l,capture:o}),{unsubscribe:()=>this.offById(c)}}once(t,e,i,n={}){return this.on(t,e,i,{...n,once:!0})}off(t,e,i){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(l=>l.handler!==i);r.forEach(l=>{l.handler===i&&(t.removeEventListener(e,l.wrappedHandler),this._removeFromScope(l))}),a.length===0?this._listeners.delete(n):this._listeners.set(n,a)}offById(t){for(const[e,i]of this._listeners){const n=i.findIndex(r=>r.id===t);if(n!==-1){const r=i[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),i.splice(n,1),i.length===0&&this._listeners.delete(e),this._removeFromScope(r),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(i=>{this.offById(i)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const i=this._getEventKey(t,e);if(!this._listeners.has(i))return;this._listeners.get(i).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(i)}else for(const[i,n]of this._listeners){const[r]=i.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(i))}}emit(t,e,i={}){const n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,i={}){if(!this._scopeListeners.has(t))return;const n=this._scopeListeners.get(t),r=new Set;for(const[a,l]of this._listeners)l.forEach(o=>{n.includes(o.id)&&r.add(o.target)});r.forEach(a=>{this.emit(a,e,i)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let i=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[l]=r.split(":");l===n&&(i+=a.length)}return i}getScopeListenerCount(t){return this._scopeListeners.has(t)?this._scopeListeners.get(t).length:0}hasListeners(t,e=null){return this.getListenerCount(t,e)>0}_getEventKey(t,e){return`${this._getTargetId(t)}:${e}`}_getTargetId(t){return t===document?"document":t===window?"window":t===document.body?"body":(t._kupolaId||(t._kupolaId=this._generateId()),t._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(t){if(!t.scope||!this._scopeListeners.has(t.scope))return;const e=this._scopeListeners.get(t.scope),i=e.indexOf(t.id);i!==-1&&(e.splice(i,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(i=>{i.target.removeEventListener(i.eventName,i.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const H=new $e;function ja(s,t,e,i){return H.on(s,t,e,i)}function Ja(s,t,e,i){return H.once(s,t,e,i)}function Za(s,t,e){H.off(s,t,e)}function Ga(s,t,e){return H.emit(s,t,e)}function Qa(s,t){return H.emitGlobal(s,t)}function tl(s){H.offByScope(s)}function el(s,t){H.offAll(s,t)}function il(s,t){return H.getListenerCount(s,t)}class Be{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const i=U();this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.closeOnClick=e.closeOnClick!==void 0?e.closeOnClick:i.dropdown?.closeOnClick!==void 0?i.dropdown.closeOnClick:!0,this.appendToBody=e.appendToBody!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(i=>i.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this._triggerKeydownHandler=t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);!e&&!i&&this.hideMenu()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=e=>this._itemClickHandler(e),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,i=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const n=this.menu.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?(this.menu.style.top=`${t.top-n.height-4}px`,this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+n.width>i?(this.menu.style.left=`${t.right-n.width}px`,this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const n=e-t.bottom,r=t.top;n<menuRect.height&&r>n?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>i?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex,this._originalDisplay=this.menu.style.display;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=e,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){!this.menu||!this._originalParent||(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this.menu.style.display=this._originalDisplay||"",this._originalParent=null,console.log("[Dropdown] Menu restored from body"))}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this._itemClickHandler||(this._itemClickHandler=e=>{e.stopPropagation();const i=e.currentTarget;i.classList.contains("is-disabled")||i.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(n=>n.classList.remove("is-selected")),i.classList.add("is-selected"),this.triggerText&&!i.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=i.textContent.trim()),this.element.setAttribute("data-value",i.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:i,value:i.getAttribute("data-value"),text:i.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach((e,i)=>{if(e.type==="divider"){const n=document.createElement("div");n.className="ds-dropdown__divider",this.menu.appendChild(n)}else{const n=document.createElement("div");n.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),n.textContent=e.text||e.label||"",e.value!==void 0&&n.setAttribute("data-value",e.value),e.icon&&(n.innerHTML=e.icon+n.innerHTML),e.disabled&&n.classList.add("is-disabled"),n._dropdownItemClickHandler=r=>this._itemClickHandler(r),n.addEventListener("click",n._dropdownItemClickHandler),this.menu.appendChild(n)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function vt(s,t){s._kupolaDropdown&&s._kupolaDropdown.destroy();const e=new Be(s,t);e.init(),s._kupolaDropdown=e}function sl(s=document){s.querySelectorAll(".ds-dropdown").forEach(t=>{vt(t)})}function bt(s){s._kupolaDropdown&&(s._kupolaDropdown.destroy(),s._kupolaDropdown=null)}function nl(){document.querySelectorAll(".ds-dropdown").forEach(s=>{bt(s)})}w.register("dropdown",vt,bt);class qe{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=e.appendToBody!==!1,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,e)},this._bindOptionClicks(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getVisibleOptions();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusOption(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(e);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus();break}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);!e&&!i&&this.hideOptions()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const i=this.filteredOptions.includes(e);e.el.style.display=i?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const i=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===i);e.style.display=n?"":"none"}),this.focusIndex=-1}_renderRemoteOptions(t){this._optionClickHandler||(this._optionClickHandler=e=>{e.stopPropagation();const i=e.currentTarget;if(i.classList.contains("is-disabled"))return;const n=i.getAttribute("data-value");this.multiple?this._toggleMultiOption(n,i):this._selectSingleOption(n,i)}),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),t.forEach(e=>{const i=document.createElement("div");i.className="ds-select__option",i.setAttribute("data-value",e.value),i.textContent=e.text||e.label,e.disabled&&i.classList.add("is-disabled"),this.selectedValues.has(e.value)&&i.classList.add("is-selected"),i._selectOptionClickHandler=n=>this._optionClickHandler(n),i.addEventListener("click",i._selectOptionClickHandler),this.optionsEl.appendChild(i)}),this.allOptions=t.map(e=>({el:this.optionsEl.querySelector(`[data-value="${e.value}"]`),value:e.value,text:e.text||e.label,group:"",disabled:!!e.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(i=>i.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(e.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(t,e){if(this.selectedValues.has(t))this.selectedValues.delete(t),e.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),e.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const e=this.allOptions.find(r=>r.value===t);if(!e)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=e.text;const n=document.createElement("button");n.className="ds-select__tag-close",n.type="button",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this.selectedValues.delete(t);const a=this.optionsEl.querySelector(`[data-value="${t}"]`);a&&a.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(n),this.tagsWrap.appendChild(i)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;t===0?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else this.selectedValues.size===0&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}_updateClearBtn(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}_syncNativeSelect(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect){if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const e=this.optionsEl.querySelector(`[data-value="${t.value}"]`);e&&e.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler=e=>this._optionClickHandler(e),t.addEventListener("click",t._selectOptionClickHandler)})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=e,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){!this.optionsEl||!this._originalParent||(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,i=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const n=this.optionsEl.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?this.optionsEl.style.top=`${t.top-n.height-4}px`:this.optionsEl.style.top=`${t.bottom+4}px`,t.left+n.width>i?this.optionsEl.style.left=`${t.right-n.width}px`:this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(i=>i.value===t);return e?{value:e.value,text:e.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(e=>this.selectedValues.add(e)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.classList.toggle("is-selected",this.selectedValues.has(e.getAttribute("data-value")))}),this._updateTags(),this._updateValueDisplay()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{const i=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",i),i&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function Et(s,t){const e=new qe(s,t);e.init(),s._kupolaSelect=e}function rl(s=document){s.querySelectorAll(".ds-select").forEach(t=>{Et(t)})}function Oe(s){s._kupolaSelect&&(s._kupolaSelect.destroy(),s._kupolaSelect=null)}w.register("select",Et,Oe);class Fe{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const i=U(),n=i.datepicker?.weekStart!==void 0?i.datepicker.weekStart:1;this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart!==void 0?e.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=e.appendToBody!==!1,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&(this._endInputClickHandler=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this._endInputClickHandler)),this._documentClickListener=H.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",i).replace("DD",n)}_isDateDisabled(t){if(this.minDate){const e=typeof this.minDate=="string"?this._parseDate(this.minDate):this.minDate;if(t<e)return!0}if(this.maxDate){const e=typeof this.maxDate=="string"?this._parseDate(this.maxDate):this.maxDate;if(t>e)return!0}return this.disabledDate?this.disabledDate(t):!1}_isToday(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isSameDay(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isInRange(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const e=t.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=i&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,n>=a?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top=`${t.top-a-4}px`,this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(i=>{i!==this.calendarEl&&(i.style.display="none",i.setAttribute("hidden",""))}),e||(this.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){!this.element.contains(t.target)&&!this.calendarEl.contains(t.target)&&(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const t=Y().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){!this.calendarEl||!this._originalParent||(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(f=>{f._dayClickHandler&&f.removeEventListener("click",f._dayClickHandler)}),this.viewMode==="years"){this._renderYearsView();return}if(this.viewMode==="months"){this._renderMonthsView();return}const e=this.currentDate.getFullYear(),i=this.currentDate.getMonth();t.innerHTML="";const n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",f=>{f.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[i]}`,a.addEventListener("click",f=>{f.stopPropagation(),this.viewMode="months",this._renderCalendar()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',l.addEventListener("click",f=>{f.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(f=>{const g=document.createElement("span");g.className="ds-datepicker__weekday",g.textContent=f,o.appendChild(g)}),t.appendChild(o);const d=document.createElement("div");d.className="ds-datepicker__days";const u=new Date(e,i,1).getDay(),p=new Date(e,i+1,0).getDate(),m=(u-this.weekStart+7)%7;for(let f=0;f<m;f++){const g=document.createElement("span");g.className="ds-datepicker__day ds-datepicker__day--empty",d.appendChild(g)}for(let f=1;f<=p;f++){const g=new Date(e,i,f),v=document.createElement("button");v.className="ds-datepicker__day",v.type="button",v.textContent=f,this._formatDate(g),this._isToday(g)&&v.classList.add("is-today"),this.range?((this._isSameDay(g,this.rangeStart)||this._isSameDay(g,this.rangeEnd))&&v.classList.add("is-selected"),this._isInRange(g)&&v.classList.add("is-in-range")):this._isSameDay(g,this.selectedDate)&&v.classList.add("is-selected"),this._isDateDisabled(g)&&(v.classList.add("is-disabled"),v.disabled=!0);const y=()=>this._selectDate(g);v.addEventListener("click",y),v._dayClickHandler=y,d.appendChild(v)}if(t.appendChild(d),this.showToday){const f=document.createElement("div");f.className="ds-datepicker__footer";const g=document.createElement("button");g.className="ds-datepicker__today-btn",g.type="button",g.textContent=this.todayText,g.addEventListener("click",y=>{y.stopPropagation(),this._goToToday()});const v=document.createElement("button");v.className="ds-datepicker__clear-btn",v.type="button",v.textContent=this.clearText,v.addEventListener("click",y=>{y.stopPropagation(),this._clearDate()}),f.appendChild(g),f.appendChild(v),t.appendChild(f)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=e-6,n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",c=>{c.stopPropagation()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',l.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const d=i+c,u=document.createElement("button");u.className="ds-datepicker__year-cell",u.type="button",u.textContent=d,d===e&&u.classList.add("is-selected"),u.addEventListener("click",p=>{p.stopPropagation(),this.currentDate.setFullYear(d),this.viewMode="months",this._renderCalendar()}),o.appendChild(u)}t.appendChild(o)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=e,r.addEventListener("click",o=>{o.stopPropagation(),this.viewMode="years",this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--next",a.type="button",a.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',a.addEventListener("click",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),i.appendChild(n),i.appendChild(r),i.appendChild(a),t.appendChild(i);const l=document.createElement("div");l.className="ds-datepicker__months-grid",this.months.forEach((o,c)=>{const d=document.createElement("button");d.className="ds-datepicker__month-cell",d.type="button",d.textContent=o,c===this.currentDate.getMonth()&&d.classList.add("is-selected"),d.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),l.appendChild(d)}),t.appendChild(l)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this.endInput&&this._endInputClickHandler&&this.endInput.removeEventListener("click",this._endInputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function kt(s,t){const e=new Fe(s,t);e.init(),s._kupolaDatepicker=e}function al(s=document){s.querySelectorAll(".ds-datepicker").forEach(t=>{kt(t)})}function Ne(s){s._kupolaDatepicker&&(s._kupolaDatepicker.destroy(),s._kupolaDatepicker=null)}w.register("datepicker",kt,Ne);class Re{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=H.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(t,e,i){if(this.disabledTime)return this.disabledTime(t,e,i);const n=t*3600+e*60+i;if(this.minTime){const r=this.minTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n<a)return!0}if(this.maxTime){const r=this.maxTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n>a)return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const n=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")} ${n}`:`${t}:${String(e).padStart(2,"0")} ${n}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):r>=a?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this._syncPanelSelection(),this.calculatePosition();return}this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+=`<div class="ds-timepicker__section">
7
7
  <div class="ds-timepicker__section-label">Hour</div>
8
8
  <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>
9
9
  </div>`,t+=`<div class="ds-timepicker__section">