@kupola/kupola 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kupola.cjs.js +17 -17
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +745 -737
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.umd.js +17 -17
- package/dist/kupola.umd.js.map +1 -1
- package/js/theme.js +10 -0
- package/package.json +1 -1
- package/dist/kupola.css +0 -9139
- package/dist/kupola.min.css +0 -1
package/dist/kupola.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(h,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(h=typeof globalThis<"u"?globalThis:h||self,B(h.Kupola={}))})(this,function(h){"use strict";class B{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const l of s){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 s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ms=new B("app");function Ts(i="app"){return new B(i)}const Is=new Set(["__proto__","prototype","constructor"]);function J(i){return Is.has(i)}function As(i){return i?i.trim():""}function zs(i){return i?i.replace(/^\s+/,""):""}function Ps(i){return i?i.replace(/\s+$/,""):""}function $s(i){return i?i.toUpperCase():""}function qs(i){return i?i.toLowerCase():""}function Bs(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Fs(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Ns(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Os(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Rs(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Vs(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Ks(i,t,e){return i?i.split(t).join(e):""}function Ws(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Us(i,t){return(i||"").startsWith(t)}function Ys(i,t){return(i||"").endsWith(t)}function Xs(i,t){return(i||"").includes(t)}function js(i,t){return(i||"").repeat(t)}function Js(i){return(i||"").split("").reverse().join("")}function Gs(i,t){return!i||!t?0:i.split(t).length-1}function Zs(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Qs(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function ti(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function ei(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Ot={trim:As,trimLeft:zs,trimRight:Ps,toUpperCase:$s,toLowerCase:qs,capitalize:Bs,camelize:Fs,hyphenate:Ns,padStart:Os,padEnd:Rs,truncate:Vs,replaceAll:Ks,format:Ws,startsWith:Us,endsWith:Ys,includes:Xs,repeat:js,reverse:Js,countOccurrences:Gs,escapeHtml:Zs,unescapeHtml:Qs,generateRandom:ti,generateUUID:ei};function si(i){return Array.isArray(i)}function ii(i){return!i||i.length===0}function ni(i){return i?i.length:0}function ri(i,t){return i&&i.length>0?i[0]:t}function ai(i,t){return i&&i.length>0?i[i.length-1]:t}function li(i,t,e){return i&&i[t]!==void 0?i[t]:e}function oi(i,t,e){return i?i.slice(t,e):[]}function ci(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function hi(i,t=","){return i?i.join(t):""}function di(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function ui(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function pi(i,t){return i?i.includes(t):!1}function fi(i,...t){return i&&i.push(...t),i}function mi(i){return i?i.pop():void 0}function gi(i){return i?i.shift():void 0}function _i(i,...t){return i&&i.unshift(...t),i}function yi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function vi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function bi(i,t,e){return i&&(i.splice(t,0,e),i)}function Ei(i){return i?i.slice().reverse():[]}function ki(i,t){return i?i.slice().sort(t):[]}function wi(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function xi(i,t){return i?i.filter(t):[]}function Ci(i,t){return i?i.map(t):[]}function Si(i,t,e){return i?i.reduce(t,e):e}function Li(i,t){i&&i.forEach(t)}function Di(i,t){return i?i.every(t):!0}function Hi(i,t){return i?i.some(t):!1}function Mi(i,t){return i?i.find(t):void 0}function Ti(i,t){return i?i.findIndex(t):-1}function Ii(i,t=1){return i?i.flat(t):[]}function Rt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(Rt(e)):t.concat(e),[]):[]}function Ai(i){return i?[...new Set(i)]:[]}function zi(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function Pi(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function $i(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Vt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function qi(i){return!i||i.length===0?0:Vt(i)/i.length}function Bi(i){return i&&i.length>0?Math.max(...i):-1/0}function Fi(i){return i&&i.length>0?Math.min(...i):1/0}function Ni(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Oi(...i){return[...new Set(i.flat().filter(Boolean))]}function Ri(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Vi(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Kt={isArray:si,isEmpty:ii,size:ni,first:ri,last:ai,get:li,slice:oi,concat:ci,join:hi,indexOf:di,lastIndexOf:ui,includes:pi,push:fi,pop:mi,shift:gi,unshift:_i,remove:yi,removeAt:vi,insert:bi,reverse:Ei,sort:ki,sortBy:wi,filter:xi,map:Ci,reduce:Si,forEach:Li,every:Di,some:Hi,find:Mi,findIndex:Ti,flat:Ii,flattenDeep:Rt,unique:Ai,uniqueBy:zi,chunk:Pi,shuffle:$i,sum:Vt,average:qi,max:Bi,min:Fi,intersection:Ni,union:Oi,difference:Ri,zip:Vi};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Ki(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Wi(i){return i?Object.keys(i):[]}function Ui(i){return i?Object.values(i):[]}function Yi(i){return i?Object.entries(i):[]}function Xi(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function ji(i,t,e){if(!i)return e;const s=t.split(".");return s.some(J)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Ji(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(J))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Gi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function Zi(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Wt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{J(s)||(rt(e[s])&&rt(t[s])?t[s]=Wt(t[s],e[s]):t[s]=e[s])}),t),{})}function Qi(i){return i&&JSON.parse(JSON.stringify(i))}function Y(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,Y(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(Y(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(Y(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{J(s)||(e[s]=Y(i[s],t))}),e}function tn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function en(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function sn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function nn(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function rn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function an(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function ln(i){return i?Object.keys(i).length:0}function on(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Ut(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Ut(i[n],t[n]))}function Yt(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&Yt(i[t])}),i)}function cn(i){return i&&Object.seal(i)}const Xt={isObject:rt,isEmpty:Ki,keys:Wi,values:Ui,entries:Yi,has:Xi,get:ji,set:Ji,pick:Gi,omit:Zi,merge:Wt,clone:Qi,deepClone:Y,forEach:tn,map:en,filter:sn,reduce:nn,toArray:rn,fromArray:an,size:ln,invert:on,isEqual:Ut,freeze:Yt,seal:cn};function L(i){return typeof i=="number"&&!isNaN(i)}function hn(i){return Number.isInteger(i)}function dn(i){return L(i)&&!Number.isInteger(i)}function un(i){return L(i)&&i>0}function pn(i){return L(i)&&i<0}function fn(i){return L(i)&&i===0}function mn(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function gn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function _n(i){return L(i)?Math.floor(i):i}function yn(i){return L(i)?Math.ceil(i):i}function vn(i){return L(i)?Math.abs(i):i}function bn(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function En(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function jt(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function kn(...i){const t=i.flat().filter(L);return t.length>0?jt(t)/t.length:0}function Jt(i=0,t=1){return Math.random()*(t-i)+i}function wn(i,t){return Math.floor(Jt(i,t+1))}function xn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Cn(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Sn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Ln(i,t=0){return L(i)?i.toFixed(t):String(i)}function Dn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Hn(i){return Number.isNaN(i)}function Mn(i){return Number.isFinite(i)}function Tn(i,t=10){return Number.parseInt(i,t)}function In(i){return Number.parseFloat(i)}function An(i,t=0){const e=Number(i);return isNaN(e)?t:e}function zn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function Pn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const Gt={isNumber:L,isInteger:hn,isFloat:dn,isPositive:un,isNegative:pn,isZero:fn,clamp:mn,round:gn,floor:_n,ceil:yn,abs:vn,min:bn,max:En,sum:jt,average:kn,random:Jt,randomInt:wn,format:xn,formatCurrency:Cn,formatPercent:Sn,toFixed:Ln,toPrecision:Dn,isNaN:Hn,isFinite:Mn,parseInt:Tn,parseFloat:In,toNumber:An,safeDivide:zn,safeMultiply:Pn};function G(){return Date.now()}function V(){const i=new Date;return i.setHours(0,0,0,0),i}function $n(){const i=V();return i.setDate(i.getDate()+1),i}function qn(){const i=V();return i.setDate(i.getDate()-1),i}function x(i){return i instanceof Date&&!isNaN(i.getTime())}function Zt(i){return x(i)}function Bn(i){const t=new Date(i);return Zt(t)?t:null}function Fn(i,t="YYYY-MM-DD HH:mm:ss"){if(!x(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),l=String(i.getSeconds()).padStart(2,"0"),o=String(i.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",d)}function Nn(i){return x(i)?i.toISOString():""}function On(i){return x(i)?new Date(i.toUTCString()):null}function Rn(i,t){if(!x(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Vn(i,t){if(!x(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Kn(i,t){if(!x(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Wn(i,t){if(!x(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function Z(i,t){if(!x(i)||!x(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Un(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function Yn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function Xn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function jn(i){return x(i)?Z(i,V())===0:!1}function Jn(i){return x(i)?Z(i,V())===-1:!1}function Gn(i){return x(i)?Z(i,V())===1:!1}function Zn(i){return x(i)?i.getTime()>G():!1}function Qn(i){return x(i)?i.getTime()<G():!1}function tr(i){if(!x(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function er(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function sr(i){if(!x(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function ir(i){return x(i)?Math.ceil((i.getMonth()+1)/3):0}function nr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function rr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function ar(i){return x(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function lr(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function Qt(i,t=1){if(!x(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function or(i,t=1){if(!x(i))return i;const e=Qt(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function cr(i){if(!x(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function hr(i){if(!x(i))return"";const e=G()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,l=30*r,o=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`: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 te={now:G,today:V,tomorrow:$n,yesterday:qn,isDate:x,isValid:Zt,parse:Bn,format:Fn,toISO:Nn,toUTC:On,addDays:Rn,addHours:Vn,addMinutes:Kn,addSeconds:Wn,diffDays:Z,diffHours:Un,diffMinutes:Yn,diffSeconds:Xn,isToday:jn,isYesterday:Jn,isTomorrow:Gn,isFuture:Zn,isPast:Qn,isLeapYear:tr,getDaysInMonth:er,getWeekOfYear:sr,getQuarter:ir,startOfDay:nr,endOfDay:rr,startOfMonth:ar,endOfMonth:lr,startOfWeek:Qt,endOfWeek:or,getAge:cr,fromNow:hr};function ee(i,t,e={}){let s=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){i.apply(r,n)}function d(){a=Date.now(),l?(s=setTimeout(u,t),c()):s=setTimeout(u,t)}function u(){s=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(),s?(clearTimeout(s),s=setTimeout(u,p())):d()}}function se(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function l(){i.apply(a,r),r=null,a=null}return function(...o){s?n&&(r=o,a=this):(s=!0,r=o,a=this,l(),setTimeout(()=>{s=!1,n&&r&&l()},t))}}function dr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function ur(i){return/^1[3-9]\d{9}$/.test(i||"")}function pr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ie(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function ne(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function fr(i){return ie(i)||ne(i)}function mr(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function gr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function _r(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function re(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function ae(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function le(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function yr(i){return re(i)||ae(i)||le(i)}function vr(i){return!isNaN(new Date(i).getTime())}function br(i){try{return JSON.parse(i),!0}catch{return!1}}function Er(i){return!i||i.trim()===""}function kr(i){return/^\s+$/.test(i||"")}function wr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function xr(i){return/^-?\d+$/.test(i||"")}function Cr(i){return/^-?\d+\.\d+$/.test(i||"")}function Sr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Lr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Dr(i){return/^[a-zA-Z]+$/.test(i||"")}function Hr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Mr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Tr(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Ir(i,t){return(i||"").length>=t}function Ar(i,t){return(i||"").length<=t}function zr(i,t){return t instanceof RegExp?t.test(i||""):!1}function Pr(i,t){return String(i)===String(t)}function oe(i,t){return(i||"").includes(t)}function $r(i,t){return!oe(i,t)}function qr(i){return Array.isArray(i)}function Br(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Fr(i,t){return i?i.length>=t:!1}function Nr(i,t){return i?i.length<=t:!1}function Or(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Rr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Vr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");at[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,i);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const at={isEmail:dr,isPhone:ur,isURL:pr,isIPv4:ie,isIPv6:ne,isIP:fr,isIDCard:mr,isPassport:gr,isCreditCard:_r,isHexColor:re,isRGB:ae,isRGBA:le,isColor:yr,isDate:vr,isJSON:br,isEmpty:Er,isWhitespace:kr,isNumber:wr,isInteger:xr,isFloat:Cr,isPositive:Sr,isNegative:Lr,isAlpha:Dr,isAlphaNumeric:Hr,isChinese:Mr,isLength:Tr,minLength:Ir,maxLength:Ar,matches:zr,equals:Pr,contains:oe,notContains:$r,isArray:qr,arrayLength:Br,arrayMinLength:Fr,arrayMaxLength:Nr,isObject:Or,hasKeys:Rr,validate:Vr};function Kr(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(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 D=0;D<16;D++)y[D]=u.charCodeAt(D*4)&255|(u.charCodeAt(D*4+1)&255)<<8|(u.charCodeAt(D*4+2)&255)<<16|(u.charCodeAt(D*4+3)&255)<<24;let k=m,E=f,b=g,C=v;for(let D=0;D<64;D++){let S,H;const A=Math.floor(D/16),$=D%16;A===0?(S=E&b|~E&C,H=$):A===1?(S=C&E|~C&b,H=(5*$+1)%16):A===2?(S=E^b^C,H=(3*$+5)%16):(S=b^(E|~C),H=7*$%16);const O=C;C=b,b=E,E=E+r(k+S+s[D]+y[H]&4294967295,n[A][D%4]),k=O}return[m+k&4294967295,f+E&4294967295,g+b&4294967295,v+C&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 Wr(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,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 C=s(u[b-15],7)^s(u[b-15],18)^u[b-15]>>>3,D=s(u[b-2],17)^s(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+C+u[b-7]+D&4294967295}let[p,m,f,g,v,y,k,E]=d;for(let b=0;b<64;b++){const C=s(v,6)^s(v,11)^s(v,25),D=v&y^~v&k,S=E+C+D+e[b]+u[b]&4294967295,H=s(p,2)^s(p,13)^s(p,22),A=p&m^p&f^m&f,$=H+A&4294967295;E=k,k=y,y=v,v=g+S&4294967295,g=f,f=m,m=p,p=S+$&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]+k&4294967295,d[7]+E&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 Ur(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,l=n[s++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(s>n.length+1?"=":t[d])+(s>n.length?"=":t[u])}return e}function Yr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),l=t.indexOf(i.charAt(s++)),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 Xr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ce={md5:Kr,sha256:Wr,base64Encode:Ur,base64Decode:Yr,uuid:Xr},P=new Map;async function Q(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function jr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>Q(n,t)));const s=[];for(const n of i)s.push(await Q(n,t));return s}async function he(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=s,l.defer=n,l.onload=()=>{P.set(i,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${i}`))},l.src=i,document.head.appendChild(l)})}async function de(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Jr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Gr(i,t="image"){switch(t){case"image":return Q(i);case"script":return he(i);case"stylesheet":case"style":return de(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function Zr(i){return P.has(i)}function Qr(){P.clear()}function ta(i){P.delete(i)}const ue={loadImage:Q,loadImages:jr,loadScript:he,loadStylesheet:de,loadFont:Jr,preload:Gr,isLoaded:Zr,clearCache:Qr,clearCacheByUrl:ta},ea={string:Ot,array:Kt,object:Xt,number:Gt,date:te,debounce:ee,throttle:se,validator:at,crypto:ce,preload:ue};function sa(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class pe{constructor(){this.children={},this.keys=[]}}class lt{constructor(){this.root=new pe}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new pe),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const 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("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const _={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class fe{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),l=Reflect.set(e,s,n,r),o=this.resolvePath(e,s);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={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,s);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,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((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(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=sa(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,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=s==="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,s,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(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=localStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);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(s){const c=this._decrypt(l,s);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,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={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,s);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(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const 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 s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[]}}class ot{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,s),this.state=q.data?.[this._stateKey]||q.createReactive(s,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),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 me{constructor(){this.stores=new Map}createStore(t,e){const s=new ot(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof ot&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ge{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb: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:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function T(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new fe,ia=new ge,ct=new me;function na(i,t){return ct.createStore(i,t)}function ra(i){return ct.getStore(i)}const _e="kupola-theme",ye="kupola-brand",K=[{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 W(){return localStorage.getItem(_e)||"dark"}function tt(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(_e,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function X(){return localStorage.getItem(ye)||"zengqing"}function et(i){const t=K.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(ye,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function ve(){const i=W();tt(i);const t=X();et(t);const e=document.querySelector("[data-theme-toggle]");if(e){const l=e.onclick;e.onclick=function(o){o.preventDefault();const d=W()==="dark"?"light":"dark";tt(d),typeof l=="function"&&l.call(this,o)}}let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",K.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,s.appendChild(o)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=s.style.display==="none";s.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(l){l.stopPropagation()});function r(l){s&&n&&!s.contains(l.target)&&!n.contains(l.target)&&(s.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");et(c),s&&(s.style.display="none")})})}function aa(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",W()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=W()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const l=W()==="dark"?"light":"dark";tt(l)},i}function la(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",K.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,i.appendChild(l)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",X()),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=K.find(a=>a.id===X()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=K.find(a=>a.id===X()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=i.style.display==="none";i.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");et(o),i.style.display="none"})}),{toggleBtn:t,container:i}}class be{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new be,oa=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of oa)i.attr&&!w._dataAttrs.includes(i.attr)&&w._dataAttrs.push(i.attr),i.cls&&!w._cssClasses.includes(i.cls)&&w._cssClasses.push(i.cls);class j{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 B,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
|
|
1
|
+
(function(h,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(h=typeof globalThis<"u"?globalThis:h||self,B(h.Kupola={}))})(this,function(h){"use strict";class B{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const l of s){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 s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ts=new B("app");function Is(i="app"){return new B(i)}const As=new Set(["__proto__","prototype","constructor"]);function J(i){return As.has(i)}function zs(i){return i?i.trim():""}function Ps(i){return i?i.replace(/^\s+/,""):""}function $s(i){return i?i.replace(/\s+$/,""):""}function qs(i){return i?i.toUpperCase():""}function Bs(i){return i?i.toLowerCase():""}function Fs(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Ns(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Os(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Rs(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Vs(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Ks(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Ws(i,t,e){return i?i.split(t).join(e):""}function Us(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Ys(i,t){return(i||"").startsWith(t)}function Xs(i,t){return(i||"").endsWith(t)}function js(i,t){return(i||"").includes(t)}function Js(i,t){return(i||"").repeat(t)}function Gs(i){return(i||"").split("").reverse().join("")}function Zs(i,t){return!i||!t?0:i.split(t).length-1}function Qs(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function ti(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function ei(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function si(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Ot={trim:zs,trimLeft:Ps,trimRight:$s,toUpperCase:qs,toLowerCase:Bs,capitalize:Fs,camelize:Ns,hyphenate:Os,padStart:Rs,padEnd:Vs,truncate:Ks,replaceAll:Ws,format:Us,startsWith:Ys,endsWith:Xs,includes:js,repeat:Js,reverse:Gs,countOccurrences:Zs,escapeHtml:Qs,unescapeHtml:ti,generateRandom:ei,generateUUID:si};function ii(i){return Array.isArray(i)}function ni(i){return!i||i.length===0}function ri(i){return i?i.length:0}function ai(i,t){return i&&i.length>0?i[0]:t}function li(i,t){return i&&i.length>0?i[i.length-1]:t}function oi(i,t,e){return i&&i[t]!==void 0?i[t]:e}function ci(i,t,e){return i?i.slice(t,e):[]}function hi(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function di(i,t=","){return i?i.join(t):""}function ui(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function pi(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function fi(i,t){return i?i.includes(t):!1}function mi(i,...t){return i&&i.push(...t),i}function gi(i){return i?i.pop():void 0}function _i(i){return i?i.shift():void 0}function yi(i,...t){return i&&i.unshift(...t),i}function vi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function bi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function Ei(i,t,e){return i&&(i.splice(t,0,e),i)}function ki(i){return i?i.slice().reverse():[]}function wi(i,t){return i?i.slice().sort(t):[]}function xi(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function Ci(i,t){return i?i.filter(t):[]}function Si(i,t){return i?i.map(t):[]}function Li(i,t,e){return i?i.reduce(t,e):e}function Di(i,t){i&&i.forEach(t)}function Hi(i,t){return i?i.every(t):!0}function Mi(i,t){return i?i.some(t):!1}function Ti(i,t){return i?i.find(t):void 0}function Ii(i,t){return i?i.findIndex(t):-1}function Ai(i,t=1){return i?i.flat(t):[]}function Rt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(Rt(e)):t.concat(e),[]):[]}function zi(i){return i?[...new Set(i)]:[]}function Pi(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function $i(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function qi(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Vt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function Bi(i){return!i||i.length===0?0:Vt(i)/i.length}function Fi(i){return i&&i.length>0?Math.max(...i):-1/0}function Ni(i){return i&&i.length>0?Math.min(...i):1/0}function Oi(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Ri(...i){return[...new Set(i.flat().filter(Boolean))]}function Vi(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Ki(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Kt={isArray:ii,isEmpty:ni,size:ri,first:ai,last:li,get:oi,slice:ci,concat:hi,join:di,indexOf:ui,lastIndexOf:pi,includes:fi,push:mi,pop:gi,shift:_i,unshift:yi,remove:vi,removeAt:bi,insert:Ei,reverse:ki,sort:wi,sortBy:xi,filter:Ci,map:Si,reduce:Li,forEach:Di,every:Hi,some:Mi,find:Ti,findIndex:Ii,flat:Ai,flattenDeep:Rt,unique:zi,uniqueBy:Pi,chunk:$i,shuffle:qi,sum:Vt,average:Bi,max:Fi,min:Ni,intersection:Oi,union:Ri,difference:Vi,zip:Ki};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Wi(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Ui(i){return i?Object.keys(i):[]}function Yi(i){return i?Object.values(i):[]}function Xi(i){return i?Object.entries(i):[]}function ji(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function Ji(i,t,e){if(!i)return e;const s=t.split(".");return s.some(J)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Gi(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(J))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Zi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function Qi(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Wt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{J(s)||(rt(e[s])&&rt(t[s])?t[s]=Wt(t[s],e[s]):t[s]=e[s])}),t),{})}function tn(i){return i&&JSON.parse(JSON.stringify(i))}function Y(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,Y(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(Y(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(Y(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{J(s)||(e[s]=Y(i[s],t))}),e}function en(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function sn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function nn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function rn(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function an(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function ln(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function on(i){return i?Object.keys(i).length:0}function cn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Ut(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Ut(i[n],t[n]))}function Yt(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&Yt(i[t])}),i)}function hn(i){return i&&Object.seal(i)}const Xt={isObject:rt,isEmpty:Wi,keys:Ui,values:Yi,entries:Xi,has:ji,get:Ji,set:Gi,pick:Zi,omit:Qi,merge:Wt,clone:tn,deepClone:Y,forEach:en,map:sn,filter:nn,reduce:rn,toArray:an,fromArray:ln,size:on,invert:cn,isEqual:Ut,freeze:Yt,seal:hn};function L(i){return typeof i=="number"&&!isNaN(i)}function dn(i){return Number.isInteger(i)}function un(i){return L(i)&&!Number.isInteger(i)}function pn(i){return L(i)&&i>0}function fn(i){return L(i)&&i<0}function mn(i){return L(i)&&i===0}function gn(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function _n(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function yn(i){return L(i)?Math.floor(i):i}function vn(i){return L(i)?Math.ceil(i):i}function bn(i){return L(i)?Math.abs(i):i}function En(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function kn(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function jt(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function wn(...i){const t=i.flat().filter(L);return t.length>0?jt(t)/t.length:0}function Jt(i=0,t=1){return Math.random()*(t-i)+i}function xn(i,t){return Math.floor(Jt(i,t+1))}function Cn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Sn(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Ln(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Dn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Hn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Mn(i){return Number.isNaN(i)}function Tn(i){return Number.isFinite(i)}function In(i,t=10){return Number.parseInt(i,t)}function An(i){return Number.parseFloat(i)}function zn(i,t=0){const e=Number(i);return isNaN(e)?t:e}function Pn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function $n(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const Gt={isNumber:L,isInteger:dn,isFloat:un,isPositive:pn,isNegative:fn,isZero:mn,clamp:gn,round:_n,floor:yn,ceil:vn,abs:bn,min:En,max:kn,sum:jt,average:wn,random:Jt,randomInt:xn,format:Cn,formatCurrency:Sn,formatPercent:Ln,toFixed:Dn,toPrecision:Hn,isNaN:Mn,isFinite:Tn,parseInt:In,parseFloat:An,toNumber:zn,safeDivide:Pn,safeMultiply:$n};function G(){return Date.now()}function K(){const i=new Date;return i.setHours(0,0,0,0),i}function qn(){const i=K();return i.setDate(i.getDate()+1),i}function Bn(){const i=K();return i.setDate(i.getDate()-1),i}function x(i){return i instanceof Date&&!isNaN(i.getTime())}function Zt(i){return x(i)}function Fn(i){const t=new Date(i);return Zt(t)?t:null}function Nn(i,t="YYYY-MM-DD HH:mm:ss"){if(!x(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),l=String(i.getSeconds()).padStart(2,"0"),o=String(i.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",d)}function On(i){return x(i)?i.toISOString():""}function Rn(i){return x(i)?new Date(i.toUTCString()):null}function Vn(i,t){if(!x(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Kn(i,t){if(!x(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Wn(i,t){if(!x(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Un(i,t){if(!x(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function Z(i,t){if(!x(i)||!x(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Yn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function Xn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function jn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function Jn(i){return x(i)?Z(i,K())===0:!1}function Gn(i){return x(i)?Z(i,K())===-1:!1}function Zn(i){return x(i)?Z(i,K())===1:!1}function Qn(i){return x(i)?i.getTime()>G():!1}function tr(i){return x(i)?i.getTime()<G():!1}function er(i){if(!x(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function sr(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function ir(i){if(!x(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function nr(i){return x(i)?Math.ceil((i.getMonth()+1)/3):0}function rr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function ar(i){if(!x(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function lr(i){return x(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function or(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function Qt(i,t=1){if(!x(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function cr(i,t=1){if(!x(i))return i;const e=Qt(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function hr(i){if(!x(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function dr(i){if(!x(i))return"";const e=G()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,l=30*r,o=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`: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 te={now:G,today:K,tomorrow:qn,yesterday:Bn,isDate:x,isValid:Zt,parse:Fn,format:Nn,toISO:On,toUTC:Rn,addDays:Vn,addHours:Kn,addMinutes:Wn,addSeconds:Un,diffDays:Z,diffHours:Yn,diffMinutes:Xn,diffSeconds:jn,isToday:Jn,isYesterday:Gn,isTomorrow:Zn,isFuture:Qn,isPast:tr,isLeapYear:er,getDaysInMonth:sr,getWeekOfYear:ir,getQuarter:nr,startOfDay:rr,endOfDay:ar,startOfMonth:lr,endOfMonth:or,startOfWeek:Qt,endOfWeek:cr,getAge:hr,fromNow:dr};function ee(i,t,e={}){let s=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){i.apply(r,n)}function d(){a=Date.now(),l?(s=setTimeout(u,t),c()):s=setTimeout(u,t)}function u(){s=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(),s?(clearTimeout(s),s=setTimeout(u,p())):d()}}function se(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function l(){i.apply(a,r),r=null,a=null}return function(...o){s?n&&(r=o,a=this):(s=!0,r=o,a=this,l(),setTimeout(()=>{s=!1,n&&r&&l()},t))}}function ur(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function pr(i){return/^1[3-9]\d{9}$/.test(i||"")}function fr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ie(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function ne(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function mr(i){return ie(i)||ne(i)}function gr(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function _r(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function yr(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function re(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function ae(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function le(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function vr(i){return re(i)||ae(i)||le(i)}function br(i){return!isNaN(new Date(i).getTime())}function Er(i){try{return JSON.parse(i),!0}catch{return!1}}function kr(i){return!i||i.trim()===""}function wr(i){return/^\s+$/.test(i||"")}function xr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Cr(i){return/^-?\d+$/.test(i||"")}function Sr(i){return/^-?\d+\.\d+$/.test(i||"")}function Lr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Dr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Hr(i){return/^[a-zA-Z]+$/.test(i||"")}function Mr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Tr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Ir(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Ar(i,t){return(i||"").length>=t}function zr(i,t){return(i||"").length<=t}function Pr(i,t){return t instanceof RegExp?t.test(i||""):!1}function $r(i,t){return String(i)===String(t)}function oe(i,t){return(i||"").includes(t)}function qr(i,t){return!oe(i,t)}function Br(i){return Array.isArray(i)}function Fr(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Nr(i,t){return i?i.length>=t:!1}function Or(i,t){return i?i.length<=t:!1}function Rr(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Vr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Kr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");at[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,i);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const at={isEmail:ur,isPhone:pr,isURL:fr,isIPv4:ie,isIPv6:ne,isIP:mr,isIDCard:gr,isPassport:_r,isCreditCard:yr,isHexColor:re,isRGB:ae,isRGBA:le,isColor:vr,isDate:br,isJSON:Er,isEmpty:kr,isWhitespace:wr,isNumber:xr,isInteger:Cr,isFloat:Sr,isPositive:Lr,isNegative:Dr,isAlpha:Hr,isAlphaNumeric:Mr,isChinese:Tr,isLength:Ir,minLength:Ar,maxLength:zr,matches:Pr,equals:$r,contains:oe,notContains:qr,isArray:Br,arrayLength:Fr,arrayMinLength:Nr,arrayMaxLength:Or,isObject:Rr,hasKeys:Vr,validate:Kr};function Wr(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(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 D=0;D<16;D++)y[D]=u.charCodeAt(D*4)&255|(u.charCodeAt(D*4+1)&255)<<8|(u.charCodeAt(D*4+2)&255)<<16|(u.charCodeAt(D*4+3)&255)<<24;let k=m,E=f,b=g,C=v;for(let D=0;D<64;D++){let S,H;const A=Math.floor(D/16),$=D%16;A===0?(S=E&b|~E&C,H=$):A===1?(S=C&E|~C&b,H=(5*$+1)%16):A===2?(S=E^b^C,H=(3*$+5)%16):(S=b^(E|~C),H=7*$%16);const O=C;C=b,b=E,E=E+r(k+S+s[D]+y[H]&4294967295,n[A][D%4]),k=O}return[m+k&4294967295,f+E&4294967295,g+b&4294967295,v+C&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 Ur(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,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 C=s(u[b-15],7)^s(u[b-15],18)^u[b-15]>>>3,D=s(u[b-2],17)^s(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+C+u[b-7]+D&4294967295}let[p,m,f,g,v,y,k,E]=d;for(let b=0;b<64;b++){const C=s(v,6)^s(v,11)^s(v,25),D=v&y^~v&k,S=E+C+D+e[b]+u[b]&4294967295,H=s(p,2)^s(p,13)^s(p,22),A=p&m^p&f^m&f,$=H+A&4294967295;E=k,k=y,y=v,v=g+S&4294967295,g=f,f=m,m=p,p=S+$&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]+k&4294967295,d[7]+E&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 Yr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,l=n[s++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(s>n.length+1?"=":t[d])+(s>n.length?"=":t[u])}return e}function Xr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),l=t.indexOf(i.charAt(s++)),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 jr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ce={md5:Wr,sha256:Ur,base64Encode:Yr,base64Decode:Xr,uuid:jr},P=new Map;async function Q(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function Jr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>Q(n,t)));const s=[];for(const n of i)s.push(await Q(n,t));return s}async function he(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=s,l.defer=n,l.onload=()=>{P.set(i,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${i}`))},l.src=i,document.head.appendChild(l)})}async function de(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Gr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Zr(i,t="image"){switch(t){case"image":return Q(i);case"script":return he(i);case"stylesheet":case"style":return de(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function Qr(i){return P.has(i)}function ta(){P.clear()}function ea(i){P.delete(i)}const ue={loadImage:Q,loadImages:Jr,loadScript:he,loadStylesheet:de,loadFont:Gr,preload:Zr,isLoaded:Qr,clearCache:ta,clearCacheByUrl:ea},sa={string:Ot,array:Kt,object:Xt,number:Gt,date:te,debounce:ee,throttle:se,validator:at,crypto:ce,preload:ue};function ia(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class pe{constructor(){this.children={},this.keys=[]}}class lt{constructor(){this.root=new pe}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new pe),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const 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("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const _={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class fe{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),l=Reflect.set(e,s,n,r),o=this.resolvePath(e,s);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={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,s);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,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((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(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ia(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,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=s==="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,s,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(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=localStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);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(s){const c=this._decrypt(l,s);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,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={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,s);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(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const 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 s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[]}}class ot{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,s),this.state=q.data?.[this._stateKey]||q.createReactive(s,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),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 me{constructor(){this.stores=new Map}createStore(t,e){const s=new ot(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof ot&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ge{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb: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:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function T(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new fe,na=new ge,ct=new me;function ra(i,t){return ct.createStore(i,t)}function aa(i){return ct.getStore(i)}const _e="kupola-theme",ye="kupola-brand",W=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function R(){return localStorage.getItem(_e)||"dark"}function tt(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(_e,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function X(){return localStorage.getItem(ye)||"zengqing"}function et(i){const t=W.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(ye,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function ve(i){const t=i.querySelector(".theme-icon");if(t){const e=R();t.src=e==="dark"?"/icons/sun.svg":"/icons/moon.svg"}}function be(){const i=R();tt(i);const t=X();et(t);const e=document.querySelector("[data-theme-toggle]");if(e){ve(e);const l=e.onclick;e.onclick=function(o){o.preventDefault();const d=R()==="dark"?"light":"dark";tt(d),ve(e),typeof l=="function"&&l.call(this,o)}}let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",W.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,s.appendChild(o)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=s.style.display==="none";s.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(l){l.stopPropagation()});function r(l){s&&n&&!s.contains(l.target)&&!n.contains(l.target)&&(s.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");et(c),s&&(s.style.display="none")})})}function la(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",R()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=R()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const l=R()==="dark"?"light":"dark";tt(l)},i}function oa(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",W.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,i.appendChild(l)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",X()),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=W.find(a=>a.id===X()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=W.find(a=>a.id===X()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=i.style.display==="none";i.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");et(o),i.style.display="none"})}),{toggleBtn:t,container:i}}class Ee{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new Ee,ca=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of ca)i.attr&&!w._dataAttrs.includes(i.attr)&&w._dataAttrs.push(i.attr),i.cls&&!w._cssClasses.includes(i.cls)&&w._cssClasses.push(i.cls);class j{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 B,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
|
|
2
2
|
<div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">
|
|
3
3
|
<div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>
|
|
4
4
|
<div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>
|
|
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 s=new Set;for(;e&&e.constructor!==Object&&e.constructor!==j;){for(const[n,r]of Object.entries(t))s.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]?.()),s.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 ht(i,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const s=i.prototype[e];s?i.prototype[e]=function(...n){return t[e].apply(this,n),s.apply(this,n)}:i.prototype[e]=t[e]}else i.prototype[e]=t[e]})}class Ee{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 j))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 s=this.lazyComponents.get(t);if(!s)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await s(),a=r.default||r;if(!(a.prototype instanceof j))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(s=>{const n=this.mixins.get(s);n&&ht(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),s=[];e.forEach(n=>{s.push(this._upgradeElement(n))}),await Promise.all(s)}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 s=this.components.get(e);if(!s){try{s=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=s;n&&n.split(",").forEach(l=>{const o=this.mixins.get(l.trim());o&&ht(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(s=>{s.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(()=>{})})}}),s.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 Ee);async function dt(){typeof window<"u"&&(q.loadPersisted(),q.bind(),ve(),await w.initializeAll(),h.kupolaRegistry&&await h.kupolaRegistry.bootstrap())}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",dt):typeof window<"u"&&setTimeout(dt,0);function ca(i,t){h.kupolaRegistry&&h.kupolaRegistry.register(i,t)}function ha(i,t){h.kupolaRegistry&&h.kupolaRegistry.registerLazy(i,t)}function da(i){return h.kupolaRegistry?h.kupolaRegistry.bootstrap(i):Promise.resolve()}function ua(i,t){h.kupolaRegistry&&h.kupolaRegistry.defineMixin(i,t)}function pa(i,...t){h.kupolaRegistry&&h.kupolaRegistry.useMixin(i,...t)}function fa(i,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${i}"): options must be an object`);t.componentClass?h.kupolaRegistry&&h.kupolaRegistry.register(i,t.componentClass):t.lazy&&h.kupolaRegistry&&h.kupolaRegistry.registerLazy(i,t.lazy),t.init?w.register(i,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&w.register(i,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class ut{constructor(t={}){this.locales=t.locales||{},this.currentLocale=t.defaultLocale||"zh-CN",this.fallbackLocale=t.fallbackLocale||"zh-CN",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(s=>{const n=s.dataset.kupolaI18n;if(n)try{const r=JSON.parse(s.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 s of Object.keys(e))e[s]instanceof Object&&s in t?this._mergeDeep(t[s],e[s]):t[s]=e[s]}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 s=this._getTranslation(t,this.currentLocale);return s||(s=this._getTranslation(t,this.fallbackLocale)),s?this._interpolate(s,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const s=t.split(this.delimiter);let n=this.locales[e];for(const r of s)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,(s,n)=>e[n]!==void 0?e[n]:s)}n(t,e,s={}){const n=this.t(t,{...s,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(s){return console.error("Failed to load locale:",s),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const s=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(s,e).format(n)}formatNumber(t,e={}){const s=e.locale||this.currentLocale;return new Intl.NumberFormat(s,e).format(t)}formatCurrency(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...s}).format(t)}formatRelativeTime(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,s).format(t,e)}}const F=new ut;function ma(i){return new ut(i)}function ga(i,t={}){return F.t(i,t)}function _a(i,t,e={}){return F.n(i,t,e)}function ya(i){return F.setLocale(i)}function va(){return F.getLocale()}function ba(i,t={}){return F.formatDate(i,t)}function Ea(i,t={}){return F.formatNumber(i,t)}function ka(i,t,e={}){return F.formatCurrency(i,t,e)}class ke{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,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:s,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=p=>{a&&this.offById(c),s.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,s,n={}){return this.on(t,e,s,{...n,once:!0})}off(t,e,s){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(l=>l.handler!==s);r.forEach(l=>{l.handler===s&&(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,s]of this._listeners){const n=s.findIndex(r=>r.id===t);if(n!==-1){const r=s[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),s.splice(n,1),s.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(s=>{this.offById(s)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const s=this._getEventKey(t,e);if(!this._listeners.has(s))return;this._listeners.get(s).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(s)}else for(const[s,n]of this._listeners){const[r]=s.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(s))}}emit(t,e,s={}){const n=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,s={}){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,s)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let s=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[l]=r.split(":");l===n&&(s+=a.length)}return s}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),s=e.indexOf(t.id);s!==-1&&(e.splice(s,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(s=>{s.target.removeEventListener(s.eventName,s.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const M=new ke;function wa(i,t,e,s){return M.on(i,t,e,s)}function xa(i,t,e,s){return M.once(i,t,e,s)}function Ca(i,t,e){M.off(i,t,e)}function Sa(i,t,e){return M.emit(i,t,e)}function La(i,t){return M.emitGlobal(i,t)}function Da(i){M.offByScope(i)}function Ha(i,t){M.offAll(i,t)}function Ma(i,t){return M.getListenerCount(i,t)}class we{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)}`,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.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._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=>{const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),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=>{this.element.contains(t.target)||this.hideMenu()},this._documentClickListener=M.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.addEventListener("click",this._itemClickHandler),t._dropdownItemClickHandler=this._itemClickHandler})}_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(),s=window.innerHeight,n=window.innerWidth;this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup");const r=s-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.menu.style.display="block",this.element.classList.add("is-open"),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.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})))}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 s=document.createElement("div");s.className="ds-dropdown__divider",this.menu.appendChild(s)}else{const s=document.createElement("div");s.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),s.textContent=e.text||e.label||"",e.value!==void 0&&s.setAttribute("data-value",e.value),e.icon&&(s.innerHTML=e.icon+s.innerHTML),e.disabled&&s.classList.add("is-disabled"),this.menu.appendChild(s)}}),this._bindMenuItems()}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._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 pt(i,t){const e=new we(i,t);e.init(),i._kupolaDropdown=e}function Ta(i=document){i.querySelectorAll(".ds-dropdown").forEach(t=>{pt(t)})}function ft(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}function Ia(){document.querySelectorAll(".ds-dropdown").forEach(i=>{ft(i)})}w.register("dropdown",pt,ft);class xe{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.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=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=>{const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const s=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(s,e):this._selectSingleOption(s,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=>{this.element.contains(t.target)||this.hideOptions()},this._documentClickListener=M.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 s=this.filteredOptions.includes(e);e.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const s=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===s);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 s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",e.value),s.textContent=e.text||e.label,e.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(e.value)&&s.classList.add("is-selected"),s.addEventListener("click",this._optionClickHandler),s._selectOptionClickHandler=this._optionClickHandler,this.optionsEl.appendChild(s)}),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(s=>s.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 s=document.createElement("span");s.className="ds-select__tag",s.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()}),s.appendChild(n),this.tagsWrap.appendChild(s)}))}_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.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler})}_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.optionsEl.style.display="block",this.icon&&(this.icon.style.transform="rotate(180deg)"),this.element.classList.add("is-open"),this.focusIndex=-1,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.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}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(s=>s.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 s=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",s),s&&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._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function mt(i,t){const e=new xe(i,t);e.init(),i._kupolaSelect=e}function Aa(i=document){i.querySelectorAll(".ds-select").forEach(t=>{mt(t)})}function Ce(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}w.register("select",mt,Ce);class Se{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)}`,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||parseInt(t.getAttribute("data-datepicker-week-start"))||0,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._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=M.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=M.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(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",s).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(),s=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=s&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;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(s=>{s!==this.calendarEl&&(s.style.display="none",s.setAttribute("hidden",""))}),e||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days")}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(),s=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[s]}`,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,s,1).getDay(),p=new Date(e,s+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,s,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(),s=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=`${s} - ${s+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=s+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(),s=document.createElement("div");s.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()}),s.appendChild(n),s.appendChild(r),s.appendChild(a),t.appendChild(s);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._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 gt(i,t){const e=new Se(i,t);e.init(),i._kupolaDatepicker=e}function za(i=document){i.querySelectorAll(".ds-datepicker").forEach(t=>{gt(t)})}function Le(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}w.register("datepicker",gt,Le);class De{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=M.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=M.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 s=t.split(":");s.length>=2&&(this.selectedHour=parseInt(s[0])||0,this.selectedMinute=parseInt(s[1])||0,this.selectedSecond=s[2]&&parseInt(s[2])||0)}_isTimeDisabled(t,e,s){if(this.disabledTime)return this.disabledTime(t,e,s);const n=t*3600+e*60+s;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,s=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(s).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(s).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 s=new Set;for(;e&&e.constructor!==Object&&e.constructor!==j;){for(const[n,r]of Object.entries(t))s.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]?.()),s.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 ht(i,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const s=i.prototype[e];s?i.prototype[e]=function(...n){return t[e].apply(this,n),s.apply(this,n)}:i.prototype[e]=t[e]}else i.prototype[e]=t[e]})}class ke{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 j))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 s=this.lazyComponents.get(t);if(!s)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await s(),a=r.default||r;if(!(a.prototype instanceof j))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(s=>{const n=this.mixins.get(s);n&&ht(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),s=[];e.forEach(n=>{s.push(this._upgradeElement(n))}),await Promise.all(s)}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 s=this.components.get(e);if(!s){try{s=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=s;n&&n.split(",").forEach(l=>{const o=this.mixins.get(l.trim());o&&ht(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(s=>{s.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(()=>{})})}}),s.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 ke);async function dt(){typeof window<"u"&&(q.loadPersisted(),q.bind(),be(),await w.initializeAll(),h.kupolaRegistry&&await h.kupolaRegistry.bootstrap())}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",dt):typeof window<"u"&&setTimeout(dt,0);function ha(i,t){h.kupolaRegistry&&h.kupolaRegistry.register(i,t)}function da(i,t){h.kupolaRegistry&&h.kupolaRegistry.registerLazy(i,t)}function ua(i){return h.kupolaRegistry?h.kupolaRegistry.bootstrap(i):Promise.resolve()}function pa(i,t){h.kupolaRegistry&&h.kupolaRegistry.defineMixin(i,t)}function fa(i,...t){h.kupolaRegistry&&h.kupolaRegistry.useMixin(i,...t)}function ma(i,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${i}"): options must be an object`);t.componentClass?h.kupolaRegistry&&h.kupolaRegistry.register(i,t.componentClass):t.lazy&&h.kupolaRegistry&&h.kupolaRegistry.registerLazy(i,t.lazy),t.init?w.register(i,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&w.register(i,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class ut{constructor(t={}){this.locales=t.locales||{},this.currentLocale=t.defaultLocale||"zh-CN",this.fallbackLocale=t.fallbackLocale||"zh-CN",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(s=>{const n=s.dataset.kupolaI18n;if(n)try{const r=JSON.parse(s.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 s of Object.keys(e))e[s]instanceof Object&&s in t?this._mergeDeep(t[s],e[s]):t[s]=e[s]}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 s=this._getTranslation(t,this.currentLocale);return s||(s=this._getTranslation(t,this.fallbackLocale)),s?this._interpolate(s,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const s=t.split(this.delimiter);let n=this.locales[e];for(const r of s)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,(s,n)=>e[n]!==void 0?e[n]:s)}n(t,e,s={}){const n=this.t(t,{...s,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(s){return console.error("Failed to load locale:",s),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const s=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(s,e).format(n)}formatNumber(t,e={}){const s=e.locale||this.currentLocale;return new Intl.NumberFormat(s,e).format(t)}formatCurrency(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...s}).format(t)}formatRelativeTime(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,s).format(t,e)}}const F=new ut;function ga(i){return new ut(i)}function _a(i,t={}){return F.t(i,t)}function ya(i,t,e={}){return F.n(i,t,e)}function va(i){return F.setLocale(i)}function ba(){return F.getLocale()}function Ea(i,t={}){return F.formatDate(i,t)}function ka(i,t={}){return F.formatNumber(i,t)}function wa(i,t,e={}){return F.formatCurrency(i,t,e)}class we{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,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:s,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=p=>{a&&this.offById(c),s.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,s,n={}){return this.on(t,e,s,{...n,once:!0})}off(t,e,s){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(l=>l.handler!==s);r.forEach(l=>{l.handler===s&&(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,s]of this._listeners){const n=s.findIndex(r=>r.id===t);if(n!==-1){const r=s[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),s.splice(n,1),s.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(s=>{this.offById(s)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const s=this._getEventKey(t,e);if(!this._listeners.has(s))return;this._listeners.get(s).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(s)}else for(const[s,n]of this._listeners){const[r]=s.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(s))}}emit(t,e,s={}){const n=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,s={}){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,s)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let s=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[l]=r.split(":");l===n&&(s+=a.length)}return s}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),s=e.indexOf(t.id);s!==-1&&(e.splice(s,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(s=>{s.target.removeEventListener(s.eventName,s.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const M=new we;function xa(i,t,e,s){return M.on(i,t,e,s)}function Ca(i,t,e,s){return M.once(i,t,e,s)}function Sa(i,t,e){M.off(i,t,e)}function La(i,t,e){return M.emit(i,t,e)}function Da(i,t){return M.emitGlobal(i,t)}function Ha(i){M.offByScope(i)}function Ma(i,t){M.offAll(i,t)}function Ta(i,t){return M.getListenerCount(i,t)}class xe{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)}`,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.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._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=>{const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),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=>{this.element.contains(t.target)||this.hideMenu()},this._documentClickListener=M.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.addEventListener("click",this._itemClickHandler),t._dropdownItemClickHandler=this._itemClickHandler})}_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(),s=window.innerHeight,n=window.innerWidth;this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup");const r=s-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.menu.style.display="block",this.element.classList.add("is-open"),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.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})))}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 s=document.createElement("div");s.className="ds-dropdown__divider",this.menu.appendChild(s)}else{const s=document.createElement("div");s.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),s.textContent=e.text||e.label||"",e.value!==void 0&&s.setAttribute("data-value",e.value),e.icon&&(s.innerHTML=e.icon+s.innerHTML),e.disabled&&s.classList.add("is-disabled"),this.menu.appendChild(s)}}),this._bindMenuItems()}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._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 pt(i,t){const e=new xe(i,t);e.init(),i._kupolaDropdown=e}function Ia(i=document){i.querySelectorAll(".ds-dropdown").forEach(t=>{pt(t)})}function ft(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}function Aa(){document.querySelectorAll(".ds-dropdown").forEach(i=>{ft(i)})}w.register("dropdown",pt,ft);class Ce{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.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=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=>{const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const s=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(s,e):this._selectSingleOption(s,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=>{this.element.contains(t.target)||this.hideOptions()},this._documentClickListener=M.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 s=this.filteredOptions.includes(e);e.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const s=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===s);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 s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",e.value),s.textContent=e.text||e.label,e.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(e.value)&&s.classList.add("is-selected"),s.addEventListener("click",this._optionClickHandler),s._selectOptionClickHandler=this._optionClickHandler,this.optionsEl.appendChild(s)}),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(s=>s.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 s=document.createElement("span");s.className="ds-select__tag",s.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()}),s.appendChild(n),this.tagsWrap.appendChild(s)}))}_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.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler})}_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.optionsEl.style.display="block",this.icon&&(this.icon.style.transform="rotate(180deg)"),this.element.classList.add("is-open"),this.focusIndex=-1,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.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}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(s=>s.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 s=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",s),s&&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._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function mt(i,t){const e=new Ce(i,t);e.init(),i._kupolaSelect=e}function za(i=document){i.querySelectorAll(".ds-select").forEach(t=>{mt(t)})}function Se(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}w.register("select",mt,Se);class Le{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)}`,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||parseInt(t.getAttribute("data-datepicker-week-start"))||0,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._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=M.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=M.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(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",s).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(),s=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=s&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;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(s=>{s!==this.calendarEl&&(s.style.display="none",s.setAttribute("hidden",""))}),e||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days")}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(),s=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[s]}`,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,s,1).getDay(),p=new Date(e,s+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,s,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(),s=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=`${s} - ${s+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=s+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(),s=document.createElement("div");s.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()}),s.appendChild(n),s.appendChild(r),s.appendChild(a),t.appendChild(s);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._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 gt(i,t){const e=new Le(i,t);e.init(),i._kupolaDatepicker=e}function Pa(i=document){i.querySelectorAll(".ds-datepicker").forEach(t=>{gt(t)})}function De(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}w.register("datepicker",gt,De);class He{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=M.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=M.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 s=t.split(":");s.length>=2&&(this.selectedHour=parseInt(s[0])||0,this.selectedMinute=parseInt(s[1])||0,this.selectedSecond=s[2]&&parseInt(s[2])||0)}_isTimeDisabled(t,e,s){if(this.disabledTime)return this.disabledTime(t,e,s);const n=t*3600+e*60+s;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,s=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(s).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(s).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">
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</div>
|
|
27
27
|
<div class="ds-timepicker__body">${t}</div>
|
|
28
28
|
${this.clearable?'<div class="ds-timepicker__footer"><button class="ds-timepicker__clear-btn" type="button">Clear</button></div>':""}
|
|
29
|
-
`,this.element.appendChild(this.panelEl),this._populateHourGrid(),this._populateMinuteGrid(),this.showSeconds&&this._populateSecondGrid(),this.use12Hour&&this._populateAmPmGrid(),this.clearable){const e=this.panelEl.querySelector(".ds-timepicker__clear-btn");e&&e.addEventListener("click",s=>{s.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",e=>e.stopPropagation()),this._syncPanelSelection(),setTimeout(()=>{this.calculatePosition(),this._scrollToSelection()},0)}_populateHourGrid(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;const e=this.use12Hour?1:0;for(let s=e;s<(this.use12Hour?13:24);s+=this.hourStep){const n=document.createElement("button");n.type="button",n.className="ds-timepicker__item",n.textContent=String(s).padStart(2,"0"),n.dataset.value=s,n.addEventListener("click",()=>{let r=s;this.use12Hour&&(s===12?r=this.isPM?12:0:r=this.isPM?s+12:s),this.selectedHour=r,this._updateDisplay(),this._syncGridSelection("hour",s),this._confirmSelection()}),t.appendChild(n)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(s)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(s)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=e,s.dataset.value=e,s.addEventListener("click",()=>{this.isPM=e==="PM",this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this._updateDisplay(),t.querySelectorAll(".ds-timepicker__item").forEach(n=>n.classList.remove("is-selected")),s.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(s)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),s=this.panelEl.querySelector(".ds-timepicker__display-second"),n=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const r=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(r).padStart(2,"0")}e&&(e.textContent=String(this.selectedMinute).padStart(2,"0")),s&&(s.textContent=String(this.selectedSecond).padStart(2,"0")),n&&(n.textContent=this.selectedHour>=12?"PM":"AM")}_syncPanelSelection(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this._syncGridSelection("hour",t),this._syncGridSelection("minute",this.selectedMinute),this._syncGridSelection("second",this.selectedSecond);const e=this.panelEl.querySelector('[data-type="ampm"]');e&&e.querySelectorAll(".ds-timepicker__item").forEach(s=>{s.classList.toggle("is-selected",s.dataset.value==="PM"==this.selectedHour>=12)}),this._updateDisplay()}_syncGridSelection(t,e){const s=this.panelEl.querySelector(`[data-type="${t}"]`);s&&s.querySelectorAll(".ds-timepicker__item").forEach(n=>{n.classList.toggle("is-selected",parseInt(n.dataset.value)===e)})}_scrollToSelection(){["hour","minute","second"].forEach(t=>{const e=this.panelEl.querySelector(`[data-type="${t}"]`);if(!e)return;const s=e.querySelector(".is-selected");s&&s.scrollIntoView({block:"center"})})}_confirmSelection(){this.input.value=this._formatTime()}hideTimepicker(t){this.panelEl&&this.panelEl.style.display==="block"&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this._formatTime(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this._formatTime()})))}resizeHandler(){this.panelEl&&this.panelEl.style.display==="block"&&this.calculatePosition()}setTime(t,e,s){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,e)),this.selectedSecond=Math.max(0,Math.min(59,s||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this._formatTime()),this.panelEl&&this._syncPanelSelection()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.__kupolaInitialized&&(this.inputWrap&&this._inputWrapClickHandler&&this.inputWrap.removeEventListener("click",this._inputWrapClickHandler),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._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function _t(i,t){const e=new De(i,t);e.init(),i._kupolaTimepicker=e}function Pa(i=document){i.querySelectorAll(".ds-timepicker").forEach(t=>{_t(t)})}function He(i){i._kupolaTimepicker&&(i._kupolaTimepicker.destroy(),i._kupolaTimepicker=null)}w.register("timepicker",_t,He);class Me{constructor(t,e={}){if(this.element=t,this.track=t.querySelector(".ds-slider__track"),this.fill=t.querySelector(".ds-slider__fill"),this.input=t.querySelector(".ds-slider__input"),this.valueEl=t.querySelector(".ds-slider__value"),this.range=e.range||t.hasAttribute("data-slider-range"),this.vertical=e.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=e.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=e.showTooltip!==!1,this.showMarks=e.marks||t.hasAttribute("data-slider-marks"),this.markStep=e.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=e.tooltipFormat||(s=>s),this.onChange=e.onChange||null,this.onInput=e.onInput||null,this.inputEnd=t.querySelector(".ds-slider__input--end"),this.fillEnd=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this._listeners=[],this._isDragging=!1,this._activeThumb=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this._build(),this._bindEvents(),this.updateSlider()}_build(){this.vertical&&this.element.classList.add("ds-slider--vertical"),this.disabled&&this.element.classList.add("is-disabled"),this.element.querySelector(".ds-slider__thumb")?this.thumbStart=this.element.querySelector(".ds-slider__thumb--start"):(this.thumbStart=document.createElement("div"),this.thumbStart.className="ds-slider__thumb ds-slider__thumb--start",this.thumbStart.setAttribute("role","slider"),this.thumbStart.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbStart),this.showTooltip&&(this.tooltipStart=document.createElement("div"),this.tooltipStart.className="ds-slider__tooltip",this.thumbStart.appendChild(this.tooltipStart))),this.range&&(this.element.classList.add("ds-slider--range"),this.element.querySelector(".ds-slider__thumb--end")?this.thumbEnd=this.element.querySelector(".ds-slider__thumb--end"):(this.thumbEnd=document.createElement("div"),this.thumbEnd.className="ds-slider__thumb ds-slider__thumb--end",this.thumbEnd.setAttribute("role","slider"),this.thumbEnd.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbEnd),this.showTooltip&&(this.tooltipEnd=document.createElement("div"),this.tooltipEnd.className="ds-slider__tooltip",this.thumbEnd.appendChild(this.tooltipEnd)))),this.showMarks&&this._renderMarks()}_renderMarks(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);for(let s=t;s<=e;s+=this.markStep){const n=document.createElement("div");n.className="ds-slider__mark";const r=(s-t)/(e-t)*100;this.vertical?n.style.bottom=r+"%":n.style.left=r+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=s,n.appendChild(a),this.marksEl.appendChild(n)}this.element.appendChild(this.marksEl)}_bindEvents(){if(this.input){const t=()=>this.updateSlider(),e=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",e),this._listeners.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:e})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this._listeners.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this._bindThumbDrag(this.thumbStart,"start"),this.thumbEnd&&this._bindThumbDrag(this.thumbEnd,"end"),this.track){const t=e=>{this.disabled||this._handleTrackClick(e)};this.track.addEventListener("click",t),this._listeners.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=e=>this._handleKeyboard(e,"start");this.thumbStart.addEventListener("keydown",t),this._listeners.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=e=>this._handleKeyboard(e,"end");this.thumbEnd.addEventListener("keydown",t),this._listeners.push({el:this.thumbEnd,event:"keydown",handler:t})}}_bindThumbDrag(t,e){const s=a=>{this.disabled||(a.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",r))},n=a=>{if(!this._isDragging)return;a.preventDefault();const l=a.touches?a.touches[0].clientX:a.clientX,o=a.touches?a.touches[0].clientY:a.clientY,c=this.track.getBoundingClientRect();let d;this.vertical?d=1-(o-c.top)/c.height:d=(l-c.left)/c.width,d=Math.max(0,Math.min(1,d));const u=parseFloat(this.input?.min||0),p=parseFloat(this.input?.max||100),m=parseFloat(this.input?.step||1);let f=u+d*(p-u);if(f=Math.round(f/m)*m,f=Math.max(u,Math.min(p,f)),e==="start"&&this.range&&this.inputEnd){const g=parseFloat(this.inputEnd.value);f>g&&(f=g)}if(e==="end"&&this.range&&this.input){const g=parseFloat(this.input.value);f<g&&(f=g)}e==="start"&&this.input?this.input.value=f:e==="end"&&this.inputEnd&&(this.inputEnd.value=f),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:d})},r=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",r),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",s),t.addEventListener("touchstart",s,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:s},{el:t,event:"touchstart",handler:s})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),s=t.clientX,n=t.clientY;let r;this.vertical?r=1-(n-e.top)/e.height:r=(s-e.left)/e.width,r=Math.max(0,Math.min(1,r));const a=parseFloat(this.input?.min||0),l=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let c=a+r*(l-a);if(c=Math.round(c/o)*o,this.range){const d=parseFloat(this.input?.value||0),u=parseFloat(this.inputEnd?.value||0),p=Math.abs(c-d),m=Math.abs(c-u);p<=m?this.input&&(this.input.value=Math.min(c,u)):this.inputEnd&&(this.inputEnd.value=Math.max(c,d))}else this.input&&(this.input.value=c);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const s=e==="start"?this.input:this.inputEnd;if(!s)return;const n=parseFloat(s.step||1),r=parseFloat(s.min||0),a=parseFloat(s.max||100);let l=parseFloat(s.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),l=Math.min(a,l+n);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),l=Math.max(r,l-n);break;case"Home":t.preventDefault(),l=r;break;case"End":t.preventDefault(),l=a;break;default:return}s.value=l,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const s=parseFloat(this.input?.value||0),n=parseFloat(this.inputEnd?.value||0),r=(s-t)/(e-t)*100,a=(n-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=r+"%",this.fill.style.height=a-r+"%"):(this.fill.style.left=r+"%",this.fill.style.width=a-r+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=r+"%":this.thumbStart.style.left=r+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(s)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(n)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(s)} - ${this.tooltipFormat(n)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",n)}else{const s=this.input?.value||0,n=(s-t)/(e-t)*100;this.vertical?this.fill.style.height=`${n}%`:this.fill.style.width=`${n}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(s))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(s))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.element.setAttribute("aria-valuenow",s)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.marksEl&&this.marksEl.remove(),this.track=null,this.fill=null,this.input=null,this.inputEnd=null,this.valueEl=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.element=null}setValue(t,e){this.input&&(this.input.value=t),e!==void 0&&this.inputEnd&&(this.inputEnd.value=e),this.updateSlider()}getValue(){return this.range&&this.inputEnd?[parseFloat(this.input?.value||0),parseFloat(this.inputEnd?.value||0)]:parseFloat(this.input?.value||0)}enable(){this.disabled=!1,this.element.classList.remove("is-disabled")}disable(){this.disabled=!0,this.element.classList.add("is-disabled")}}function yt(i,t){if(!i.__kupolaInitialized)try{const e=new Me(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function Te(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function $a(){document.querySelectorAll(".ds-slider").forEach(i=>{yt(i)})}w.register("slider",yt,Te);class Ie{constructor(t,e={}){this.element=t,this.track=t.querySelector(".ds-carousel__track"),this.items=t.querySelectorAll(".ds-carousel__item"),this.prevBtn=t.querySelector(".ds-carousel__prev"),this.nextBtn=t.querySelector(".ds-carousel__next"),this.indicators=t.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=t.querySelector(".ds-carousel__auto"),this.mode=e.mode||t.getAttribute("data-carousel-mode")||"slide",this.vertical=e.vertical||t.hasAttribute("data-carousel-vertical"),this.autoPlay=e.autoPlay!==!1,this.interval=e.interval||parseInt(t.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=e.transitionDuration||parseInt(t.getAttribute("data-carousel-duration"))||500,this.loop=e.loop!==!1,this.pauseOnHover=e.pauseOnHover!==!1,this.swipe=e.swipe!==!1,this.swipeThreshold=e.swipeThreshold||50,this.keyboardNav=e.keyboardNav||t.hasAttribute("data-carousel-keyboard"),this.onChange=e.onChange||null,this.currentIndex=0,this.totalItems=this.items.length,this.autoPlayTimer=null,this.isAutoPlaying=!1,this.isTransitioning=!1,this.touchStartX=0,this.touchStartY=0,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!1,this._mouseEnterHandler=()=>{this.pauseOnHover&&this.stopAutoPlay()},this._mouseLeaveHandler=()=>{this.pauseOnHover&&this.autoPlay&&this.startAutoPlay()},this.init()}init(){this._prevClickHandler=()=>this.prev(),this._nextClickHandler=()=>this.next(),this._autoClickHandler=()=>this.toggleAutoPlay(),this._indicatorClickHandlers=[],this.prevBtn&&this.prevBtn.addEventListener("click",this._prevClickHandler),this.nextBtn&&this.nextBtn.addEventListener("click",this._nextClickHandler),this.indicators.forEach((t,e)=>{const s=()=>this.goTo(e);this._indicatorClickHandlers.push(s),t.addEventListener("click",s)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.swipe&&(this._touchStartHandler=t=>this._handleTouchStart(t),this._touchMoveHandler=t=>this._handleTouchMove(t),this._touchEndHandler=()=>this._handleTouchEnd(),this.element.addEventListener("touchstart",this._touchStartHandler,{passive:!0}),this.element.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),this.element.addEventListener("touchend",this._touchEndHandler)),this.keyboardNav&&(this._keydownHandler=t=>{this.element.contains(document.activeElement)&&(t.key==="ArrowLeft"||t.key==="ArrowUp"?(t.preventDefault(),this.prev()):(t.key==="ArrowRight"||t.key==="ArrowDown")&&(t.preventDefault(),this.next()))},this.element.addEventListener("keydown",this._keydownHandler)),this.mode==="fade"&&this.element.classList.add("ds-carousel--fade"),this.vertical&&this.element.classList.add("ds-carousel--vertical"),this.track&&(this.track.style.transitionDuration=this.transitionDuration+"ms"),this.updateIndicators(),this.autoPlay&&this.startAutoPlay(),this.element.addEventListener("mouseenter",this._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(t){if(this.isTransitioning||t<0||t>=this.totalItems)return;this.isTransitioning=!0;const e=this.currentIndex;if(this.currentIndex=t,this.mode==="fade")this.items.forEach((s,n)=>{s.style.opacity=n===t?"1":"0",s.style.zIndex=n===t?"1":"0"});else if(this.vertical){const s=-t*100;this.track.style.transform=`translateY(${s}%)`}else{const s=-t*100;this.track.style.transform=`translateX(${s}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:t,prevIndex:e,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:t,prevIndex:e,total:this.totalItems},bubbles:!0}))}prev(){this.currentIndex>0?this.goTo(this.currentIndex-1):this.loop&&this.goTo(this.totalItems-1)}next(){this.currentIndex<this.totalItems-1?this.goTo(this.currentIndex+1):this.loop&&this.goTo(0)}updateIndicators(){this.indicators.forEach((t,e)=>{t.classList.toggle("is-active",e===this.currentIndex)}),this.loop||(this.prevBtn&&(this.prevBtn.disabled=this.currentIndex===0),this.nextBtn&&(this.nextBtn.disabled=this.currentIndex===this.totalItems-1))}startAutoPlay(){this.totalItems<=1||(this.stopAutoPlay(),this.isAutoPlaying=!0,this.autoBtn&&this.autoBtn.classList.add("is-active"),this.autoPlayTimer=setInterval(()=>this.next(),this.interval))}stopAutoPlay(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.isAutoPlaying=!1,this.autoBtn&&this.autoBtn.classList.remove("is-active")}toggleAutoPlay(){this.isAutoPlaying?this.stopAutoPlay():this.startAutoPlay()}_handleTouchStart(t){this.touchStartX=t.touches[0].clientX,this.touchStartY=t.touches[0].clientY,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!0,this.isAutoPlaying&&(this.stopAutoPlay(),this._wasAutoPlaying=!0)}_handleTouchMove(t){if(!this.isSwiping)return;this.touchDeltaX=t.touches[0].clientX-this.touchStartX,this.touchDeltaY=t.touches[0].clientY-this.touchStartY;const e=Math.abs(this.touchDeltaX),s=Math.abs(this.touchDeltaY);e>s&&e>10&&t.preventDefault()}_handleTouchEnd(){if(!this.isSwiping)return;this.isSwiping=!1;const t=Math.abs(this.touchDeltaX),e=Math.abs(this.touchDeltaY);t>this.swipeThreshold&&t>e&&(this.touchDeltaX>0?this.prev():this.next()),this._wasAutoPlaying&&(this.startAutoPlay(),this._wasAutoPlaying=!1)}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this._mouseEnterHandler),this.element.removeEventListener("mouseleave",this._mouseLeaveHandler),this.prevBtn&&this._prevClickHandler&&this.prevBtn.removeEventListener("click",this._prevClickHandler),this.nextBtn&&this._nextClickHandler&&this.nextBtn.removeEventListener("click",this._nextClickHandler),this.autoBtn&&this._autoClickHandler&&this.autoBtn.removeEventListener("click",this._autoClickHandler),this.indicators.forEach((t,e)=>{const s=this._indicatorClickHandlers[e];s&&t.removeEventListener("click",s)}),this._touchStartHandler&&this.element.removeEventListener("touchstart",this._touchStartHandler),this._touchMoveHandler&&this.element.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndHandler&&this.element.removeEventListener("touchend",this._touchEndHandler),this._keydownHandler&&this.element.removeEventListener("keydown",this._keydownHandler),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function vt(i,t){if(i.__kupolaInitialized)return;const e=new Ie(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function qa(i=document){i.querySelectorAll(".ds-carousel").forEach(t=>{vt(t)})}function Ae(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}w.register("carousel",vt,Ae);class ze{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=e.placement||t.getAttribute("data-drawer-placement")||"right",this.width=e.width||t.getAttribute("data-drawer-width")||"400px",this.height=e.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=e.escClose!==!1,this.maskClosable=e.maskClosable!==!1,this.showMask=e.showMask!==!1,this.onOpen=e.onOpen||null,this.onClose=e.onClose||null,this.onBeforeClose=e.onBeforeClose||null,this._keydownHandler=null,this._bindEvents()}_bindEvents(){const t=this.mask?.querySelector(".ds-drawer__close"),e=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),s=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible"),document.body.style.overflow="",this.onClose&&this.onClose(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-close",{bubbles:!0})))},this.handleMaskClick=n=>{this.maskClosable&&n.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),e&&e.addEventListener("click",this.closeDrawer),s&&s.addEventListener("click",this.closeDrawer),this.escClose&&(this._keydownHandler=n=>{n.key==="Escape"&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this._keydownHandler)),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:e,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer}].filter(n=>n.el)}_applyPlacement(){this.drawerEl&&(this.drawerEl.classList.remove("ds-drawer--right","ds-drawer--left","ds-drawer--top","ds-drawer--bottom"),this.drawerEl.classList.add(`ds-drawer--${this.placement}`),this.placement==="left"||this.placement==="right"?this.drawerEl.style.width=this.width:this.drawerEl.style.height=this.height,!this.showMask&&this.mask&&(this.mask.style.background="transparent",this.mask.style.pointerEvents="none",this.drawerEl.style.boxShadow="0 0 24px rgba(0,0,0,0.15)"))}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._listeners=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._applyPlacement(),this.mask&&this.mask.classList.add("is-visible"),this.drawerEl&&this.drawerEl.classList.add("is-visible"),document.body.style.overflow="hidden",this.onOpen&&this.onOpen(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-open",{bubbles:!0}))}close(){this.closeDrawer()}isOpen(){return this.drawerEl?.classList.contains("is-visible")||!1}}function st(i,t){if(i.__kupolaInitialized)return;const e=new ze(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Pe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ba(){document.querySelectorAll("[data-drawer]").forEach(i=>{i.addEventListener("click",()=>{const t=i.getAttribute("data-drawer"),e=document.getElementById(t);e&&(st(e,{placement:i.getAttribute("data-drawer-placement")||"right",width:i.getAttribute("data-drawer-width"),height:i.getAttribute("data-drawer-height")}),e.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(i=>{const t=i.parentElement;t&&st(t)})}w.register("drawer",st,Pe);class z{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close"),this.fullscreen=e.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=e.closableOnMask!==!1,this.escClose=e.escClose!==!1,this.width=e.width||t.getAttribute("data-modal-width")||"",this.center=e.center!==!1,this.onBeforeOpen=e.onBeforeOpen||null,this.onBeforeClose=e.onBeforeClose||null,this.onOpened=e.onOpened||null,this.onClosed=e.onClosed||null,this._isOpen=!1,this._keydownHandler=s=>{this.escClose&&s.key==="Escape"&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=s=>{this.closableOnMask&&s.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.addEventListener("click",this._maskClickHandler),document.addEventListener("keydown",this._keydownHandler),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){this.onBeforeOpen&&this.onBeforeOpen()===!1||(this.mask&&(this.mask.classList.add("is-visible"),this.mask.classList.add("ds-modal-fade-enter"),requestAnimationFrame(()=>{this.mask.classList.add("ds-modal-fade-enter-active")})),this.modal&&(this.modal.classList.add("ds-modal-zoom-enter"),requestAnimationFrame(()=>{this.modal.classList.add("ds-modal-zoom-enter-active")})),this._isOpen||(z._openCount=(z._openCount||0)+1,this._isOpen=!0),document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0})))}close(){this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&(this.mask.classList.remove("ds-modal-fade-enter-active"),this.mask.classList.add("ds-modal-fade-leave-active")),this.modal&&(this.modal.classList.remove("ds-modal-zoom-enter-active"),this.modal.classList.add("ds-modal-zoom-leave-active")),setTimeout(()=>{this.mask&&this.mask.classList.remove("is-visible","ds-modal-fade-enter","ds-modal-fade-leave-active"),this.modal&&this.modal.classList.remove("ds-modal-zoom-enter","ds-modal-zoom-leave-active")},300),this._isOpen&&(z._openCount=Math.max(0,(z._openCount||0)-1),this._isOpen=!1,z._openCount===0&&(document.body.style.overflow="")),this.onClosed&&setTimeout(()=>this.onClosed(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-close",{bubbles:!0})))}toggleFullscreen(){this.fullscreen=!this.fullscreen,this.modal&&this.modal.classList.toggle("ds-modal--fullscreen",this.fullscreen)}isVisible(){return this.mask&&this.mask.classList.contains("is-visible")}destroy(){document.removeEventListener("keydown",this._keydownHandler),this.closeBtn&&this.closeBtn.removeEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.removeEventListener("click",this._maskClickHandler),this._isOpen&&(z._openCount=Math.max(0,(z._openCount||0)-1),this._isOpen=!1,z._openCount===0&&(document.body.style.overflow=""))}}z._openCount=0;function bt(i={}){const{title:t="",content:e="",html:s=!1,width:n="480px",fullscreen:r=!1,showCancel:a=!0,showConfirm:l=!0,confirmText:o="OK",cancelText:c="Cancel",confirmClass:d="ds-btn--brand",cancelClass:u="ds-btn--ghost",closable:p=!0,maskClosable:m=!0,onConfirm:f,onCancel:g,onOpen:v,onClose:y,footer:k=null}=i,E=document.createElement("div");E.className="ds-modal-container";let b="";k!==null&&(typeof k=="string"?b=`<div class="ds-modal__footer">${k}</div>`:(l||a)&&(b=`<div class="ds-modal__footer">
|
|
29
|
+
`,this.element.appendChild(this.panelEl),this._populateHourGrid(),this._populateMinuteGrid(),this.showSeconds&&this._populateSecondGrid(),this.use12Hour&&this._populateAmPmGrid(),this.clearable){const e=this.panelEl.querySelector(".ds-timepicker__clear-btn");e&&e.addEventListener("click",s=>{s.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",e=>e.stopPropagation()),this._syncPanelSelection(),setTimeout(()=>{this.calculatePosition(),this._scrollToSelection()},0)}_populateHourGrid(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;const e=this.use12Hour?1:0;for(let s=e;s<(this.use12Hour?13:24);s+=this.hourStep){const n=document.createElement("button");n.type="button",n.className="ds-timepicker__item",n.textContent=String(s).padStart(2,"0"),n.dataset.value=s,n.addEventListener("click",()=>{let r=s;this.use12Hour&&(s===12?r=this.isPM?12:0:r=this.isPM?s+12:s),this.selectedHour=r,this._updateDisplay(),this._syncGridSelection("hour",s),this._confirmSelection()}),t.appendChild(n)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(s)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(s)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=e,s.dataset.value=e,s.addEventListener("click",()=>{this.isPM=e==="PM",this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this._updateDisplay(),t.querySelectorAll(".ds-timepicker__item").forEach(n=>n.classList.remove("is-selected")),s.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(s)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),s=this.panelEl.querySelector(".ds-timepicker__display-second"),n=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const r=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(r).padStart(2,"0")}e&&(e.textContent=String(this.selectedMinute).padStart(2,"0")),s&&(s.textContent=String(this.selectedSecond).padStart(2,"0")),n&&(n.textContent=this.selectedHour>=12?"PM":"AM")}_syncPanelSelection(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this._syncGridSelection("hour",t),this._syncGridSelection("minute",this.selectedMinute),this._syncGridSelection("second",this.selectedSecond);const e=this.panelEl.querySelector('[data-type="ampm"]');e&&e.querySelectorAll(".ds-timepicker__item").forEach(s=>{s.classList.toggle("is-selected",s.dataset.value==="PM"==this.selectedHour>=12)}),this._updateDisplay()}_syncGridSelection(t,e){const s=this.panelEl.querySelector(`[data-type="${t}"]`);s&&s.querySelectorAll(".ds-timepicker__item").forEach(n=>{n.classList.toggle("is-selected",parseInt(n.dataset.value)===e)})}_scrollToSelection(){["hour","minute","second"].forEach(t=>{const e=this.panelEl.querySelector(`[data-type="${t}"]`);if(!e)return;const s=e.querySelector(".is-selected");s&&s.scrollIntoView({block:"center"})})}_confirmSelection(){this.input.value=this._formatTime()}hideTimepicker(t){this.panelEl&&this.panelEl.style.display==="block"&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this._formatTime(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this._formatTime()})))}resizeHandler(){this.panelEl&&this.panelEl.style.display==="block"&&this.calculatePosition()}setTime(t,e,s){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,e)),this.selectedSecond=Math.max(0,Math.min(59,s||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this._formatTime()),this.panelEl&&this._syncPanelSelection()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.__kupolaInitialized&&(this.inputWrap&&this._inputWrapClickHandler&&this.inputWrap.removeEventListener("click",this._inputWrapClickHandler),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._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function _t(i,t){const e=new He(i,t);e.init(),i._kupolaTimepicker=e}function $a(i=document){i.querySelectorAll(".ds-timepicker").forEach(t=>{_t(t)})}function Me(i){i._kupolaTimepicker&&(i._kupolaTimepicker.destroy(),i._kupolaTimepicker=null)}w.register("timepicker",_t,Me);class Te{constructor(t,e={}){if(this.element=t,this.track=t.querySelector(".ds-slider__track"),this.fill=t.querySelector(".ds-slider__fill"),this.input=t.querySelector(".ds-slider__input"),this.valueEl=t.querySelector(".ds-slider__value"),this.range=e.range||t.hasAttribute("data-slider-range"),this.vertical=e.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=e.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=e.showTooltip!==!1,this.showMarks=e.marks||t.hasAttribute("data-slider-marks"),this.markStep=e.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=e.tooltipFormat||(s=>s),this.onChange=e.onChange||null,this.onInput=e.onInput||null,this.inputEnd=t.querySelector(".ds-slider__input--end"),this.fillEnd=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this._listeners=[],this._isDragging=!1,this._activeThumb=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this._build(),this._bindEvents(),this.updateSlider()}_build(){this.vertical&&this.element.classList.add("ds-slider--vertical"),this.disabled&&this.element.classList.add("is-disabled"),this.element.querySelector(".ds-slider__thumb")?this.thumbStart=this.element.querySelector(".ds-slider__thumb--start"):(this.thumbStart=document.createElement("div"),this.thumbStart.className="ds-slider__thumb ds-slider__thumb--start",this.thumbStart.setAttribute("role","slider"),this.thumbStart.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbStart),this.showTooltip&&(this.tooltipStart=document.createElement("div"),this.tooltipStart.className="ds-slider__tooltip",this.thumbStart.appendChild(this.tooltipStart))),this.range&&(this.element.classList.add("ds-slider--range"),this.element.querySelector(".ds-slider__thumb--end")?this.thumbEnd=this.element.querySelector(".ds-slider__thumb--end"):(this.thumbEnd=document.createElement("div"),this.thumbEnd.className="ds-slider__thumb ds-slider__thumb--end",this.thumbEnd.setAttribute("role","slider"),this.thumbEnd.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbEnd),this.showTooltip&&(this.tooltipEnd=document.createElement("div"),this.tooltipEnd.className="ds-slider__tooltip",this.thumbEnd.appendChild(this.tooltipEnd)))),this.showMarks&&this._renderMarks()}_renderMarks(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);for(let s=t;s<=e;s+=this.markStep){const n=document.createElement("div");n.className="ds-slider__mark";const r=(s-t)/(e-t)*100;this.vertical?n.style.bottom=r+"%":n.style.left=r+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=s,n.appendChild(a),this.marksEl.appendChild(n)}this.element.appendChild(this.marksEl)}_bindEvents(){if(this.input){const t=()=>this.updateSlider(),e=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",e),this._listeners.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:e})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this._listeners.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this._bindThumbDrag(this.thumbStart,"start"),this.thumbEnd&&this._bindThumbDrag(this.thumbEnd,"end"),this.track){const t=e=>{this.disabled||this._handleTrackClick(e)};this.track.addEventListener("click",t),this._listeners.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=e=>this._handleKeyboard(e,"start");this.thumbStart.addEventListener("keydown",t),this._listeners.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=e=>this._handleKeyboard(e,"end");this.thumbEnd.addEventListener("keydown",t),this._listeners.push({el:this.thumbEnd,event:"keydown",handler:t})}}_bindThumbDrag(t,e){const s=a=>{this.disabled||(a.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",r))},n=a=>{if(!this._isDragging)return;a.preventDefault();const l=a.touches?a.touches[0].clientX:a.clientX,o=a.touches?a.touches[0].clientY:a.clientY,c=this.track.getBoundingClientRect();let d;this.vertical?d=1-(o-c.top)/c.height:d=(l-c.left)/c.width,d=Math.max(0,Math.min(1,d));const u=parseFloat(this.input?.min||0),p=parseFloat(this.input?.max||100),m=parseFloat(this.input?.step||1);let f=u+d*(p-u);if(f=Math.round(f/m)*m,f=Math.max(u,Math.min(p,f)),e==="start"&&this.range&&this.inputEnd){const g=parseFloat(this.inputEnd.value);f>g&&(f=g)}if(e==="end"&&this.range&&this.input){const g=parseFloat(this.input.value);f<g&&(f=g)}e==="start"&&this.input?this.input.value=f:e==="end"&&this.inputEnd&&(this.inputEnd.value=f),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:d})},r=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",r),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",s),t.addEventListener("touchstart",s,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:s},{el:t,event:"touchstart",handler:s})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),s=t.clientX,n=t.clientY;let r;this.vertical?r=1-(n-e.top)/e.height:r=(s-e.left)/e.width,r=Math.max(0,Math.min(1,r));const a=parseFloat(this.input?.min||0),l=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let c=a+r*(l-a);if(c=Math.round(c/o)*o,this.range){const d=parseFloat(this.input?.value||0),u=parseFloat(this.inputEnd?.value||0),p=Math.abs(c-d),m=Math.abs(c-u);p<=m?this.input&&(this.input.value=Math.min(c,u)):this.inputEnd&&(this.inputEnd.value=Math.max(c,d))}else this.input&&(this.input.value=c);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const s=e==="start"?this.input:this.inputEnd;if(!s)return;const n=parseFloat(s.step||1),r=parseFloat(s.min||0),a=parseFloat(s.max||100);let l=parseFloat(s.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),l=Math.min(a,l+n);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),l=Math.max(r,l-n);break;case"Home":t.preventDefault(),l=r;break;case"End":t.preventDefault(),l=a;break;default:return}s.value=l,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const s=parseFloat(this.input?.value||0),n=parseFloat(this.inputEnd?.value||0),r=(s-t)/(e-t)*100,a=(n-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=r+"%",this.fill.style.height=a-r+"%"):(this.fill.style.left=r+"%",this.fill.style.width=a-r+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=r+"%":this.thumbStart.style.left=r+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(s)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(n)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(s)} - ${this.tooltipFormat(n)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",n)}else{const s=this.input?.value||0,n=(s-t)/(e-t)*100;this.vertical?this.fill.style.height=`${n}%`:this.fill.style.width=`${n}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(s))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(s))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.element.setAttribute("aria-valuenow",s)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.marksEl&&this.marksEl.remove(),this.track=null,this.fill=null,this.input=null,this.inputEnd=null,this.valueEl=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.element=null}setValue(t,e){this.input&&(this.input.value=t),e!==void 0&&this.inputEnd&&(this.inputEnd.value=e),this.updateSlider()}getValue(){return this.range&&this.inputEnd?[parseFloat(this.input?.value||0),parseFloat(this.inputEnd?.value||0)]:parseFloat(this.input?.value||0)}enable(){this.disabled=!1,this.element.classList.remove("is-disabled")}disable(){this.disabled=!0,this.element.classList.add("is-disabled")}}function yt(i,t){if(!i.__kupolaInitialized)try{const e=new Te(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function Ie(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function qa(){document.querySelectorAll(".ds-slider").forEach(i=>{yt(i)})}w.register("slider",yt,Ie);class Ae{constructor(t,e={}){this.element=t,this.track=t.querySelector(".ds-carousel__track"),this.items=t.querySelectorAll(".ds-carousel__item"),this.prevBtn=t.querySelector(".ds-carousel__prev"),this.nextBtn=t.querySelector(".ds-carousel__next"),this.indicators=t.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=t.querySelector(".ds-carousel__auto"),this.mode=e.mode||t.getAttribute("data-carousel-mode")||"slide",this.vertical=e.vertical||t.hasAttribute("data-carousel-vertical"),this.autoPlay=e.autoPlay!==!1,this.interval=e.interval||parseInt(t.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=e.transitionDuration||parseInt(t.getAttribute("data-carousel-duration"))||500,this.loop=e.loop!==!1,this.pauseOnHover=e.pauseOnHover!==!1,this.swipe=e.swipe!==!1,this.swipeThreshold=e.swipeThreshold||50,this.keyboardNav=e.keyboardNav||t.hasAttribute("data-carousel-keyboard"),this.onChange=e.onChange||null,this.currentIndex=0,this.totalItems=this.items.length,this.autoPlayTimer=null,this.isAutoPlaying=!1,this.isTransitioning=!1,this.touchStartX=0,this.touchStartY=0,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!1,this._mouseEnterHandler=()=>{this.pauseOnHover&&this.stopAutoPlay()},this._mouseLeaveHandler=()=>{this.pauseOnHover&&this.autoPlay&&this.startAutoPlay()},this.init()}init(){this._prevClickHandler=()=>this.prev(),this._nextClickHandler=()=>this.next(),this._autoClickHandler=()=>this.toggleAutoPlay(),this._indicatorClickHandlers=[],this.prevBtn&&this.prevBtn.addEventListener("click",this._prevClickHandler),this.nextBtn&&this.nextBtn.addEventListener("click",this._nextClickHandler),this.indicators.forEach((t,e)=>{const s=()=>this.goTo(e);this._indicatorClickHandlers.push(s),t.addEventListener("click",s)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.swipe&&(this._touchStartHandler=t=>this._handleTouchStart(t),this._touchMoveHandler=t=>this._handleTouchMove(t),this._touchEndHandler=()=>this._handleTouchEnd(),this.element.addEventListener("touchstart",this._touchStartHandler,{passive:!0}),this.element.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),this.element.addEventListener("touchend",this._touchEndHandler)),this.keyboardNav&&(this._keydownHandler=t=>{this.element.contains(document.activeElement)&&(t.key==="ArrowLeft"||t.key==="ArrowUp"?(t.preventDefault(),this.prev()):(t.key==="ArrowRight"||t.key==="ArrowDown")&&(t.preventDefault(),this.next()))},this.element.addEventListener("keydown",this._keydownHandler)),this.mode==="fade"&&this.element.classList.add("ds-carousel--fade"),this.vertical&&this.element.classList.add("ds-carousel--vertical"),this.track&&(this.track.style.transitionDuration=this.transitionDuration+"ms"),this.updateIndicators(),this.autoPlay&&this.startAutoPlay(),this.element.addEventListener("mouseenter",this._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(t){if(this.isTransitioning||t<0||t>=this.totalItems)return;this.isTransitioning=!0;const e=this.currentIndex;if(this.currentIndex=t,this.mode==="fade")this.items.forEach((s,n)=>{s.style.opacity=n===t?"1":"0",s.style.zIndex=n===t?"1":"0"});else if(this.vertical){const s=-t*100;this.track.style.transform=`translateY(${s}%)`}else{const s=-t*100;this.track.style.transform=`translateX(${s}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:t,prevIndex:e,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:t,prevIndex:e,total:this.totalItems},bubbles:!0}))}prev(){this.currentIndex>0?this.goTo(this.currentIndex-1):this.loop&&this.goTo(this.totalItems-1)}next(){this.currentIndex<this.totalItems-1?this.goTo(this.currentIndex+1):this.loop&&this.goTo(0)}updateIndicators(){this.indicators.forEach((t,e)=>{t.classList.toggle("is-active",e===this.currentIndex)}),this.loop||(this.prevBtn&&(this.prevBtn.disabled=this.currentIndex===0),this.nextBtn&&(this.nextBtn.disabled=this.currentIndex===this.totalItems-1))}startAutoPlay(){this.totalItems<=1||(this.stopAutoPlay(),this.isAutoPlaying=!0,this.autoBtn&&this.autoBtn.classList.add("is-active"),this.autoPlayTimer=setInterval(()=>this.next(),this.interval))}stopAutoPlay(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.isAutoPlaying=!1,this.autoBtn&&this.autoBtn.classList.remove("is-active")}toggleAutoPlay(){this.isAutoPlaying?this.stopAutoPlay():this.startAutoPlay()}_handleTouchStart(t){this.touchStartX=t.touches[0].clientX,this.touchStartY=t.touches[0].clientY,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!0,this.isAutoPlaying&&(this.stopAutoPlay(),this._wasAutoPlaying=!0)}_handleTouchMove(t){if(!this.isSwiping)return;this.touchDeltaX=t.touches[0].clientX-this.touchStartX,this.touchDeltaY=t.touches[0].clientY-this.touchStartY;const e=Math.abs(this.touchDeltaX),s=Math.abs(this.touchDeltaY);e>s&&e>10&&t.preventDefault()}_handleTouchEnd(){if(!this.isSwiping)return;this.isSwiping=!1;const t=Math.abs(this.touchDeltaX),e=Math.abs(this.touchDeltaY);t>this.swipeThreshold&&t>e&&(this.touchDeltaX>0?this.prev():this.next()),this._wasAutoPlaying&&(this.startAutoPlay(),this._wasAutoPlaying=!1)}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this._mouseEnterHandler),this.element.removeEventListener("mouseleave",this._mouseLeaveHandler),this.prevBtn&&this._prevClickHandler&&this.prevBtn.removeEventListener("click",this._prevClickHandler),this.nextBtn&&this._nextClickHandler&&this.nextBtn.removeEventListener("click",this._nextClickHandler),this.autoBtn&&this._autoClickHandler&&this.autoBtn.removeEventListener("click",this._autoClickHandler),this.indicators.forEach((t,e)=>{const s=this._indicatorClickHandlers[e];s&&t.removeEventListener("click",s)}),this._touchStartHandler&&this.element.removeEventListener("touchstart",this._touchStartHandler),this._touchMoveHandler&&this.element.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndHandler&&this.element.removeEventListener("touchend",this._touchEndHandler),this._keydownHandler&&this.element.removeEventListener("keydown",this._keydownHandler),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function vt(i,t){if(i.__kupolaInitialized)return;const e=new Ae(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Ba(i=document){i.querySelectorAll(".ds-carousel").forEach(t=>{vt(t)})}function ze(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}w.register("carousel",vt,ze);class Pe{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=e.placement||t.getAttribute("data-drawer-placement")||"right",this.width=e.width||t.getAttribute("data-drawer-width")||"400px",this.height=e.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=e.escClose!==!1,this.maskClosable=e.maskClosable!==!1,this.showMask=e.showMask!==!1,this.onOpen=e.onOpen||null,this.onClose=e.onClose||null,this.onBeforeClose=e.onBeforeClose||null,this._keydownHandler=null,this._bindEvents()}_bindEvents(){const t=this.mask?.querySelector(".ds-drawer__close"),e=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),s=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible"),document.body.style.overflow="",this.onClose&&this.onClose(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-close",{bubbles:!0})))},this.handleMaskClick=n=>{this.maskClosable&&n.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),e&&e.addEventListener("click",this.closeDrawer),s&&s.addEventListener("click",this.closeDrawer),this.escClose&&(this._keydownHandler=n=>{n.key==="Escape"&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this._keydownHandler)),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:e,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer}].filter(n=>n.el)}_applyPlacement(){this.drawerEl&&(this.drawerEl.classList.remove("ds-drawer--right","ds-drawer--left","ds-drawer--top","ds-drawer--bottom"),this.drawerEl.classList.add(`ds-drawer--${this.placement}`),this.placement==="left"||this.placement==="right"?this.drawerEl.style.width=this.width:this.drawerEl.style.height=this.height,!this.showMask&&this.mask&&(this.mask.style.background="transparent",this.mask.style.pointerEvents="none",this.drawerEl.style.boxShadow="0 0 24px rgba(0,0,0,0.15)"))}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._listeners=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._applyPlacement(),this.mask&&this.mask.classList.add("is-visible"),this.drawerEl&&this.drawerEl.classList.add("is-visible"),document.body.style.overflow="hidden",this.onOpen&&this.onOpen(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-open",{bubbles:!0}))}close(){this.closeDrawer()}isOpen(){return this.drawerEl?.classList.contains("is-visible")||!1}}function st(i,t){if(i.__kupolaInitialized)return;const e=new Pe(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function $e(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Fa(){document.querySelectorAll("[data-drawer]").forEach(i=>{i.addEventListener("click",()=>{const t=i.getAttribute("data-drawer"),e=document.getElementById(t);e&&(st(e,{placement:i.getAttribute("data-drawer-placement")||"right",width:i.getAttribute("data-drawer-width"),height:i.getAttribute("data-drawer-height")}),e.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(i=>{const t=i.parentElement;t&&st(t)})}w.register("drawer",st,$e);class z{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close"),this.fullscreen=e.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=e.closableOnMask!==!1,this.escClose=e.escClose!==!1,this.width=e.width||t.getAttribute("data-modal-width")||"",this.center=e.center!==!1,this.onBeforeOpen=e.onBeforeOpen||null,this.onBeforeClose=e.onBeforeClose||null,this.onOpened=e.onOpened||null,this.onClosed=e.onClosed||null,this._isOpen=!1,this._keydownHandler=s=>{this.escClose&&s.key==="Escape"&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=s=>{this.closableOnMask&&s.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.addEventListener("click",this._maskClickHandler),document.addEventListener("keydown",this._keydownHandler),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){this.onBeforeOpen&&this.onBeforeOpen()===!1||(this.mask&&(this.mask.classList.add("is-visible"),this.mask.classList.add("ds-modal-fade-enter"),requestAnimationFrame(()=>{this.mask.classList.add("ds-modal-fade-enter-active")})),this.modal&&(this.modal.classList.add("ds-modal-zoom-enter"),requestAnimationFrame(()=>{this.modal.classList.add("ds-modal-zoom-enter-active")})),this._isOpen||(z._openCount=(z._openCount||0)+1,this._isOpen=!0),document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0})))}close(){this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&(this.mask.classList.remove("ds-modal-fade-enter-active"),this.mask.classList.add("ds-modal-fade-leave-active")),this.modal&&(this.modal.classList.remove("ds-modal-zoom-enter-active"),this.modal.classList.add("ds-modal-zoom-leave-active")),setTimeout(()=>{this.mask&&this.mask.classList.remove("is-visible","ds-modal-fade-enter","ds-modal-fade-leave-active"),this.modal&&this.modal.classList.remove("ds-modal-zoom-enter","ds-modal-zoom-leave-active")},300),this._isOpen&&(z._openCount=Math.max(0,(z._openCount||0)-1),this._isOpen=!1,z._openCount===0&&(document.body.style.overflow="")),this.onClosed&&setTimeout(()=>this.onClosed(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-close",{bubbles:!0})))}toggleFullscreen(){this.fullscreen=!this.fullscreen,this.modal&&this.modal.classList.toggle("ds-modal--fullscreen",this.fullscreen)}isVisible(){return this.mask&&this.mask.classList.contains("is-visible")}destroy(){document.removeEventListener("keydown",this._keydownHandler),this.closeBtn&&this.closeBtn.removeEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.removeEventListener("click",this._maskClickHandler),this._isOpen&&(z._openCount=Math.max(0,(z._openCount||0)-1),this._isOpen=!1,z._openCount===0&&(document.body.style.overflow=""))}}z._openCount=0;function bt(i={}){const{title:t="",content:e="",html:s=!1,width:n="480px",fullscreen:r=!1,showCancel:a=!0,showConfirm:l=!0,confirmText:o="OK",cancelText:c="Cancel",confirmClass:d="ds-btn--brand",cancelClass:u="ds-btn--ghost",closable:p=!0,maskClosable:m=!0,onConfirm:f,onCancel:g,onOpen:v,onClose:y,footer:k=null}=i,E=document.createElement("div");E.className="ds-modal-container";let b="";k!==null&&(typeof k=="string"?b=`<div class="ds-modal__footer">${k}</div>`:(l||a)&&(b=`<div class="ds-modal__footer">
|
|
30
30
|
${a?`<button class="ds-btn ${u}" data-modal-cancel>${c}</button>`:""}
|
|
31
31
|
${l?`<button class="ds-btn ${d}" data-modal-confirm>${o}</button>`:""}
|
|
32
32
|
</div>`)),E.innerHTML=`
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
${b}
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
|
-
`,document.body.appendChild(E);const C=new z(E,{fullscreen:r,closableOnMask:m}),D=E.querySelector(".ds-modal__title");D&&(D.textContent=t);const S=E.querySelector(".ds-modal__body");S&&(s?S.innerHTML=e:S.textContent=e);const H=E.querySelector("[data-modal-confirm]"),A=E.querySelector("[data-modal-cancel]");let $=!1;const O=async()=>{if(f){H.disabled=!0,H.classList.add("is-loading");try{if(await f()===!1){H.disabled=!1,H.classList.remove("is-loading");return}}catch{H.disabled=!1,H.classList.remove("is-loading");return}}$=!0,C.close()},
|
|
47
|
+
`,document.body.appendChild(E);const C=new z(E,{fullscreen:r,closableOnMask:m}),D=E.querySelector(".ds-modal__title");D&&(D.textContent=t);const S=E.querySelector(".ds-modal__body");S&&(s?S.innerHTML=e:S.textContent=e);const H=E.querySelector("[data-modal-confirm]"),A=E.querySelector("[data-modal-cancel]");let $=!1;const O=async()=>{if(f){H.disabled=!0,H.classList.add("is-loading");try{if(await f()===!1){H.disabled=!1,H.classList.remove("is-loading");return}}catch{H.disabled=!1,H.classList.remove("is-loading");return}}$=!0,C.close()},Ms=()=>{g&&g(),C.close()};H&&H.addEventListener("click",O),A&&A.addEventListener("click",Ms);const Dl=()=>{setTimeout(()=>{H&&H.removeEventListener("click",O),A&&A.removeEventListener("click",Ms),C.destroy(),E.remove(),y&&y($)},300)},Hl=C.close.bind(C);return C.close=()=>{Hl(),Dl()},C.open(),v&&setTimeout(()=>v(),50),C}function Na(i){return typeof i=="string"&&(i={content:i}),bt({...i,showCancel:!0,showConfirm:!0})}function Oa(i){return typeof i=="string"&&(i={content:i}),bt({...i,showCancel:!1,showConfirm:!0})}function Et(i){if(i.__kupolaInitialized)return;const t=new z(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function qe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ra(){document.querySelectorAll(".ds-modal-container").forEach(i=>{Et(i)})}w.register("modal",Et,qe);class Va{static normal(t={}){return this._create({type:"normal",...t})}static success(t={}){return this._create({type:"success",...t})}static warning(t={}){return this._create({type:"warning",...t})}static error(t={}){return this._create({type:"error",...t})}static info(t={}){return this._create({type:"info",...t})}static confirm(t={}){return this._create({type:"confirm",...t})}static _create(t){const{type:e="normal",title:s="",content:n="",onConfirm:r,onCancel:a}=t,l={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},o=document.createElement("div");o.className="ds-modal-container",o.innerHTML=`
|
|
48
48
|
<div class="ds-modal-mask">
|
|
49
49
|
<div class="ds-modal" style="max-width: 360px">
|
|
50
50
|
<div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
</div>
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
|
-
`,document.body.appendChild(o),s&&(o.querySelector(".ds-dialog__title").textContent=s),o.querySelector(".ds-dialog__content").textContent=n;const c=o.querySelector(".ds-modal-mask"),d=o.querySelector("[data-dialog-confirm]"),u=o.querySelector("[data-dialog-cancel]"),p=function(y){y.key==="Escape"&&(a&&a(),v())},m=function(y){y.target===c&&(a&&a(),v())},f=function(){r&&r(),v()},g=function(){a&&a(),v()},v=()=>{c.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",p),c.removeEventListener("click",m),d&&d.removeEventListener("click",f),u&&u.removeEventListener("click",g),setTimeout(()=>o.remove(),300)};return c.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",f),u&&u.addEventListener("click",g),c.addEventListener("click",m),document.addEventListener("keydown",p),{close:v}}}const
|
|
63
|
+
`,document.body.appendChild(o),s&&(o.querySelector(".ds-dialog__title").textContent=s),o.querySelector(".ds-dialog__content").textContent=n;const c=o.querySelector(".ds-modal-mask"),d=o.querySelector("[data-dialog-confirm]"),u=o.querySelector("[data-dialog-cancel]"),p=function(y){y.key==="Escape"&&(a&&a(),v())},m=function(y){y.target===c&&(a&&a(),v())},f=function(){r&&r(),v()},g=function(){a&&a(),v()},v=()=>{c.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",p),c.removeEventListener("click",m),d&&d.removeEventListener("click",f),u&&u.removeEventListener("click",g),setTimeout(()=>o.remove(),300)};return c.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",f),u&&u.addEventListener("click",g),c.addEventListener("click",m),document.addEventListener("keydown",p),{close:v}}}const Ka={normal:function(i){this.show({...i,type:"normal"})},success:function(i){this.show({...i,type:"success"})},error:function(i){this.show({...i,type:"error"})},warning:function(i){this.show({...i,type:"warning"})},info:function(i){this.show({...i,type:"info"})},show:function(i){const{title:t,message:e,type:s="normal",duration:n=4e3}=i,r=document.createElement("div");r.className=`ds-notification__item ds-notification__item--${s}`;const a={normal:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};r.innerHTML=`
|
|
64
64
|
<div class="ds-notification__icon ds-notification__icon--${s}">${a[s]}</div>
|
|
65
65
|
<div class="ds-notification__content">
|
|
66
66
|
${t?'<div class="ds-notification__title"></div>':""}
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
<button class="ds-notification__close">
|
|
70
70
|
<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>
|
|
71
71
|
</button>
|
|
72
|
-
`,t&&(r.querySelector(".ds-notification__title").textContent=t),e&&(r.querySelector(".ds-notification__message").textContent=e);let l=document.querySelector(".ds-notification");l||(l=document.createElement("div"),l.className="ds-notification",document.body.appendChild(l)),l.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),r.querySelector(".ds-notification__close").addEventListener("click",()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)}),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};function
|
|
72
|
+
`,t&&(r.querySelector(".ds-notification__title").textContent=t),e&&(r.querySelector(".ds-notification__message").textContent=e);let l=document.querySelector(".ds-notification");l||(l=document.createElement("div"),l.className="ds-notification",document.body.appendChild(l)),l.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),r.querySelector(".ds-notification__close").addEventListener("click",()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)}),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};function Wa(){}const Ua={normal:function(i,t={}){this.show(i,"normal",t)},success:function(i,t={}){this.show(i,"success",t)},error:function(i,t={}){this.show(i,"error",t)},warning:function(i,t={}){this.show(i,"warning",t)},info:function(i,t={}){this.show(i,"info",t)},show:function(i,t="normal",e={}){const{duration:s=3e3}=e,n=document.createElement("div");n.className=`ds-message__item ds-message__item--${t}`;const r={normal:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};n.innerHTML=`
|
|
73
73
|
<div class="ds-message__icon ds-message__icon--${t}">${r[t]}</div>
|
|
74
74
|
<div class="ds-message__content"></div>
|
|
75
|
-
`,n.querySelector(".ds-message__content").textContent=i;let a=document.querySelector(".ds-message");a||(a=document.createElement("div"),a.className="ds-message",document.body.appendChild(a)),a.appendChild(n),setTimeout(()=>{n.classList.add("is-visible")},10),s>0&&setTimeout(()=>{n.classList.remove("is-visible"),n.classList.add("is-exiting"),setTimeout(()=>n.remove(),300)},s)}};function
|
|
75
|
+
`,n.querySelector(".ds-message__content").textContent=i;let a=document.querySelector(".ds-message");a||(a=document.createElement("div"),a.className="ds-message",document.body.appendChild(a)),a.appendChild(n),setTimeout(()=>{n.classList.add("is-visible")},10),s>0&&setTimeout(()=>{n.classList.remove("is-visible"),n.classList.add("is-exiting"),setTimeout(()=>n.remove(),300)},s)}};function Ya(){}function Be(i){return i?i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class Fe{constructor(t){this.element=t,this.dropzone=t.querySelector(".ds-fileupload__dropzone"),this.input=t.querySelector(".ds-fileupload__input"),this.list=t.querySelector(".ds-fileupload__list"),this.progress=t.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(t.getAttribute("data-max-size"))||0,this.maxCount=parseInt(t.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const t=a=>{a.target===this.input||this.input.contains(a.target)||this.input.click()},e=a=>{const l=Array.from(a.target.files);this.addFiles(l),a.target.value=""},s=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.add("is-dragging")},n=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.remove("is-dragging")},r=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.remove("is-dragging");const l=Array.from(a.dataTransfer.files);this.addFiles(l)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",e),this.dropzone.addEventListener("dragover",s),this.dropzone.addEventListener("dragleave",n),this.dropzone.addEventListener("drop",r),this._listeners.push({el:this.dropzone,event:"click",handler:t},{el:this.input,event:"change",handler:e},{el:this.dropzone,event:"dragover",handler:s},{el:this.dropzone,event:"dragleave",handler:n},{el:this.dropzone,event:"drop",handler:r})}addFiles(t){t.forEach(e=>{if(this.maxCount>0&&this.files.length>=this.maxCount){this.showError(`Maximum ${this.maxCount} files allowed`);return}this.isValidFile(e)&&(this.files.push(e),this.renderFileItem(e),this.showPreview(e))}),this.dispatchChange()}isValidFile(t){const e=this.input.getAttribute("accept");if(e&&e!==""){const s=e.split(",").map(l=>l.trim()),n=t.type,r=t.name.toLowerCase();if(!s.some(l=>l.startsWith(".")?r.endsWith(l):l.includes("/")?l.endsWith("/*")?n.startsWith(l.replace("/*","")):n===l:!0))return this.showError(`File type not allowed: ${t.type}`),!1}return this.maxSize>0&&t.size>this.maxSize?(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1):!0}renderFileItem(t){const e=document.createElement("div");e.className="ds-fileupload__item",e.dataset.filename=t.name;const s=this.getFileIcon(t.type);e.innerHTML=`
|
|
76
76
|
<div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">
|
|
77
77
|
${s}
|
|
78
78
|
</div>
|
|
79
|
-
<span class="ds-fileupload__filename">${this.truncateFilename(
|
|
79
|
+
<span class="ds-fileupload__filename">${this.truncateFilename(Be(t.name))}</span>
|
|
80
80
|
<span class="ds-fileupload__size">${this.formatSize(t.size)}</span>
|
|
81
81
|
<button class="ds-fileupload__remove" type="button" aria-label="Remove file">
|
|
82
82
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -85,14 +85,14 @@
|
|
|
85
85
|
</svg>
|
|
86
86
|
</button>
|
|
87
87
|
`;const n=e.querySelector(".ds-fileupload__remove"),r=()=>{this.removeFile(t,e)};n.addEventListener("click",r),this._listeners.push({el:n,event:"click",handler:r}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(e)}getFileIcon(t){return t.startsWith("image/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>':t.startsWith("video/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>':t.startsWith("audio/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>':t.includes("pdf")||t.includes("document")||t.includes("text")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>':t.includes("zip")||t.includes("archive")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M16 11V7a4 4 0 0 0-8 0v4"/><polyline points="10 14 8 16 6 14"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>'}truncateFilename(t,e=20){if(t.length<=e)return t;const s=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,e-s.length-3)+"..."+s}formatSize(t){if(t===0)return"0 B";const e=1024,s=["B","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,n)).toFixed(1))+" "+s[n]}removeFile(t,e){this.files=this.files.filter(s=>s!==t),e&&e.remove(),this.files.length===0&&this.list&&(this.list.remove(),this.list=null),this.dispatchChange()}clearFiles(){this.files=[],this.list&&(this.list.remove(),this.list=null),this.preview&&(this.preview.innerHTML=""),this.clearError(),this.dispatchChange()}showError(t){this.clearError(),this.dropzone.classList.add("is-error");const e=document.createElement("div");e.className="ds-fileupload__error",e.textContent=t,e.setAttribute("role","alert"),e.setAttribute("aria-live","polite"),this.dropzone.appendChild(e),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const t=this.dropzone.querySelector(".ds-fileupload__error");t&&t.remove()}showPreview(t){if(!t.type.startsWith("image/"))return;this.preview||(this.preview=document.createElement("div"),this.preview.className="ds-fileupload__preview",this.element.insertBefore(this.preview,this.list||null));const e=new FileReader;e.onload=s=>{const n=document.createElement("div");n.className="ds-fileupload__preview-item",n.innerHTML=`
|
|
88
|
-
<img src="${s.target.result}" alt="${
|
|
88
|
+
<img src="${s.target.result}" alt="${Be(t.name)}">
|
|
89
89
|
<button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">
|
|
90
90
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
91
91
|
<path d="M18 6L6 18"/>
|
|
92
92
|
<path d="M6 6l12 12"/>
|
|
93
93
|
</svg>
|
|
94
94
|
</button>
|
|
95
|
-
`;const r=n.querySelector(".ds-fileupload__preview-remove"),a=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),n.remove(),this.preview&&this.preview.children.length===0&&(this.preview.remove(),this.preview=null)};r.addEventListener("click",a),this._listeners.push({el:r,event:"click",handler:a}),this.preview.appendChild(n)},e.readAsDataURL(t)}updateProgress(t){this.progress||(this.progress=document.createElement("div"),this.progress.className="ds-fileupload__progress",this.element.insertBefore(this.progress,this.list||null)),this.progress.style.display="block";const e=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");e.className="ds-fileupload__progress-bar",e.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(e),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const e=100;let s=0;Math.max(1,Math.floor(t.size/e));const n=setInterval(()=>{s++;const r=Math.min(100,Math.floor(s/e*100));this.updateProgress(r),s>=e&&(clearInterval(n),this.updateProgress(100))},Math.max(50,Math.floor(5e3/e)));return n}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function kt(i){if(i.__kupolaInitialized)return;const t=new Be(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function Fe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ya(){document.querySelectorAll(".ds-fileupload").forEach(i=>{kt(i)})}w.register("fileupload",kt,Fe);class Ne{constructor(t,e={}){this.element=t,this.headers=[],this._listeners=[],this.accordion=e.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=e.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=e.disabledItems||[],this.defaultExpanded=e.defaultExpanded||[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach((e,s)=>{const n=e.closest(".ds-collapse__item"),r=e.nextElementSibling;if(!n||!r||!r.classList.contains("ds-collapse__content"))return;const a=n.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(s);a&&n.classList.add("is-disabled");let l=n.classList.contains("is-active");(this.defaultExpanded==="all"||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(s))&&(l=!0),l?(n.classList.add("is-active"),r.style.height=r.scrollHeight+"px",r.style.overflow="hidden",setTimeout(()=>{n.classList.contains("is-active")&&(r.style.height="auto",r.style.overflow="visible")},this.animationDuration)):(n.classList.remove("is-active"),r.style.height="0",r.style.overflow="hidden");const o=()=>{if(a)return;const c=n.classList.contains("is-active");this.accordion&&!c&&this.headers.forEach((d,u)=>{u!==s&&d.item.classList.contains("is-active")&&this._collapseItem(d)}),c?this._collapseItem({item:n,content:r}):this._expandItem({item:n,content:r}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:s,expanded:!c,item:n},bubbles:!0}))};e.addEventListener("click",o),this.headers.push({header:e,item:n,content:r,clickHandler:o,isDisabled:a}),this._listeners.push({el:e,event:"click",handler:o})})}_expandItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height="0",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height=s.scrollHeight+"px",e.classList.add("is-active");const n=()=>{s.removeEventListener("transitionend",n),e.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible"),s.style.transition=""};s.addEventListener("transitionend",n),this._listeners.push({el:s,event:"transitionend",handler:n})}_collapseItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height=s.scrollHeight+"px",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height="0",e.classList.remove("is-active");const n=()=>{s.removeEventListener("transitionend",n),s.style.transition=""};s.addEventListener("transitionend",n),this._listeners.push({el:s,event:"transitionend",handler:n})}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.headers=null,this.element=null}toggle(t){const e=this.headers[t];e&&!e.isDisabled&&e.clickHandler()}expand(t){const e=this.headers[t];e&&!e.item.classList.contains("is-active")&&!e.isDisabled&&(this.accordion&&this.headers.forEach((s,n)=>{n!==t&&s.item.classList.contains("is-active")&&this._collapseItem(s)}),this._expandItem(e))}collapse(t){const e=this.headers[t];e&&e.item.classList.contains("is-active")&&this._collapseItem(e)}expandAll(){this.accordion||this.headers.forEach((t,e)=>{!t.item.classList.contains("is-active")&&!t.isDisabled&&this._expandItem(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this._collapseItem(t)})}getExpandedIndices(){return this.headers.map((t,e)=>t.item.classList.contains("is-active")?e:-1).filter(t=>t>=0)}disable(t){this.headers[t]&&(this.headers[t].isDisabled=!0,this.headers[t].item.classList.add("is-disabled"))}enable(t){this.headers[t]&&(this.headers[t].isDisabled=!1,this.headers[t].item.classList.remove("is-disabled"))}}function wt(i,t){if(i.__kupolaInitialized)return;const e=new Ne(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Oe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Xa(){document.querySelectorAll(".ds-collapse").forEach(i=>{wt(i)})}w.register("collapse",wt,Oe);class Re{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-color-picker__trigger"),this.panel=t.querySelector(".ds-color-picker__panel"),this.valueSpan=t.querySelector(".ds-color-picker__value"),this.customInput=t.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=e,this.value=e.value||"#007bff",this.showAlpha=e.showAlpha!==!1,this.mode=e.mode||"hex",this.previousColors=e.previousColors||this._getStoredColors(),this.previousColorsLimit=e.previousColorsLimit||12,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this._colorStringToHSB(this.value)}_getStoredColors(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}_storeColors(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}_addPreviousColor(t){const e=this.previousColors.indexOf(t);e!==-1&&this.previousColors.splice(e,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this._storeColors(),this._renderPreviousColors()}_colorStringToHSB(t){const e=t.replace(/^#/,""),s=parseInt(e.substring(0,2),16)/255,n=parseInt(e.substring(2,4),16)/255,r=parseInt(e.substring(4,6),16)/255,a=e.length===8?parseInt(e.substring(6,8),16)/255:1,l=Math.max(s,n,r),o=Math.min(s,n,r);let c=0,d=0,u=l;const p=l-o;if(d=l===0?0:p/l,l!==o)switch(l){case s:c=((n-r)/p+(n<r?6:0))/6;break;case n:c=((r-s)/p+2)/6;break;case r:c=((s-n)/p+4)/6;break}this.hue=Math.round(c*360),this.saturation=Math.round(d*100),this.brightness=Math.round(u*100),this.alpha=Math.round(a*100)}_HSBToColorString(t,e,s,n=1){e/=100,s/=100,n/=100;const r=u=>(u+t/60)%6,a=u=>s*(1-e*Math.max(0,Math.min(r(u),4-r(u),1))),l=Math.round(a(5)*255),o=Math.round(a(3)*255),c=Math.round(a(1)*255);if(this.mode==="rgb")return n<1?`rgba(${l}, ${o}, ${c}, ${n.toFixed(2)})`:`rgb(${l}, ${o}, ${c})`;if(this.mode==="hsl")return n<1?`hsla(${t}, ${Math.round(e*100)}%, ${Math.round(s*100)}%, ${n.toFixed(2)})`:`hsl(${t}, ${Math.round(e*100)}%, ${Math.round(s*100)}%)`;const d=`#${l.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`;return n<1?d+Math.round(n*255).toString(16).padStart(2,"0"):d}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const s=document.createElement("button");s.className="ds-color-picker__color",s.style.backgroundColor=e,s.setAttribute("data-color",e),s.addEventListener("click",this._colorClickHandler),t.appendChild(s)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),s=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),e&&(e.style.background=`hsl(${this.hue}, 100%, 50%)`),s&&this.showAlpha&&(s.value=this.alpha,s.style.background=`linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel||this.element.__kupolaInitialized)return;this._triggerClickHandler=n=>{n.stopPropagation(),this.togglePanel()},this._colorClickHandler=n=>{const a=n.currentTarget.getAttribute("data-color");this.updateColor(a),this.hidePanel()},this._inputInputHandler=n=>{const r=n.target.value;this._isValidColor(r)&&this.updateColor(r)},this._alphaChangeHandler=n=>{this.alpha=parseInt(n.target.value),this._updateFromHSB()},this._modeChangeHandler=n=>{const r=n.currentTarget;this.mode=r.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(a=>a.classList.remove("is-active")),r.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=n=>{this.hue=parseInt(n.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=n=>{const r=n.currentTarget.getBoundingClientRect(),a=n.clientX-r.left,l=n.clientY-r.top;this.saturation=Math.round(a/r.width*100),this.brightness=Math.round((1-l/r.height)*100),this._updateFromHSB()},this._documentClickHandler=n=>{this.element.contains(n.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n.addEventListener("click",this._colorClickHandler),n._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this._hueChangeHandler);const e=this.panel.querySelector(".ds-color-picker__sv");e&&(e.addEventListener("click",this._saturationChangeHandler),e.addEventListener("mousemove",n=>{n.buttons===1&&this._saturationChangeHandler(n)}));const s=this.panel.querySelector(".ds-color-picker__alpha");s&&this.showAlpha&&s.addEventListener("input",this._alphaChangeHandler),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.addEventListener("click",this._modeChangeHandler),n.getAttribute("data-mode")===this.mode&&n.classList.add("is-active")}),this._documentClickListener=M.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._renderPreviousColors(),this._renderColorPanel(),this._updateDisplay(),this.element.__kupolaInitialized=!0}_isValidColor(t){const e=new Option().style;return e.color=t,e.color!==""}_updateFromHSB(){const t=this._HSBToColorString(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}}))}_updateDisplay(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this._renderColorPanel()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this._isValidColor(t)&&(this.value=t,this._colorStringToHSB(t),this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}})))}setValue(t){this.updateColor(t)}getValue(){return this.value}setMode(t){(t==="hex"||t==="rgb"||t==="hsl")&&(this.mode=t,this._updateDisplay())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this._updateFromHSB()}getAlpha(){return this.alpha}destroy(){if(!this.element.__kupolaInitialized)return;this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n._colorPickerColorHandler&&n.removeEventListener("click",n._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this._hueChangeHandler&&t.removeEventListener("input",this._hueChangeHandler);const e=this.panel?.querySelector(".ds-color-picker__sv");e&&this._saturationChangeHandler&&(e.removeEventListener("click",this._saturationChangeHandler),e.removeEventListener("mousemove",this._saturationChangeHandler));const s=this.panel?.querySelector(".ds-color-picker__alpha");s&&this._alphaChangeHandler&&s.removeEventListener("input",this._alphaChangeHandler),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.removeEventListener("click",this._modeChangeHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.element.__kupolaInitialized=!1}}function xt(i,t){const e=new Re(i,t);e.init(),i._kupolaColorPicker=e}function ja(i=document){i.querySelectorAll(".ds-color-picker").forEach(t=>{xt(t)})}function Ve(i){i._kupolaColorPicker&&(i._kupolaColorPicker.destroy(),i._kupolaColorPicker=null)}w.register("color-picker",xt,Ve);class Ke{constructor(t,e={}){if(this.element=t,this.titleEl=t.querySelector(".ds-calendar__title"),this.daysEl=t.querySelector(".ds-calendar__days"),this.prevBtn=t.querySelector(".ds-calendar__nav--prev"),this.nextBtn=t.querySelector(".ds-calendar__nav--next"),this.todayBtn=t.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=e.selectedDate?new Date(e.selectedDate):null,this.rangeStart=e.rangeStart?new Date(e.rangeStart):null,this.rangeEnd=e.rangeEnd?new Date(e.rangeEnd):null,this.isRangeMode=e.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=e.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=e.events||[],this.i18n=e.i18n||{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortWeekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",selectRangeStart:"Select start date",selectRangeEnd:"Select end date"},this.onSelect=e.onSelect||null,this.onRangeSelect=e.onRangeSelect||null,this.onChange=e.onChange||null,this.onEventClick=e.onEventClick||null,this._init()}_init(){this.render();const t=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()},e=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()},s=()=>{this.currentDate=new Date,this.render(),this._emitChange()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this._listeners.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",e),this._listeners.push({el:this.nextBtn,event:"click",handler:e})),this.todayBtn&&(this.todayBtn.addEventListener("click",s),this._listeners.push({el:this.todayBtn,event:"click",handler:s}))}_emitChange(){const t={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(t),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:t,bubbles:!0}))}_formatDate(t){const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${s}-${n}`}_isSameDay(t,e){return!t||!e?!1:this._formatDate(t)===this._formatDate(e)}_isDateInRange(t){if(!this.rangeStart||!this.rangeEnd)return!1;const e=this._formatDate(t),s=this._formatDate(this.rangeStart),n=this._formatDate(this.rangeEnd);return e>=s&&e<=n}_isRangeStart(t){return this._isSameDay(t,this.rangeStart)}_isRangeEnd(t){return this._isSameDay(t,this.rangeEnd)}_getEventsForDate(t){const e=this._formatDate(t);return this.events.filter(s=>{const n=s.date||s.start,r=s.end;if(!n)return!1;const a=typeof n=="string"?n:this._formatDate(n);if(!r)return a===e;const l=typeof r=="string"?r:this._formatDate(r);return e>=a&&e<=l})}render(){const t=this.currentDate.getFullYear(),e=this.currentDate.getMonth();this.viewMode==="week"?this._renderWeekView(t,e):this._renderMonthView(t,e)}_renderMonthView(t,e){this.titleEl.textContent=`${t} ${this.i18n.months[e]}`;const s=new Date(t,e,1).getDay(),n=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let l=0;l<s;l++){const o=document.createElement("span");o.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(o)}const r=new Date,a=this._formatDate(r);for(let l=1;l<=n;l++){const o=new Date(t,e,l),c=document.createElement("button");c.className="ds-calendar__day",c.textContent=l;const d=this._formatDate(o);d===a&&c.classList.add("is-today"),this._isSameDay(o,this.selectedDate)&&c.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(o)&&c.classList.add("is-range-start"),this._isRangeEnd(o)&&c.classList.add("is-range-end"),this._isDateInRange(o)&&c.classList.add("is-in-range"));const u=this._getEventsForDate(o);if(u.length>0){c.classList.add("has-events");const m=document.createElement("span");m.className="ds-calendar__day-event",m.style.backgroundColor=u[0].color||"#007bff",c.appendChild(m)}const p=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(m=>m.classList.remove("is-selected")),c.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(o,this.rangeEnd)?(this.rangeStart=o,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(o<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=o):this.rangeEnd=o,this.onRangeSelect&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-range-select",{detail:{start:this.rangeStart,end:this.rangeEnd},bubbles:!0}))):(this.selectedDate=o,this.onSelect&&this.onSelect({date:o,dateStr:d}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:o,dateStr:d},bubbles:!0}))),u.forEach(m=>{this.onEventClick&&this.onEventClick(m,o)}),this.render()};c.addEventListener("click",p),this._listeners.push({el:c,event:"click",handler:p}),this.daysEl.appendChild(c)}}_renderWeekView(t,e){const s=this.currentDate.getDay(),n=new Date(t,e,this.currentDate.getDate()-s+(s===0?-6:1)),r=n,a=new Date(n);a.setDate(n.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[r.getMonth()]} ${r.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${t}`,this.daysEl.innerHTML="";const l=new Date,o=this._formatDate(l);for(let c=0;c<7;c++){const d=new Date(n);d.setDate(n.getDate()+c);const u=document.createElement("button");u.className="ds-calendar__day ds-calendar__day--week";const p=document.createElement("span");p.className="ds-calendar__day-header",p.textContent=this.i18n.shortWeekdays[d.getDay()],u.appendChild(p);const m=document.createElement("span");m.className="ds-calendar__day-number",m.textContent=d.getDate(),u.appendChild(m);const f=this._formatDate(d);f===o&&u.classList.add("is-today"),this._isSameDay(d,this.selectedDate)&&u.classList.add("is-selected");const g=this._getEventsForDate(d);if(g.length>0){const y=document.createElement("span");y.className="ds-calendar__day-events",g.slice(0,3).forEach(k=>{const E=document.createElement("span");E.className="ds-calendar__day-event",E.style.backgroundColor=k.color||"#007bff",y.appendChild(E)}),u.appendChild(y)}const v=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(y=>y.classList.remove("is-selected")),u.classList.add("is-selected"),this.selectedDate=d,this.onSelect&&this.onSelect({date:d,dateStr:f}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:d,dateStr:f},bubbles:!0})),this.render()};u.addEventListener("click",v),this._listeners.push({el:u,event:"click",handler:v}),this.daysEl.appendChild(u)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,e){this.rangeStart=t?new Date(t):null,this.rangeEnd=e?new Date(e):null,this.render(),this.onRangeSelect&&this.rangeStart&&this.rangeEnd&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd})}getRange(){return{start:this.rangeStart,end:this.rangeEnd}}setEvents(t){this.events=t||[],this.render()}addEvent(t){this.events.push(t),this.render()}removeEvent(t){this.events=this.events.filter(e=>e.id!==t),this.render()}setViewMode(t){(t==="month"||t==="week")&&(this.viewMode=t,this.render(),this._emitChange())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this._emitChange()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this._emitChange()}goToToday(){this.currentDate=new Date,this.render(),this._emitChange()}goToDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this._emitChange()}}function Ct(i,t){if(!i.__kupolaInitialized)try{const e=new Ke(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function We(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ja(){document.querySelectorAll(".ds-calendar").forEach(i=>{Ct(i)})}w.register("calendar",Ct,We);class Ue{constructor(t,e={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.maxCount=e.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=e.allowDuplicates!==!1,this.color=e.color||t.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const e=t.querySelector(".ds-dynamic-tags__remove");if(e){const s=n=>{n.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",s),this._listeners.push({el:e,event:"click",handler:s})}}),this.input){const t=()=>{const n=this.input.value.trim();if(!n)return;if(!this.allowDuplicates&&this.hasTag(n)){this.input.value="";return}if(this.getTags().length>=this.maxCount){this.input.value="",this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const r=this.createTag(n);this.element.insertBefore(r,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},e=n=>{n.key==="Enter"&&(n.preventDefault(),n.stopPropagation(),t())};this.input.addEventListener("keydown",e),this._listeners.push({el:this.input,event:"keydown",handler:e});const s=()=>{this.input.focus()};this.element.addEventListener("click",s),this._listeners.push({el:this.element,event:"click",handler:s})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const s=document.createTextNode(t);e.appendChild(s);const n=document.createElement("button");n.className="ds-dynamic-tags__remove",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>',e.appendChild(n);const r=a=>{a.stopPropagation(),e.remove(),this.dispatchChange()};return n.addEventListener("click",r),this._listeners.push({el:n,event:"click",handler:r}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t)return!0;return!1}addTag(t,e){if(!t||!this.input||!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const s=this.createTag(t);if(e){const n=["ds-dynamic-tags__tag--default","ds-dynamic-tags__tag--primary","ds-dynamic-tags__tag--success","ds-dynamic-tags__tag--warning","ds-dynamic-tags__tag--danger","ds-dynamic-tags__tag--info"];n.forEach(r=>s.classList.remove(r)),n.includes(`ds-dynamic-tags__tag--${e}`)&&s.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(s,this.input),this.dispatchChange()}removeTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];s&&(s.remove(),this.dispatchChange())}removeTagByValue(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t){s.remove(),this.dispatchChange();return}}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{t.push(e.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{const s=Array.from(e.classList).find(n=>n.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:e.textContent.trim(),color:s})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(e=>{typeof e=="string"?this.addTag(e):e&&typeof e=="object"&&e.value&&this.addTag(e.value,e.color)})}setMaxCount(t){this.maxCount=t,this.element.setAttribute("data-dynamic-tags-max",t)}getMaxCount(){return this.maxCount}setAllowDuplicates(t){this.allowDuplicates=t}isAllowDuplicates(){return this.allowDuplicates}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-dynamic-tags-color",t))}getColor(){return this.color}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-change",{detail:{tags:this.getTags(),tagsWithColor:this.getTagsWithColor(),count:this.getTags().length,maxCount:this.maxCount}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.input=null,this.element=null}}function St(i,t){if(i.__kupolaInitialized)return;const e=new Ue(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Ye(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ga(){document.querySelectorAll(".ds-dynamic-tags").forEach(i=>{St(i)})}w.register("dynamic-tags",St,Ye);class Lt{constructor(t={}){this.images=t.images||[],this.currentIndex=t.currentIndex||0,this.overlay=null,this.closeHandler=this.close.bind(this),this.keyHandler=this.handleKeydown.bind(this),this.clickHandler=this.handleOverlayClick.bind(this),this.zoom=1,this.rotation=0,this.zoomStep=t.zoomStep||.2,this.minZoom=t.minZoom||.5,this.maxZoom=t.maxZoom||3,this.init()}init(){this.createOverlay()}createOverlay(){this.overlay=document.createElement("div"),this.overlay.className="ds-image-preview-overlay",this.overlay.innerHTML=`
|
|
95
|
+
`;const r=n.querySelector(".ds-fileupload__preview-remove"),a=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),n.remove(),this.preview&&this.preview.children.length===0&&(this.preview.remove(),this.preview=null)};r.addEventListener("click",a),this._listeners.push({el:r,event:"click",handler:a}),this.preview.appendChild(n)},e.readAsDataURL(t)}updateProgress(t){this.progress||(this.progress=document.createElement("div"),this.progress.className="ds-fileupload__progress",this.element.insertBefore(this.progress,this.list||null)),this.progress.style.display="block";const e=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");e.className="ds-fileupload__progress-bar",e.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(e),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const e=100;let s=0;Math.max(1,Math.floor(t.size/e));const n=setInterval(()=>{s++;const r=Math.min(100,Math.floor(s/e*100));this.updateProgress(r),s>=e&&(clearInterval(n),this.updateProgress(100))},Math.max(50,Math.floor(5e3/e)));return n}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function kt(i){if(i.__kupolaInitialized)return;const t=new Fe(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function Ne(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Xa(){document.querySelectorAll(".ds-fileupload").forEach(i=>{kt(i)})}w.register("fileupload",kt,Ne);class Oe{constructor(t,e={}){this.element=t,this.headers=[],this._listeners=[],this.accordion=e.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=e.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=e.disabledItems||[],this.defaultExpanded=e.defaultExpanded||[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach((e,s)=>{const n=e.closest(".ds-collapse__item"),r=e.nextElementSibling;if(!n||!r||!r.classList.contains("ds-collapse__content"))return;const a=n.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(s);a&&n.classList.add("is-disabled");let l=n.classList.contains("is-active");(this.defaultExpanded==="all"||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(s))&&(l=!0),l?(n.classList.add("is-active"),r.style.height=r.scrollHeight+"px",r.style.overflow="hidden",setTimeout(()=>{n.classList.contains("is-active")&&(r.style.height="auto",r.style.overflow="visible")},this.animationDuration)):(n.classList.remove("is-active"),r.style.height="0",r.style.overflow="hidden");const o=()=>{if(a)return;const c=n.classList.contains("is-active");this.accordion&&!c&&this.headers.forEach((d,u)=>{u!==s&&d.item.classList.contains("is-active")&&this._collapseItem(d)}),c?this._collapseItem({item:n,content:r}):this._expandItem({item:n,content:r}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:s,expanded:!c,item:n},bubbles:!0}))};e.addEventListener("click",o),this.headers.push({header:e,item:n,content:r,clickHandler:o,isDisabled:a}),this._listeners.push({el:e,event:"click",handler:o})})}_expandItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height="0",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height=s.scrollHeight+"px",e.classList.add("is-active");const n=()=>{s.removeEventListener("transitionend",n),e.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible"),s.style.transition=""};s.addEventListener("transitionend",n),this._listeners.push({el:s,event:"transitionend",handler:n})}_collapseItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height=s.scrollHeight+"px",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height="0",e.classList.remove("is-active");const n=()=>{s.removeEventListener("transitionend",n),s.style.transition=""};s.addEventListener("transitionend",n),this._listeners.push({el:s,event:"transitionend",handler:n})}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.headers=null,this.element=null}toggle(t){const e=this.headers[t];e&&!e.isDisabled&&e.clickHandler()}expand(t){const e=this.headers[t];e&&!e.item.classList.contains("is-active")&&!e.isDisabled&&(this.accordion&&this.headers.forEach((s,n)=>{n!==t&&s.item.classList.contains("is-active")&&this._collapseItem(s)}),this._expandItem(e))}collapse(t){const e=this.headers[t];e&&e.item.classList.contains("is-active")&&this._collapseItem(e)}expandAll(){this.accordion||this.headers.forEach((t,e)=>{!t.item.classList.contains("is-active")&&!t.isDisabled&&this._expandItem(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this._collapseItem(t)})}getExpandedIndices(){return this.headers.map((t,e)=>t.item.classList.contains("is-active")?e:-1).filter(t=>t>=0)}disable(t){this.headers[t]&&(this.headers[t].isDisabled=!0,this.headers[t].item.classList.add("is-disabled"))}enable(t){this.headers[t]&&(this.headers[t].isDisabled=!1,this.headers[t].item.classList.remove("is-disabled"))}}function wt(i,t){if(i.__kupolaInitialized)return;const e=new Oe(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Re(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function ja(){document.querySelectorAll(".ds-collapse").forEach(i=>{wt(i)})}w.register("collapse",wt,Re);class Ve{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-color-picker__trigger"),this.panel=t.querySelector(".ds-color-picker__panel"),this.valueSpan=t.querySelector(".ds-color-picker__value"),this.customInput=t.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=e,this.value=e.value||"#007bff",this.showAlpha=e.showAlpha!==!1,this.mode=e.mode||"hex",this.previousColors=e.previousColors||this._getStoredColors(),this.previousColorsLimit=e.previousColorsLimit||12,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this._colorStringToHSB(this.value)}_getStoredColors(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}_storeColors(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}_addPreviousColor(t){const e=this.previousColors.indexOf(t);e!==-1&&this.previousColors.splice(e,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this._storeColors(),this._renderPreviousColors()}_colorStringToHSB(t){const e=t.replace(/^#/,""),s=parseInt(e.substring(0,2),16)/255,n=parseInt(e.substring(2,4),16)/255,r=parseInt(e.substring(4,6),16)/255,a=e.length===8?parseInt(e.substring(6,8),16)/255:1,l=Math.max(s,n,r),o=Math.min(s,n,r);let c=0,d=0,u=l;const p=l-o;if(d=l===0?0:p/l,l!==o)switch(l){case s:c=((n-r)/p+(n<r?6:0))/6;break;case n:c=((r-s)/p+2)/6;break;case r:c=((s-n)/p+4)/6;break}this.hue=Math.round(c*360),this.saturation=Math.round(d*100),this.brightness=Math.round(u*100),this.alpha=Math.round(a*100)}_HSBToColorString(t,e,s,n=1){e/=100,s/=100,n/=100;const r=u=>(u+t/60)%6,a=u=>s*(1-e*Math.max(0,Math.min(r(u),4-r(u),1))),l=Math.round(a(5)*255),o=Math.round(a(3)*255),c=Math.round(a(1)*255);if(this.mode==="rgb")return n<1?`rgba(${l}, ${o}, ${c}, ${n.toFixed(2)})`:`rgb(${l}, ${o}, ${c})`;if(this.mode==="hsl")return n<1?`hsla(${t}, ${Math.round(e*100)}%, ${Math.round(s*100)}%, ${n.toFixed(2)})`:`hsl(${t}, ${Math.round(e*100)}%, ${Math.round(s*100)}%)`;const d=`#${l.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`;return n<1?d+Math.round(n*255).toString(16).padStart(2,"0"):d}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const s=document.createElement("button");s.className="ds-color-picker__color",s.style.backgroundColor=e,s.setAttribute("data-color",e),s.addEventListener("click",this._colorClickHandler),t.appendChild(s)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),s=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),e&&(e.style.background=`hsl(${this.hue}, 100%, 50%)`),s&&this.showAlpha&&(s.value=this.alpha,s.style.background=`linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel||this.element.__kupolaInitialized)return;this._triggerClickHandler=n=>{n.stopPropagation(),this.togglePanel()},this._colorClickHandler=n=>{const a=n.currentTarget.getAttribute("data-color");this.updateColor(a),this.hidePanel()},this._inputInputHandler=n=>{const r=n.target.value;this._isValidColor(r)&&this.updateColor(r)},this._alphaChangeHandler=n=>{this.alpha=parseInt(n.target.value),this._updateFromHSB()},this._modeChangeHandler=n=>{const r=n.currentTarget;this.mode=r.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(a=>a.classList.remove("is-active")),r.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=n=>{this.hue=parseInt(n.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=n=>{const r=n.currentTarget.getBoundingClientRect(),a=n.clientX-r.left,l=n.clientY-r.top;this.saturation=Math.round(a/r.width*100),this.brightness=Math.round((1-l/r.height)*100),this._updateFromHSB()},this._documentClickHandler=n=>{this.element.contains(n.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n.addEventListener("click",this._colorClickHandler),n._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this._hueChangeHandler);const e=this.panel.querySelector(".ds-color-picker__sv");e&&(e.addEventListener("click",this._saturationChangeHandler),e.addEventListener("mousemove",n=>{n.buttons===1&&this._saturationChangeHandler(n)}));const s=this.panel.querySelector(".ds-color-picker__alpha");s&&this.showAlpha&&s.addEventListener("input",this._alphaChangeHandler),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.addEventListener("click",this._modeChangeHandler),n.getAttribute("data-mode")===this.mode&&n.classList.add("is-active")}),this._documentClickListener=M.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._renderPreviousColors(),this._renderColorPanel(),this._updateDisplay(),this.element.__kupolaInitialized=!0}_isValidColor(t){const e=new Option().style;return e.color=t,e.color!==""}_updateFromHSB(){const t=this._HSBToColorString(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}}))}_updateDisplay(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this._renderColorPanel()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this._isValidColor(t)&&(this.value=t,this._colorStringToHSB(t),this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}})))}setValue(t){this.updateColor(t)}getValue(){return this.value}setMode(t){(t==="hex"||t==="rgb"||t==="hsl")&&(this.mode=t,this._updateDisplay())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this._updateFromHSB()}getAlpha(){return this.alpha}destroy(){if(!this.element.__kupolaInitialized)return;this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n._colorPickerColorHandler&&n.removeEventListener("click",n._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this._hueChangeHandler&&t.removeEventListener("input",this._hueChangeHandler);const e=this.panel?.querySelector(".ds-color-picker__sv");e&&this._saturationChangeHandler&&(e.removeEventListener("click",this._saturationChangeHandler),e.removeEventListener("mousemove",this._saturationChangeHandler));const s=this.panel?.querySelector(".ds-color-picker__alpha");s&&this._alphaChangeHandler&&s.removeEventListener("input",this._alphaChangeHandler),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.removeEventListener("click",this._modeChangeHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.element.__kupolaInitialized=!1}}function xt(i,t){const e=new Ve(i,t);e.init(),i._kupolaColorPicker=e}function Ja(i=document){i.querySelectorAll(".ds-color-picker").forEach(t=>{xt(t)})}function Ke(i){i._kupolaColorPicker&&(i._kupolaColorPicker.destroy(),i._kupolaColorPicker=null)}w.register("color-picker",xt,Ke);class We{constructor(t,e={}){if(this.element=t,this.titleEl=t.querySelector(".ds-calendar__title"),this.daysEl=t.querySelector(".ds-calendar__days"),this.prevBtn=t.querySelector(".ds-calendar__nav--prev"),this.nextBtn=t.querySelector(".ds-calendar__nav--next"),this.todayBtn=t.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=e.selectedDate?new Date(e.selectedDate):null,this.rangeStart=e.rangeStart?new Date(e.rangeStart):null,this.rangeEnd=e.rangeEnd?new Date(e.rangeEnd):null,this.isRangeMode=e.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=e.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=e.events||[],this.i18n=e.i18n||{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortWeekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",selectRangeStart:"Select start date",selectRangeEnd:"Select end date"},this.onSelect=e.onSelect||null,this.onRangeSelect=e.onRangeSelect||null,this.onChange=e.onChange||null,this.onEventClick=e.onEventClick||null,this._init()}_init(){this.render();const t=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()},e=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()},s=()=>{this.currentDate=new Date,this.render(),this._emitChange()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this._listeners.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",e),this._listeners.push({el:this.nextBtn,event:"click",handler:e})),this.todayBtn&&(this.todayBtn.addEventListener("click",s),this._listeners.push({el:this.todayBtn,event:"click",handler:s}))}_emitChange(){const t={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(t),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:t,bubbles:!0}))}_formatDate(t){const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${s}-${n}`}_isSameDay(t,e){return!t||!e?!1:this._formatDate(t)===this._formatDate(e)}_isDateInRange(t){if(!this.rangeStart||!this.rangeEnd)return!1;const e=this._formatDate(t),s=this._formatDate(this.rangeStart),n=this._formatDate(this.rangeEnd);return e>=s&&e<=n}_isRangeStart(t){return this._isSameDay(t,this.rangeStart)}_isRangeEnd(t){return this._isSameDay(t,this.rangeEnd)}_getEventsForDate(t){const e=this._formatDate(t);return this.events.filter(s=>{const n=s.date||s.start,r=s.end;if(!n)return!1;const a=typeof n=="string"?n:this._formatDate(n);if(!r)return a===e;const l=typeof r=="string"?r:this._formatDate(r);return e>=a&&e<=l})}render(){const t=this.currentDate.getFullYear(),e=this.currentDate.getMonth();this.viewMode==="week"?this._renderWeekView(t,e):this._renderMonthView(t,e)}_renderMonthView(t,e){this.titleEl.textContent=`${t} ${this.i18n.months[e]}`;const s=new Date(t,e,1).getDay(),n=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let l=0;l<s;l++){const o=document.createElement("span");o.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(o)}const r=new Date,a=this._formatDate(r);for(let l=1;l<=n;l++){const o=new Date(t,e,l),c=document.createElement("button");c.className="ds-calendar__day",c.textContent=l;const d=this._formatDate(o);d===a&&c.classList.add("is-today"),this._isSameDay(o,this.selectedDate)&&c.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(o)&&c.classList.add("is-range-start"),this._isRangeEnd(o)&&c.classList.add("is-range-end"),this._isDateInRange(o)&&c.classList.add("is-in-range"));const u=this._getEventsForDate(o);if(u.length>0){c.classList.add("has-events");const m=document.createElement("span");m.className="ds-calendar__day-event",m.style.backgroundColor=u[0].color||"#007bff",c.appendChild(m)}const p=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(m=>m.classList.remove("is-selected")),c.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(o,this.rangeEnd)?(this.rangeStart=o,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(o<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=o):this.rangeEnd=o,this.onRangeSelect&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-range-select",{detail:{start:this.rangeStart,end:this.rangeEnd},bubbles:!0}))):(this.selectedDate=o,this.onSelect&&this.onSelect({date:o,dateStr:d}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:o,dateStr:d},bubbles:!0}))),u.forEach(m=>{this.onEventClick&&this.onEventClick(m,o)}),this.render()};c.addEventListener("click",p),this._listeners.push({el:c,event:"click",handler:p}),this.daysEl.appendChild(c)}}_renderWeekView(t,e){const s=this.currentDate.getDay(),n=new Date(t,e,this.currentDate.getDate()-s+(s===0?-6:1)),r=n,a=new Date(n);a.setDate(n.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[r.getMonth()]} ${r.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${t}`,this.daysEl.innerHTML="";const l=new Date,o=this._formatDate(l);for(let c=0;c<7;c++){const d=new Date(n);d.setDate(n.getDate()+c);const u=document.createElement("button");u.className="ds-calendar__day ds-calendar__day--week";const p=document.createElement("span");p.className="ds-calendar__day-header",p.textContent=this.i18n.shortWeekdays[d.getDay()],u.appendChild(p);const m=document.createElement("span");m.className="ds-calendar__day-number",m.textContent=d.getDate(),u.appendChild(m);const f=this._formatDate(d);f===o&&u.classList.add("is-today"),this._isSameDay(d,this.selectedDate)&&u.classList.add("is-selected");const g=this._getEventsForDate(d);if(g.length>0){const y=document.createElement("span");y.className="ds-calendar__day-events",g.slice(0,3).forEach(k=>{const E=document.createElement("span");E.className="ds-calendar__day-event",E.style.backgroundColor=k.color||"#007bff",y.appendChild(E)}),u.appendChild(y)}const v=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(y=>y.classList.remove("is-selected")),u.classList.add("is-selected"),this.selectedDate=d,this.onSelect&&this.onSelect({date:d,dateStr:f}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:d,dateStr:f},bubbles:!0})),this.render()};u.addEventListener("click",v),this._listeners.push({el:u,event:"click",handler:v}),this.daysEl.appendChild(u)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,e){this.rangeStart=t?new Date(t):null,this.rangeEnd=e?new Date(e):null,this.render(),this.onRangeSelect&&this.rangeStart&&this.rangeEnd&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd})}getRange(){return{start:this.rangeStart,end:this.rangeEnd}}setEvents(t){this.events=t||[],this.render()}addEvent(t){this.events.push(t),this.render()}removeEvent(t){this.events=this.events.filter(e=>e.id!==t),this.render()}setViewMode(t){(t==="month"||t==="week")&&(this.viewMode=t,this.render(),this._emitChange())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this._emitChange()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this._emitChange()}goToToday(){this.currentDate=new Date,this.render(),this._emitChange()}goToDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this._emitChange()}}function Ct(i,t){if(!i.__kupolaInitialized)try{const e=new We(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function Ue(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ga(){document.querySelectorAll(".ds-calendar").forEach(i=>{Ct(i)})}w.register("calendar",Ct,Ue);class Ye{constructor(t,e={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.maxCount=e.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=e.allowDuplicates!==!1,this.color=e.color||t.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const e=t.querySelector(".ds-dynamic-tags__remove");if(e){const s=n=>{n.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",s),this._listeners.push({el:e,event:"click",handler:s})}}),this.input){const t=()=>{const n=this.input.value.trim();if(!n)return;if(!this.allowDuplicates&&this.hasTag(n)){this.input.value="";return}if(this.getTags().length>=this.maxCount){this.input.value="",this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const r=this.createTag(n);this.element.insertBefore(r,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},e=n=>{n.key==="Enter"&&(n.preventDefault(),n.stopPropagation(),t())};this.input.addEventListener("keydown",e),this._listeners.push({el:this.input,event:"keydown",handler:e});const s=()=>{this.input.focus()};this.element.addEventListener("click",s),this._listeners.push({el:this.element,event:"click",handler:s})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const s=document.createTextNode(t);e.appendChild(s);const n=document.createElement("button");n.className="ds-dynamic-tags__remove",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>',e.appendChild(n);const r=a=>{a.stopPropagation(),e.remove(),this.dispatchChange()};return n.addEventListener("click",r),this._listeners.push({el:n,event:"click",handler:r}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t)return!0;return!1}addTag(t,e){if(!t||!this.input||!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const s=this.createTag(t);if(e){const n=["ds-dynamic-tags__tag--default","ds-dynamic-tags__tag--primary","ds-dynamic-tags__tag--success","ds-dynamic-tags__tag--warning","ds-dynamic-tags__tag--danger","ds-dynamic-tags__tag--info"];n.forEach(r=>s.classList.remove(r)),n.includes(`ds-dynamic-tags__tag--${e}`)&&s.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(s,this.input),this.dispatchChange()}removeTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];s&&(s.remove(),this.dispatchChange())}removeTagByValue(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t){s.remove(),this.dispatchChange();return}}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{t.push(e.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{const s=Array.from(e.classList).find(n=>n.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:e.textContent.trim(),color:s})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(e=>{typeof e=="string"?this.addTag(e):e&&typeof e=="object"&&e.value&&this.addTag(e.value,e.color)})}setMaxCount(t){this.maxCount=t,this.element.setAttribute("data-dynamic-tags-max",t)}getMaxCount(){return this.maxCount}setAllowDuplicates(t){this.allowDuplicates=t}isAllowDuplicates(){return this.allowDuplicates}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-dynamic-tags-color",t))}getColor(){return this.color}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-change",{detail:{tags:this.getTags(),tagsWithColor:this.getTagsWithColor(),count:this.getTags().length,maxCount:this.maxCount}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.input=null,this.element=null}}function St(i,t){if(i.__kupolaInitialized)return;const e=new Ye(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Xe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Za(){document.querySelectorAll(".ds-dynamic-tags").forEach(i=>{St(i)})}w.register("dynamic-tags",St,Xe);class Lt{constructor(t={}){this.images=t.images||[],this.currentIndex=t.currentIndex||0,this.overlay=null,this.closeHandler=this.close.bind(this),this.keyHandler=this.handleKeydown.bind(this),this.clickHandler=this.handleOverlayClick.bind(this),this.zoom=1,this.rotation=0,this.zoomStep=t.zoomStep||.2,this.minZoom=t.minZoom||.5,this.maxZoom=t.maxZoom||3,this.init()}init(){this.createOverlay()}createOverlay(){this.overlay=document.createElement("div"),this.overlay.className="ds-image-preview-overlay",this.overlay.innerHTML=`
|
|
96
96
|
<button class="ds-image-preview__close" type="button" aria-label="Close preview">
|
|
97
97
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
98
98
|
<path d="M18 6L6 18"/>
|
|
@@ -153,10 +153,10 @@
|
|
|
153
153
|
<div class="ds-image-preview__indicators"></div>
|
|
154
154
|
`,document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const t=this.overlay.querySelector(".ds-image-preview__close"),e=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this._prevHandler=()=>this.prev(),this._nextHandler=()=>this.next(),t.addEventListener("click",this.closeHandler),e.addEventListener("click",this._prevHandler),s.addEventListener("click",this._nextHandler),this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(a=>{a.addEventListener("click",l=>{const o=a.getAttribute("data-action");this.handleToolbarAction(o)})}),this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",a=>{a.preventDefault(),a.deltaY<0?this.zoomIn():this.zoomOut()},{passive:!1})}handleToolbarAction(t){switch(t){case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"zoom-reset":this.resetZoom();break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break}}zoomIn(){this.zoom=Math.min(this.maxZoom,this.zoom+this.zoomStep),this.updateTransform()}zoomOut(){this.zoom=Math.max(this.minZoom,this.zoom-this.zoomStep),this.updateTransform()}resetZoom(){this.zoom=1,this.rotation=0,this.updateTransform()}rotate(t){this.rotation+=t,this.updateTransform()}setRotation(t){this.rotation=t,this.updateTransform()}setZoom(t){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t)),this.updateTransform()}updateTransform(){const t=this.overlay.querySelector(".ds-image-preview__content img");t&&(t.style.transform=`scale(${this.zoom}) rotate(${this.rotation}deg)`)}handleKeydown(t){if(this.overlay.classList.contains("is-visible"))switch(t.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"+":case"=":t.preventDefault(),this.zoomIn();break;case"-":case"_":t.preventDefault(),this.zoomOut();break;case"0":t.preventDefault(),this.resetZoom();break;case"[":t.preventDefault(),this.rotate(-90);break;case"]":t.preventDefault(),this.rotate(90);break}}handleOverlayClick(t){t.target===this.overlay&&this.close()}show(t,e=0){this.images=t,this.currentIndex=Math.min(Math.max(e,0),t.length-1),this.resetZoom(),this.render(),this.overlay.classList.add("is-visible"),document.addEventListener("keydown",this.keyHandler),this.overlay.addEventListener("click",this.clickHandler),document.body.style.overflow="hidden"}close(){this.overlay.classList.remove("is-visible"),document.removeEventListener("keydown",this.keyHandler),this.overlay.removeEventListener("click",this.clickHandler),document.body.style.overflow=""}prev(){this.currentIndex>0&&(this.currentIndex--,this.resetZoom(),this.render())}next(){this.currentIndex<this.images.length-1&&(this.currentIndex++,this.resetZoom(),this.render())}goTo(t){t>=0&&t<this.images.length&&(this.currentIndex=t,this.resetZoom(),this.render())}render(){const t=this.overlay.querySelector(".ds-image-preview__content img"),e=this.overlay.querySelector(".ds-image-preview__title"),s=this.overlay.querySelector(".ds-image-preview__meta"),n=this.overlay.querySelector(".ds-image-preview__indicators"),r=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),l=this.images[this.currentIndex];t.src=l.src,t.alt=l.alt||"",e.textContent=l.title||"",s.textContent=l.meta||`${this.currentIndex+1} / ${this.images.length}`,r.disabled=this.currentIndex===0,a.disabled=this.currentIndex===this.images.length-1,n.innerHTML=this.images.map((o,c)=>`
|
|
155
155
|
<button class="ds-image-preview__indicator${c===this.currentIndex?" is-active":""}" type="button" data-index="${c}" aria-label="Go to image ${c+1}"></button>
|
|
156
|
-
`).join(""),n.querySelectorAll(".ds-image-preview__indicator").forEach(o=>{const c=()=>{this.goTo(parseInt(o.dataset.index))};o.addEventListener("click",c),o._clickHandler=c})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(r=>{r._clickHandler&&r.removeEventListener("click",r._clickHandler)});const e=this.overlay?.querySelector(".ds-image-preview__close"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),n=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),s&&this._prevHandler&&s.removeEventListener("click",this._prevHandler),n&&this._nextHandler&&n.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let U=null;function Za(){U||(U=new Lt),document.querySelectorAll("[data-image-preview]").forEach(i=>{i.addEventListener("click",()=>{const t=JSON.parse(i.getAttribute("data-image-preview")),e=parseInt(i.getAttribute("data-image-index"))||0;U.show(t,e)})})}function Qa(i,t=0){U||(U=new Lt),U.show(i,t)}class Xe{constructor(t,e={}){this.element=t,this.closeBtn=t.querySelector(".ds-tag__close"),this.checkbox=t.querySelector(".ds-tag__checkbox"),this.editInput=t.querySelector(".ds-tag__input"),this._listeners=[],this.color=e.color||t.getAttribute("data-tag-color")||"default",this.size=e.size||t.getAttribute("data-tag-size")||"default",this.checkable=e.checkable||t.hasAttribute("data-tag-checkable"),this.checked=e.checked||t.hasAttribute("data-tag-checked"),this.editable=e.editable||t.hasAttribute("data-tag-editable"),this.maxLength=e.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this._applyStyles(),this.closeBtn){const t=e=>{e.stopPropagation(),this.element.dispatchEvent(new CustomEvent("kupola:tag-remove",{detail:{tag:this.element,content:this.getContent()},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",t),this._listeners.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=e=>{e.target!==this.checkbox&&e.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this._listeners.push({el:this.element,event:"click",handler:t}),this.checkbox){const e=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",e),this._listeners.push({el:this.checkbox,event:"change",handler:e})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this._listeners.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const e=()=>{this.endEdit()},s=n=>{n.key==="Enter"?this.endEdit():n.key==="Escape"&&this.cancelEdit()};this.editInput.addEventListener("blur",e),this.editInput.addEventListener("keydown",s),this._listeners.push({el:this.editInput,event:"blur",handler:e}),this._listeners.push({el:this.editInput,event:"keydown",handler:s})}}}_applyStyles(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],e=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(s=>this.element.classList.remove(s)),e.forEach(s=>this.element.classList.remove(s)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),e.includes(`ds-tag--${this.size}`)&&this.element.classList.add(`ds-tag--${this.size}`),this.checkable&&this.element.classList.add("ds-tag--checkable"),this.checked&&this.element.classList.add("is-checked"),this.editable&&this.element.classList.add("ds-tag--editable")}setContent(t){this.editable&&this.editInput&&(this.editInput.value=t);const e=[];this.element.childNodes.forEach(l=>{l.nodeType===Node.TEXT_NODE&&e.push(l)}),e.forEach(l=>l.remove());const s=this.element.querySelector(".ds-tag__close"),n=this.element.querySelector(".ds-tag__checkbox"),r=this.element.querySelector(".ds-tag__input"),a=s||n||r||null;this.element.insertBefore(document.createTextNode(t),a),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:t},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-tag-color",t),this._applyStyles())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this._applyStyles())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=this.checked),this.element.dispatchEvent(new CustomEvent("kupola:tag-check",{detail:{tag:this.element,checked:this.checked,content:this.getContent()},bubbles:!0}))}setChecked(t){this.checked=t,this.element.setAttribute("data-tag-checked",t?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=t)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const t=this.getContent();if(this.editInput)this.editInput.value=t;else{const e=document.createElement("input");e.type="text",e.className="ds-tag__input",e.value=t,e.maxLength=this.maxLength,this.editInput=e;const s=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,s);const n=()=>this.endEdit(),r=a=>{a.key==="Enter"?this.endEdit():a.key==="Escape"&&this.cancelEdit()};e.addEventListener("blur",n),e.addEventListener("keydown",r),this._listeners.push({el:e,event:"blur",handler:n}),this._listeners.push({el:e,event:"keydown",handler:r})}this.element.classList.add("is-editing"),setTimeout(()=>{this.editInput&&(this.editInput.focus(),this.editInput.select())},0)}endEdit(){if(!this.editable||!this.element.classList.contains("is-editing"))return;const t=this.editInput.value.trim();this.element.classList.remove("is-editing"),t&&t!==this.getContent()&&(this.setContent(t),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:t},bubbles:!0})))}cancelEdit(){!this.editable||!this.element.classList.contains("is-editing")||(this.element.classList.remove("is-editing"),this.editInput&&(this.editInput.value=this.getContent()))}setEditable(t){this.editable=t,t?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this._applyStyles()}isEditable(){return this.editable}setCheckable(t){this.checkable!==t&&(this.destroy(),this.checkable=t,t?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function Dt(i,t){if(i.__kupolaInitialized)return;const e=new Xe(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function je(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function tl(){document.querySelectorAll(".ds-tag").forEach(i=>{Dt(i)})}w.register("tag",Dt,je);class Je{constructor(t){this.element=t,this.valueElement=t.querySelector(".ds-statcard__value"),this.progressFill=t.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(t=>{t.forEach(e=>{e.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this._observer.observe(this.element)}animateValue(){if(!this.valueElement)return;const t=this.valueElement.textContent,e=t.match(/[\d.,]+/);if(!e)return;const s=parseFloat(e[0].replace(",","")),n=t.substring(0,e.index),r=t.substring(e.index+e[0].length),a=1500,l=performance.now(),o=0,c=d=>{const u=d-l,p=Math.min(u/a,1),m=1-Math.pow(1-p,3),f=o+(s-o)*m;let g;s>=1e6?g=(f/1e6).toFixed(1)+"M":s>=1e3?g=(f/1e3).toFixed(1)+"K":Number.isInteger(s)?g=Math.floor(f).toLocaleString():g=f.toFixed(2),this.valueElement.textContent=n+g+r,p<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}animateProgress(){if(!this.progressFill)return;const t=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=t}updateValue(t,e={}){if(!this.valueElement)return;const s=e.duration||800,n=this.valueElement.textContent,r=n.match(/[\d.,]+/);if(!r){this.valueElement.textContent=t;return}const a=n.substring(0,r.index),l=n.substring(r.index+r[0].length),o=parseFloat(r[0].replace(",","")),c=parseFloat(t),d=performance.now(),u=p=>{const m=p-d,f=Math.min(m/s,1),g=1-Math.pow(1-f,3),v=o+(c-o)*g;let y;c>=1e6?y=(v/1e6).toFixed(1)+"M":c>=1e3?y=(v/1e3).toFixed(1)+"K":Number.isInteger(c)?y=Math.floor(v).toLocaleString():y=v.toFixed(2),this.valueElement.textContent=a+y+l,f<1&&requestAnimationFrame(u)};requestAnimationFrame(u)}updateProgress(t,e={}){if(!this.progressFill)return;const s=e.duration||600,n=parseFloat(this.progressFill.style.width||"0"),r=Math.min(Math.max(t,0),100),a=performance.now(),l=o=>{const c=o-a,d=Math.min(c/s,1),u=1-Math.pow(1-d,3),p=n+(r-n)*u;this.progressFill.style.width=p+"%",d<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}setTrend(t,e){const s=this.element.querySelector(".ds-statcard__trend");if(!s)return;s.className=`ds-statcard__trend ds-statcard__trend--${t}`;const n=t==="up"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/></svg>':t==="down"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 18 10.5 8.5 15.5 13.5 23 6"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="12 19 18 13 12 7 6 13"/></svg>';s.innerHTML=n+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function Ht(i){if(i.__kupolaInitialized)return;const t=new Je(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function Ge(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function el(){document.querySelectorAll(".ds-statcard").forEach(i=>{Ht(i)})}w.register("statcard",Ht,Ge);class Ze{constructor(t,e={}){this.element=t,this.data=e.data||[],this.startDate=e.startDate||this.getOneYearAgo(),this.endDate=e.endDate||new Date,this.cellSize=e.cellSize||14,this.onCellClick=e.onCellClick||null,this.tooltip=null,this.baseColor=e.color||t.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const t=new Date;return t.setFullYear(t.getFullYear()-1),t}init(){this.render(),this.createTooltip()}getDataByDate(t){const e=this.formatDate(t),s=this.data.find(n=>n.date===e);return s?s.value:0}formatDate(t){const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${s}-${n}`}getLevel(t,e){if(t===0)return 0;(!e||e===0)&&(e=Math.max(...this.data.map(n=>n.value),1));const s=t/e;return s<.2?1:s<.4?2:s<.6?3:s<.8?4:5}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:34,g:197,b:94}}getCellColor(t){const e=this.hexToRgb(this.baseColor);if(t===0)return"rgba(0, 0, 0, 0.1)";const s=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${s})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let s=-1;for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1)){const r=n.getMonth(),a=n.getDate();r!==s&&a===1&&(e.push({month:r,label:t[r],offset:Math.floor((n-this.startDate)/(1e3*60*60*24))}),s=r)}return e}getWeekCount(){let t=0;const s=new Date(this.startDate).getDay();for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1))n.getDay()===0&&t++;return s!==0&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let s=[];const r=new Date(this.startDate).getDay();for(let y=1;y<r;y++)s.push(null);for(let y=new Date(this.startDate);y<=this.endDate;y.setDate(y.getDate()+1))s.push(new Date(y)),(y.getDay()===6||y.getTime()===this.endDate.getTime())&&(e.push(s),s=[]);const a=e.length,l=this.element.classList.contains("ds-heatmap--compact")?12:16,o=a*l,c=document.createElement("div");c.className="ds-heatmap__container";const d=document.createElement("div");d.className="ds-heatmap__labels-and-grid";const u=document.createElement("div");u.className="ds-heatmap__weekday-labels";const p=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__weekday-label",k.textContent=y,k.style.height=p+"px",k.style.lineHeight=p+"px",u.appendChild(k)}),d.appendChild(u);const m=document.createElement("div");m.className="ds-heatmap__grid-container";const f=document.createElement("div");f.className="ds-heatmap__month-labels",f.style.width=o+"px";const g=this.getMonthLabels();g.forEach((y,k)=>{const E=document.createElement("div");E.className="ds-heatmap__month-label",E.textContent=y.label;const b=g[k+1];let C;b?C=Math.ceil((b.offset-y.offset)/7):C=a-Math.floor(y.offset/7),E.style.width=C*l+"px",f.appendChild(E)}),m.appendChild(f);const v=document.createElement("div");v.className="ds-heatmap__grid",e.forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__week-column",y.forEach(E=>{if(E===null){const b=document.createElement("div");b.className="ds-heatmap__cell",b.style.visibility="hidden",k.appendChild(b)}else{const b=this.getDataByDate(E),C=Math.max(...this.data.map(O=>O.value),1),D=this.getLevel(b,C),S=document.createElement("div");S.className="ds-heatmap__cell",S.dataset.date=this.formatDate(E),S.dataset.value=b,S.style.backgroundColor=this.getCellColor(D);const H=O=>this.showTooltip(O,E,b),A=()=>this.hideTooltip(),$=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(E),value:b})};S.addEventListener("mouseenter",H),S.addEventListener("mouseleave",A),S.addEventListener("click",$),this._listeners.push({el:S,event:"mouseenter",handler:H},{el:S,event:"mouseleave",handler:A},{el:S,event:"click",handler:$}),k.appendChild(S)}}),v.appendChild(k)}),m.appendChild(v),d.appendChild(m),c.appendChild(d),t.appendChild(c),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const s=document.createElement("span");s.className="ds-heatmap__legend-label",s.textContent="少";const n=document.createElement("div");n.className="ds-heatmap__legend-cells";for(let a=0;a<=5;a++){const l=document.createElement("div");l.className="ds-heatmap__legend-cell",l.style.backgroundColor=this.getCellColor(a),n.appendChild(l)}const r=document.createElement("span");r.className="ds-heatmap__legend-label",r.textContent="多",e.appendChild(s),e.appendChild(n),e.appendChild(r),t.appendChild(e)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(t,e,s){const n=t.target.getBoundingClientRect(),r=150;this.tooltip.innerHTML=`
|
|
156
|
+
`).join(""),n.querySelectorAll(".ds-image-preview__indicator").forEach(o=>{const c=()=>{this.goTo(parseInt(o.dataset.index))};o.addEventListener("click",c),o._clickHandler=c})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(r=>{r._clickHandler&&r.removeEventListener("click",r._clickHandler)});const e=this.overlay?.querySelector(".ds-image-preview__close"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),n=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),s&&this._prevHandler&&s.removeEventListener("click",this._prevHandler),n&&this._nextHandler&&n.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let U=null;function Qa(){U||(U=new Lt),document.querySelectorAll("[data-image-preview]").forEach(i=>{i.addEventListener("click",()=>{const t=JSON.parse(i.getAttribute("data-image-preview")),e=parseInt(i.getAttribute("data-image-index"))||0;U.show(t,e)})})}function tl(i,t=0){U||(U=new Lt),U.show(i,t)}class je{constructor(t,e={}){this.element=t,this.closeBtn=t.querySelector(".ds-tag__close"),this.checkbox=t.querySelector(".ds-tag__checkbox"),this.editInput=t.querySelector(".ds-tag__input"),this._listeners=[],this.color=e.color||t.getAttribute("data-tag-color")||"default",this.size=e.size||t.getAttribute("data-tag-size")||"default",this.checkable=e.checkable||t.hasAttribute("data-tag-checkable"),this.checked=e.checked||t.hasAttribute("data-tag-checked"),this.editable=e.editable||t.hasAttribute("data-tag-editable"),this.maxLength=e.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this._applyStyles(),this.closeBtn){const t=e=>{e.stopPropagation(),this.element.dispatchEvent(new CustomEvent("kupola:tag-remove",{detail:{tag:this.element,content:this.getContent()},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",t),this._listeners.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=e=>{e.target!==this.checkbox&&e.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this._listeners.push({el:this.element,event:"click",handler:t}),this.checkbox){const e=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",e),this._listeners.push({el:this.checkbox,event:"change",handler:e})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this._listeners.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const e=()=>{this.endEdit()},s=n=>{n.key==="Enter"?this.endEdit():n.key==="Escape"&&this.cancelEdit()};this.editInput.addEventListener("blur",e),this.editInput.addEventListener("keydown",s),this._listeners.push({el:this.editInput,event:"blur",handler:e}),this._listeners.push({el:this.editInput,event:"keydown",handler:s})}}}_applyStyles(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],e=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(s=>this.element.classList.remove(s)),e.forEach(s=>this.element.classList.remove(s)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),e.includes(`ds-tag--${this.size}`)&&this.element.classList.add(`ds-tag--${this.size}`),this.checkable&&this.element.classList.add("ds-tag--checkable"),this.checked&&this.element.classList.add("is-checked"),this.editable&&this.element.classList.add("ds-tag--editable")}setContent(t){this.editable&&this.editInput&&(this.editInput.value=t);const e=[];this.element.childNodes.forEach(l=>{l.nodeType===Node.TEXT_NODE&&e.push(l)}),e.forEach(l=>l.remove());const s=this.element.querySelector(".ds-tag__close"),n=this.element.querySelector(".ds-tag__checkbox"),r=this.element.querySelector(".ds-tag__input"),a=s||n||r||null;this.element.insertBefore(document.createTextNode(t),a),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:t},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-tag-color",t),this._applyStyles())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this._applyStyles())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=this.checked),this.element.dispatchEvent(new CustomEvent("kupola:tag-check",{detail:{tag:this.element,checked:this.checked,content:this.getContent()},bubbles:!0}))}setChecked(t){this.checked=t,this.element.setAttribute("data-tag-checked",t?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=t)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const t=this.getContent();if(this.editInput)this.editInput.value=t;else{const e=document.createElement("input");e.type="text",e.className="ds-tag__input",e.value=t,e.maxLength=this.maxLength,this.editInput=e;const s=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,s);const n=()=>this.endEdit(),r=a=>{a.key==="Enter"?this.endEdit():a.key==="Escape"&&this.cancelEdit()};e.addEventListener("blur",n),e.addEventListener("keydown",r),this._listeners.push({el:e,event:"blur",handler:n}),this._listeners.push({el:e,event:"keydown",handler:r})}this.element.classList.add("is-editing"),setTimeout(()=>{this.editInput&&(this.editInput.focus(),this.editInput.select())},0)}endEdit(){if(!this.editable||!this.element.classList.contains("is-editing"))return;const t=this.editInput.value.trim();this.element.classList.remove("is-editing"),t&&t!==this.getContent()&&(this.setContent(t),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:t},bubbles:!0})))}cancelEdit(){!this.editable||!this.element.classList.contains("is-editing")||(this.element.classList.remove("is-editing"),this.editInput&&(this.editInput.value=this.getContent()))}setEditable(t){this.editable=t,t?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this._applyStyles()}isEditable(){return this.editable}setCheckable(t){this.checkable!==t&&(this.destroy(),this.checkable=t,t?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function Dt(i,t){if(i.__kupolaInitialized)return;const e=new je(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function Je(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function el(){document.querySelectorAll(".ds-tag").forEach(i=>{Dt(i)})}w.register("tag",Dt,Je);class Ge{constructor(t){this.element=t,this.valueElement=t.querySelector(".ds-statcard__value"),this.progressFill=t.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(t=>{t.forEach(e=>{e.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this._observer.observe(this.element)}animateValue(){if(!this.valueElement)return;const t=this.valueElement.textContent,e=t.match(/[\d.,]+/);if(!e)return;const s=parseFloat(e[0].replace(",","")),n=t.substring(0,e.index),r=t.substring(e.index+e[0].length),a=1500,l=performance.now(),o=0,c=d=>{const u=d-l,p=Math.min(u/a,1),m=1-Math.pow(1-p,3),f=o+(s-o)*m;let g;s>=1e6?g=(f/1e6).toFixed(1)+"M":s>=1e3?g=(f/1e3).toFixed(1)+"K":Number.isInteger(s)?g=Math.floor(f).toLocaleString():g=f.toFixed(2),this.valueElement.textContent=n+g+r,p<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}animateProgress(){if(!this.progressFill)return;const t=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=t}updateValue(t,e={}){if(!this.valueElement)return;const s=e.duration||800,n=this.valueElement.textContent,r=n.match(/[\d.,]+/);if(!r){this.valueElement.textContent=t;return}const a=n.substring(0,r.index),l=n.substring(r.index+r[0].length),o=parseFloat(r[0].replace(",","")),c=parseFloat(t),d=performance.now(),u=p=>{const m=p-d,f=Math.min(m/s,1),g=1-Math.pow(1-f,3),v=o+(c-o)*g;let y;c>=1e6?y=(v/1e6).toFixed(1)+"M":c>=1e3?y=(v/1e3).toFixed(1)+"K":Number.isInteger(c)?y=Math.floor(v).toLocaleString():y=v.toFixed(2),this.valueElement.textContent=a+y+l,f<1&&requestAnimationFrame(u)};requestAnimationFrame(u)}updateProgress(t,e={}){if(!this.progressFill)return;const s=e.duration||600,n=parseFloat(this.progressFill.style.width||"0"),r=Math.min(Math.max(t,0),100),a=performance.now(),l=o=>{const c=o-a,d=Math.min(c/s,1),u=1-Math.pow(1-d,3),p=n+(r-n)*u;this.progressFill.style.width=p+"%",d<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}setTrend(t,e){const s=this.element.querySelector(".ds-statcard__trend");if(!s)return;s.className=`ds-statcard__trend ds-statcard__trend--${t}`;const n=t==="up"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/></svg>':t==="down"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 18 10.5 8.5 15.5 13.5 23 6"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="12 19 18 13 12 7 6 13"/></svg>';s.innerHTML=n+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function Ht(i){if(i.__kupolaInitialized)return;const t=new Ge(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function Ze(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function sl(){document.querySelectorAll(".ds-statcard").forEach(i=>{Ht(i)})}w.register("statcard",Ht,Ze);class Qe{constructor(t,e={}){this.element=t,this.data=e.data||[],this.startDate=e.startDate||this.getOneYearAgo(),this.endDate=e.endDate||new Date,this.cellSize=e.cellSize||14,this.onCellClick=e.onCellClick||null,this.tooltip=null,this.baseColor=e.color||t.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const t=new Date;return t.setFullYear(t.getFullYear()-1),t}init(){this.render(),this.createTooltip()}getDataByDate(t){const e=this.formatDate(t),s=this.data.find(n=>n.date===e);return s?s.value:0}formatDate(t){const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${s}-${n}`}getLevel(t,e){if(t===0)return 0;(!e||e===0)&&(e=Math.max(...this.data.map(n=>n.value),1));const s=t/e;return s<.2?1:s<.4?2:s<.6?3:s<.8?4:5}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:34,g:197,b:94}}getCellColor(t){const e=this.hexToRgb(this.baseColor);if(t===0)return"rgba(0, 0, 0, 0.1)";const s=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${s})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let s=-1;for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1)){const r=n.getMonth(),a=n.getDate();r!==s&&a===1&&(e.push({month:r,label:t[r],offset:Math.floor((n-this.startDate)/(1e3*60*60*24))}),s=r)}return e}getWeekCount(){let t=0;const s=new Date(this.startDate).getDay();for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1))n.getDay()===0&&t++;return s!==0&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let s=[];const r=new Date(this.startDate).getDay();for(let y=1;y<r;y++)s.push(null);for(let y=new Date(this.startDate);y<=this.endDate;y.setDate(y.getDate()+1))s.push(new Date(y)),(y.getDay()===6||y.getTime()===this.endDate.getTime())&&(e.push(s),s=[]);const a=e.length,l=this.element.classList.contains("ds-heatmap--compact")?12:16,o=a*l,c=document.createElement("div");c.className="ds-heatmap__container";const d=document.createElement("div");d.className="ds-heatmap__labels-and-grid";const u=document.createElement("div");u.className="ds-heatmap__weekday-labels";const p=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__weekday-label",k.textContent=y,k.style.height=p+"px",k.style.lineHeight=p+"px",u.appendChild(k)}),d.appendChild(u);const m=document.createElement("div");m.className="ds-heatmap__grid-container";const f=document.createElement("div");f.className="ds-heatmap__month-labels",f.style.width=o+"px";const g=this.getMonthLabels();g.forEach((y,k)=>{const E=document.createElement("div");E.className="ds-heatmap__month-label",E.textContent=y.label;const b=g[k+1];let C;b?C=Math.ceil((b.offset-y.offset)/7):C=a-Math.floor(y.offset/7),E.style.width=C*l+"px",f.appendChild(E)}),m.appendChild(f);const v=document.createElement("div");v.className="ds-heatmap__grid",e.forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__week-column",y.forEach(E=>{if(E===null){const b=document.createElement("div");b.className="ds-heatmap__cell",b.style.visibility="hidden",k.appendChild(b)}else{const b=this.getDataByDate(E),C=Math.max(...this.data.map(O=>O.value),1),D=this.getLevel(b,C),S=document.createElement("div");S.className="ds-heatmap__cell",S.dataset.date=this.formatDate(E),S.dataset.value=b,S.style.backgroundColor=this.getCellColor(D);const H=O=>this.showTooltip(O,E,b),A=()=>this.hideTooltip(),$=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(E),value:b})};S.addEventListener("mouseenter",H),S.addEventListener("mouseleave",A),S.addEventListener("click",$),this._listeners.push({el:S,event:"mouseenter",handler:H},{el:S,event:"mouseleave",handler:A},{el:S,event:"click",handler:$}),k.appendChild(S)}}),v.appendChild(k)}),m.appendChild(v),d.appendChild(m),c.appendChild(d),t.appendChild(c),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const s=document.createElement("span");s.className="ds-heatmap__legend-label",s.textContent="少";const n=document.createElement("div");n.className="ds-heatmap__legend-cells";for(let a=0;a<=5;a++){const l=document.createElement("div");l.className="ds-heatmap__legend-cell",l.style.backgroundColor=this.getCellColor(a),n.appendChild(l)}const r=document.createElement("span");r.className="ds-heatmap__legend-label",r.textContent="多",e.appendChild(s),e.appendChild(n),e.appendChild(r),t.appendChild(e)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(t,e,s){const n=t.target.getBoundingClientRect(),r=150;this.tooltip.innerHTML=`
|
|
157
157
|
<div class="ds-heatmap__tooltip-date">${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日</div>
|
|
158
158
|
<div class="ds-heatmap__tooltip-value">${s} contributions</div>
|
|
159
|
-
`,this.tooltip.style.left=Math.min(n.left+n.width/2-r/2,window.innerWidth-r-16)+"px",this.tooltip.style.top=n.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(t){this._listeners.forEach(({el:e,event:s,handler:n})=>{e.removeEventListener(s,n)}),this._listeners=[],this.data=t,this.render()}setDateRange(t,e){this.startDate=t,this.endDate=e,this.render()}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function Mt(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-heatmap-data");let e=[];if(t)try{e=JSON.parse(t)}catch{e=ts()}else e=ts();const s=new Ze(i,{data:e,onCellClick:n=>{}});i.__kupolaInstance=s,i.__kupolaInitialized=!0}function Qe(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function sl(){document.querySelectorAll(".ds-heatmap").forEach(i=>{Mt(i)})}function ts(){const i=[],t=new Date,e=new Date;e.setFullYear(e.getFullYear()-1);for(let s=new Date(e);s<=t;s.setDate(s.getDate()+1)){const n=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0"),o=s.getDay()===0||s.getDay()===6?Math.random()*20:Math.random()*50,c=Math.floor(o);i.push({date:`${n}-${r}-${a}`,value:c>0?c:Math.floor(Math.random()*30)+1})}return i}w.register("heatmap",Mt,Qe);class es{constructor(t,e={}){this.element=t,this.tooltipEl=null,this.options=e,this.delay=e.delay||parseInt(t.getAttribute("data-tooltip-delay"))||0,this.hideDelay=e.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=e.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=e.html||t.hasAttribute("data-tooltip-html"),this.theme=e.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=e.position||t.getAttribute("data-tooltip-position")||"top",this.animation=e.animation!==!1,this.mouseFollow=e.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this._showTooltip=null,this._hideTooltip=null,this._showTimer=null,this._hideTimer=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._mouseMoveHandler=null,this.isVisible=!1}init(){this.element.__kupolaInitialized||(this._showTooltip=()=>{this.delay>0?this._showTimer=setTimeout(()=>this.show(),this.delay):this.show()},this._hideTooltip=()=>{this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.hideDelay>0?this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this._clickHandler=()=>{this.isVisible?this.hide():this.show()},this._mouseMoveHandler=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const e=this.tooltipEl.getBoundingClientRect();let s=t.clientX+10,n=t.clientY+10;const r=window.innerWidth,a=window.innerHeight;s+e.width>r&&(s=t.clientX-e.width-10),n+e.height>a&&(n=t.clientY-e.height-10),this.tooltipEl.style.left=`${s}px`,this.tooltipEl.style.top=`${n}px`},(this.trigger==="hover"||this.trigger==="focus")&&(this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.mouseFollow&&this.element.addEventListener("mousemove",this._mouseMoveHandler)),this.trigger==="click"&&(this.element.addEventListener("click",this._clickHandler),document.addEventListener("click",t=>{this.isVisible&&!this.element.contains(t.target)&&!this.tooltipEl?.contains(t.target)&&this.hide()})),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip)),this.element.__kupolaInitialized=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");t&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{this.tooltipEl.classList.add("is-visible"),this.mouseFollow||this._positionTooltip(),this.isVisible=!0,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-show",{detail:{tooltip:this.tooltipEl},bubbles:!0}))}))}hide(){if(!this.isVisible||!this.tooltipEl)return;this.tooltipEl.classList.remove("is-visible");const t=this.tooltipEl;setTimeout(()=>{t===this.tooltipEl&&(t.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:t},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}_positionTooltip(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),e=this.tooltipEl.getBoundingClientRect(),s=window.innerWidth,n=window.innerHeight;let r,a;switch(this.position){case"bottom":r=t.left+t.width/2-e.width/2,a=t.bottom+8;break;case"right":r=t.right+8,a=t.top+t.height/2-e.height/2;break;case"left":r=t.left-e.width-8,a=t.top+t.height/2-e.height/2;break;case"top":default:r=t.left+t.width/2-e.width/2,a=t.top-e.height-8;break}r<8&&(r=8),r+e.width>s&&(r=s-e.width-8),a<8&&(a=8),a+e.height>n&&(a=n-e.height-8),this.tooltipEl.style.left=`${r}px`,this.tooltipEl.style.top=`${a}px`,this.tooltipEl.style.position="fixed"}updateContent(t,e=!1){this.element.setAttribute("data-tooltip",t),e?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=e,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this._positionTooltip())}setPosition(t){["top","bottom","left","right"].includes(t)&&(this.position=t,this.element.setAttribute("data-tooltip-position",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this._positionTooltip()))}setTheme(t){this.theme=t,this.element.setAttribute("data-tooltip-theme",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(t){this.delay=t,this.element.setAttribute("data-tooltip-delay",t)}setHideDelay(t){this.hideDelay=t,this.element.setAttribute("data-tooltip-hide-delay",t)}setTrigger(t){["hover","click","focus","manual"].includes(t)&&(this.destroy(),this.trigger=t,this.element.setAttribute("data-tooltip-trigger",t),this.init())}enableMouseFollow(t){this.mouseFollow=t,t?(this.element.setAttribute("data-tooltip-mouse-follow",""),this.element.addEventListener("mousemove",this._mouseMoveHandler)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this._mouseMoveHandler))}destroy(){this.element.__kupolaInitialized&&(this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),(this.trigger==="hover"||this.trigger==="focus")&&(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("mouseleave",this._hideTooltip)),this.trigger==="click"&&this.element.removeEventListener("click",this._clickHandler),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.removeEventListener("focus",this._showTooltip),this.element.removeEventListener("blur",this._hideTooltip)),this.mouseFollow&&this.element.removeEventListener("mousemove",this._mouseMoveHandler),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this._showTooltip=null,this._hideTooltip=null,this._clickHandler=null,this._mouseMoveHandler=null,this.element.__kupolaInitialized=!1)}}function Tt(i,t){const e=new es(i,t);e.init(),i._kupolaTooltip=e}function il(i=document){i.querySelectorAll("[data-tooltip]").forEach(t=>{Tt(t)})}function ss(i){i._kupolaTooltip&&(i._kupolaTooltip.destroy(),i._kupolaTooltip=null)}w.register("tooltip",Tt,ss);class is{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,e){this.customValidators[t]=e}addAsyncValidator(t,e){this.customAsyncValidators[t]=e}validate(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s={},n=t.querySelectorAll("[data-validate]");let r=!1;return n.forEach(a=>{const l=a.name||a.id,o=this.parseRules(a.getAttribute("data-validate")),c=this.getValue(a);for(const[d,u]of Object.entries(o))if((this.customValidators[d]||this.validators[d])?.(c,u))this.clearError(a);else{s[l]=this.getErrorMessage(d,u,a),this.showError(a,s[l]),r=!0;break}}),this.formStates[e]={valid:!r,errors:s,errorCount:Object.keys(s).length},this.updateFormState(t),!r}getValue(t){if(t.classList.contains("ds-datepicker__input")||t.classList.contains("ds-timepicker__input"))return t.value.trim();if(t.closest(".ds-select")){const e=t.closest(".ds-select"),s=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return s?s.textContent.trim():""}if(t.closest(".ds-fileupload")){const s=t.closest(".ds-fileupload").__fileUploadInstance;return s&&s.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.getValue(t);for(const[n,r]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(s,r))return this.showError(t,this.getErrorMessage(n,r,t)),!1;return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let e=!0;return t.forEach(s=>{this.validate(s)||(e=!1)}),e}async validateAsync(t,e={}){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,n=e.group,r=n?t.querySelectorAll(`[data-validate][data-validate-group="${n}"]`):t.querySelectorAll("[data-validate]");let a=!1;for(const o of r)await this.validateInputAsync(o)||(a=!0);const l={};return r.forEach(o=>{const c=o.name||o.id,d=o.parentElement.querySelector(".ds-input__error");d&&(l[c]=d.textContent)}),this.formStates[s]={valid:!a,errors:l,errorCount:Object.keys(l).length},this.updateFormState(t),!a}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.parseRules(t.getAttribute("data-validate-async")||""),n=this.getValue(t);for(const[r,a]of Object.entries(e))if(!(this.customValidators[r]||this.validators[r])?.(n,a))return this.showError(t,this.getErrorMessage(r,a,t)),!1;for(const[r,a]of Object.entries(s)){const l=this.customAsyncValidators[r]||this.asyncValidators[r];if(l)try{if(!await l(n,a,t))return this.showError(t,this.getErrorMessage(r,a,t)),!1}catch(o){return this.showError(t,o.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const s=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let n=!1;for(const r of s)await this.validateInputAsync(r)||(n=!0);return!n}getGroups(t){const e=new Set;return t.querySelectorAll("[data-validate-group]").forEach(s=>{e.add(s.getAttribute("data-validate-group"))}),Array.from(e)}getFormState(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[e]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const e=this.getFormState(t);e.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),e.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),e.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),e.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>n.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>{n.hasAttribute("data-permanent-disabled")||(n.disabled=!1)}));const s=t.querySelector(".ds-form__status");s&&(e.errorCount>0?(s.textContent=`${e.errorCount} ${e.errorCount===1?"error":"errors"} found`,s.classList.add("ds-form__status--error")):(s.textContent="All fields are valid",s.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].disabled=e,this.updateFormState(t)}resetForm(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[e]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(s=>{s.classList.remove("ds-input--error");const n=s.parentElement?.querySelector(".ds-input__error");n&&(n.textContent="")}),this.updateFormState(t)}parseRules(t){const e={};return t.split("|").forEach(n=>{const[r,a]=n.split(":");e[r]=a?a.split(","):[]}),e}validateRequired(t){return t!==""}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[e]){return t.length>=parseInt(e)}validateMaxLength(t,[e]){return t.length<=parseInt(e)}validatePattern(t,[e]){return new RegExp(e).test(t)}validateMin(t,[e]){return parseFloat(t)>=parseFloat(e)}validateMax(t,[e]){return parseFloat(t)<=parseFloat(e)}validateEqualTo(t,[e]){const s=document.getElementById(e);return s&&t===s.value}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,e){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let s=t.parentElement.querySelector(".ds-input__error");s||(s=document.createElement("span"),s.className="ds-input__error",s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),t.parentElement.appendChild(s)),s.textContent=e,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:e}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const e=t.parentElement.querySelector(".ds-input__error");e&&e.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const e=document.createElement("span");e.className="ds-input__status-icon ds-input__status-icon--success",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(e)}removeStatusIcon(t){const e=t.parentElement.querySelector(".ds-input__status-icon");e&&e.remove()}getErrorMessage(t,e,s){const n=s.getAttribute(`data-message-${t}`);return n||{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${e[0]} characters`,maxLength:`Maximum length is ${e[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${e[0]}`,max:`Maximum value is ${e[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const I=new is;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(i=>{i.addEventListener("submit",async t=>{const e=i.id||`form-${Math.random().toString(36).substr(2,9)}`;if(I.submitting.has(e)){t.preventDefault();return}t.preventDefault();const s=i.querySelector("[data-validate-async]")!==null;let n;if(s?n=await I.validateAsync(i):n=I.validate(i),n){I.submitting.add(e);const r=i.querySelector('button[type="submit"]');if(r){const a=r.textContent;r.setAttribute("data-original-text",a),r.textContent="Submitting...",r.disabled=!0}try{const a=i.getAttribute("data-on-submit");a&&window[a]?await window[a](i):i.submit()}finally{I.submitting.delete(e),r&&(r.textContent=r.getAttribute("data-original-text")||"Submit",r.disabled=!1)}}else{const r=i.querySelector(".ds-input--error");r&&r.focus()}}),i.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const n=document.activeElement;if(n&&n.closest(".ds-select"))return;I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)},50)});const s=((n,r)=>{let a;return(...l)=>{clearTimeout(a),a=setTimeout(()=>n(...l),r)}})(()=>{const n=I.getValue(t);n.length>0||t.classList.contains("ds-input--error")?I.validateInput(t)&&n&&I.showSuccess(t):I.removeStatusIcon(t)},300);t.addEventListener("input",s),t.addEventListener("keyup",n=>{n.key==="Enter"&&I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)})})})}));class ns{constructor(t,e={}){this.element=t,this.data=e.data||[],this.itemHeight=e.itemHeight||48,this.itemWidth=e.itemWidth||200,this.bufferSize=e.bufferSize||5,this.renderItem=e.renderItem||this.defaultRenderItem,this.onItemClick=e.onItemClick||null,this.onItemSelect=e.onItemSelect||null,this.onScroll=e.onScroll||null,this.onScrollEnd=e.onScrollEnd||null,this.selectedKey=e.selectedKey||null,this.keyField=e.keyField||"id",this.useDynamicHeight=e.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=e.estimatedHeight||48,this.container=null,this.scrollbarTrack=null,this.scrollbarThumb=null,this.totalHeight=0,this.startIndex=0,this.endIndex=0,this.isScrolling=!1,this.scrollTimeout=null,this.lastScrollTop=0,this.lastScrollLeft=0,this.init()}defaultRenderItem(t,e){return`
|
|
159
|
+
`,this.tooltip.style.left=Math.min(n.left+n.width/2-r/2,window.innerWidth-r-16)+"px",this.tooltip.style.top=n.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(t){this._listeners.forEach(({el:e,event:s,handler:n})=>{e.removeEventListener(s,n)}),this._listeners=[],this.data=t,this.render()}setDateRange(t,e){this.startDate=t,this.endDate=e,this.render()}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function Mt(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-heatmap-data");let e=[];if(t)try{e=JSON.parse(t)}catch{e=es()}else e=es();const s=new Qe(i,{data:e,onCellClick:n=>{}});i.__kupolaInstance=s,i.__kupolaInitialized=!0}function ts(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function il(){document.querySelectorAll(".ds-heatmap").forEach(i=>{Mt(i)})}function es(){const i=[],t=new Date,e=new Date;e.setFullYear(e.getFullYear()-1);for(let s=new Date(e);s<=t;s.setDate(s.getDate()+1)){const n=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0"),o=s.getDay()===0||s.getDay()===6?Math.random()*20:Math.random()*50,c=Math.floor(o);i.push({date:`${n}-${r}-${a}`,value:c>0?c:Math.floor(Math.random()*30)+1})}return i}w.register("heatmap",Mt,ts);class ss{constructor(t,e={}){this.element=t,this.tooltipEl=null,this.options=e,this.delay=e.delay||parseInt(t.getAttribute("data-tooltip-delay"))||0,this.hideDelay=e.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=e.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=e.html||t.hasAttribute("data-tooltip-html"),this.theme=e.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=e.position||t.getAttribute("data-tooltip-position")||"top",this.animation=e.animation!==!1,this.mouseFollow=e.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this._showTooltip=null,this._hideTooltip=null,this._showTimer=null,this._hideTimer=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._mouseMoveHandler=null,this.isVisible=!1}init(){this.element.__kupolaInitialized||(this._showTooltip=()=>{this.delay>0?this._showTimer=setTimeout(()=>this.show(),this.delay):this.show()},this._hideTooltip=()=>{this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.hideDelay>0?this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this._clickHandler=()=>{this.isVisible?this.hide():this.show()},this._mouseMoveHandler=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const e=this.tooltipEl.getBoundingClientRect();let s=t.clientX+10,n=t.clientY+10;const r=window.innerWidth,a=window.innerHeight;s+e.width>r&&(s=t.clientX-e.width-10),n+e.height>a&&(n=t.clientY-e.height-10),this.tooltipEl.style.left=`${s}px`,this.tooltipEl.style.top=`${n}px`},(this.trigger==="hover"||this.trigger==="focus")&&(this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.mouseFollow&&this.element.addEventListener("mousemove",this._mouseMoveHandler)),this.trigger==="click"&&(this.element.addEventListener("click",this._clickHandler),document.addEventListener("click",t=>{this.isVisible&&!this.element.contains(t.target)&&!this.tooltipEl?.contains(t.target)&&this.hide()})),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip)),this.element.__kupolaInitialized=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");t&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{this.tooltipEl.classList.add("is-visible"),this.mouseFollow||this._positionTooltip(),this.isVisible=!0,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-show",{detail:{tooltip:this.tooltipEl},bubbles:!0}))}))}hide(){if(!this.isVisible||!this.tooltipEl)return;this.tooltipEl.classList.remove("is-visible");const t=this.tooltipEl;setTimeout(()=>{t===this.tooltipEl&&(t.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:t},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}_positionTooltip(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),e=this.tooltipEl.getBoundingClientRect(),s=window.innerWidth,n=window.innerHeight;let r,a;switch(this.position){case"bottom":r=t.left+t.width/2-e.width/2,a=t.bottom+8;break;case"right":r=t.right+8,a=t.top+t.height/2-e.height/2;break;case"left":r=t.left-e.width-8,a=t.top+t.height/2-e.height/2;break;case"top":default:r=t.left+t.width/2-e.width/2,a=t.top-e.height-8;break}r<8&&(r=8),r+e.width>s&&(r=s-e.width-8),a<8&&(a=8),a+e.height>n&&(a=n-e.height-8),this.tooltipEl.style.left=`${r}px`,this.tooltipEl.style.top=`${a}px`,this.tooltipEl.style.position="fixed"}updateContent(t,e=!1){this.element.setAttribute("data-tooltip",t),e?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=e,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this._positionTooltip())}setPosition(t){["top","bottom","left","right"].includes(t)&&(this.position=t,this.element.setAttribute("data-tooltip-position",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this._positionTooltip()))}setTheme(t){this.theme=t,this.element.setAttribute("data-tooltip-theme",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(t){this.delay=t,this.element.setAttribute("data-tooltip-delay",t)}setHideDelay(t){this.hideDelay=t,this.element.setAttribute("data-tooltip-hide-delay",t)}setTrigger(t){["hover","click","focus","manual"].includes(t)&&(this.destroy(),this.trigger=t,this.element.setAttribute("data-tooltip-trigger",t),this.init())}enableMouseFollow(t){this.mouseFollow=t,t?(this.element.setAttribute("data-tooltip-mouse-follow",""),this.element.addEventListener("mousemove",this._mouseMoveHandler)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this._mouseMoveHandler))}destroy(){this.element.__kupolaInitialized&&(this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),(this.trigger==="hover"||this.trigger==="focus")&&(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("mouseleave",this._hideTooltip)),this.trigger==="click"&&this.element.removeEventListener("click",this._clickHandler),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.removeEventListener("focus",this._showTooltip),this.element.removeEventListener("blur",this._hideTooltip)),this.mouseFollow&&this.element.removeEventListener("mousemove",this._mouseMoveHandler),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this._showTooltip=null,this._hideTooltip=null,this._clickHandler=null,this._mouseMoveHandler=null,this.element.__kupolaInitialized=!1)}}function Tt(i,t){const e=new ss(i,t);e.init(),i._kupolaTooltip=e}function nl(i=document){i.querySelectorAll("[data-tooltip]").forEach(t=>{Tt(t)})}function is(i){i._kupolaTooltip&&(i._kupolaTooltip.destroy(),i._kupolaTooltip=null)}w.register("tooltip",Tt,is);class ns{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,e){this.customValidators[t]=e}addAsyncValidator(t,e){this.customAsyncValidators[t]=e}validate(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s={},n=t.querySelectorAll("[data-validate]");let r=!1;return n.forEach(a=>{const l=a.name||a.id,o=this.parseRules(a.getAttribute("data-validate")),c=this.getValue(a);for(const[d,u]of Object.entries(o))if((this.customValidators[d]||this.validators[d])?.(c,u))this.clearError(a);else{s[l]=this.getErrorMessage(d,u,a),this.showError(a,s[l]),r=!0;break}}),this.formStates[e]={valid:!r,errors:s,errorCount:Object.keys(s).length},this.updateFormState(t),!r}getValue(t){if(t.classList.contains("ds-datepicker__input")||t.classList.contains("ds-timepicker__input"))return t.value.trim();if(t.closest(".ds-select")){const e=t.closest(".ds-select"),s=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return s?s.textContent.trim():""}if(t.closest(".ds-fileupload")){const s=t.closest(".ds-fileupload").__fileUploadInstance;return s&&s.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.getValue(t);for(const[n,r]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(s,r))return this.showError(t,this.getErrorMessage(n,r,t)),!1;return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let e=!0;return t.forEach(s=>{this.validate(s)||(e=!1)}),e}async validateAsync(t,e={}){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,n=e.group,r=n?t.querySelectorAll(`[data-validate][data-validate-group="${n}"]`):t.querySelectorAll("[data-validate]");let a=!1;for(const o of r)await this.validateInputAsync(o)||(a=!0);const l={};return r.forEach(o=>{const c=o.name||o.id,d=o.parentElement.querySelector(".ds-input__error");d&&(l[c]=d.textContent)}),this.formStates[s]={valid:!a,errors:l,errorCount:Object.keys(l).length},this.updateFormState(t),!a}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.parseRules(t.getAttribute("data-validate-async")||""),n=this.getValue(t);for(const[r,a]of Object.entries(e))if(!(this.customValidators[r]||this.validators[r])?.(n,a))return this.showError(t,this.getErrorMessage(r,a,t)),!1;for(const[r,a]of Object.entries(s)){const l=this.customAsyncValidators[r]||this.asyncValidators[r];if(l)try{if(!await l(n,a,t))return this.showError(t,this.getErrorMessage(r,a,t)),!1}catch(o){return this.showError(t,o.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const s=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let n=!1;for(const r of s)await this.validateInputAsync(r)||(n=!0);return!n}getGroups(t){const e=new Set;return t.querySelectorAll("[data-validate-group]").forEach(s=>{e.add(s.getAttribute("data-validate-group"))}),Array.from(e)}getFormState(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[e]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const e=this.getFormState(t);e.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),e.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),e.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),e.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>n.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>{n.hasAttribute("data-permanent-disabled")||(n.disabled=!1)}));const s=t.querySelector(".ds-form__status");s&&(e.errorCount>0?(s.textContent=`${e.errorCount} ${e.errorCount===1?"error":"errors"} found`,s.classList.add("ds-form__status--error")):(s.textContent="All fields are valid",s.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].disabled=e,this.updateFormState(t)}resetForm(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[e]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(s=>{s.classList.remove("ds-input--error");const n=s.parentElement?.querySelector(".ds-input__error");n&&(n.textContent="")}),this.updateFormState(t)}parseRules(t){const e={};return t.split("|").forEach(n=>{const[r,a]=n.split(":");e[r]=a?a.split(","):[]}),e}validateRequired(t){return t!==""}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[e]){return t.length>=parseInt(e)}validateMaxLength(t,[e]){return t.length<=parseInt(e)}validatePattern(t,[e]){return new RegExp(e).test(t)}validateMin(t,[e]){return parseFloat(t)>=parseFloat(e)}validateMax(t,[e]){return parseFloat(t)<=parseFloat(e)}validateEqualTo(t,[e]){const s=document.getElementById(e);return s&&t===s.value}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,e){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let s=t.parentElement.querySelector(".ds-input__error");s||(s=document.createElement("span"),s.className="ds-input__error",s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),t.parentElement.appendChild(s)),s.textContent=e,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:e}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const e=t.parentElement.querySelector(".ds-input__error");e&&e.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const e=document.createElement("span");e.className="ds-input__status-icon ds-input__status-icon--success",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(e)}removeStatusIcon(t){const e=t.parentElement.querySelector(".ds-input__status-icon");e&&e.remove()}getErrorMessage(t,e,s){const n=s.getAttribute(`data-message-${t}`);return n||{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${e[0]} characters`,maxLength:`Maximum length is ${e[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${e[0]}`,max:`Maximum value is ${e[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const I=new ns;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(i=>{i.addEventListener("submit",async t=>{const e=i.id||`form-${Math.random().toString(36).substr(2,9)}`;if(I.submitting.has(e)){t.preventDefault();return}t.preventDefault();const s=i.querySelector("[data-validate-async]")!==null;let n;if(s?n=await I.validateAsync(i):n=I.validate(i),n){I.submitting.add(e);const r=i.querySelector('button[type="submit"]');if(r){const a=r.textContent;r.setAttribute("data-original-text",a),r.textContent="Submitting...",r.disabled=!0}try{const a=i.getAttribute("data-on-submit");a&&window[a]?await window[a](i):i.submit()}finally{I.submitting.delete(e),r&&(r.textContent=r.getAttribute("data-original-text")||"Submit",r.disabled=!1)}}else{const r=i.querySelector(".ds-input--error");r&&r.focus()}}),i.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const n=document.activeElement;if(n&&n.closest(".ds-select"))return;I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)},50)});const s=((n,r)=>{let a;return(...l)=>{clearTimeout(a),a=setTimeout(()=>n(...l),r)}})(()=>{const n=I.getValue(t);n.length>0||t.classList.contains("ds-input--error")?I.validateInput(t)&&n&&I.showSuccess(t):I.removeStatusIcon(t)},300);t.addEventListener("input",s),t.addEventListener("keyup",n=>{n.key==="Enter"&&I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)})})})}));class rs{constructor(t,e={}){this.element=t,this.data=e.data||[],this.itemHeight=e.itemHeight||48,this.itemWidth=e.itemWidth||200,this.bufferSize=e.bufferSize||5,this.renderItem=e.renderItem||this.defaultRenderItem,this.onItemClick=e.onItemClick||null,this.onItemSelect=e.onItemSelect||null,this.onScroll=e.onScroll||null,this.onScrollEnd=e.onScrollEnd||null,this.selectedKey=e.selectedKey||null,this.keyField=e.keyField||"id",this.useDynamicHeight=e.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=e.estimatedHeight||48,this.container=null,this.scrollbarTrack=null,this.scrollbarThumb=null,this.totalHeight=0,this.startIndex=0,this.endIndex=0,this.isScrolling=!1,this.scrollTimeout=null,this.lastScrollTop=0,this.lastScrollLeft=0,this.init()}defaultRenderItem(t,e){return`
|
|
160
160
|
<div class="ds-virtual-list__item-content">
|
|
161
161
|
<div class="ds-virtual-list__item-icon">
|
|
162
162
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -179,8 +179,8 @@
|
|
|
179
179
|
</div>
|
|
180
180
|
</div>
|
|
181
181
|
<div class="ds-virtual-list__container"></div>
|
|
182
|
-
`,this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this._scrollHandler=t=>this.handleScroll(t),this._thumbDragStartHandler=t=>this.handleThumbDragStart(t),this._thumbDragMoveHandler=t=>this.handleThumbDragMove(t),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=t=>{t.preventDefault(),this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=t.deltaX+t.deltaY:this.element.scrollTop+=t.deltaY+t.deltaX},this.element.addEventListener("scroll",this._scrollHandler),this.scrollbarThumb.addEventListener("mousedown",this._thumbDragStartHandler),document.addEventListener("mousemove",this._thumbDragMoveHandler),document.addEventListener("mouseup",this._thumbDragEndHandler),this.element.addEventListener("wheel",this._wheelHandler,{passive:!1}),this._listeners=[{el:this.element,event:"scroll",handler:this._scrollHandler},{el:this.scrollbarThumb,event:"mousedown",handler:this._thumbDragStartHandler},{el:document,event:"mousemove",handler:this._thumbDragMoveHandler},{el:document,event:"mouseup",handler:this._thumbDragEndHandler},{el:this.element,event:"wheel",handler:this._wheelHandler}]}handleScroll(t){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:s,isHorizontal:e,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex}),this.updateScrollState(),this.renderVisibleItems(),this.updateScrollbar()}updateScrollState(){this.isScrolling=!0,this.element.classList.add("ds-virtual-list--scrolling"),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{if(this.isScrolling=!1,this.element.classList.remove("ds-virtual-list--scrolling"),this.onScrollEnd){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:e,isHorizontal:t,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(t){const e=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const s=this.data[t][this.keyField]||t;if(this.dynamicHeightCache.has(s))return this.dynamicHeightCache.get(s)}return e?this.itemWidth:this.itemHeight}getItemPositions(){const t=[];let e=0;return this.data.forEach((s,n)=>{const r=this.getItemSize(n);t.push({start:e,end:e+r,size:r}),e+=r}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((s,n,r)=>s+this.getItemSize(r),0);const e=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*e}getIndexAtOffset(t){if(this.useDynamicHeight){const n=this.getItemPositions();for(let r=0;r<n.length;r++)if(t>=n[r].start&&t<n[r].end)return r;return this.data.length-1}const s=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(t/s)}renderVisibleItems(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop,s=t?this.element.clientWidth:this.element.clientHeight,n=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let r=Math.min(this.data.length-1,this.getIndexAtOffset(e+s)+this.bufferSize);r<n&&(r=n),this.startIndex=n,this.endIndex=r;const a=this.data.slice(n,r+1);let l="",o=0;if(this.useDynamicHeight)o=this.getItemPositions()[n]?.start||0;else{const c=t?this.itemWidth:this.itemHeight;o=n*c}a.forEach((c,d)=>{const u=n+d,p=c[this.keyField]||u,m=this.selectedKey===p,f=this.getItemSize(u);l+=this._buildItemHtml(c,u,p,m,f,o,t),o+=f}),this.container.innerHTML=l,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(c=>{c.addEventListener("click",()=>this.handleItemClick(c))})}_buildItemHtml(t,e,s,n,r,a,l){const o=n?" is-selected":"",c=this.renderItem(t,e);return l?`<div class="ds-virtual-list__item${o}" style="position: absolute; top: 0; left: ${a}px; width: ${r}px; height: 100%;" data-index="${e}" data-key="${s}">${c}</div>`:`<div class="ds-virtual-list__item${o}" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${r}px;" data-index="${e}" data-key="${s}">${c}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const s=parseInt(e.dataset.index),n=this.data[s][this.keyField]||s,r=e.offsetHeight;r!==this.getItemSize(s)&&(this.dynamicHeightCache.set(n,r),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),s=t.dataset.key,n=this.data[e];this.onItemClick&&this.onItemClick({item:n,index:e,key:s}),this.onItemSelect&&this.select(s)}select(t){if(this.selectedKey=t,this.onItemSelect){const e=this.data.findIndex(s=>s[this.keyField]===t);e!==-1&&this.onItemSelect({item:this.data[e],index:e,key:t})}this.renderVisibleItems()}updateScrollbar(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize(),s=t?this.element.clientWidth:this.element.clientHeight,n=t?this.element.scrollLeft:this.element.scrollTop;if(t){this.scrollbarThumb.style.display="none";return}const r=Math.max(20,s/e*s),a=s-r,l=n/(e-s||1)*a;this.scrollbarThumb.style.height=r+"px",this.scrollbarThumb.style.top=l+"px"}handleThumbDragStart(t){t.preventDefault(),this.isDragging=!0,this.dragStartY=t.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(t){if(!this.isDragging)return;const e=this.element.clientHeight,s=this.getTotalSize(),n=parseFloat(this.scrollbarThumb.style.height)||e,r=e-n,a=t.clientY-this.dragStartY;let l=this.dragStartTop+a;l=Math.max(0,Math.min(l,r)),this.scrollbarThumb.style.top=l+"px";const o=l/r*(s-e||0);this.element.scrollTop=o}handleThumbDragEnd(){this.isDragging=!1}update(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize();t?(this.container.style.width=e+"px",this.container.style.height="100%"):(this.container.style.height=e+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(t){this.data=t,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(t){this.data.push(t),this.update()}removeItem(t){this.data.splice(t,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(t,e){this.data.splice(t,0,e),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(t,e="smooth"){const s=this.element.classList.contains("ds-virtual-list--horizontal");let n=0;if(this.useDynamicHeight)n=this.getItemPositions()[t]?.start||0;else{const r=s?this.itemWidth:this.itemHeight;n=t*r}s?this.element.scrollTo({left:n,behavior:e}):this.element.scrollTo({top:n,behavior:e})}scrollToKey(t,e="smooth"){const s=this.data.findIndex(n=>n[this.keyField]===t);s!==-1&&this.scrollTo(s,e)}scrollToTop(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[e?"left":"top"]:0,behavior:t})}scrollToBottom(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=this.getTotalSize(),n=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:s-n,behavior:t})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((t,e)=>({item:t,index:this.startIndex+e,key:t[this.keyField]||this.startIndex+e}))}getItemIndex(t){return this.data.findIndex(e=>e[this.keyField]===t)}getItem(t){const e=this.getItemIndex(t);return e!==-1?this.data[e]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this._listeners=null,this._scrollHandler=null,this._thumbDragStartHandler=null,this._thumbDragMoveHandler=null,this._thumbDragEndHandler=null,this._wheelHandler=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function rs(i=1e3){const t=[],e=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let s=1;s<=i;s++){const n=Math.floor(Math.random()*e.length),r=Math.floor(Math.random()*1e4);t.push({id:s,title:`${e[n]} ${r}`,subtitle:`Last modified ${Math.floor(Math.random()*30)} days ago`,type:e[n].toLowerCase()})}return t}function as(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-virtual-list");let e=[];if(t)try{e=JSON.parse(t)}catch{e=rs(1e3)}else e=rs(1e3);const s=new ns(i,{data:e,onItemClick:n=>{},onItemSelect:n=>{}});i.__kupolaInstance=s,i.__kupolaInitialized=!0}function ls(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}w.register("virtual-list",as,ls);const nl='xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter"',It={globe:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 0 20"/><path d="M12 2a15.3 15.3 0 0 0 0 20"/>',dashboard:'<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>',mouse:'<rect x="6" y="2" width="12" height="20" rx="6"/><line x1="12" y1="6" x2="12" y2="11"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',square:'<rect x="3" y="3" width="18" height="18"/>',circle:'<circle cx="12" cy="12" r="9"/>',list:'<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',palette:'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',type:'<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',ruler:'<rect x="3" y="9" width="18" height="6" transform="rotate(-45 12 12)"/><line x1="7.5" y1="12.5" x2="9" y2="14"/><line x1="11" y1="9" x2="12.5" y2="10.5"/><line x1="14.5" y1="5.5" x2="16" y2="7"/>',sparkles:'<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',refresh:'<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',external:'<polyline points="14 4 20 4 20 10"/><line x1="20" y1="4" x2="11" y2="13"/><path d="M20 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5"/>',settings:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',sliders:'<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',minus:'<line x1="5" y1="12" x2="19" y2="12"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',github:'<path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/>',"message-circle":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/>',"message-plus":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/><line x1="12" y1="9" x2="12" y2="15"/><line x1="9" y1="12" x2="15" y2="12"/>',gear:'<path d="M9.3 5.7 6.375 5.025 5.025 6.375 5.7 9.3 3 11.1 3 12.9 5.7 14.7 5.025 17.625 6.375 18.975 9.3 18.3 11.1 21 12.9 21 14.7 18.3 17.625 18.975 18.975 17.625 18.3 14.7 21 12.9 21 11.1 18.3 9.3 18.975 6.375 17.625 5.025 14.7 5.7 12.9 3 11.1 3 9.3 5.7Z"/><circle cx="12" cy="12" r="3"/>',"user-circle":'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="2.5"/><path d="M7 17.5a5 5 0 0 1 10 0"/>',shield:'<path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/>',check:'<polyline points="4 12 10 18 20 6"/>',"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"alert-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',"alert-triangle":'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',"info-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"x-circle":'<circle cx="12" cy="12" r="9"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/>',alert:'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',info:'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>',user:'<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',users:'<path d="M2 21v-1a5 5 0 0 1 5-5h3a5 5 0 0 1 5 5v1"/><circle cx="8.5" cy="8" r="3.5"/><path d="M22 21v-1a5 5 0 0 0-4-4.9"/><path d="M16 3.1A4 4 0 0 1 16 11"/>',box:'<polyline points="3 7 12 2 21 7 21 17 12 22 3 17 3 7"/><line x1="3" y1="7" x2="12" y2="12"/><line x1="21" y1="7" x2="12" y2="12"/><line x1="12" y1="22" x2="12" y2="12"/>',zap:'<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',moon:'<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',sun:'<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',cmd:'<path d="M9 6h6v12H9z"/><rect x="3" y="3" width="6" height="6"/><rect x="15" y="3" width="6" height="6"/><rect x="3" y="15" width="6" height="6"/><rect x="15" y="15" width="6" height="6"/>',key:'<circle cx="7.5" cy="14.5" r="3.5"/><line x1="10" y1="12" x2="22" y2="12"/><line x1="22" y1="12" x2="22" y2="16"/><line x1="18" y1="12" x2="18" y2="15"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',mic:'<rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/>',at:'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',hash:'<line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/>',"sidebar-left":'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/>',"sidebar-right":'<rect x="3" y="3" width="18" height="18"/><line x1="15" y1="3" x2="15" y2="21"/>',"panel-bottom":'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="15" x2="21" y2="15"/>',git:'<circle cx="6" cy="5" r="3"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><line x1="6" y1="8" x2="6" y2="16"/><path d="M18 8v3a4 4 0 0 1-4 4h-4"/>',bug:'<rect x="8" y="6" width="8" height="14" rx="4"/><line x1="12" y1="11" x2="12" y2="20"/><line x1="3" y1="9" x2="8" y2="9"/><line x1="3" y1="14" x2="8" y2="14"/><line x1="3" y1="19" x2="8" y2="19"/><line x1="16" y1="9" x2="21" y2="9"/><line x1="16" y1="14" x2="21" y2="14"/><line x1="16" y1="19" x2="21" y2="19"/><line x1="9" y1="6" x2="9" y2="3"/><line x1="15" y1="6" x2="15" y2="3"/>',"search-menu":'<circle cx="11" cy="11" r="6"/><line x1="20" y1="20" x2="16" y2="16"/><line x1="3" y1="20" x2="13" y2="20"/>',extensions:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M17.5 14v3.5H21a2 2 0 0 1 0 4h-3.5V21a2 2 0 0 1-4 0v-3.5H14a2 2 0 0 1 0-4h3.5z"/>',wrench:'<path d="M14.7 6.3a4 4 0 0 0 5 5L21 12.5l-7.5 7.5a3 3 0 0 1-4.2-4.2L16.7 8 14.7 6.3z"/><path d="M14.7 6.3 12 9l-3-3 2.7-2.7a4 4 0 0 1 3 3z"/>',"message-square":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',"file-text":'<path d="M14 3H6v18h12V8z"/><polyline points="14 3 14 8 18 8"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="15" y2="17"/>',"scroll-text":'<path d="M5 4h11a3 3 0 0 1 3 3v10H8v3a1 1 0 0 1-1 1 3 3 0 0 1-3-3V7a3 3 0 0 1 1-3z"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/>',atom:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',"arrow-right-to-line":'<line x1="20" y1="4" x2="20" y2="20"/><line x1="3" y1="12" x2="17" y2="12"/><polyline points="11 6 17 12 11 18"/>',"info-square":'<rect x="3" y="3" width="18" height="18"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"arrow-minimize":'<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',"arrow-expand":'<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',logo:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',"more-h":'<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',edit:'<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',trash:'<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',file:'<path d="M14 3H6v18h12V7z"/><polyline points="14 3 14 7 18 7"/>',files:'<path d="M21 8v13H8V3h8z"/><polyline points="16 3 16 8 21 8"/><path d="M8 7H3v14h13v-3"/>',"grid-2x2":'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',layout:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',image:'<rect x="3" y="3" width="18" height="18"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><polyline points="3 18 9 12 13 16 17 12 21 16"/>',play:'<polygon points="6 4 20 12 6 20 6 4"/>',pause:'<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',help:'<rect x="3" y="3" width="18" height="18"/><path d="M9 9a3 3 0 0 1 6 0c0 2-3 2-3 4"/><line x1="12" y1="17" x2="12" y2="17.01"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',eye:'<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/>',star:'<polygon points="12 3 15 9 22 10 17 14 18 21 12 18 6 21 7 14 2 10 9 9 12 3"/>',heart:'<path d="M12 21s-7-5-7-11a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 6-7 11-7 11z"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',calendar:'<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',clock:'<circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 16 14"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',send:'<polygon points="3 12 21 4 17 21 12 13 3 12"/>',link:'<path d="M10 14a4 4 0 0 1 0-6l3-3a4 4 0 0 1 6 6l-1.5 1.5"/><path d="M14 10a4 4 0 0 1 0 6l-3 3a4 4 0 0 1-6-6l1.5-1.5"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',"log-out":'<path d="M14 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9"/><polyline points="16 16 21 12 16 8"/><line x1="9" y1="12" x2="21" y2="12"/>',menu:'<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',dollar:'<line x1="12" y1="2" x2="12" y2="22"/><path d="M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',bar:'<line x1="3" y1="21" x2="21" y2="21"/><rect x="5" y="11" width="3" height="8"/><rect x="10.5" y="6" width="3" height="13"/><rect x="16" y="14" width="3" height="5"/>',"trending-up":'<polyline points="3 17 9 11 13 15 21 7"/><polyline points="15 7 21 7 21 13"/>',"trending-down":'<polyline points="3 7 9 13 13 9 21 17"/><polyline points="15 17 21 17 21 11"/>',columns:'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M7 8h10v4a5 5 0 0 1-10 0V8z"/><path d="M12 17v5"/>',cpu:'<rect x="6" y="6" width="12" height="12"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="2" x2="9" y2="6"/><line x1="15" y1="2" x2="15" y2="6"/><line x1="9" y1="18" x2="9" y2="22"/><line x1="15" y1="18" x2="15" y2="22"/><line x1="2" y1="9" x2="6" y2="9"/><line x1="2" y1="15" x2="6" y2="15"/><line x1="18" y1="9" x2="22" y2="9"/><line x1="18" y1="15" x2="22" y2="15"/>',code:'<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',apple:'<path fill="currentColor" stroke="none" d="M17.05 12.04c-.03-3.04 2.49-4.5 2.6-4.57-1.42-2.07-3.62-2.36-4.4-2.39-1.87-.19-3.65 1.1-4.6 1.1-.96 0-2.42-1.08-3.98-1.05-2.05.03-3.94 1.19-4.99 3.02-2.13 3.69-.54 9.13 1.53 12.12 1.01 1.46 2.21 3.1 3.78 3.04 1.52-.06 2.09-.98 3.93-.98 1.83 0 2.36.98 3.97.95 1.64-.03 2.68-1.49 3.68-2.96 1.16-1.7 1.64-3.35 1.66-3.43-.04-.02-3.18-1.22-3.21-4.85zM14.06 4.34c.83-1.01 1.39-2.41 1.24-3.81-1.2.05-2.65.8-3.51 1.8-.77.89-1.45 2.31-1.27 3.68 1.34.1 2.71-.68 3.54-1.67z"/>'};function At(i,t=16,e="0 0 24 24"){const s=It[i];return s?`<svg ${nl.replace('width="16"',`width="${t}"`).replace('height="16"',`height="${t}"`).replace('viewBox="0 0 24 24"',`viewBox="${e}"`)}>${s}</svg>`:""}function it(i=document){i.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),s=+t.getAttribute("data-size")||16,n=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=At(e,s,n),t.classList.add("icon")})}const rl={svg:At,render:it,PATHS:It};typeof document<"u"&&(document.readyState!=="loading"?it():document.addEventListener("DOMContentLoaded",()=>it()));class os{constructor(t){this.element=t,this.hoursEl=t.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=t.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=t.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const t=this.element.getAttribute("data-end-time");if(t)return new Date(t).getTime();const e=parseInt(this.element.getAttribute("data-hours"))||0,s=parseInt(this.element.getAttribute("data-minutes"))||0,n=parseInt(this.element.getAttribute("data-seconds"))||0;return new Date().getTime()+(e*3600+s*60+n)*1e3}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const t=new Date().getTime(),e=this.endTime-t;if(e<=0){this.stop(),this.displayTime(0,0,0),this.dispatchComplete();return}const s=Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),n=Math.floor(e%(1e3*60*60)/(1e3*60)),r=Math.floor(e%(1e3*60)/1e3);this.displayTime(s,n,r)}displayTime(t,e,s){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(e).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(s).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=t*1e3,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("kupola:countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function zt(i){if(i.__kupolaInitialized)return;const t=new os(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function cs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function al(){document.querySelectorAll(".ds-countdown").forEach(t=>{zt(t)})}w.register("countdown",zt,cs);class hs{constructor(t){if(this.element=t,this.minusBtn=t.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=t.querySelector(".ds-number-input__btn--increase"),this.inputEl=t.querySelector(".ds-number-input__input"),this._listeners=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const t=()=>this.updateValue(-this.step),e=()=>this.updateValue(this.step),s=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",s),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:s})}updateValue(t){let e=parseInt(this.inputEl.value)||0;e+=t,e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let t=parseInt(this.inputEl.value);isNaN(t)&&(t=0),t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}updateState(){const t=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=t<=this.min,this.plusBtn.disabled=t>=this.max}setValue(t){t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(t,e){this.min=t,this.max=e,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Pt(i){if(!i.__kupolaInitialized)try{const t=new hs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function ds(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function ll(){document.querySelectorAll(".ds-number-input").forEach(i=>{Pt(i)})}w.register("number-input",Pt,ds);class us{constructor(t){this.container=t,this.track=t.querySelector(".ds-slider-captcha__track"),this.btn=t.querySelector(".ds-slider-captcha__btn"),this.text=t.querySelector(".ds-slider-captcha__text"),this.progress=t.querySelector(".ds-slider-captcha__progress"),this.statusEl=t.querySelector(".ds-slider-captcha__status"),this.refreshBtn=t.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=t.querySelector(".ds-slider-captcha__footer-refresh"),this.config={tolerance:6,minPoints:20,minDuration:300,maxDuration:1e4,minSpeedDelta:.3,maxAttempts:5},this.isDragging=!1,this.startX=0,this.startY=0,this.currentX=0,this.trackData=[],this.startTime=0,this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.targetX=0,this.distractorX=0,this.angle=0,this.distractorAngle=0,this.maxAngle=parseInt(t.getAttribute("data-angle"))||30,this.shape=t.getAttribute("data-shape")||"circle",this.hasDistractor=this.shape!=="circle",this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this._mouseDownHandler=null,this._mouseMoveHandler=null,this._mouseUpHandler=null,this._touchStartHandler=null,this._touchMoveHandler=null,this._touchEndHandler=null,this._mouseMoveListener=null,this._mouseUpListener=null,this._touchMoveListener=null,this._touchEndListener=null}init(){!this.track||!this.btn||this.container._initialized||(this._mouseDownHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.clientX,this.startY=t.clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._mouseMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,s=this.btn.offsetWidth,n=e-s-8;let r=t.clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.clientX,t.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._touchMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,s=this.btn.offsetWidth,n=e-s-8;let r=t.touches[0].clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.touches[0].clientX,t.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),this._mouseMoveListener=M.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=M.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=M.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=M.on(document,"touchend",this._touchEndHandler,{scope:this.scope}),this.btn.addEventListener("touchstart",this._touchStartHandler,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container._initialized=!0,this.loadCaptcha())}generateTarget(){const t=this.track.offsetWidth,e=this.btn.offsetWidth,s=14,n=t*.35,r=t*.85-e,a=t*.6;if(this.angle=Math.floor(Math.random()*(this.maxAngle+1)),this.hasDistractor)do this.distractorAngle=Math.floor(Math.random()*(this.maxAngle+1));while(Math.abs(this.distractorAngle-this.angle)<5);this.hasDistractor?Math.random()>.5?(this.targetX=Math.floor(n+Math.random()*(a-n-e)),this.distractorX=Math.floor(a+Math.random()*(r-a))):(this.targetX=Math.floor(a+Math.random()*(r-a)),this.distractorX=Math.floor(n+Math.random()*(a-n-e))):this.targetX=Math.floor(n+Math.random()*(r-n));const l=this.container.querySelector(".ds-slider-captcha__target");if(l&&(l.style.left=this.targetX+s+e/2+"px",l.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",l.style.display="block"),this.hasDistractor){const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.style.left=this.distractorX+s+e/2+"px",o.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",o.style.display="block")}else{const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.style.display="none")}}resetSlider(){this.btn.className="ds-slider-captcha__btn",this.btn.style.transform="rotate("+this.angle+"deg)",this.btn.innerHTML="",this.btn.style.left="14px",this.btn.style.display="block",this.progress&&(this.progress.style.width="0%",this.progress.style.display="block"),this.text&&(this.text.textContent="按住滑块,拖动到缺口位置",this.text.style.color=""),this.refreshBtn&&(this.refreshBtn.style.display="none"),this.currentX=0,this.trackData=[],this.container.classList.remove("is-verified","is-error","is-disabled")}loadCaptcha(){this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.generateTarget(),this.resetSlider(),this.statusEl&&(this.statusEl.textContent="请完成验证",this.statusEl.className="ds-slider-captcha__status")}collectTrack(t,e){const n=Date.now()-this.startTime;let r=0,a=0;if(this.trackData.length>0){const o=this.trackData[this.trackData.length-1],c=this.currentX-o.x,d=n-o.t;if(d>0&&(r=c/d,this.trackData.length>1)){const u=this.trackData[this.trackData.length-2],p=o.t-u.t;if(p>0){const m=(o.x-u.x)/p;a=r-m}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:n,v:r,a});const l=this.container.querySelector(".ds-slider-captcha__point-count");l&&(l.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const t=this.trackData[this.trackData.length-1].x,e=this.hasDistractor?Math.abs(t-this.distractorX):1/0,s=Math.abs(t-this.targetX);if(this.hasDistractor&&e<s&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(s>this.config.tolerance)return{passed:!1,msg:"验证失败"};const n=[];for(let d=1;d<this.trackData.length;d++){const u=this.trackData[d].x-this.trackData[d-1].x,p=this.trackData[d].t-this.trackData[d-1].t;p>0&&p<500&&n.push(u/p)}if(n.length<3)return{passed:!1,msg:"验证失败"};const r=Math.max(...n),a=Math.min(...n);if(r-a<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let l=!1;for(const d of this.trackData)if(Math.abs(d.y)>2){l=!0;break}if(!l&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const o=this.trackData[this.trackData.length-1].t;if(o<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(o>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const c=[];for(let d=1;d<n.length;d++)c.push(Math.abs(n[d]-n[d-1]));return c.length>2&&c.reduce((u,p)=>u+p,0)/c.length<.05?{passed:!1,msg:"验证失败"}:{passed:!0,msg:"验证通过"}}verifyCaptcha(){this.isProcessing||this.isVerified||(this.isProcessing=!0,this.statusEl&&(this.statusEl.textContent="验证中...",this.statusEl.className="ds-slider-captcha__status is-loading"),this.btn.style.cursor="wait",this.container.classList.add("is-disabled"),setTimeout(()=>{const t=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",t.passed){this.isVerified=!0,this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const e=this.container.querySelector(".ds-slider-captcha__target");e&&(e.style.display="none");const s=this.container.querySelector(".ds-slider-captcha__target--distractor");s&&(s.style.display="none"),this.text&&(this.text.textContent="验证通过",this.text.style.color="var(--status-success-default)"),this.statusEl&&(this.statusEl.textContent="验证成功",this.statusEl.className="ds-slider-captcha__status is-success"),this.container.classList.add("is-verified"),this.container.classList.remove("is-disabled");const n=this.container.getAttribute("data-on-verified");n&&typeof window[n]=="function"&&window[n](this.container)}else if(this.attempts++,this.text&&(this.text.textContent=t.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=t.msg,this.statusEl.className="ds-slider-captcha__status is-error"),this.container.getAttribute("data-err-refresh")==="auto")setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const s=this.container.querySelector(".ds-slider-captcha__target");s&&(s.style.display="none");const n=this.container.querySelector(".ds-slider-captcha__target--distractor");n&&(n.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}},300))}destroy(){this.container._initialized&&(this.btn&&this._mouseDownHandler&&this.btn.removeEventListener("mousedown",this._mouseDownHandler),this.btn&&this._touchStartHandler&&this.btn.removeEventListener("touchstart",this._touchStartHandler),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this._mouseMoveListener&&this._mouseMoveListener.unsubscribe?this._mouseMoveListener.unsubscribe():this._mouseMoveHandler&&document.removeEventListener("mousemove",this._mouseMoveHandler),this._mouseUpListener&&this._mouseUpListener.unsubscribe?this._mouseUpListener.unsubscribe():this._mouseUpHandler&&document.removeEventListener("mouseup",this._mouseUpHandler),this._touchMoveListener&&this._touchMoveListener.unsubscribe?this._touchMoveListener.unsubscribe():this._touchMoveHandler&&document.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndListener&&this._touchEndListener.unsubscribe?this._touchEndListener.unsubscribe():this._touchEndHandler&&document.removeEventListener("touchend",this._touchEndHandler),this.container._initialized=!1)}}function ps(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{const t=new us(i);t.init(),i._kupolaSlideCaptcha=t})}function fs(i){i._kupolaSlideCaptcha&&(i._kupolaSlideCaptcha.destroy(),i._kupolaSlideCaptcha=null)}function ms(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{fs(i)})}w.register("slide-captcha",ps,ms);class gs{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this._submitHandler=null,this._fieldHandlers=new Map,this._init()}_init(){this._setupValidators(),this._collectFields(),this._bindEvents()}_setupValidators(){this.validators={required:t=>typeof t=="string"?t.trim()!=="":Array.isArray(t)?t.length>0:t!=null,email:t=>t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t):!0,phone:t=>t?/^1[3-9]\d{9}$/.test(t):!0,url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>t?!isNaN(parseFloat(t))&&isFinite(t):!0,minlength:(t,e)=>t?t.length>=parseInt(e):!0,maxlength:(t,e)=>t?t.length<=parseInt(e):!0,min:(t,e)=>t?parseFloat(t)>=parseFloat(e):!0,max:(t,e)=>t?parseFloat(t)<=parseFloat(e):!0,pattern:(t,e)=>t?new RegExp(e).test(t):!0,equalTo:(t,e)=>{const s=document.getElementById(e);return s?t===s.value:!0}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}_collectFields(){this.form.querySelectorAll("input, select, textarea").forEach(e=>{e.hasAttribute("data-kupola-ignore")||this.fields.push(e)})}_bindEvents(){this._submitHandler=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this._submitHandler),this.fields.forEach(t=>{const e=()=>this.validateField(t),s=()=>this.clearError(t);this._fieldHandlers.set(t,{blur:e,input:s}),t.addEventListener("blur",e),t.addEventListener("input",s)})}validate(){let t=!0;return this.fields.forEach(e=>{this.validateField(e)||(t=!1)}),t}validateField(t){const e=this._getFieldErrors(t);return e.length>0?(this.showError(t,e[0]),!1):(this.clearError(t),!0)}_getFieldErrors(t){const e=[],s=this._getFieldValue(t);for(const[n,r]of Object.entries(this.validators)){const a=t.getAttribute(`data-${n}`);if(a!==null&&!r(s,a)){let o=this.errorMessages[n];typeof o=="function"&&(o=o(a)),e.push(o)}}return e}_getFieldValue(t){const e=t.type;if(e==="checkbox")return t.checked;if(e==="radio"){const s=t.name,n=this.form.querySelector(`input[name="${s}"]:checked`);return n?n.value:null}return e==="select-multiple"?Array.from(t.selectedOptions).map(s=>s.value):t.value}showError(t,e){this.clearError(t);const s=document.createElement("span");s.className="ds-form-error",s.textContent=e,t.classList.add("ds-form-field--error");const n=t.parentElement;n.classList.contains("ds-form-field")?n.appendChild(s):t.parentNode.insertBefore(s,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const e=t.parentElement.querySelector(".ds-form-error");e&&e.remove()}addValidator(t,e,s){this.validators[t]=e,this.errorMessages[t]=s}getData(){const t={};return this.fields.forEach(e=>{const s=e.name;if(!s)return;const n=this._getFieldValue(e);e.type==="checkbox"?(t[s]||(t[s]=[]),e.checked&&t[s].push(e.value)):e.type==="radio"?!t[s]&&e.checked&&(t[s]=e.value):t[s]=n}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(n=>{const r=n.type;if(r==="checkbox"){const a=Array.isArray(t[e])?t[e]:[t[e]];n.checked=a.includes(n.value)}else if(r==="radio")n.checked=n.value===t[e];else if(r==="select-multiple"){const a=Array.isArray(t[e])?t[e]:[t[e]];Array.from(n.options).forEach(l=>{l.selected=a.includes(l.value)})}else n.value=t[e]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this._submitHandler&&this.form&&this.form.removeEventListener("submit",this._submitHandler),this._fieldHandlers.forEach((t,e)=>{e.removeEventListener("blur",t.blur),e.removeEventListener("input",t.input)}),this._submitHandler=null,this._fieldHandlers.clear(),this._fieldHandlers=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function _s(i){const t=document.querySelectorAll(i||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const s=new gs(e);e._kupolaForm=s}),t.length}function ol(i){return i._kupolaForm}function cl(i){const t=i._kupolaForm;return t?t.validate():!1}w.register("form-validation",_s);class ys{constructor(){this._queue=new Set,this._scheduled=!1,this._flushDepth=0,this._maxDepth=10}schedule(t){this._queue.add(t),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){if(this._flushDepth>=this._maxDepth){console.warn("[Kupola Scheduler] Max flush depth reached, possible infinite loop detected"),this._queue.clear(),this._scheduled=!1;return}const t=Array.from(this._queue);this._queue.clear(),this._scheduled=!1,this._flushDepth++;const e=new Set;for(const s of t)if(!e.has(s)){e.add(s);try{s()}catch(n){console.error("[DependsScheduler]",n)}}this._flushDepth--}}const hl=new ys;class vs{constructor(t,e){this.data=t,this.createdAt=Date.now(),this.ttl=e}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class $t{constructor(){this._store=new Map}get(t){const e=this._store.get(t);return e||null}set(t,e,s=6e4){this._store.set(t,new vs(e,s))}has(t){return this._store.has(t)}delete(t){this._store.delete(t)}clear(){this._store.clear()}getStale(t){const e=this._store.get(t);return e?e.data:null}}class N extends Error{constructor(t,e,s){super(t),this.name="DependsError",this.code=e,this.cause=s,this.timestamp=Date.now()}}let nt=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null;function dl(i){if(!i||typeof i.fetch!="function")throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");nt=i.fetch.bind(i)}function ul(){return nt}function pl(){nt=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null}class R{constructor(t,e){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=e,this.subscribers=[],this.pending=null,this.retryCount=t.retry??0,this.retryDelay=t.retryDelay??1e3,this.onError=t.onError||null}subscribe(t){return this.subscribers.push(t),()=>{const e=this.subscribers.indexOf(t);e>-1&&this.subscribers.splice(e,1)}}notify(){hl.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(t){throw new N("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const e=this.cache.get(this.cacheKey);return e&&e.isFresh?e.data:e&&e.isStale?(this._revalidate(t),e.data):this._fetchWithRetry(t)}async _fetchWithRetry(t,e=0){try{const s=await this.fetch(t);return this.cache.set(this.cacheKey,s,this.staleTime),this.notify(),s}catch(s){if(e<this.retryCount){const r=this.retryDelay*Math.pow(2,e),a=Math.random()*r*.5,l=r+a;return await new Promise(o=>setTimeout(o,l)),this._fetchWithRetry(t,e+1)}const n=s instanceof N?s:new N(s.message||"Fetch failed","FETCH_ERROR",s);if(this.onError)try{this.onError(n)}catch{}throw n}}async _revalidate(t){try{await this._fetchWithRetry(t)}catch{}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class bs extends R{constructor(t,e){super(t,e),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let e=this.config.source;for(const d in t)e=e.replace(`:${d}`,encodeURIComponent(t[d]));const s=[];for(const[d,u]of Object.entries(this.queryParams||{}))s.push(`${encodeURIComponent(d)}=${encodeURIComponent(u)}`);for(const d in t)this.config.source.includes(`:${d}`)||s.push(`${encodeURIComponent(d)}=${encodeURIComponent(t[d])}`);s.length>0&&(e+=(e.includes("?")?"&":"?")+s.join("&"));const n={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...this.headers}};["POST","PUT","PATCH"].includes(n.method)&&(n.body=JSON.stringify(t));const r=nt;if(!r)throw new N("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const a=await r(e,n),l=typeof a.ok=="boolean"?a.ok:a.status>=200&&a.status<300,o=typeof a.status=="number"?a.status:0;if(!l)throw new N(`HTTP ${o}`,"HTTP_ERROR");return typeof a.json=="function"?await a.json():a.data!==void 0?a.data:a}}class qt extends R{constructor(t,e){super(t,e),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=t.sync!==!1,this.sync&&typeof window<"u"&&(this._storageHandler=s=>{s.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(t===null)return this.defaultValue;try{return JSON.parse(t)}catch{return t}}catch{return this.defaultValue}}setValue(t){const e=typeof t=="string"?t:JSON.stringify(t);localStorage.setItem(this.storageKey,e),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class Es extends R{constructor(t,e){super(t,e),this.paramName=t.source.replace("route:","")}async fetch(){if(typeof window>"u")return"";const e=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));return e?decodeURIComponent(e[1]):new URLSearchParams(location.search).get(this.paramName)||""}}class ks extends R{async fetch(t){return await this.config.source(t)}}class ws extends R{async fetch(){return this.config.source}}class Bt extends R{constructor(t,e){super(t,e),this.ws=null,this.reconnect=t.reconnect!==!1,this.reconnectDelay=t.reconnectDelay||3e3,this._reconnectAttempt=0,this._maxReconnectDelay=t.maxReconnectDelay||3e4,this.messageHandler=null,this._connected=!1,this._destroyed=!1}async fetch(){return new Promise((t,e)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,this._reconnectAttempt=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=s=>{let n;try{n=JSON.parse(s.data)}catch{n=s.data}this.cache.set(this.cacheKey,n,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=s=>{this._connected||e(new N("WebSocket connection failed","WS_ERROR",s))},this.ws.onclose=()=>{if(this._connected=!1,this.reconnect&&!this._destroyed){const s=this.reconnectDelay*Math.pow(2,this._reconnectAttempt),n=Math.random()*s*.3,r=Math.min(s+n,this._maxReconnectDelay);this._reconnectAttempt++,setTimeout(()=>{this._destroyed||this.fetch().catch(()=>{})},r)}}}catch(s){e(new N("WebSocket creation failed","WS_ERROR",s))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(typeof t=="string"?t:JSON.stringify(t))}destroy(){this._destroyed=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Ft(i,t){const e=i.source;return typeof e=="function"?new ks(i,t):typeof e=="string"&&(e.startsWith("ws://")||e.startsWith("wss://"))?new Bt(i,t):typeof e=="string"&&(e.startsWith("/")||e.startsWith("http"))?new bs(i,t):typeof e=="string"&&e.startsWith("localStorage:")?new qt(i,t):typeof e=="string"&&e.startsWith("route:")?new Es(i,t):new ws(i,t)}function fl(i,t){const e={},s=new $t,n=[];for(const r in t){let f=function(){return xs(i)},a=t[r];typeof a=="string"&&(a={source:a});const l={...a,cacheKey:a.cacheKey||`${r}-${JSON.stringify(xs(i))}`},o=Ft(l,s),c=T(null),d=T(!0),u=T(null),p=T(null);let m=0;async function g(){const k=++m;d.value=!0,u.value=null;try{const E=await o.getValue(f());if(k!==m)return;c.value=E,p.value=Date.now()}catch(E){if(k!==m)return;u.value=E.message||"Unknown error"}finally{k===m&&(d.value=!1)}}g();const v=o.subscribe(()=>{const k=s.getStale(o.cacheKey);k!=null&&(c.value=k,p.value=Date.now())});n.push(v);const y=Object.keys(i);y.length>0&&y.forEach(k=>{const E=i[k];if(E&&typeof E=="object"&&"value"in E&&E._subscribers){const b=()=>{o.invalidate(),g()};E._subscribers.add(b),n.push(()=>E._subscribers.delete(b))}}),e[r]={data:c,loading:d,error:u,lastUpdated:p,refresh(){return o.invalidate(),g()},setValue(k){o instanceof qt&&(o.setValue(k),c.value=k)},send(k){o instanceof Bt&&o.send(k)},_source:o}}return e._dispose=()=>{if(n.forEach(r=>r()),window.__kupolaDepInstances){const r=window.__kupolaDepInstances.indexOf(e);r!==-1&&window.__kupolaDepInstances.splice(r,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(e),e}function ml(i){const t=new $t,e=Ft(i,t),s=T(null),n=T(!0),r=T(null);let a=0;async function l(){const o=++a;n.value=!0,r.value=null;try{const c=await e.getValue(i.params||{});if(o!==a)return;s.value=c}catch(c){if(o!==a)return;r.value=c.message||"Unknown error"}finally{o===a&&(n.value=!1)}}return l(),e.subscribe(()=>{const o=t.getStale(e.cacheKey);o!=null&&(s.value=o)}),{data:s,loading:n,error:r,refresh(){return e.invalidate(),l()}}}function xs(i){const t={};for(const e in i){const s=i[e];s&&typeof s=="object"&&"value"in s?t[e]=s.value:t[e]=s}return t}function gl(){}class Cs{constructor(t,e={}){this.element=typeof t=="string"?document.querySelector(t):t,this.options=e,this.columns=(e.columns||[]).map((s,n)=>({...s,_index:n})),this.rowKey=e.rowKey||"id",this._data=[],this._loading=!1,this.striped=e.striped!==!1,this.bordered=e.bordered||!1,this.hoverable=e.hoverable!==!1,this.compact=e.compact||!1,this.emptyText=e.emptyText||"暂无数据",this.loadingText=e.loadingText||"加载中...",this.multiSort=e.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=e.pagination!==!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._pageSize=e.pageSize||10,this._currentPage=1,this._total=0,this.selection=e.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=e.selectionColumnTitle||"",this.expandable=e.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=e.expandColumnTitle||"",this.editable=e.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=e.resizable||!1,this.draggable=e.draggable||!1,this._dragState=null,this.tree=e.tree||null,this._treeExpandedKeys=new Set,e.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=e.virtualScroll||null,this._scrollContainer=null,this._scrollHandler=null,this._resizeCleanups=[],this._filterDebounceTimer=null,this._reactiveCleanups=[],this.mergeCells=e.mergeCells||null,this.onSort=e.onSort||null,this.onPageChange=e.onPageChange||null,this.onRowClick=e.onRowClick||null,this.onFilter=e.onFilter||null,this.onSelect=e.onSelect||null,this.onExpand=e.onExpand||null,this.onEditSave=e.onEditSave||null,this.onEditCancel=e.onEditCancel||null,this.onRowDragEnd=e.onRowDragEnd||null,this.onColumnResize=e.onColumnResize||null,this.sortKey=T(null),this.sortOrder=T(null),this.currentPage=T(1),this.filterText=T(""),this.selectedKeys=T([]),this._init()}_init(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&typeof t=="object"&&"value"in t?(this._data=Array.isArray(t.value)?t.value:[],t.subscribe&&this._reactiveCleanups.push(t.subscribe(e=>{this._data=Array.isArray(e)?e:[],this._total=this._data.length,this.render()}))):Array.isArray(t)?this._data=t:this._data=[],this.tree&&this._treeExpandAll&&this._flattenForExpand(this._data),this._total=this._getFlatData(this._data).length,this.render()}setLoading(t){t&&typeof t=="object"&&"value"in t?(this._loading=t.value,t.subscribe&&this._reactiveCleanups.push(t.subscribe(e=>{this._loading=e,this.render()}))):this._loading=!!t,this.render()}_flattenForExpand(t,e=0,s=null){const n=this.tree?.childrenKey||"children",r=[];for(const a of t){const l=a[this.rowKey];r.push({...a,_level:e,_parentKey:s,_hasChildren:!!(a[n]&&a[n].length)}),a[n]&&a[n].length&&r.push(...this._flattenForExpand(a[n],e+1,l))}return r}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const s=this.tree?.childrenKey||"children",n=[];for(const r of t){const a=r[this.rowKey];n.push({...r,_level:e,_hasChildren:!!(r[s]&&r[s].length)}),r[s]&&r[s].length&&this._treeExpandedKeys.has(a)&&n.push(...this._flattenVisible(r[s],e+1))}return n}getProcessedData(){let t=this.tree?[...this._data]:[...this._data];if(this._filterText){const n=this._filterText.toLowerCase();this.tree?t=this._filterTree(t,n):t=t.filter(r=>this.columns.some(a=>{const l=r[a.key];return l!=null&&String(l).toLowerCase().includes(n)}))}this._sorts.length>0&&(this.tree?t=this._sortTree(t):t=this._sortFlat(t));const e=this.tree?this._flattenVisible(t):t;this._total=e.length;let s=e;if(this._showPagination&&this._pageSize>0){const n=(this._currentPage-1)*this._pageSize;s=e.slice(n,n+this._pageSize)}return s}_filterTree(t,e){const s=this.tree?.childrenKey||"children";return t.reduce((n,r)=>{const a=r[s]?this._filterTree(r[s],e):[];return(this.columns.some(o=>{const c=r[o.key];return c!=null&&String(c).toLowerCase().includes(e)})||a.length>0)&&(n.push({...r,[s]:a}),a.length>0&&this._treeExpandedKeys.add(r[this.rowKey])),n},[])}_sortFlat(t){return[...t].sort((e,s)=>{for(const n of this._sorts){const r=this.columns.find(c=>c.key===n.key);let a=e[n.key],l=s[n.key],o=0;if(r?.sorter?o=r.sorter(a,l,n.order):a==null?o=1:l==null?o=-1:typeof a=="number"&&typeof l=="number"?o=n.order==="asc"?a-l:l-a:o=n.order==="asc"?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),o!==0)return o}return 0})}_sortTree(t){const e=this._sortFlat(t),s=this.tree?.childrenKey||"children";return e.map(n=>n[s]?.length?{...n,[s]:this._sortTree(n[s])}:n)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const s=document.createElement("div");s.className="kupola-table-container";const n=document.createElement("table");n.className=this._getTableClass(),n.appendChild(this._renderThead()),this.virtualScroll?n.appendChild(this._renderVirtualTbody(t)):n.appendChild(this._renderTbody(t)),s.appendChild(n),e.appendChild(s),this._showPagination&&this._total>0&&e.appendChild(this._renderPagination()),this.resizable&&this._initColumnResize(),this.draggable&&this._initRowDrag(),this._applyStickyColumns()}_renderThead(){const t=document.createElement("thead"),e=document.createElement("tr");if(this.selection&&this._renderSelectionHeader(e),this.expandable){const s=document.createElement("th");s.className="kupola-table-col-expand",e.appendChild(s)}return this.columns.forEach(s=>{const n=this._renderColumnHeader(s);e.appendChild(n)}),t.appendChild(e),t}_renderSelectionHeader(t){const e=document.createElement("th");if(e.className="kupola-table-col-selection",this.selection==="checkbox"){const s=document.createElement("input");s.type="checkbox";const r=this.getProcessedData().map(a=>a[this.rowKey]);s.checked=r.length>0&&r.every(a=>this._selectedKeys.has(a)),s.addEventListener("change",()=>s.checked?this.selectAll():this.deselectAll()),e.appendChild(s)}t.appendChild(e)}_renderColumnHeader(t){const e=document.createElement("th");if(e.textContent=t.title||t.key,t.width&&(e.style.width=typeof t.width=="number"?t.width+"px":t.width),t.minWidth&&(e.style.minWidth=typeof t.minWidth=="number"?t.minWidth+"px":t.minWidth),t.align&&(e.style.textAlign=t.align),t.fixed&&e.setAttribute("data-fixed",t.fixed),t.sortable&&this._renderSortIndicator(e,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const s=document.createElement("span");s.className="kupola-table-resize-handle",s.setAttribute("data-col-key",t.key),e.appendChild(s)}return e}_renderSortIndicator(t,e){t.classList.add("kupola-table-sortable");const s=this._sorts.find(r=>r.key===e.key);s&&t.classList.add(`kupola-table-sort-${s.order}`),t.addEventListener("click",r=>{this.resizable&&r.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const n=document.createElement("span");n.className="kupola-table-sort-icon",s?n.textContent=this.multiSort?` ${this._sorts.indexOf(s)+1}${s.order==="asc"?"▲":"▼"}`:s.order==="asc"?" ▲":" ▼":n.textContent=" ⇅",t.appendChild(n)}_renderTbody(t){const e=document.createElement("tbody");if(this._loading)e.appendChild(this._renderStatusRow(this.loadingText,"kupola-table-loading"));else if(t.length===0)e.appendChild(this._renderStatusRow(this.emptyText,"kupola-table-empty"));else{const s=this.mergeCells?this.mergeCells(t):[],n=new Map;s.forEach(a=>n.set(`${a.row}-${a.col}`,a));const r=new Set;t.forEach((a,l)=>{const o=a[this.rowKey]??l,c=this._selectedKeys.has(o),d=this._expandedKeys.has(o),u=this._renderDataRow(a,l,o,c,r,n);if(e.appendChild(u),this.expandable&&d){const p=document.createElement("tr");p.className="kupola-table-expand-row";const m=document.createElement("td"),f=this.columns.length+(this.selection?1:0)+1;m.colSpan=f,m.className="kupola-table-expand-content";const g=this.expandable(a);typeof g=="string"?m.innerHTML=g:g instanceof HTMLElement&&m.appendChild(g),p.appendChild(m),e.appendChild(p)}})}return e}_renderDataRow(t,e,s,n,r,a){const l=document.createElement("tr");return l.setAttribute("data-row-key",s),n&&l.classList.add("kupola-table-row-selected"),this.draggable&&(l.draggable=!0,l.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(l,s,n),this.expandable&&this._renderExpandCell(l,s),this.columns.forEach((o,c)=>{if(r.has(`${e}-${c}`))return;const d=this._renderDataCell(t,e,s,o,c,r,a);l.appendChild(d)}),this.onRowClick&&(l.style.cursor="pointer",l.addEventListener("click",o=>{o.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,o)})),l}_renderSelectionCell(t,e,s){const n=document.createElement("td");n.className="kupola-table-col-selection";const r=document.createElement("input");r.type=this.selection,r.checked=s,r.addEventListener("change",()=>{this.selection==="radio"?(this._selectedKeys.clear(),this._selectedKeys.add(e)):s?this._selectedKeys.delete(e):this._selectedKeys.add(e),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),n.appendChild(r),t.appendChild(n)}_renderExpandCell(t,e){const s=document.createElement("td");s.className="kupola-table-col-expand";const n=document.createElement("button");n.className="kupola-table-expand-btn",n.textContent=this._expandedKeys.has(e)?"▼":"▶",n.type="button",n.addEventListener("click",()=>this._toggleExpand(e)),s.appendChild(n),t.appendChild(s)}_renderDataCell(t,e,s,n,r,a,l){const o=document.createElement("td");n.align&&(o.style.textAlign=n.align),n.fixed&&(o.setAttribute("data-fixed",n.fixed),o.classList.add(`kupola-table-fixed-${n.fixed}`));const c=l.get(`${e}-${r}`);if(c){c.rowSpan>1&&(o.rowSpan=c.rowSpan),c.colSpan>1&&(o.colSpan=c.colSpan);for(let u=0;u<(c.rowSpan||1);u++)for(let p=0;p<(c.colSpan||1);p++)u===0&&p===0||a.add(`${e+u}-${r+p}`)}this.tree&&r===0&&t._level>0&&this._renderTreeIndent(o,t);const d=this._editingCell&&this._editingCell.rowKey===s&&this._editingCell.colKey===n.key;if(d)o.appendChild(this._renderEditCell(n,t));else if(n.render){const u=n.render(t[n.key],t,e);typeof u=="string"?o.innerHTML=u:u instanceof HTMLElement&&o.appendChild(u)}else o.textContent=t[n.key]??"";return this.editable&&!d&&n.editable!==!1&&(o.classList.add("kupola-table-editable-cell"),o.addEventListener("dblclick",()=>this._startEdit(s,n.key,t[n.key]))),o}_renderTreeIndent(t,e){const s=document.createElement("span");if(s.className="kupola-table-tree-indent",s.style.paddingLeft=e._level*20+"px",t.appendChild(s),e._hasChildren){const n=document.createElement("button");n.className="kupola-table-tree-toggle",n.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",n.type="button",n.addEventListener("click",r=>{r.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),t.appendChild(n)}else{const n=document.createElement("span");n.className="kupola-table-tree-toggle-placeholder",t.appendChild(n)}}_renderStatusRow(t,e){const s=document.createElement("tr"),n=document.createElement("td");return n.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),n.className=e,n.textContent=t,s.appendChild(n),s}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:s=40,overscan:n=5}=this.virtualScroll,r=t.length*s;if(this._loading)return this._renderTbody(t);if(t.length===0)return this._renderTbody(t);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",e.appendChild(a),this._virtualData={data:t,rowHeight:s,overscan:n,totalHeight:r,tbody:e,topSpacer:a},this._updateVirtualScroll();const l=document.createElement("tr");l.className="kupola-table-virtual-spacer-bottom",l.style.height="0px",e.appendChild(l);const o=this.element.querySelector(".kupola-table-container");return o&&(o.style.maxHeight=this.virtualScroll.maxHeight||"400px",o.style.overflowY="auto",this._scrollHandler&&o.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),o.addEventListener("scroll",this._scrollHandler)),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:s,tbody:n,topSpacer:r}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const l=a.scrollTop,o=a.clientHeight,c=Math.max(0,Math.floor(l/e)-s),d=Math.min(t.length,Math.ceil((l+o)/e)+s);n.querySelectorAll(".kupola-table-virtual-row").forEach(f=>f.remove());const p=document.createDocumentFragment();for(let f=c;f<d;f++){const g=t[f],v=g[this.rowKey]??f,y=this._renderDataRow(g,f,v,this._selectedKeys.has(v),new Set,new Map);y.classList.add("kupola-table-virtual-row"),y.style.height=e+"px",p.appendChild(y)}r.style.height=c*e+"px";const m=n.querySelector(".kupola-table-virtual-spacer-bottom");m&&(m.style.height=(t.length-d)*e+"px"),r.after(p)}_renderEditCell(t,e){const s=document.createElement("div");s.className="kupola-table-edit-cell";const n=document.createElement("input");if(n.type=t.editType||"text",n.className="ds-input kupola-table-edit-input",n.value=this._editBuffer[t.key]??e[t.key]??"",t.editOptions){const o=document.createElement("select");o.className="ds-input kupola-table-edit-input",t.editOptions.forEach(c=>{const d=document.createElement("option");d.value=typeof c=="object"?c.value:c,d.textContent=typeof c=="object"?c.label:c,String(d.value)===String(n.value)&&(d.selected=!0),o.appendChild(d)}),o.addEventListener("change",()=>{this._editBuffer[t.key]=o.value}),s.appendChild(o)}else n.addEventListener("input",()=>{this._editBuffer[t.key]=n.value}),s.appendChild(n);const r=document.createElement("div");r.className="kupola-table-edit-actions";const a=document.createElement("button");a.className="kupola-table-edit-save",a.textContent="✓",a.type="button",a.addEventListener("click",()=>this._saveEdit(e,t));const l=document.createElement("button");return l.className="kupola-table-edit-cancel",l.textContent="✗",l.type="button",l.addEventListener("click",()=>this._cancelEdit()),r.appendChild(a),r.appendChild(l),s.appendChild(r),n.addEventListener("keydown",o=>{o.key==="Enter"&&this._saveEdit(e,t),o.key==="Escape"&&this._cancelEdit()}),setTimeout(()=>n.focus?.(),0),s}_startEdit(t,e,s){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:s},this.render()}_saveEdit(t,e){const s=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,s,this._data):t[e.key]=s,this._editingCell=null,this._editBuffer={},this.render()}_cancelEdit(){this.onEditCancel&&this.onEditCancel(this._editingCell),this._editingCell=null,this._editBuffer={},this.render()}_handleSort(t){if(this.multiSort){const e=this._sorts.findIndex(s=>s.key===t);if(e>=0){const s=this._sorts[e];s.order==="asc"?s.order="desc":this._sorts.splice(e,1)}else this._sorts.push({key:t,order:"asc"})}else{const e=this._sorts.find(s=>s.key===t);e?e.order==="asc"?e.order="desc":this._sorts=[]:this._sorts=[{key:t,order:"asc"}]}this.sortKey.value=this._sorts.map(e=>e.key).join(","),this.sortOrder.value=this._sorts.map(e=>e.order).join(","),this._currentPage=1,this.onSort&&this.onSort(this._sorts),this.render()}_toggleExpand(t){this._expandedKeys.has(t)?this._expandedKeys.delete(t):this._expandedKeys.add(t),this.onExpand&&this.onExpand(t,this._expandedKeys.has(t)),this.render()}_toggleTreeExpand(t){this._treeExpandedKeys.has(t)?this._treeExpandedKeys.delete(t):this._treeExpandedKeys.add(t),this.render()}selectRow(t){this._selectedKeys.add(t),this._syncSelected(),this.render()}deselectRow(t){this._selectedKeys.delete(t),this._syncSelected(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this._selectedKeys.add(t[this.rowKey])),this._syncSelected(),this.render()}deselectAll(){this._selectedKeys.clear(),this._syncSelected(),this.render()}invertSelection(){this.getProcessedData().forEach(e=>{const s=e[this.rowKey];this._selectedKeys.has(s)?this._selectedKeys.delete(s):this._selectedKeys.add(s)}),this._syncSelected(),this.render()}getSelectedKeys(){return[...this._selectedKeys]}getSelectedRows(){return(this.tree?this._flattenForExpand(this._data):this._data).filter(e=>this._selectedKeys.has(e[this.rowKey]))}_syncSelected(){this.selectedKeys.value=[...this._selectedKeys]}_initColumnResize(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(e=>{e.addEventListener("mousedown",s=>{s.preventDefault();const n=e.getAttribute("data-col-key"),r=e.parentElement,a=s.clientX,l=r.offsetWidth,o=d=>{const u=Math.max(50,l+(d.clientX-a));r.style.width=u+"px";const p=this.columns.find(m=>m.key===n);p&&(p.width=u),this.onColumnResize&&this.onColumnResize(n,u)},c=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",c),this._resizeCleanups.push(c)})})}_initRowDrag(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(e=>{e.addEventListener("dragstart",s=>{this._dragState={fromKey:e.getAttribute("data-row-key")},e.classList.add("kupola-table-dragging"),s.dataTransfer.effectAllowed="move"}),e.addEventListener("dragover",s=>{s.preventDefault(),s.dataTransfer.dropEffect="move",e.classList.add("kupola-table-drag-over")}),e.addEventListener("dragleave",()=>e.classList.remove("kupola-table-drag-over")),e.addEventListener("drop",s=>this._handleRowDrop(s,e)),e.addEventListener("dragend",()=>{e.classList.remove("kupola-table-dragging"),this._dragState=null})})}_handleRowDrop(t,e){if(t.preventDefault(),e.classList.remove("kupola-table-drag-over"),!this._dragState)return;const s=e.getAttribute("data-row-key");if(this._dragState.fromKey===s)return;const n=this._data.findIndex(a=>String(a[this.rowKey])===this._dragState.fromKey),r=this._data.findIndex(a=>String(a[this.rowKey])===s);if(n>=0&&r>=0){const[a]=this._data.splice(n,1);this._data.splice(r,0,a),this.onRowDragEnd&&this.onRowDragEnd(a,n,r,this._data),this.render()}}_applyStickyColumns(){const t=this.columns.filter(n=>n.fixed==="left");this.selection,this.expandable,t.forEach(n=>{const r=this.element.querySelectorAll('th[data-fixed="left"]'),a=this.element.querySelectorAll('td[data-fixed="left"]'),l=this.columns.indexOf(n);let o=(this.selection?40:0)+(this.expandable?40:0);for(let c=0;c<l;c++)this.columns[c].fixed==="left"&&(o+=this.columns[c]._resolvedWidth||120);r.forEach(c=>{c.textContent.startsWith(n.title||n.key)&&(c.style.position="sticky",c.style.left=o+"px",c.style.zIndex="2",n._resolvedWidth=c.offsetWidth)}),a.forEach(c=>{c.style.position="sticky",c.style.left=o+"px",c.style.zIndex="1",c.style.background="inherit"})});let e=0;[...this.columns].filter(n=>n.fixed==="right").reverse().forEach(n=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(a=>{a.style.position="sticky",a.style.right=e+"px",a.style.zIndex="1"}),e+=n._resolvedWidth||n.width||120})}_renderToolbar(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const n=document.createElement("input");n.type="text",n.className="ds-input kupola-table-filter-input",n.placeholder=this.options.filterPlaceholder||"搜索...",n.value=this._filterText,n.addEventListener("input",()=>{clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=setTimeout(()=>{this._filterText=n.value,this._currentPage=1,this.filterText.value=this._filterText,this.onFilter&&this.onFilter(this._filterText),this.render()},300)}),t.appendChild(n)}const e=document.createElement("div");if(e.className="kupola-table-toolbar-right",this.selection&&this._selectedKeys.size>0){const n=document.createElement("span");n.className="kupola-table-selection-info",n.textContent=`已选 ${this._selectedKeys.size} 项`,e.appendChild(n);const r=document.createElement("button");r.className="ds-btn ds-btn--sm",r.textContent="反选",r.type="button",r.addEventListener("click",()=>this.invertSelection()),e.appendChild(r)}if(this.options.showExport){const n=document.createElement("button");n.className="ds-btn ds-btn--sm ds-btn--secondary",n.textContent="导出 CSV",n.type="button",n.addEventListener("click",()=>this.exportCSV()),e.appendChild(n)}const s=document.createElement("span");return s.className="kupola-table-info",s.textContent=`共 ${this._total} 条`,e.appendChild(s),t.appendChild(e),t}_renderPagination(){const t=Math.ceil(this._total/this._pageSize);if(t<=1)return document.createElement("div");const e=document.createElement("div");if(e.className="kupola-table-pagination",this.options.showPageSize){const l=document.createElement("select");l.className="kupola-table-page-size",this._pageSizes.forEach(o=>{const c=document.createElement("option");c.value=o,c.textContent=`${o} 条/页`,o===this._pageSize&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",()=>{this._pageSize=parseInt(l.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(l)}const s=document.createElement("div");s.className="kupola-table-pages";const n=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));n.disabled=this._currentPage<=1,s.appendChild(n),this._getPageRange(this._currentPage,t).forEach(l=>{if(l==="..."){const o=document.createElement("span");o.className="kupola-table-page-ellipsis",o.textContent="...",s.appendChild(o)}else{const o=this._createPageBtn(l,()=>this._goToPage(l));l===this._currentPage&&o.classList.add("active"),s.appendChild(o)}});const r=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));r.disabled=this._currentPage>=t,s.appendChild(r),e.appendChild(s);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${t}`,e.appendChild(a),e}_createPageBtn(t,e){const s=document.createElement("button");return s.className="kupola-table-page-btn",s.textContent=t,s.type="button",s.addEventListener("click",e),s}_goToPage(t){const e=Math.ceil(this._total/this._pageSize);t<1||t>e||(this._currentPage=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this._pageSize),this.render())}_getPageRange(t,e){if(e<=7)return Array.from({length:e},(n,r)=>r+1);const s=[];if(t<=3){for(let n=1;n<=5;n++)s.push(n);s.push("...",e)}else if(t>=e-2){s.push(1,"...");for(let n=e-4;n<=e;n++)s.push(n)}else{s.push(1,"...");for(let n=t-1;n<=t+1;n++)s.push(n);s.push("...",e)}return s}exportCSV(t="export.csv"){const e=this.getProcessedData(),s=this.columns.map(c=>c.title||c.key),n=e.map(c=>this.columns.map(d=>{let u=c[d.key];return u==null&&(u=""),u=String(u).replace(/"/g,'""'),`"${u}"`}).join(",")),r="\uFEFF"+[s.join(","),...n].join(`
|
|
183
|
-
`),a=new Blob([r],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),o=document.createElement("a");o.href=l,o.download=t,o.click(),URL.revokeObjectURL(l)}_getTableClass(){const t=["kupola-table"];return this.striped&&t.push("kupola-table-striped"),this.bordered&&t.push("kupola-table-bordered"),this.hoverable&&t.push("kupola-table-hover"),this.compact&&t.push("kupola-table-compact"),t.join(" ")}refresh(){this.render()}getPage(){return{current:this._currentPage,pageSize:this._pageSize,total:this._total}}setColumns(t){this.columns=t.map((e,s)=>({...e,_index:s})),this.render()}destroy(){if(this._scrollHandler){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null}this._filterDebounceTimer&&(clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=null),this._resizeCleanups.forEach(t=>t()),this._resizeCleanups=[],this._reactiveCleanups.forEach(t=>t.unsubscribe()),this._reactiveCleanups=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this._data=[],this._virtualData=null,this._dragState=null,this._editingCell=null,this._editBuffer={}}}function Nt(i,t){return new
|
|
182
|
+
`,this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this._scrollHandler=t=>this.handleScroll(t),this._thumbDragStartHandler=t=>this.handleThumbDragStart(t),this._thumbDragMoveHandler=t=>this.handleThumbDragMove(t),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=t=>{t.preventDefault(),this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=t.deltaX+t.deltaY:this.element.scrollTop+=t.deltaY+t.deltaX},this.element.addEventListener("scroll",this._scrollHandler),this.scrollbarThumb.addEventListener("mousedown",this._thumbDragStartHandler),document.addEventListener("mousemove",this._thumbDragMoveHandler),document.addEventListener("mouseup",this._thumbDragEndHandler),this.element.addEventListener("wheel",this._wheelHandler,{passive:!1}),this._listeners=[{el:this.element,event:"scroll",handler:this._scrollHandler},{el:this.scrollbarThumb,event:"mousedown",handler:this._thumbDragStartHandler},{el:document,event:"mousemove",handler:this._thumbDragMoveHandler},{el:document,event:"mouseup",handler:this._thumbDragEndHandler},{el:this.element,event:"wheel",handler:this._wheelHandler}]}handleScroll(t){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:s,isHorizontal:e,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex}),this.updateScrollState(),this.renderVisibleItems(),this.updateScrollbar()}updateScrollState(){this.isScrolling=!0,this.element.classList.add("ds-virtual-list--scrolling"),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{if(this.isScrolling=!1,this.element.classList.remove("ds-virtual-list--scrolling"),this.onScrollEnd){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:e,isHorizontal:t,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(t){const e=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const s=this.data[t][this.keyField]||t;if(this.dynamicHeightCache.has(s))return this.dynamicHeightCache.get(s)}return e?this.itemWidth:this.itemHeight}getItemPositions(){const t=[];let e=0;return this.data.forEach((s,n)=>{const r=this.getItemSize(n);t.push({start:e,end:e+r,size:r}),e+=r}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((s,n,r)=>s+this.getItemSize(r),0);const e=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*e}getIndexAtOffset(t){if(this.useDynamicHeight){const n=this.getItemPositions();for(let r=0;r<n.length;r++)if(t>=n[r].start&&t<n[r].end)return r;return this.data.length-1}const s=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(t/s)}renderVisibleItems(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop,s=t?this.element.clientWidth:this.element.clientHeight,n=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let r=Math.min(this.data.length-1,this.getIndexAtOffset(e+s)+this.bufferSize);r<n&&(r=n),this.startIndex=n,this.endIndex=r;const a=this.data.slice(n,r+1);let l="",o=0;if(this.useDynamicHeight)o=this.getItemPositions()[n]?.start||0;else{const c=t?this.itemWidth:this.itemHeight;o=n*c}a.forEach((c,d)=>{const u=n+d,p=c[this.keyField]||u,m=this.selectedKey===p,f=this.getItemSize(u);l+=this._buildItemHtml(c,u,p,m,f,o,t),o+=f}),this.container.innerHTML=l,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(c=>{c.addEventListener("click",()=>this.handleItemClick(c))})}_buildItemHtml(t,e,s,n,r,a,l){const o=n?" is-selected":"",c=this.renderItem(t,e);return l?`<div class="ds-virtual-list__item${o}" style="position: absolute; top: 0; left: ${a}px; width: ${r}px; height: 100%;" data-index="${e}" data-key="${s}">${c}</div>`:`<div class="ds-virtual-list__item${o}" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${r}px;" data-index="${e}" data-key="${s}">${c}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const s=parseInt(e.dataset.index),n=this.data[s][this.keyField]||s,r=e.offsetHeight;r!==this.getItemSize(s)&&(this.dynamicHeightCache.set(n,r),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),s=t.dataset.key,n=this.data[e];this.onItemClick&&this.onItemClick({item:n,index:e,key:s}),this.onItemSelect&&this.select(s)}select(t){if(this.selectedKey=t,this.onItemSelect){const e=this.data.findIndex(s=>s[this.keyField]===t);e!==-1&&this.onItemSelect({item:this.data[e],index:e,key:t})}this.renderVisibleItems()}updateScrollbar(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize(),s=t?this.element.clientWidth:this.element.clientHeight,n=t?this.element.scrollLeft:this.element.scrollTop;if(t){this.scrollbarThumb.style.display="none";return}const r=Math.max(20,s/e*s),a=s-r,l=n/(e-s||1)*a;this.scrollbarThumb.style.height=r+"px",this.scrollbarThumb.style.top=l+"px"}handleThumbDragStart(t){t.preventDefault(),this.isDragging=!0,this.dragStartY=t.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(t){if(!this.isDragging)return;const e=this.element.clientHeight,s=this.getTotalSize(),n=parseFloat(this.scrollbarThumb.style.height)||e,r=e-n,a=t.clientY-this.dragStartY;let l=this.dragStartTop+a;l=Math.max(0,Math.min(l,r)),this.scrollbarThumb.style.top=l+"px";const o=l/r*(s-e||0);this.element.scrollTop=o}handleThumbDragEnd(){this.isDragging=!1}update(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize();t?(this.container.style.width=e+"px",this.container.style.height="100%"):(this.container.style.height=e+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(t){this.data=t,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(t){this.data.push(t),this.update()}removeItem(t){this.data.splice(t,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(t,e){this.data.splice(t,0,e),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(t,e="smooth"){const s=this.element.classList.contains("ds-virtual-list--horizontal");let n=0;if(this.useDynamicHeight)n=this.getItemPositions()[t]?.start||0;else{const r=s?this.itemWidth:this.itemHeight;n=t*r}s?this.element.scrollTo({left:n,behavior:e}):this.element.scrollTo({top:n,behavior:e})}scrollToKey(t,e="smooth"){const s=this.data.findIndex(n=>n[this.keyField]===t);s!==-1&&this.scrollTo(s,e)}scrollToTop(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[e?"left":"top"]:0,behavior:t})}scrollToBottom(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=this.getTotalSize(),n=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:s-n,behavior:t})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((t,e)=>({item:t,index:this.startIndex+e,key:t[this.keyField]||this.startIndex+e}))}getItemIndex(t){return this.data.findIndex(e=>e[this.keyField]===t)}getItem(t){const e=this.getItemIndex(t);return e!==-1?this.data[e]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this._listeners=null,this._scrollHandler=null,this._thumbDragStartHandler=null,this._thumbDragMoveHandler=null,this._thumbDragEndHandler=null,this._wheelHandler=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function as(i=1e3){const t=[],e=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let s=1;s<=i;s++){const n=Math.floor(Math.random()*e.length),r=Math.floor(Math.random()*1e4);t.push({id:s,title:`${e[n]} ${r}`,subtitle:`Last modified ${Math.floor(Math.random()*30)} days ago`,type:e[n].toLowerCase()})}return t}function ls(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-virtual-list");let e=[];if(t)try{e=JSON.parse(t)}catch{e=as(1e3)}else e=as(1e3);const s=new rs(i,{data:e,onItemClick:n=>{},onItemSelect:n=>{}});i.__kupolaInstance=s,i.__kupolaInitialized=!0}function os(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}w.register("virtual-list",ls,os);const rl='xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter"',It={globe:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 0 20"/><path d="M12 2a15.3 15.3 0 0 0 0 20"/>',dashboard:'<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>',mouse:'<rect x="6" y="2" width="12" height="20" rx="6"/><line x1="12" y1="6" x2="12" y2="11"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',square:'<rect x="3" y="3" width="18" height="18"/>',circle:'<circle cx="12" cy="12" r="9"/>',list:'<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',palette:'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',type:'<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',ruler:'<rect x="3" y="9" width="18" height="6" transform="rotate(-45 12 12)"/><line x1="7.5" y1="12.5" x2="9" y2="14"/><line x1="11" y1="9" x2="12.5" y2="10.5"/><line x1="14.5" y1="5.5" x2="16" y2="7"/>',sparkles:'<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',refresh:'<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',external:'<polyline points="14 4 20 4 20 10"/><line x1="20" y1="4" x2="11" y2="13"/><path d="M20 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5"/>',settings:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',sliders:'<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',minus:'<line x1="5" y1="12" x2="19" y2="12"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',github:'<path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/>',"message-circle":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/>',"message-plus":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/><line x1="12" y1="9" x2="12" y2="15"/><line x1="9" y1="12" x2="15" y2="12"/>',gear:'<path d="M9.3 5.7 6.375 5.025 5.025 6.375 5.7 9.3 3 11.1 3 12.9 5.7 14.7 5.025 17.625 6.375 18.975 9.3 18.3 11.1 21 12.9 21 14.7 18.3 17.625 18.975 18.975 17.625 18.3 14.7 21 12.9 21 11.1 18.3 9.3 18.975 6.375 17.625 5.025 14.7 5.7 12.9 3 11.1 3 9.3 5.7Z"/><circle cx="12" cy="12" r="3"/>',"user-circle":'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="2.5"/><path d="M7 17.5a5 5 0 0 1 10 0"/>',shield:'<path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/>',check:'<polyline points="4 12 10 18 20 6"/>',"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"alert-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',"alert-triangle":'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',"info-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"x-circle":'<circle cx="12" cy="12" r="9"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/>',alert:'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',info:'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>',user:'<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',users:'<path d="M2 21v-1a5 5 0 0 1 5-5h3a5 5 0 0 1 5 5v1"/><circle cx="8.5" cy="8" r="3.5"/><path d="M22 21v-1a5 5 0 0 0-4-4.9"/><path d="M16 3.1A4 4 0 0 1 16 11"/>',box:'<polyline points="3 7 12 2 21 7 21 17 12 22 3 17 3 7"/><line x1="3" y1="7" x2="12" y2="12"/><line x1="21" y1="7" x2="12" y2="12"/><line x1="12" y1="22" x2="12" y2="12"/>',zap:'<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',moon:'<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',sun:'<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',cmd:'<path d="M9 6h6v12H9z"/><rect x="3" y="3" width="6" height="6"/><rect x="15" y="3" width="6" height="6"/><rect x="3" y="15" width="6" height="6"/><rect x="15" y="15" width="6" height="6"/>',key:'<circle cx="7.5" cy="14.5" r="3.5"/><line x1="10" y1="12" x2="22" y2="12"/><line x1="22" y1="12" x2="22" y2="16"/><line x1="18" y1="12" x2="18" y2="15"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',mic:'<rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/>',at:'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',hash:'<line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/>',"sidebar-left":'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/>',"sidebar-right":'<rect x="3" y="3" width="18" height="18"/><line x1="15" y1="3" x2="15" y2="21"/>',"panel-bottom":'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="15" x2="21" y2="15"/>',git:'<circle cx="6" cy="5" r="3"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><line x1="6" y1="8" x2="6" y2="16"/><path d="M18 8v3a4 4 0 0 1-4 4h-4"/>',bug:'<rect x="8" y="6" width="8" height="14" rx="4"/><line x1="12" y1="11" x2="12" y2="20"/><line x1="3" y1="9" x2="8" y2="9"/><line x1="3" y1="14" x2="8" y2="14"/><line x1="3" y1="19" x2="8" y2="19"/><line x1="16" y1="9" x2="21" y2="9"/><line x1="16" y1="14" x2="21" y2="14"/><line x1="16" y1="19" x2="21" y2="19"/><line x1="9" y1="6" x2="9" y2="3"/><line x1="15" y1="6" x2="15" y2="3"/>',"search-menu":'<circle cx="11" cy="11" r="6"/><line x1="20" y1="20" x2="16" y2="16"/><line x1="3" y1="20" x2="13" y2="20"/>',extensions:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M17.5 14v3.5H21a2 2 0 0 1 0 4h-3.5V21a2 2 0 0 1-4 0v-3.5H14a2 2 0 0 1 0-4h3.5z"/>',wrench:'<path d="M14.7 6.3a4 4 0 0 0 5 5L21 12.5l-7.5 7.5a3 3 0 0 1-4.2-4.2L16.7 8 14.7 6.3z"/><path d="M14.7 6.3 12 9l-3-3 2.7-2.7a4 4 0 0 1 3 3z"/>',"message-square":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',"file-text":'<path d="M14 3H6v18h12V8z"/><polyline points="14 3 14 8 18 8"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="15" y2="17"/>',"scroll-text":'<path d="M5 4h11a3 3 0 0 1 3 3v10H8v3a1 1 0 0 1-1 1 3 3 0 0 1-3-3V7a3 3 0 0 1 1-3z"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/>',atom:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',"arrow-right-to-line":'<line x1="20" y1="4" x2="20" y2="20"/><line x1="3" y1="12" x2="17" y2="12"/><polyline points="11 6 17 12 11 18"/>',"info-square":'<rect x="3" y="3" width="18" height="18"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"arrow-minimize":'<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',"arrow-expand":'<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',logo:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',"more-h":'<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',edit:'<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',trash:'<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',file:'<path d="M14 3H6v18h12V7z"/><polyline points="14 3 14 7 18 7"/>',files:'<path d="M21 8v13H8V3h8z"/><polyline points="16 3 16 8 21 8"/><path d="M8 7H3v14h13v-3"/>',"grid-2x2":'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',layout:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',image:'<rect x="3" y="3" width="18" height="18"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><polyline points="3 18 9 12 13 16 17 12 21 16"/>',play:'<polygon points="6 4 20 12 6 20 6 4"/>',pause:'<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',help:'<rect x="3" y="3" width="18" height="18"/><path d="M9 9a3 3 0 0 1 6 0c0 2-3 2-3 4"/><line x1="12" y1="17" x2="12" y2="17.01"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',eye:'<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/>',star:'<polygon points="12 3 15 9 22 10 17 14 18 21 12 18 6 21 7 14 2 10 9 9 12 3"/>',heart:'<path d="M12 21s-7-5-7-11a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 6-7 11-7 11z"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',calendar:'<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',clock:'<circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 16 14"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',send:'<polygon points="3 12 21 4 17 21 12 13 3 12"/>',link:'<path d="M10 14a4 4 0 0 1 0-6l3-3a4 4 0 0 1 6 6l-1.5 1.5"/><path d="M14 10a4 4 0 0 1 0 6l-3 3a4 4 0 0 1-6-6l1.5-1.5"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',"log-out":'<path d="M14 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9"/><polyline points="16 16 21 12 16 8"/><line x1="9" y1="12" x2="21" y2="12"/>',menu:'<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',dollar:'<line x1="12" y1="2" x2="12" y2="22"/><path d="M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',bar:'<line x1="3" y1="21" x2="21" y2="21"/><rect x="5" y="11" width="3" height="8"/><rect x="10.5" y="6" width="3" height="13"/><rect x="16" y="14" width="3" height="5"/>',"trending-up":'<polyline points="3 17 9 11 13 15 21 7"/><polyline points="15 7 21 7 21 13"/>',"trending-down":'<polyline points="3 7 9 13 13 9 21 17"/><polyline points="15 17 21 17 21 11"/>',columns:'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M7 8h10v4a5 5 0 0 1-10 0V8z"/><path d="M12 17v5"/>',cpu:'<rect x="6" y="6" width="12" height="12"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="2" x2="9" y2="6"/><line x1="15" y1="2" x2="15" y2="6"/><line x1="9" y1="18" x2="9" y2="22"/><line x1="15" y1="18" x2="15" y2="22"/><line x1="2" y1="9" x2="6" y2="9"/><line x1="2" y1="15" x2="6" y2="15"/><line x1="18" y1="9" x2="22" y2="9"/><line x1="18" y1="15" x2="22" y2="15"/>',code:'<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',apple:'<path fill="currentColor" stroke="none" d="M17.05 12.04c-.03-3.04 2.49-4.5 2.6-4.57-1.42-2.07-3.62-2.36-4.4-2.39-1.87-.19-3.65 1.1-4.6 1.1-.96 0-2.42-1.08-3.98-1.05-2.05.03-3.94 1.19-4.99 3.02-2.13 3.69-.54 9.13 1.53 12.12 1.01 1.46 2.21 3.1 3.78 3.04 1.52-.06 2.09-.98 3.93-.98 1.83 0 2.36.98 3.97.95 1.64-.03 2.68-1.49 3.68-2.96 1.16-1.7 1.64-3.35 1.66-3.43-.04-.02-3.18-1.22-3.21-4.85zM14.06 4.34c.83-1.01 1.39-2.41 1.24-3.81-1.2.05-2.65.8-3.51 1.8-.77.89-1.45 2.31-1.27 3.68 1.34.1 2.71-.68 3.54-1.67z"/>'};function At(i,t=16,e="0 0 24 24"){const s=It[i];return s?`<svg ${rl.replace('width="16"',`width="${t}"`).replace('height="16"',`height="${t}"`).replace('viewBox="0 0 24 24"',`viewBox="${e}"`)}>${s}</svg>`:""}function it(i=document){i.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),s=+t.getAttribute("data-size")||16,n=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=At(e,s,n),t.classList.add("icon")})}const al={svg:At,render:it,PATHS:It};typeof document<"u"&&(document.readyState!=="loading"?it():document.addEventListener("DOMContentLoaded",()=>it()));class cs{constructor(t){this.element=t,this.hoursEl=t.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=t.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=t.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const t=this.element.getAttribute("data-end-time");if(t)return new Date(t).getTime();const e=parseInt(this.element.getAttribute("data-hours"))||0,s=parseInt(this.element.getAttribute("data-minutes"))||0,n=parseInt(this.element.getAttribute("data-seconds"))||0;return new Date().getTime()+(e*3600+s*60+n)*1e3}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const t=new Date().getTime(),e=this.endTime-t;if(e<=0){this.stop(),this.displayTime(0,0,0),this.dispatchComplete();return}const s=Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),n=Math.floor(e%(1e3*60*60)/(1e3*60)),r=Math.floor(e%(1e3*60)/1e3);this.displayTime(s,n,r)}displayTime(t,e,s){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(e).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(s).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=t*1e3,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("kupola:countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function zt(i){if(i.__kupolaInitialized)return;const t=new cs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function hs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function ll(){document.querySelectorAll(".ds-countdown").forEach(t=>{zt(t)})}w.register("countdown",zt,hs);class ds{constructor(t){if(this.element=t,this.minusBtn=t.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=t.querySelector(".ds-number-input__btn--increase"),this.inputEl=t.querySelector(".ds-number-input__input"),this._listeners=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const t=()=>this.updateValue(-this.step),e=()=>this.updateValue(this.step),s=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",s),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:s})}updateValue(t){let e=parseInt(this.inputEl.value)||0;e+=t,e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let t=parseInt(this.inputEl.value);isNaN(t)&&(t=0),t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}updateState(){const t=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=t<=this.min,this.plusBtn.disabled=t>=this.max}setValue(t){t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(t,e){this.min=t,this.max=e,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Pt(i){if(!i.__kupolaInitialized)try{const t=new ds(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function us(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function ol(){document.querySelectorAll(".ds-number-input").forEach(i=>{Pt(i)})}w.register("number-input",Pt,us);class ps{constructor(t){this.container=t,this.track=t.querySelector(".ds-slider-captcha__track"),this.btn=t.querySelector(".ds-slider-captcha__btn"),this.text=t.querySelector(".ds-slider-captcha__text"),this.progress=t.querySelector(".ds-slider-captcha__progress"),this.statusEl=t.querySelector(".ds-slider-captcha__status"),this.refreshBtn=t.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=t.querySelector(".ds-slider-captcha__footer-refresh"),this.config={tolerance:6,minPoints:20,minDuration:300,maxDuration:1e4,minSpeedDelta:.3,maxAttempts:5},this.isDragging=!1,this.startX=0,this.startY=0,this.currentX=0,this.trackData=[],this.startTime=0,this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.targetX=0,this.distractorX=0,this.angle=0,this.distractorAngle=0,this.maxAngle=parseInt(t.getAttribute("data-angle"))||30,this.shape=t.getAttribute("data-shape")||"circle",this.hasDistractor=this.shape!=="circle",this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this._mouseDownHandler=null,this._mouseMoveHandler=null,this._mouseUpHandler=null,this._touchStartHandler=null,this._touchMoveHandler=null,this._touchEndHandler=null,this._mouseMoveListener=null,this._mouseUpListener=null,this._touchMoveListener=null,this._touchEndListener=null}init(){!this.track||!this.btn||this.container._initialized||(this._mouseDownHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.clientX,this.startY=t.clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._mouseMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,s=this.btn.offsetWidth,n=e-s-8;let r=t.clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.clientX,t.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._touchMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,s=this.btn.offsetWidth,n=e-s-8;let r=t.touches[0].clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.touches[0].clientX,t.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),this._mouseMoveListener=M.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=M.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=M.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=M.on(document,"touchend",this._touchEndHandler,{scope:this.scope}),this.btn.addEventListener("touchstart",this._touchStartHandler,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container._initialized=!0,this.loadCaptcha())}generateTarget(){const t=this.track.offsetWidth,e=this.btn.offsetWidth,s=14,n=t*.35,r=t*.85-e,a=t*.6;if(this.angle=Math.floor(Math.random()*(this.maxAngle+1)),this.hasDistractor)do this.distractorAngle=Math.floor(Math.random()*(this.maxAngle+1));while(Math.abs(this.distractorAngle-this.angle)<5);this.hasDistractor?Math.random()>.5?(this.targetX=Math.floor(n+Math.random()*(a-n-e)),this.distractorX=Math.floor(a+Math.random()*(r-a))):(this.targetX=Math.floor(a+Math.random()*(r-a)),this.distractorX=Math.floor(n+Math.random()*(a-n-e))):this.targetX=Math.floor(n+Math.random()*(r-n));const l=this.container.querySelector(".ds-slider-captcha__target");if(l&&(l.style.left=this.targetX+s+e/2+"px",l.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",l.style.display="block"),this.hasDistractor){const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.style.left=this.distractorX+s+e/2+"px",o.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",o.style.display="block")}else{const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.style.display="none")}}resetSlider(){this.btn.className="ds-slider-captcha__btn",this.btn.style.transform="rotate("+this.angle+"deg)",this.btn.innerHTML="",this.btn.style.left="14px",this.btn.style.display="block",this.progress&&(this.progress.style.width="0%",this.progress.style.display="block"),this.text&&(this.text.textContent="按住滑块,拖动到缺口位置",this.text.style.color=""),this.refreshBtn&&(this.refreshBtn.style.display="none"),this.currentX=0,this.trackData=[],this.container.classList.remove("is-verified","is-error","is-disabled")}loadCaptcha(){this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.generateTarget(),this.resetSlider(),this.statusEl&&(this.statusEl.textContent="请完成验证",this.statusEl.className="ds-slider-captcha__status")}collectTrack(t,e){const n=Date.now()-this.startTime;let r=0,a=0;if(this.trackData.length>0){const o=this.trackData[this.trackData.length-1],c=this.currentX-o.x,d=n-o.t;if(d>0&&(r=c/d,this.trackData.length>1)){const u=this.trackData[this.trackData.length-2],p=o.t-u.t;if(p>0){const m=(o.x-u.x)/p;a=r-m}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:n,v:r,a});const l=this.container.querySelector(".ds-slider-captcha__point-count");l&&(l.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const t=this.trackData[this.trackData.length-1].x,e=this.hasDistractor?Math.abs(t-this.distractorX):1/0,s=Math.abs(t-this.targetX);if(this.hasDistractor&&e<s&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(s>this.config.tolerance)return{passed:!1,msg:"验证失败"};const n=[];for(let d=1;d<this.trackData.length;d++){const u=this.trackData[d].x-this.trackData[d-1].x,p=this.trackData[d].t-this.trackData[d-1].t;p>0&&p<500&&n.push(u/p)}if(n.length<3)return{passed:!1,msg:"验证失败"};const r=Math.max(...n),a=Math.min(...n);if(r-a<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let l=!1;for(const d of this.trackData)if(Math.abs(d.y)>2){l=!0;break}if(!l&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const o=this.trackData[this.trackData.length-1].t;if(o<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(o>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const c=[];for(let d=1;d<n.length;d++)c.push(Math.abs(n[d]-n[d-1]));return c.length>2&&c.reduce((u,p)=>u+p,0)/c.length<.05?{passed:!1,msg:"验证失败"}:{passed:!0,msg:"验证通过"}}verifyCaptcha(){this.isProcessing||this.isVerified||(this.isProcessing=!0,this.statusEl&&(this.statusEl.textContent="验证中...",this.statusEl.className="ds-slider-captcha__status is-loading"),this.btn.style.cursor="wait",this.container.classList.add("is-disabled"),setTimeout(()=>{const t=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",t.passed){this.isVerified=!0,this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const e=this.container.querySelector(".ds-slider-captcha__target");e&&(e.style.display="none");const s=this.container.querySelector(".ds-slider-captcha__target--distractor");s&&(s.style.display="none"),this.text&&(this.text.textContent="验证通过",this.text.style.color="var(--status-success-default)"),this.statusEl&&(this.statusEl.textContent="验证成功",this.statusEl.className="ds-slider-captcha__status is-success"),this.container.classList.add("is-verified"),this.container.classList.remove("is-disabled");const n=this.container.getAttribute("data-on-verified");n&&typeof window[n]=="function"&&window[n](this.container)}else if(this.attempts++,this.text&&(this.text.textContent=t.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=t.msg,this.statusEl.className="ds-slider-captcha__status is-error"),this.container.getAttribute("data-err-refresh")==="auto")setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const s=this.container.querySelector(".ds-slider-captcha__target");s&&(s.style.display="none");const n=this.container.querySelector(".ds-slider-captcha__target--distractor");n&&(n.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}},300))}destroy(){this.container._initialized&&(this.btn&&this._mouseDownHandler&&this.btn.removeEventListener("mousedown",this._mouseDownHandler),this.btn&&this._touchStartHandler&&this.btn.removeEventListener("touchstart",this._touchStartHandler),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this._mouseMoveListener&&this._mouseMoveListener.unsubscribe?this._mouseMoveListener.unsubscribe():this._mouseMoveHandler&&document.removeEventListener("mousemove",this._mouseMoveHandler),this._mouseUpListener&&this._mouseUpListener.unsubscribe?this._mouseUpListener.unsubscribe():this._mouseUpHandler&&document.removeEventListener("mouseup",this._mouseUpHandler),this._touchMoveListener&&this._touchMoveListener.unsubscribe?this._touchMoveListener.unsubscribe():this._touchMoveHandler&&document.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndListener&&this._touchEndListener.unsubscribe?this._touchEndListener.unsubscribe():this._touchEndHandler&&document.removeEventListener("touchend",this._touchEndHandler),this.container._initialized=!1)}}function fs(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{const t=new ps(i);t.init(),i._kupolaSlideCaptcha=t})}function ms(i){i._kupolaSlideCaptcha&&(i._kupolaSlideCaptcha.destroy(),i._kupolaSlideCaptcha=null)}function gs(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{ms(i)})}w.register("slide-captcha",fs,gs);class _s{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this._submitHandler=null,this._fieldHandlers=new Map,this._init()}_init(){this._setupValidators(),this._collectFields(),this._bindEvents()}_setupValidators(){this.validators={required:t=>typeof t=="string"?t.trim()!=="":Array.isArray(t)?t.length>0:t!=null,email:t=>t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t):!0,phone:t=>t?/^1[3-9]\d{9}$/.test(t):!0,url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>t?!isNaN(parseFloat(t))&&isFinite(t):!0,minlength:(t,e)=>t?t.length>=parseInt(e):!0,maxlength:(t,e)=>t?t.length<=parseInt(e):!0,min:(t,e)=>t?parseFloat(t)>=parseFloat(e):!0,max:(t,e)=>t?parseFloat(t)<=parseFloat(e):!0,pattern:(t,e)=>t?new RegExp(e).test(t):!0,equalTo:(t,e)=>{const s=document.getElementById(e);return s?t===s.value:!0}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}_collectFields(){this.form.querySelectorAll("input, select, textarea").forEach(e=>{e.hasAttribute("data-kupola-ignore")||this.fields.push(e)})}_bindEvents(){this._submitHandler=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this._submitHandler),this.fields.forEach(t=>{const e=()=>this.validateField(t),s=()=>this.clearError(t);this._fieldHandlers.set(t,{blur:e,input:s}),t.addEventListener("blur",e),t.addEventListener("input",s)})}validate(){let t=!0;return this.fields.forEach(e=>{this.validateField(e)||(t=!1)}),t}validateField(t){const e=this._getFieldErrors(t);return e.length>0?(this.showError(t,e[0]),!1):(this.clearError(t),!0)}_getFieldErrors(t){const e=[],s=this._getFieldValue(t);for(const[n,r]of Object.entries(this.validators)){const a=t.getAttribute(`data-${n}`);if(a!==null&&!r(s,a)){let o=this.errorMessages[n];typeof o=="function"&&(o=o(a)),e.push(o)}}return e}_getFieldValue(t){const e=t.type;if(e==="checkbox")return t.checked;if(e==="radio"){const s=t.name,n=this.form.querySelector(`input[name="${s}"]:checked`);return n?n.value:null}return e==="select-multiple"?Array.from(t.selectedOptions).map(s=>s.value):t.value}showError(t,e){this.clearError(t);const s=document.createElement("span");s.className="ds-form-error",s.textContent=e,t.classList.add("ds-form-field--error");const n=t.parentElement;n.classList.contains("ds-form-field")?n.appendChild(s):t.parentNode.insertBefore(s,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const e=t.parentElement.querySelector(".ds-form-error");e&&e.remove()}addValidator(t,e,s){this.validators[t]=e,this.errorMessages[t]=s}getData(){const t={};return this.fields.forEach(e=>{const s=e.name;if(!s)return;const n=this._getFieldValue(e);e.type==="checkbox"?(t[s]||(t[s]=[]),e.checked&&t[s].push(e.value)):e.type==="radio"?!t[s]&&e.checked&&(t[s]=e.value):t[s]=n}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(n=>{const r=n.type;if(r==="checkbox"){const a=Array.isArray(t[e])?t[e]:[t[e]];n.checked=a.includes(n.value)}else if(r==="radio")n.checked=n.value===t[e];else if(r==="select-multiple"){const a=Array.isArray(t[e])?t[e]:[t[e]];Array.from(n.options).forEach(l=>{l.selected=a.includes(l.value)})}else n.value=t[e]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this._submitHandler&&this.form&&this.form.removeEventListener("submit",this._submitHandler),this._fieldHandlers.forEach((t,e)=>{e.removeEventListener("blur",t.blur),e.removeEventListener("input",t.input)}),this._submitHandler=null,this._fieldHandlers.clear(),this._fieldHandlers=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function ys(i){const t=document.querySelectorAll(i||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const s=new _s(e);e._kupolaForm=s}),t.length}function cl(i){return i._kupolaForm}function hl(i){const t=i._kupolaForm;return t?t.validate():!1}w.register("form-validation",ys);class vs{constructor(){this._queue=new Set,this._scheduled=!1,this._flushDepth=0,this._maxDepth=10}schedule(t){this._queue.add(t),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){if(this._flushDepth>=this._maxDepth){console.warn("[Kupola Scheduler] Max flush depth reached, possible infinite loop detected"),this._queue.clear(),this._scheduled=!1;return}const t=Array.from(this._queue);this._queue.clear(),this._scheduled=!1,this._flushDepth++;const e=new Set;for(const s of t)if(!e.has(s)){e.add(s);try{s()}catch(n){console.error("[DependsScheduler]",n)}}this._flushDepth--}}const dl=new vs;class bs{constructor(t,e){this.data=t,this.createdAt=Date.now(),this.ttl=e}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class $t{constructor(){this._store=new Map}get(t){const e=this._store.get(t);return e||null}set(t,e,s=6e4){this._store.set(t,new bs(e,s))}has(t){return this._store.has(t)}delete(t){this._store.delete(t)}clear(){this._store.clear()}getStale(t){const e=this._store.get(t);return e?e.data:null}}class N extends Error{constructor(t,e,s){super(t),this.name="DependsError",this.code=e,this.cause=s,this.timestamp=Date.now()}}let nt=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null;function ul(i){if(!i||typeof i.fetch!="function")throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");nt=i.fetch.bind(i)}function pl(){return nt}function fl(){nt=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null}class V{constructor(t,e){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=e,this.subscribers=[],this.pending=null,this.retryCount=t.retry??0,this.retryDelay=t.retryDelay??1e3,this.onError=t.onError||null}subscribe(t){return this.subscribers.push(t),()=>{const e=this.subscribers.indexOf(t);e>-1&&this.subscribers.splice(e,1)}}notify(){dl.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(t){throw new N("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const e=this.cache.get(this.cacheKey);return e&&e.isFresh?e.data:e&&e.isStale?(this._revalidate(t),e.data):this._fetchWithRetry(t)}async _fetchWithRetry(t,e=0){try{const s=await this.fetch(t);return this.cache.set(this.cacheKey,s,this.staleTime),this.notify(),s}catch(s){if(e<this.retryCount){const r=this.retryDelay*Math.pow(2,e),a=Math.random()*r*.5,l=r+a;return await new Promise(o=>setTimeout(o,l)),this._fetchWithRetry(t,e+1)}const n=s instanceof N?s:new N(s.message||"Fetch failed","FETCH_ERROR",s);if(this.onError)try{this.onError(n)}catch{}throw n}}async _revalidate(t){try{await this._fetchWithRetry(t)}catch{}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class Es extends V{constructor(t,e){super(t,e),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let e=this.config.source;for(const d in t)e=e.replace(`:${d}`,encodeURIComponent(t[d]));const s=[];for(const[d,u]of Object.entries(this.queryParams||{}))s.push(`${encodeURIComponent(d)}=${encodeURIComponent(u)}`);for(const d in t)this.config.source.includes(`:${d}`)||s.push(`${encodeURIComponent(d)}=${encodeURIComponent(t[d])}`);s.length>0&&(e+=(e.includes("?")?"&":"?")+s.join("&"));const n={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...this.headers}};["POST","PUT","PATCH"].includes(n.method)&&(n.body=JSON.stringify(t));const r=nt;if(!r)throw new N("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const a=await r(e,n),l=typeof a.ok=="boolean"?a.ok:a.status>=200&&a.status<300,o=typeof a.status=="number"?a.status:0;if(!l)throw new N(`HTTP ${o}`,"HTTP_ERROR");return typeof a.json=="function"?await a.json():a.data!==void 0?a.data:a}}class qt extends V{constructor(t,e){super(t,e),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=t.sync!==!1,this.sync&&typeof window<"u"&&(this._storageHandler=s=>{s.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(t===null)return this.defaultValue;try{return JSON.parse(t)}catch{return t}}catch{return this.defaultValue}}setValue(t){const e=typeof t=="string"?t:JSON.stringify(t);localStorage.setItem(this.storageKey,e),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class ks extends V{constructor(t,e){super(t,e),this.paramName=t.source.replace("route:","")}async fetch(){if(typeof window>"u")return"";const e=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));return e?decodeURIComponent(e[1]):new URLSearchParams(location.search).get(this.paramName)||""}}class ws extends V{async fetch(t){return await this.config.source(t)}}class xs extends V{async fetch(){return this.config.source}}class Bt extends V{constructor(t,e){super(t,e),this.ws=null,this.reconnect=t.reconnect!==!1,this.reconnectDelay=t.reconnectDelay||3e3,this._reconnectAttempt=0,this._maxReconnectDelay=t.maxReconnectDelay||3e4,this.messageHandler=null,this._connected=!1,this._destroyed=!1}async fetch(){return new Promise((t,e)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,this._reconnectAttempt=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=s=>{let n;try{n=JSON.parse(s.data)}catch{n=s.data}this.cache.set(this.cacheKey,n,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=s=>{this._connected||e(new N("WebSocket connection failed","WS_ERROR",s))},this.ws.onclose=()=>{if(this._connected=!1,this.reconnect&&!this._destroyed){const s=this.reconnectDelay*Math.pow(2,this._reconnectAttempt),n=Math.random()*s*.3,r=Math.min(s+n,this._maxReconnectDelay);this._reconnectAttempt++,setTimeout(()=>{this._destroyed||this.fetch().catch(()=>{})},r)}}}catch(s){e(new N("WebSocket creation failed","WS_ERROR",s))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(typeof t=="string"?t:JSON.stringify(t))}destroy(){this._destroyed=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Ft(i,t){const e=i.source;return typeof e=="function"?new ws(i,t):typeof e=="string"&&(e.startsWith("ws://")||e.startsWith("wss://"))?new Bt(i,t):typeof e=="string"&&(e.startsWith("/")||e.startsWith("http"))?new Es(i,t):typeof e=="string"&&e.startsWith("localStorage:")?new qt(i,t):typeof e=="string"&&e.startsWith("route:")?new ks(i,t):new xs(i,t)}function ml(i,t){const e={},s=new $t,n=[];for(const r in t){let f=function(){return Cs(i)},a=t[r];typeof a=="string"&&(a={source:a});const l={...a,cacheKey:a.cacheKey||`${r}-${JSON.stringify(Cs(i))}`},o=Ft(l,s),c=T(null),d=T(!0),u=T(null),p=T(null);let m=0;async function g(){const k=++m;d.value=!0,u.value=null;try{const E=await o.getValue(f());if(k!==m)return;c.value=E,p.value=Date.now()}catch(E){if(k!==m)return;u.value=E.message||"Unknown error"}finally{k===m&&(d.value=!1)}}g();const v=o.subscribe(()=>{const k=s.getStale(o.cacheKey);k!=null&&(c.value=k,p.value=Date.now())});n.push(v);const y=Object.keys(i);y.length>0&&y.forEach(k=>{const E=i[k];if(E&&typeof E=="object"&&"value"in E&&E._subscribers){const b=()=>{o.invalidate(),g()};E._subscribers.add(b),n.push(()=>E._subscribers.delete(b))}}),e[r]={data:c,loading:d,error:u,lastUpdated:p,refresh(){return o.invalidate(),g()},setValue(k){o instanceof qt&&(o.setValue(k),c.value=k)},send(k){o instanceof Bt&&o.send(k)},_source:o}}return e._dispose=()=>{if(n.forEach(r=>r()),window.__kupolaDepInstances){const r=window.__kupolaDepInstances.indexOf(e);r!==-1&&window.__kupolaDepInstances.splice(r,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(e),e}function gl(i){const t=new $t,e=Ft(i,t),s=T(null),n=T(!0),r=T(null);let a=0;async function l(){const o=++a;n.value=!0,r.value=null;try{const c=await e.getValue(i.params||{});if(o!==a)return;s.value=c}catch(c){if(o!==a)return;r.value=c.message||"Unknown error"}finally{o===a&&(n.value=!1)}}return l(),e.subscribe(()=>{const o=t.getStale(e.cacheKey);o!=null&&(s.value=o)}),{data:s,loading:n,error:r,refresh(){return e.invalidate(),l()}}}function Cs(i){const t={};for(const e in i){const s=i[e];s&&typeof s=="object"&&"value"in s?t[e]=s.value:t[e]=s}return t}function _l(){}class Ss{constructor(t,e={}){this.element=typeof t=="string"?document.querySelector(t):t,this.options=e,this.columns=(e.columns||[]).map((s,n)=>({...s,_index:n})),this.rowKey=e.rowKey||"id",this._data=[],this._loading=!1,this.striped=e.striped!==!1,this.bordered=e.bordered||!1,this.hoverable=e.hoverable!==!1,this.compact=e.compact||!1,this.emptyText=e.emptyText||"暂无数据",this.loadingText=e.loadingText||"加载中...",this.multiSort=e.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=e.pagination!==!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._pageSize=e.pageSize||10,this._currentPage=1,this._total=0,this.selection=e.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=e.selectionColumnTitle||"",this.expandable=e.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=e.expandColumnTitle||"",this.editable=e.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=e.resizable||!1,this.draggable=e.draggable||!1,this._dragState=null,this.tree=e.tree||null,this._treeExpandedKeys=new Set,e.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=e.virtualScroll||null,this._scrollContainer=null,this._scrollHandler=null,this._resizeCleanups=[],this._filterDebounceTimer=null,this._reactiveCleanups=[],this.mergeCells=e.mergeCells||null,this.onSort=e.onSort||null,this.onPageChange=e.onPageChange||null,this.onRowClick=e.onRowClick||null,this.onFilter=e.onFilter||null,this.onSelect=e.onSelect||null,this.onExpand=e.onExpand||null,this.onEditSave=e.onEditSave||null,this.onEditCancel=e.onEditCancel||null,this.onRowDragEnd=e.onRowDragEnd||null,this.onColumnResize=e.onColumnResize||null,this.sortKey=T(null),this.sortOrder=T(null),this.currentPage=T(1),this.filterText=T(""),this.selectedKeys=T([]),this._init()}_init(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&typeof t=="object"&&"value"in t?(this._data=Array.isArray(t.value)?t.value:[],t.subscribe&&this._reactiveCleanups.push(t.subscribe(e=>{this._data=Array.isArray(e)?e:[],this._total=this._data.length,this.render()}))):Array.isArray(t)?this._data=t:this._data=[],this.tree&&this._treeExpandAll&&this._flattenForExpand(this._data),this._total=this._getFlatData(this._data).length,this.render()}setLoading(t){t&&typeof t=="object"&&"value"in t?(this._loading=t.value,t.subscribe&&this._reactiveCleanups.push(t.subscribe(e=>{this._loading=e,this.render()}))):this._loading=!!t,this.render()}_flattenForExpand(t,e=0,s=null){const n=this.tree?.childrenKey||"children",r=[];for(const a of t){const l=a[this.rowKey];r.push({...a,_level:e,_parentKey:s,_hasChildren:!!(a[n]&&a[n].length)}),a[n]&&a[n].length&&r.push(...this._flattenForExpand(a[n],e+1,l))}return r}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const s=this.tree?.childrenKey||"children",n=[];for(const r of t){const a=r[this.rowKey];n.push({...r,_level:e,_hasChildren:!!(r[s]&&r[s].length)}),r[s]&&r[s].length&&this._treeExpandedKeys.has(a)&&n.push(...this._flattenVisible(r[s],e+1))}return n}getProcessedData(){let t=this.tree?[...this._data]:[...this._data];if(this._filterText){const n=this._filterText.toLowerCase();this.tree?t=this._filterTree(t,n):t=t.filter(r=>this.columns.some(a=>{const l=r[a.key];return l!=null&&String(l).toLowerCase().includes(n)}))}this._sorts.length>0&&(this.tree?t=this._sortTree(t):t=this._sortFlat(t));const e=this.tree?this._flattenVisible(t):t;this._total=e.length;let s=e;if(this._showPagination&&this._pageSize>0){const n=(this._currentPage-1)*this._pageSize;s=e.slice(n,n+this._pageSize)}return s}_filterTree(t,e){const s=this.tree?.childrenKey||"children";return t.reduce((n,r)=>{const a=r[s]?this._filterTree(r[s],e):[];return(this.columns.some(o=>{const c=r[o.key];return c!=null&&String(c).toLowerCase().includes(e)})||a.length>0)&&(n.push({...r,[s]:a}),a.length>0&&this._treeExpandedKeys.add(r[this.rowKey])),n},[])}_sortFlat(t){return[...t].sort((e,s)=>{for(const n of this._sorts){const r=this.columns.find(c=>c.key===n.key);let a=e[n.key],l=s[n.key],o=0;if(r?.sorter?o=r.sorter(a,l,n.order):a==null?o=1:l==null?o=-1:typeof a=="number"&&typeof l=="number"?o=n.order==="asc"?a-l:l-a:o=n.order==="asc"?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),o!==0)return o}return 0})}_sortTree(t){const e=this._sortFlat(t),s=this.tree?.childrenKey||"children";return e.map(n=>n[s]?.length?{...n,[s]:this._sortTree(n[s])}:n)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const s=document.createElement("div");s.className="kupola-table-container";const n=document.createElement("table");n.className=this._getTableClass(),n.appendChild(this._renderThead()),this.virtualScroll?n.appendChild(this._renderVirtualTbody(t)):n.appendChild(this._renderTbody(t)),s.appendChild(n),e.appendChild(s),this._showPagination&&this._total>0&&e.appendChild(this._renderPagination()),this.resizable&&this._initColumnResize(),this.draggable&&this._initRowDrag(),this._applyStickyColumns()}_renderThead(){const t=document.createElement("thead"),e=document.createElement("tr");if(this.selection&&this._renderSelectionHeader(e),this.expandable){const s=document.createElement("th");s.className="kupola-table-col-expand",e.appendChild(s)}return this.columns.forEach(s=>{const n=this._renderColumnHeader(s);e.appendChild(n)}),t.appendChild(e),t}_renderSelectionHeader(t){const e=document.createElement("th");if(e.className="kupola-table-col-selection",this.selection==="checkbox"){const s=document.createElement("input");s.type="checkbox";const r=this.getProcessedData().map(a=>a[this.rowKey]);s.checked=r.length>0&&r.every(a=>this._selectedKeys.has(a)),s.addEventListener("change",()=>s.checked?this.selectAll():this.deselectAll()),e.appendChild(s)}t.appendChild(e)}_renderColumnHeader(t){const e=document.createElement("th");if(e.textContent=t.title||t.key,t.width&&(e.style.width=typeof t.width=="number"?t.width+"px":t.width),t.minWidth&&(e.style.minWidth=typeof t.minWidth=="number"?t.minWidth+"px":t.minWidth),t.align&&(e.style.textAlign=t.align),t.fixed&&e.setAttribute("data-fixed",t.fixed),t.sortable&&this._renderSortIndicator(e,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const s=document.createElement("span");s.className="kupola-table-resize-handle",s.setAttribute("data-col-key",t.key),e.appendChild(s)}return e}_renderSortIndicator(t,e){t.classList.add("kupola-table-sortable");const s=this._sorts.find(r=>r.key===e.key);s&&t.classList.add(`kupola-table-sort-${s.order}`),t.addEventListener("click",r=>{this.resizable&&r.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const n=document.createElement("span");n.className="kupola-table-sort-icon",s?n.textContent=this.multiSort?` ${this._sorts.indexOf(s)+1}${s.order==="asc"?"▲":"▼"}`:s.order==="asc"?" ▲":" ▼":n.textContent=" ⇅",t.appendChild(n)}_renderTbody(t){const e=document.createElement("tbody");if(this._loading)e.appendChild(this._renderStatusRow(this.loadingText,"kupola-table-loading"));else if(t.length===0)e.appendChild(this._renderStatusRow(this.emptyText,"kupola-table-empty"));else{const s=this.mergeCells?this.mergeCells(t):[],n=new Map;s.forEach(a=>n.set(`${a.row}-${a.col}`,a));const r=new Set;t.forEach((a,l)=>{const o=a[this.rowKey]??l,c=this._selectedKeys.has(o),d=this._expandedKeys.has(o),u=this._renderDataRow(a,l,o,c,r,n);if(e.appendChild(u),this.expandable&&d){const p=document.createElement("tr");p.className="kupola-table-expand-row";const m=document.createElement("td"),f=this.columns.length+(this.selection?1:0)+1;m.colSpan=f,m.className="kupola-table-expand-content";const g=this.expandable(a);typeof g=="string"?m.innerHTML=g:g instanceof HTMLElement&&m.appendChild(g),p.appendChild(m),e.appendChild(p)}})}return e}_renderDataRow(t,e,s,n,r,a){const l=document.createElement("tr");return l.setAttribute("data-row-key",s),n&&l.classList.add("kupola-table-row-selected"),this.draggable&&(l.draggable=!0,l.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(l,s,n),this.expandable&&this._renderExpandCell(l,s),this.columns.forEach((o,c)=>{if(r.has(`${e}-${c}`))return;const d=this._renderDataCell(t,e,s,o,c,r,a);l.appendChild(d)}),this.onRowClick&&(l.style.cursor="pointer",l.addEventListener("click",o=>{o.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,o)})),l}_renderSelectionCell(t,e,s){const n=document.createElement("td");n.className="kupola-table-col-selection";const r=document.createElement("input");r.type=this.selection,r.checked=s,r.addEventListener("change",()=>{this.selection==="radio"?(this._selectedKeys.clear(),this._selectedKeys.add(e)):s?this._selectedKeys.delete(e):this._selectedKeys.add(e),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),n.appendChild(r),t.appendChild(n)}_renderExpandCell(t,e){const s=document.createElement("td");s.className="kupola-table-col-expand";const n=document.createElement("button");n.className="kupola-table-expand-btn",n.textContent=this._expandedKeys.has(e)?"▼":"▶",n.type="button",n.addEventListener("click",()=>this._toggleExpand(e)),s.appendChild(n),t.appendChild(s)}_renderDataCell(t,e,s,n,r,a,l){const o=document.createElement("td");n.align&&(o.style.textAlign=n.align),n.fixed&&(o.setAttribute("data-fixed",n.fixed),o.classList.add(`kupola-table-fixed-${n.fixed}`));const c=l.get(`${e}-${r}`);if(c){c.rowSpan>1&&(o.rowSpan=c.rowSpan),c.colSpan>1&&(o.colSpan=c.colSpan);for(let u=0;u<(c.rowSpan||1);u++)for(let p=0;p<(c.colSpan||1);p++)u===0&&p===0||a.add(`${e+u}-${r+p}`)}this.tree&&r===0&&t._level>0&&this._renderTreeIndent(o,t);const d=this._editingCell&&this._editingCell.rowKey===s&&this._editingCell.colKey===n.key;if(d)o.appendChild(this._renderEditCell(n,t));else if(n.render){const u=n.render(t[n.key],t,e);typeof u=="string"?o.innerHTML=u:u instanceof HTMLElement&&o.appendChild(u)}else o.textContent=t[n.key]??"";return this.editable&&!d&&n.editable!==!1&&(o.classList.add("kupola-table-editable-cell"),o.addEventListener("dblclick",()=>this._startEdit(s,n.key,t[n.key]))),o}_renderTreeIndent(t,e){const s=document.createElement("span");if(s.className="kupola-table-tree-indent",s.style.paddingLeft=e._level*20+"px",t.appendChild(s),e._hasChildren){const n=document.createElement("button");n.className="kupola-table-tree-toggle",n.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",n.type="button",n.addEventListener("click",r=>{r.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),t.appendChild(n)}else{const n=document.createElement("span");n.className="kupola-table-tree-toggle-placeholder",t.appendChild(n)}}_renderStatusRow(t,e){const s=document.createElement("tr"),n=document.createElement("td");return n.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),n.className=e,n.textContent=t,s.appendChild(n),s}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:s=40,overscan:n=5}=this.virtualScroll,r=t.length*s;if(this._loading)return this._renderTbody(t);if(t.length===0)return this._renderTbody(t);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",e.appendChild(a),this._virtualData={data:t,rowHeight:s,overscan:n,totalHeight:r,tbody:e,topSpacer:a},this._updateVirtualScroll();const l=document.createElement("tr");l.className="kupola-table-virtual-spacer-bottom",l.style.height="0px",e.appendChild(l);const o=this.element.querySelector(".kupola-table-container");return o&&(o.style.maxHeight=this.virtualScroll.maxHeight||"400px",o.style.overflowY="auto",this._scrollHandler&&o.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),o.addEventListener("scroll",this._scrollHandler)),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:s,tbody:n,topSpacer:r}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const l=a.scrollTop,o=a.clientHeight,c=Math.max(0,Math.floor(l/e)-s),d=Math.min(t.length,Math.ceil((l+o)/e)+s);n.querySelectorAll(".kupola-table-virtual-row").forEach(f=>f.remove());const p=document.createDocumentFragment();for(let f=c;f<d;f++){const g=t[f],v=g[this.rowKey]??f,y=this._renderDataRow(g,f,v,this._selectedKeys.has(v),new Set,new Map);y.classList.add("kupola-table-virtual-row"),y.style.height=e+"px",p.appendChild(y)}r.style.height=c*e+"px";const m=n.querySelector(".kupola-table-virtual-spacer-bottom");m&&(m.style.height=(t.length-d)*e+"px"),r.after(p)}_renderEditCell(t,e){const s=document.createElement("div");s.className="kupola-table-edit-cell";const n=document.createElement("input");if(n.type=t.editType||"text",n.className="ds-input kupola-table-edit-input",n.value=this._editBuffer[t.key]??e[t.key]??"",t.editOptions){const o=document.createElement("select");o.className="ds-input kupola-table-edit-input",t.editOptions.forEach(c=>{const d=document.createElement("option");d.value=typeof c=="object"?c.value:c,d.textContent=typeof c=="object"?c.label:c,String(d.value)===String(n.value)&&(d.selected=!0),o.appendChild(d)}),o.addEventListener("change",()=>{this._editBuffer[t.key]=o.value}),s.appendChild(o)}else n.addEventListener("input",()=>{this._editBuffer[t.key]=n.value}),s.appendChild(n);const r=document.createElement("div");r.className="kupola-table-edit-actions";const a=document.createElement("button");a.className="kupola-table-edit-save",a.textContent="✓",a.type="button",a.addEventListener("click",()=>this._saveEdit(e,t));const l=document.createElement("button");return l.className="kupola-table-edit-cancel",l.textContent="✗",l.type="button",l.addEventListener("click",()=>this._cancelEdit()),r.appendChild(a),r.appendChild(l),s.appendChild(r),n.addEventListener("keydown",o=>{o.key==="Enter"&&this._saveEdit(e,t),o.key==="Escape"&&this._cancelEdit()}),setTimeout(()=>n.focus?.(),0),s}_startEdit(t,e,s){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:s},this.render()}_saveEdit(t,e){const s=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,s,this._data):t[e.key]=s,this._editingCell=null,this._editBuffer={},this.render()}_cancelEdit(){this.onEditCancel&&this.onEditCancel(this._editingCell),this._editingCell=null,this._editBuffer={},this.render()}_handleSort(t){if(this.multiSort){const e=this._sorts.findIndex(s=>s.key===t);if(e>=0){const s=this._sorts[e];s.order==="asc"?s.order="desc":this._sorts.splice(e,1)}else this._sorts.push({key:t,order:"asc"})}else{const e=this._sorts.find(s=>s.key===t);e?e.order==="asc"?e.order="desc":this._sorts=[]:this._sorts=[{key:t,order:"asc"}]}this.sortKey.value=this._sorts.map(e=>e.key).join(","),this.sortOrder.value=this._sorts.map(e=>e.order).join(","),this._currentPage=1,this.onSort&&this.onSort(this._sorts),this.render()}_toggleExpand(t){this._expandedKeys.has(t)?this._expandedKeys.delete(t):this._expandedKeys.add(t),this.onExpand&&this.onExpand(t,this._expandedKeys.has(t)),this.render()}_toggleTreeExpand(t){this._treeExpandedKeys.has(t)?this._treeExpandedKeys.delete(t):this._treeExpandedKeys.add(t),this.render()}selectRow(t){this._selectedKeys.add(t),this._syncSelected(),this.render()}deselectRow(t){this._selectedKeys.delete(t),this._syncSelected(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this._selectedKeys.add(t[this.rowKey])),this._syncSelected(),this.render()}deselectAll(){this._selectedKeys.clear(),this._syncSelected(),this.render()}invertSelection(){this.getProcessedData().forEach(e=>{const s=e[this.rowKey];this._selectedKeys.has(s)?this._selectedKeys.delete(s):this._selectedKeys.add(s)}),this._syncSelected(),this.render()}getSelectedKeys(){return[...this._selectedKeys]}getSelectedRows(){return(this.tree?this._flattenForExpand(this._data):this._data).filter(e=>this._selectedKeys.has(e[this.rowKey]))}_syncSelected(){this.selectedKeys.value=[...this._selectedKeys]}_initColumnResize(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(e=>{e.addEventListener("mousedown",s=>{s.preventDefault();const n=e.getAttribute("data-col-key"),r=e.parentElement,a=s.clientX,l=r.offsetWidth,o=d=>{const u=Math.max(50,l+(d.clientX-a));r.style.width=u+"px";const p=this.columns.find(m=>m.key===n);p&&(p.width=u),this.onColumnResize&&this.onColumnResize(n,u)},c=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",c),this._resizeCleanups.push(c)})})}_initRowDrag(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(e=>{e.addEventListener("dragstart",s=>{this._dragState={fromKey:e.getAttribute("data-row-key")},e.classList.add("kupola-table-dragging"),s.dataTransfer.effectAllowed="move"}),e.addEventListener("dragover",s=>{s.preventDefault(),s.dataTransfer.dropEffect="move",e.classList.add("kupola-table-drag-over")}),e.addEventListener("dragleave",()=>e.classList.remove("kupola-table-drag-over")),e.addEventListener("drop",s=>this._handleRowDrop(s,e)),e.addEventListener("dragend",()=>{e.classList.remove("kupola-table-dragging"),this._dragState=null})})}_handleRowDrop(t,e){if(t.preventDefault(),e.classList.remove("kupola-table-drag-over"),!this._dragState)return;const s=e.getAttribute("data-row-key");if(this._dragState.fromKey===s)return;const n=this._data.findIndex(a=>String(a[this.rowKey])===this._dragState.fromKey),r=this._data.findIndex(a=>String(a[this.rowKey])===s);if(n>=0&&r>=0){const[a]=this._data.splice(n,1);this._data.splice(r,0,a),this.onRowDragEnd&&this.onRowDragEnd(a,n,r,this._data),this.render()}}_applyStickyColumns(){const t=this.columns.filter(n=>n.fixed==="left");this.selection,this.expandable,t.forEach(n=>{const r=this.element.querySelectorAll('th[data-fixed="left"]'),a=this.element.querySelectorAll('td[data-fixed="left"]'),l=this.columns.indexOf(n);let o=(this.selection?40:0)+(this.expandable?40:0);for(let c=0;c<l;c++)this.columns[c].fixed==="left"&&(o+=this.columns[c]._resolvedWidth||120);r.forEach(c=>{c.textContent.startsWith(n.title||n.key)&&(c.style.position="sticky",c.style.left=o+"px",c.style.zIndex="2",n._resolvedWidth=c.offsetWidth)}),a.forEach(c=>{c.style.position="sticky",c.style.left=o+"px",c.style.zIndex="1",c.style.background="inherit"})});let e=0;[...this.columns].filter(n=>n.fixed==="right").reverse().forEach(n=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(a=>{a.style.position="sticky",a.style.right=e+"px",a.style.zIndex="1"}),e+=n._resolvedWidth||n.width||120})}_renderToolbar(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const n=document.createElement("input");n.type="text",n.className="ds-input kupola-table-filter-input",n.placeholder=this.options.filterPlaceholder||"搜索...",n.value=this._filterText,n.addEventListener("input",()=>{clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=setTimeout(()=>{this._filterText=n.value,this._currentPage=1,this.filterText.value=this._filterText,this.onFilter&&this.onFilter(this._filterText),this.render()},300)}),t.appendChild(n)}const e=document.createElement("div");if(e.className="kupola-table-toolbar-right",this.selection&&this._selectedKeys.size>0){const n=document.createElement("span");n.className="kupola-table-selection-info",n.textContent=`已选 ${this._selectedKeys.size} 项`,e.appendChild(n);const r=document.createElement("button");r.className="ds-btn ds-btn--sm",r.textContent="反选",r.type="button",r.addEventListener("click",()=>this.invertSelection()),e.appendChild(r)}if(this.options.showExport){const n=document.createElement("button");n.className="ds-btn ds-btn--sm ds-btn--secondary",n.textContent="导出 CSV",n.type="button",n.addEventListener("click",()=>this.exportCSV()),e.appendChild(n)}const s=document.createElement("span");return s.className="kupola-table-info",s.textContent=`共 ${this._total} 条`,e.appendChild(s),t.appendChild(e),t}_renderPagination(){const t=Math.ceil(this._total/this._pageSize);if(t<=1)return document.createElement("div");const e=document.createElement("div");if(e.className="kupola-table-pagination",this.options.showPageSize){const l=document.createElement("select");l.className="kupola-table-page-size",this._pageSizes.forEach(o=>{const c=document.createElement("option");c.value=o,c.textContent=`${o} 条/页`,o===this._pageSize&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",()=>{this._pageSize=parseInt(l.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(l)}const s=document.createElement("div");s.className="kupola-table-pages";const n=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));n.disabled=this._currentPage<=1,s.appendChild(n),this._getPageRange(this._currentPage,t).forEach(l=>{if(l==="..."){const o=document.createElement("span");o.className="kupola-table-page-ellipsis",o.textContent="...",s.appendChild(o)}else{const o=this._createPageBtn(l,()=>this._goToPage(l));l===this._currentPage&&o.classList.add("active"),s.appendChild(o)}});const r=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));r.disabled=this._currentPage>=t,s.appendChild(r),e.appendChild(s);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${t}`,e.appendChild(a),e}_createPageBtn(t,e){const s=document.createElement("button");return s.className="kupola-table-page-btn",s.textContent=t,s.type="button",s.addEventListener("click",e),s}_goToPage(t){const e=Math.ceil(this._total/this._pageSize);t<1||t>e||(this._currentPage=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this._pageSize),this.render())}_getPageRange(t,e){if(e<=7)return Array.from({length:e},(n,r)=>r+1);const s=[];if(t<=3){for(let n=1;n<=5;n++)s.push(n);s.push("...",e)}else if(t>=e-2){s.push(1,"...");for(let n=e-4;n<=e;n++)s.push(n)}else{s.push(1,"...");for(let n=t-1;n<=t+1;n++)s.push(n);s.push("...",e)}return s}exportCSV(t="export.csv"){const e=this.getProcessedData(),s=this.columns.map(c=>c.title||c.key),n=e.map(c=>this.columns.map(d=>{let u=c[d.key];return u==null&&(u=""),u=String(u).replace(/"/g,'""'),`"${u}"`}).join(",")),r="\uFEFF"+[s.join(","),...n].join(`
|
|
183
|
+
`),a=new Blob([r],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),o=document.createElement("a");o.href=l,o.download=t,o.click(),URL.revokeObjectURL(l)}_getTableClass(){const t=["kupola-table"];return this.striped&&t.push("kupola-table-striped"),this.bordered&&t.push("kupola-table-bordered"),this.hoverable&&t.push("kupola-table-hover"),this.compact&&t.push("kupola-table-compact"),t.join(" ")}refresh(){this.render()}getPage(){return{current:this._currentPage,pageSize:this._pageSize,total:this._total}}setColumns(t){this.columns=t.map((e,s)=>({...e,_index:s})),this.render()}destroy(){if(this._scrollHandler){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null}this._filterDebounceTimer&&(clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=null),this._resizeCleanups.forEach(t=>t()),this._resizeCleanups=[],this._reactiveCleanups.forEach(t=>t.unsubscribe()),this._reactiveCleanups=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this._data=[],this._virtualData=null,this._dragState=null,this._editingCell=null,this._editBuffer={}}}function Nt(i,t){return new Ss(i,t)}function yl(){document.querySelectorAll("[data-kupola-table]").forEach(i=>{const t=i.getAttribute("data-kupola-table");let e={};if(t)try{e=JSON.parse(t)}catch{}Nt(i,e)})}w.register("table",Nt);class Ls{constructor(t,e={}){this.element=typeof t=="string"?document.querySelector(t):t,this.options=e,this._current=e.current||1,this._total=e.total||0,this._pageSize=e.pageSize||10,this._maxPages=e.maxPages||7,this._showTotal=e.showTotal!==!1,this._showSizeChanger=e.showSizeChanger||!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._simple=e.simple||!1,this.current=T(this._current),this.total=T(this._total),this.onChange=e.onChange||null,this.onPageSizeChange=e.onPageSizeChange||null,this._init()}_init(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this._total/this._pageSize))}setCurrent(t){t=Math.max(1,Math.min(t,this.totalPages)),t!==this._current&&(this._current=t,this.current.value=t,this.onChange&&this.onChange(t,this._pageSize),this.render())}setTotal(t){t&&typeof t=="object"&&"value"in t?(this._total=t.value||0,t._subscribers?.add(e=>{this._total=e||0,this._current>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this._total=t,this.total.value=this._total,this.render()}setPageSize(t){this._pageSize=t,this._current=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this._current),this.render()}render(){const t=this.element;t.innerHTML="",!(this._total<=0)&&(this._simple?this._renderSimple(t):this._renderFull(t))}_renderSimple(t){const e=this.totalPages,s=this._btn("‹",()=>this.setCurrent(this._current-1));s.disabled=this._current<=1,t.appendChild(s);const n=document.createElement("span");n.className="kupola-pagination-simple-info",n.textContent=`${this._current} / ${e}`,t.appendChild(n);const r=this._btn("›",()=>this.setCurrent(this._current+1));r.disabled=this._current>=e,t.appendChild(r)}_renderFull(t){const e=this.totalPages;if(this._showTotal){const a=document.createElement("span");a.className="kupola-pagination-total",a.textContent=`共 ${this._total} 条`,t.appendChild(a)}if(this._showSizeChanger){const a=document.createElement("select");a.className="kupola-pagination-size",this._pageSizes.forEach(l=>{const o=document.createElement("option");o.value=l,o.textContent=`${l} 条/页`,l===this._pageSize&&(o.selected=!0),a.appendChild(o)}),a.addEventListener("change",()=>this.setPageSize(parseInt(a.value))),t.appendChild(a)}const s=document.createElement("div");s.className="kupola-pagination-pages";const n=this._btn("‹",()=>this.setCurrent(this._current-1));n.disabled=this._current<=1,s.appendChild(n),this._getPageRange().forEach(a=>{if(a==="..."){const l=document.createElement("span");l.className="kupola-pagination-ellipsis",l.textContent="···",s.appendChild(l)}else{const l=this._btn(a,()=>this.setCurrent(a));a===this._current&&l.classList.add("active"),s.appendChild(l)}});const r=this._btn("›",()=>this.setCurrent(this._current+1));if(r.disabled=this._current>=e,s.appendChild(r),t.appendChild(s),e>10){const a=document.createElement("span");a.className="kupola-pagination-jumper",a.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const l=a.querySelector("input");l.addEventListener("change",()=>{const o=parseInt(l.value);o>=1&&o<=e&&this.setCurrent(o)}),l.addEventListener("keydown",o=>{if(o.key==="Enter"){const c=parseInt(l.value);c>=1&&c<=e&&this.setCurrent(c)}}),t.appendChild(a)}}_btn(t,e){const s=document.createElement("button");return s.className="kupola-pagination-btn",s.textContent=t,s.type="button",s.addEventListener("click",e),s}_getPageRange(){const t=this.totalPages,e=this._maxPages;if(t<=e)return Array.from({length:t},(r,a)=>a+1);const s=[],n=Math.floor(e/2);if(this._current<=n+1){for(let r=1;r<=e-2;r++)s.push(r);s.push("...",t)}else if(this._current>=t-n){s.push(1,"...");for(let r=t-e+3;r<=t;r++)s.push(r)}else{s.push(1,"...");for(let r=this._current-n+2;r<=this._current+n-2;r++)s.push(r);s.push("...",t)}return s}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let Ds=!1;function vl(){if(Ds||typeof document>"u")return;const i=document.createElement("style");i.textContent=`
|
|
184
184
|
.kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
185
185
|
.kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }
|
|
186
186
|
.kupola-pagination-btn { min-width: 32px; height: 32px; border: 1px solid #d9d9d9; border-radius: 4px; background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
|
|
@@ -194,13 +194,13 @@
|
|
|
194
194
|
.kupola-pagination-jumper { font-size: 14px; color: #666; }
|
|
195
195
|
.kupola-pagination-jumper input { width: 50px; height: 28px; margin: 0 4px; padding: 0 8px; border: 1px solid #d9d9d9; border-radius: 4px; text-align: center; font-size: 13px; }
|
|
196
196
|
.kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }
|
|
197
|
-
`,document.head.appendChild(i),
|
|
197
|
+
`,document.head.appendChild(i),Ds=!0}function bl(i,t){return vl(),new Ls(i,t)}let Hs=!1;class El extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const t=this.querySelector('[slot="trigger"]'),e=this.querySelectorAll('[slot="item"]'),s=document.createElement("div");s.className="ds-dropdown",s.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),s.appendChild(t));const n=document.createElement("div");n.className="ds-dropdown__menu",e.forEach(r=>{r.className="ds-dropdown__item",n.appendChild(r)}),s.appendChild(n),this.innerHTML="",this.appendChild(s)}attributeChangedCallback(t,e,s){if(t==="open"){const n=this.querySelector(".ds-dropdown__menu");n&&(n.style.display=s!==null?"block":"")}}}class kl extends HTMLElement{static get observedAttributes(){return["title","position"]}connectedCallback(){const t=this.firstElementChild;t&&(t.setAttribute("data-title",this.getAttribute("title")||""),this.getAttribute("position")&&t.setAttribute("data-tooltip-position",this.getAttribute("position")))}attributeChangedCallback(t,e,s){if(t==="title"){const n=this.firstElementChild;n&&n.setAttribute("data-title",s||"")}}}class wl extends HTMLElement{connectedCallback(){this._render()}_render(){const t=document.createElement("div");t.className="ds-collapse",t.setAttribute("data-collapse",""),this.querySelectorAll("k-collapse-item").forEach(s=>{const n=s.getAttribute("title")||"",r=s.innerHTML,a=document.createElement("div");a.className="ds-collapse__item",a.innerHTML=`
|
|
198
198
|
<button class="ds-collapse__header">
|
|
199
199
|
<span>${n}</span>
|
|
200
200
|
<svg class="icon ds-collapse__chevron" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
|
|
201
201
|
</button>
|
|
202
202
|
<div class="ds-collapse__body"><div class="ds-collapse__content">${r}</div></div>
|
|
203
|
-
`,t.appendChild(a)}),this.innerHTML="",this.appendChild(t)}}class
|
|
203
|
+
`,t.appendChild(a)}),this.innerHTML="",this.appendChild(t)}}class xl extends HTMLElement{static get observedAttributes(){return["title"]}}class Cl extends HTMLElement{static get observedAttributes(){return["position","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("position")||"left",e=document.createElement("div");e.className=`ds-drawer ds-drawer--${t}`,e.setAttribute("data-drawer",""),e.innerHTML=this.innerHTML,this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,s){if(t==="open"){const n=this.querySelector(".ds-drawer");n&&n.classList.toggle("is-open",s!==null)}}}class Sl extends HTMLElement{static get observedAttributes(){return["title","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("title")||"",e=document.createElement("div");e.className="ds-backdrop",e.style.display="none",e.innerHTML=`
|
|
204
204
|
<div class="ds-dialog">
|
|
205
205
|
<div class="ds-dialog__head">
|
|
206
206
|
<span class="ds-dialog__title">${t}</span>
|
|
@@ -211,5 +211,5 @@
|
|
|
211
211
|
<div class="ds-dialog__body"></div>
|
|
212
212
|
<div class="ds-dialog__foot"></div>
|
|
213
213
|
</div>
|
|
214
|
-
`;const s=e.querySelector(".ds-dialog__body"),n=this.querySelector('[slot="body"]');n&&s.appendChild(n);const r=e.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&r.appendChild(a);const l=e.querySelector(".ds-dialog__close");l&&l.addEventListener("click",()=>this.close()),e.addEventListener("click",o=>{o.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,s){if(t==="open"){const n=this.querySelector(".ds-backdrop");n&&(n.style.display=s!==null?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}function
|
|
214
|
+
`;const s=e.querySelector(".ds-dialog__body"),n=this.querySelector('[slot="body"]');n&&s.appendChild(n);const r=e.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&r.appendChild(a);const l=e.querySelector(".ds-dialog__close");l&&l.addEventListener("click",()=>this.close()),e.addEventListener("click",o=>{o.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,s){if(t==="open"){const n=this.querySelector(".ds-backdrop");n&&(n.style.display=s!==null?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}function Ll(){if(Hs||typeof customElements>"u")return;Hs=!0;const i=[["k-dropdown",El],["k-tooltip",kl],["k-collapse",wl],["k-collapse-item",xl],["k-drawer",Cl],["k-modal",Sl]];for(const[t,e]of i)customElements.get(t)||customElements.define(t,e)}h.BRAND_OPTIONS=W,h.CacheEntry=bs,h.CacheManager=$t,h.Calendar=We,h.Carousel=Ae,h.Collapse=Oe,h.ColorPicker=Ve,h.ComponentInitializerRegistry=Ee,h.Countdown=cs,h.Datepicker=Le,h.DependsError=N,h.DependsSource=V,h.Dialog=Va,h.Drawer=Pe,h.Dropdown=xe,h.DynamicTags=Ye,h.FetchedSource=Es,h.FileUpload=Fe,h.FunctionSource=ws,h.GlobalEvents=we,h.Heatmap=Qe,h.Icons=al,h.ImagePreview=Lt,h.KupolaComponent=j,h.KupolaComponentRegistry=ke,h.KupolaDataBind=fe,h.KupolaEventBus=ge,h.KupolaForm=_s,h.KupolaI18n=ut,h.KupolaLifecycle=B,h.KupolaPagination=Ls,h.KupolaStore=ot,h.KupolaStoreManager=me,h.KupolaTable=Ss,h.KupolaUtils=sa,h.KupolaValidator=ns,h.Message=Ua,h.Modal=z,h.Notification=Ka,h.NumberInput=ds,h.PATHS=It,h.RouteSource=ks,h.Scheduler=vs,h.Select=Ce,h.SlideCaptcha=ps,h.Slider=Te,h.StatCard=Ge,h.StaticSource=xs,h.StorageSource=qt,h.Tag=je,h.Timepicker=He,h.Tooltip=ss,h.VirtualList=rs,h.WebSocketSource=Bt,h.alertModal=Oa,h.applyMixin=ht,h.arrayUtils=Kt,h.bootstrapComponents=ua,h.cleanupAllDropdowns=Aa,h.cleanupAllSlideCaptchas=gs,h.cleanupCalendar=Ue,h.cleanupCarousel=ze,h.cleanupCollapse=Re,h.cleanupColorPicker=Ke,h.cleanupCountdown=hs,h.cleanupDatepicker=De,h.cleanupDrawer=$e,h.cleanupDropdown=ft,h.cleanupDynamicTags=Xe,h.cleanupFileUpload=Ne,h.cleanupHeatmap=ts,h.cleanupModal=qe,h.cleanupNumberInput=us,h.cleanupSelect=Se,h.cleanupSlideCaptcha=ms,h.cleanupSlider=Ie,h.cleanupStatCard=Ze,h.cleanupTag=Je,h.cleanupTimepicker=Me,h.cleanupTooltip=is,h.cleanupVirtualList=os,h.clearCache=_l,h.configureHttpClient=ul,h.confirmModal=Na,h.createBrandPicker=oa,h.createI18n=ga,h.createLifecycle=Is,h.createModal=bt,h.createSource=Ft,h.createStore=ra,h.createThemeToggle=la,h.cryptoUtils=ce,h.dateUtils=te,h.debounce=ee,h.defineComponent=ma,h.defineMixin=pa,h.emit=La,h.emitGlobal=Da,h.formatCurrency=wa,h.formatDate=Ea,h.formatNumber=ka,h.getBrand=X,h.getFormInstance=cl,h.getHttpClient=pl,h.getListenerCount=Ta,h.getLocale=ba,h.getStore=aa,h.getTheme=R,h.globalEvents=M,h.initAllTables=yl,h.initCalendar=Ct,h.initCalendars=Ga,h.initCarousel=vt,h.initCarousels=Ba,h.initCollapse=wt,h.initCollapses=ja,h.initColorPicker=xt,h.initColorPickers=Ja,h.initCountdown=zt,h.initCountdowns=ll,h.initDatepicker=gt,h.initDatepickers=Pa,h.initDrawer=st,h.initDrawers=Fa,h.initDropdown=pt,h.initDropdowns=Ia,h.initDynamicTags=St,h.initDynamicTagsAll=Za,h.initFileUpload=kt,h.initFileUploads=Xa,h.initFormValidation=ys,h.initHeatmap=Mt,h.initHeatmaps=il,h.initImagePreview=Qa,h.initMessages=Ya,h.initModal=Et,h.initModals=Ra,h.initNotifications=Wa,h.initNumberInput=Pt,h.initNumberInputs=ol,h.initPagination=bl,h.initSelect=mt,h.initSelects=za,h.initSlideCaptchas=fs,h.initSlider=yt,h.initSliders=qa,h.initStatCard=Ht,h.initStatCards=sl,h.initTable=Nt,h.initTag=Dt,h.initTags=el,h.initTheme=be,h.initTimepicker=_t,h.initTimepickers=$a,h.initTooltip=Tt,h.initTooltips=nl,h.initVirtualList=ls,h.kupolaBootstrap=dt,h.kupolaData=q,h.kupolaEvents=na,h.kupolaI18n=F,h.kupolaInitializer=w,h.kupolaLifecycle=Ts,h.kupolaStoreManager=ct,h.n=ya,h.numberUtils=Gt,h.objectUtils=Xt,h.off=Sa,h.offAll=Ma,h.offByScope=Ha,h.on=xa,h.once=Ca,h.preloadUtils=ue,h.ref=T,h.registerComponent=ha,h.registerLazyComponent=da,h.registerWebComponents=Ll,h.renderIcon=it,h.resetHttpClient=fl,h.setBrand=et,h.setLocale=va,h.setTheme=tt,h.showImagePreview=tl,h.stringUtils=Ot,h.svg=At,h.t=_a,h.throttle=se,h.useDeps=ml,h.useMixin=fa,h.useQuery=gl,h.validateForm=hl,h.validator=I,h.validatorUtils=at,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
215
215
|
//# sourceMappingURL=kupola.umd.js.map
|