@kupola/kupola 1.7.8 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/colors-and-type.css +242 -287
- package/css/scaffold.css +9 -3
- package/css/theme-dark.css +2 -0
- package/css/theme-light.css +2 -0
- package/dist/core-Dfj-u6qC.cjs +1 -0
- package/dist/core-LA_QgrQO.js +4955 -0
- package/dist/core.cjs.js +1 -0
- package/dist/core.esm.js +1 -0
- package/dist/core.umd.js +1 -0
- package/dist/css/colors-and-type.css +242 -287
- package/dist/css/scaffold.css +9 -3
- package/dist/css/theme-dark.css +2 -0
- package/dist/css/theme-light.css +2 -0
- package/dist/kupola-lite.cjs.js +1 -0
- package/dist/kupola-lite.esm.js +1 -0
- package/dist/kupola.cjs.js +1 -215
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +1 -8586
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.min.js +1 -0
- package/dist/kupola.umd.js +1 -215
- package/dist/kupola.umd.js.map +1 -1
- package/dist/plugins/vite-plugin-kupola.js +110 -99
- package/dist/plugins/webpack-plugin-kupola.js +58 -0
- package/dist/react-theme.js +111 -0
- package/dist/theme-preload.js +28 -0
- package/dist/theme-standalone.js +98 -0
- package/dist/vue-theme.js +78 -0
- package/js/icons.js +153 -81
- package/js/react-theme.js +111 -0
- package/js/theme-preload.js +28 -0
- package/js/theme-standalone.js +15 -5
- package/js/theme.js +17 -1
- package/js/vue-theme.js +78 -0
- package/package.json +32 -1
- package/plugins/vite-plugin-kupola.js +110 -99
- package/plugins/webpack-plugin-kupola.js +58 -0
package/dist/kupola.cjs.js
CHANGED
|
@@ -1,215 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class nt{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const o of s){await this._resolveDepends(o.depends,t);const l=performance.now();let c,d;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){d=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const h=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:h,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 Qs=new nt("app");function ti(i="app"){return new nt(i)}const ei=new Set(["__proto__","prototype","constructor"]);function rt(i){return ei.has(i)}function si(i){return i?i.trim():""}function ii(i){return i?i.replace(/^\s+/,""):""}function ni(i){return i?i.replace(/\s+$/,""):""}function ri(i){return i?i.toUpperCase():""}function ai(i){return i?i.toLowerCase():""}function oi(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function li(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function ci(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function hi(i,t,e=" "){return(String(i)||"").padStart(t,e)}function di(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function ui(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function pi(i,t,e){return i?i.split(t).join(e):""}function fi(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function mi(i,t){return(i||"").startsWith(t)}function gi(i,t){return(i||"").endsWith(t)}function _i(i,t){return(i||"").includes(t)}function yi(i,t){return(i||"").repeat(t)}function vi(i){return(i||"").split("").reverse().join("")}function bi(i,t){return!i||!t?0:i.split(t).length-1}function xi(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Ei(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function ki(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 wi(){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 oe={trim:si,trimLeft:ii,trimRight:ni,toUpperCase:ri,toLowerCase:ai,capitalize:oi,camelize:li,hyphenate:ci,padStart:hi,padEnd:di,truncate:ui,replaceAll:pi,format:fi,startsWith:mi,endsWith:gi,includes:_i,repeat:yi,reverse:vi,countOccurrences:bi,escapeHtml:xi,unescapeHtml:Ei,generateRandom:ki,generateUUID:wi};function Ci(i){return Array.isArray(i)}function Si(i){return!i||i.length===0}function Li(i){return i?i.length:0}function Di(i,t){return i&&i.length>0?i[0]:t}function Hi(i,t){return i&&i.length>0?i[i.length-1]:t}function Mi(i,t,e){return i&&i[t]!==void 0?i[t]:e}function Ti(i,t,e){return i?i.slice(t,e):[]}function Ii(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function Ai(i,t=","){return i?i.join(t):""}function zi(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 $i(i,t){return i?i.includes(t):!1}function Bi(i,...t){return i&&i.push(...t),i}function qi(i){return i?i.pop():void 0}function Oi(i){return i?i.shift():void 0}function Fi(i,...t){return i&&i.unshift(...t),i}function Ni(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 Ri(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function Vi(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 Ui(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 Yi(i,t){return i?i.filter(t):[]}function Xi(i,t){return i?i.map(t):[]}function ji(i,t,e){return i?i.reduce(t,e):e}function Ji(i,t){i&&i.forEach(t)}function Zi(i,t){return i?i.every(t):!0}function Gi(i,t){return i?i.some(t):!1}function Qi(i,t){return i?i.find(t):void 0}function tn(i,t){return i?i.findIndex(t):-1}function en(i,t=1){return i?i.flat(t):[]}function le(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(le(e)):t.concat(e),[]):[]}function sn(i){return i?[...new Set(i)]:[]}function nn(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 rn(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 an(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 ce(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function on(i){return!i||i.length===0?0:ce(i)/i.length}function ln(i){return i&&i.length>0?Math.max(...i):-1/0}function cn(i){return i&&i.length>0?Math.min(...i):1/0}function hn(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function dn(...i){return[...new Set(i.flat().filter(Boolean))]}function un(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function pn(...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 he={isArray:Ci,isEmpty:Si,size:Li,first:Di,last:Hi,get:Mi,slice:Ti,concat:Ii,join:Ai,indexOf:zi,lastIndexOf:Pi,includes:$i,push:Bi,pop:qi,shift:Oi,unshift:Fi,remove:Ni,removeAt:Ri,insert:Vi,reverse:Ki,sort:Wi,sortBy:Ui,filter:Yi,map:Xi,reduce:ji,forEach:Ji,every:Zi,some:Gi,find:Qi,findIndex:tn,flat:en,flattenDeep:le,unique:sn,uniqueBy:nn,chunk:rn,shuffle:an,sum:ce,average:on,max:ln,min:cn,intersection:hn,union:dn,difference:un,zip:pn};function dt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function fn(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function mn(i){return i?Object.keys(i):[]}function gn(i){return i?Object.values(i):[]}function _n(i){return i?Object.entries(i):[]}function yn(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function vn(i,t,e){if(!i)return e;const s=t.split(".");return s.some(rt)?e:s.reduce((n,r)=>n&&n[r],i)??e}function bn(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(rt))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 xn(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function En(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function de(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{rt(s)||(dt(e[s])&&dt(t[s])?t[s]=de(t[s],e[s]):t[s]=e[s])}),t),{})}function kn(i){return i&&JSON.parse(JSON.stringify(i))}function X(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,X(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(X(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(X(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{rt(s)||(e[s]=X(i[s],t))}),e}function wn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function Cn(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 Ln(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function Dn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function Hn(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 Mn(i){return i?Object.keys(i).length:0}function Tn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function ue(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=>ue(i[n],t[n]))}function pe(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&pe(i[t])}),i)}function In(i){return i&&Object.seal(i)}const fe={isObject:dt,isEmpty:fn,keys:mn,values:gn,entries:_n,has:yn,get:vn,set:bn,pick:xn,omit:En,merge:de,clone:kn,deepClone:X,forEach:wn,map:Cn,filter:Sn,reduce:Ln,toArray:Dn,fromArray:Hn,size:Mn,invert:Tn,isEqual:ue,freeze:pe,seal:In};function L(i){return typeof i=="number"&&!isNaN(i)}function An(i){return Number.isInteger(i)}function zn(i){return L(i)&&!Number.isInteger(i)}function Pn(i){return L(i)&&i>0}function $n(i){return L(i)&&i<0}function Bn(i){return L(i)&&i===0}function qn(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function On(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function Fn(i){return L(i)?Math.floor(i):i}function Nn(i){return L(i)?Math.ceil(i):i}function Rn(i){return L(i)?Math.abs(i):i}function Vn(...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 me(...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?me(t)/t.length:0}function ge(i=0,t=1){return Math.random()*(t-i)+i}function Un(i,t){return Math.floor(ge(i,t+1))}function Yn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Xn(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 jn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Jn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Zn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Gn(i){return Number.isNaN(i)}function Qn(i){return Number.isFinite(i)}function tr(i,t=10){return Number.parseInt(i,t)}function er(i){return Number.parseFloat(i)}function sr(i,t=0){const e=Number(i);return isNaN(e)?t:e}function ir(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function nr(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const _e={isNumber:L,isInteger:An,isFloat:zn,isPositive:Pn,isNegative:$n,isZero:Bn,clamp:qn,round:On,floor:Fn,ceil:Nn,abs:Rn,min:Vn,max:Kn,sum:me,average:Wn,random:ge,randomInt:Un,format:Yn,formatCurrency:Xn,formatPercent:jn,toFixed:Jn,toPrecision:Zn,isNaN:Gn,isFinite:Qn,parseInt:tr,parseFloat:er,toNumber:sr,safeDivide:ir,safeMultiply:nr};function at(){return Date.now()}function W(){const i=new Date;return i.setHours(0,0,0,0),i}function rr(){const i=W();return i.setDate(i.getDate()+1),i}function ar(){const i=W();return i.setDate(i.getDate()-1),i}function k(i){return i instanceof Date&&!isNaN(i.getTime())}function ye(i){return k(i)}function or(i){const t=new Date(i);return ye(t)?t:null}function lr(i,t="YYYY-MM-DD HH:mm:ss"){if(!k(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),o=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",d)}function cr(i){return k(i)?i.toISOString():""}function hr(i){return k(i)?new Date(i.toUTCString()):null}function dr(i,t){if(!k(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function ur(i,t){if(!k(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function pr(i,t){if(!k(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function fr(i,t){if(!k(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function ot(i,t){if(!k(i)||!k(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function mr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function gr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function _r(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function yr(i){return k(i)?ot(i,W())===0:!1}function vr(i){return k(i)?ot(i,W())===-1:!1}function br(i){return k(i)?ot(i,W())===1:!1}function xr(i){return k(i)?i.getTime()>at():!1}function Er(i){return k(i)?i.getTime()<at():!1}function kr(i){if(!k(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function wr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function Cr(i){if(!k(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function Sr(i){return k(i)?Math.ceil((i.getMonth()+1)/3):0}function Lr(i){if(!k(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function Dr(i){if(!k(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function Hr(i){return k(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function Mr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function ve(i,t=1){if(!k(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function Tr(i,t=1){if(!k(i))return i;const e=ve(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function Ir(i){if(!k(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function Ar(i){if(!k(i))return"";const e=at()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,o=30*r,l=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}const be={now:at,today:W,tomorrow:rr,yesterday:ar,isDate:k,isValid:ye,parse:or,format:lr,toISO:cr,toUTC:hr,addDays:dr,addHours:ur,addMinutes:pr,addSeconds:fr,diffDays:ot,diffHours:mr,diffMinutes:gr,diffSeconds:_r,isToday:yr,isYesterday:vr,isTomorrow:br,isFuture:xr,isPast:Er,isLeapYear:kr,getDaysInMonth:wr,getWeekOfYear:Cr,getQuarter:Sr,startOfDay:Lr,endOfDay:Dr,startOfMonth:Hr,endOfMonth:Mr,startOfWeek:ve,endOfWeek:Tr,getAge:Ir,fromNow:Ar};function xe(i,t,e={}){let s=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(r,n)}function d(){a=Date.now(),o?(s=setTimeout(h,t),c()):s=setTimeout(h,t)}function h(){s=null,l&&n&&c(),n=null,r=null}function u(){return Math.max(0,t-(Date.now()-a))}return function(...f){n=f,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(h,u())):d()}}function Ee(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function o(){i.apply(a,r),r=null,a=null}return function(...l){s?n&&(r=l,a=this):(s=!0,r=l,a=this,o(),setTimeout(()=>{s=!1,n&&r&&o()},t))}}function zr(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 $r(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ke(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 we(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function Br(i){return ke(i)||we(i)}function qr(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 Or(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function Fr(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 Ce(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function Se(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 Nr(i){return Ce(i)||Se(i)||Le(i)}function Rr(i){return!isNaN(new Date(i).getTime())}function Vr(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 Ur(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Yr(i){return/^-?\d+$/.test(i||"")}function Xr(i){return/^-?\d+\.\d+$/.test(i||"")}function jr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Jr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Zr(i){return/^[a-zA-Z]+$/.test(i||"")}function Gr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Qr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function ta(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function ea(i,t){return(i||"").length>=t}function sa(i,t){return(i||"").length<=t}function ia(i,t){return t instanceof RegExp?t.test(i||""):!1}function na(i,t){return String(i)===String(t)}function De(i,t){return(i||"").includes(t)}function ra(i,t){return!De(i,t)}function aa(i){return Array.isArray(i)}function oa(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function la(i,t){return i?i.length>=t:!1}function ca(i,t){return i?i.length<=t:!1}function ha(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function da(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function ua(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");mt[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,i);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const mt={isEmail:zr,isPhone:Pr,isURL:$r,isIPv4:ke,isIPv6:we,isIP:Br,isIDCard:qr,isPassport:Or,isCreditCard:Fr,isHexColor:Ce,isRGB:Se,isRGBA:Le,isColor:Nr,isDate:Rr,isJSON:Vr,isEmpty:Kr,isWhitespace:Wr,isNumber:Ur,isInteger:Yr,isFloat:Xr,isPositive:jr,isNegative:Jr,isAlpha:Zr,isAlphaNumeric:Gr,isChinese:Qr,isLength:ta,minLength:ea,maxLength:sa,matches:ia,equals:na,contains:De,notContains:ra,isArray:aa,arrayLength:oa,arrayMinLength:la,arrayMaxLength:ca,isObject:ha,hasKeys:da,validate:ua};function pa(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(h,u){return h<<u|h>>>32-u}function a(h){const u=h.length*8;for(h+="";h.length%64!==56;)h+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)h+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)h+=String.fromCharCode(p>>>8*m&255);return h}function o(h,u){const[f,p,m,y]=u,_=[];for(let S=0;S<16;S++)_[S]=h.charCodeAt(S*4)&255|(h.charCodeAt(S*4+1)&255)<<8|(h.charCodeAt(S*4+2)&255)<<16|(h.charCodeAt(S*4+3)&255)<<24;let b=f,x=p,v=m,C=y;for(let S=0;S<64;S++){let w,A;const z=Math.floor(S/16),D=S%16;z===0?(w=x&v|~x&C,A=D):z===1?(w=C&x|~C&v,A=(5*D+1)%16):z===2?(w=x^v^C,A=(3*D+5)%16):(w=v^(x|~C),A=7*D%16);const B=C;C=v,v=x,x=x+r(b+w+s[S]+_[A]&4294967295,n[z][S%4]),b=B}return[f+b&4294967295,p+x&4294967295,m+v&4294967295,y+C&4294967295]}const l=a(t);let c=[...e];for(let h=0;h<l.length;h+=64)c=o(l.substring(h,h+64),c);let d="";return c.forEach(h=>{for(let u=0;u<4;u++)d+=(h>>>8*u&255).toString(16).padStart(2,"0")}),d}function fa(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 h=d&4294967295,u=d>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(h>>>8*f&255);return c}function r(c,d){const h=[];for(let v=0;v<16;v++)h[v]=c.charCodeAt(v*4)&255|(c.charCodeAt(v*4+1)&255)<<8|(c.charCodeAt(v*4+2)&255)<<16|(c.charCodeAt(v*4+3)&255)<<24;for(let v=16;v<64;v++){const C=s(h[v-15],7)^s(h[v-15],18)^h[v-15]>>>3,S=s(h[v-2],17)^s(h[v-2],19)^h[v-2]>>>10;h[v]=h[v-16]+C+h[v-7]+S&4294967295}let[u,f,p,m,y,_,b,x]=d;for(let v=0;v<64;v++){const C=s(y,6)^s(y,11)^s(y,25),S=y&_^~y&b,w=x+C+S+e[v]+h[v]&4294967295,A=s(u,2)^s(u,13)^s(u,22),z=u&f^u&p^f&p,D=A+z&4294967295;x=b,b=_,_=y,y=m+w&4294967295,m=p,p=f,f=u,u=w+D&4294967295}return[d[0]+u&4294967295,d[1]+f&4294967295,d[2]+p&4294967295,d[3]+m&4294967295,d[4]+y&4294967295,d[5]+_&4294967295,d[6]+b&4294967295,d[7]+x&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let d=3;d>=0;d--)l+=(c>>>8*d&255).toString(16).padStart(2,"0")}),l}function ma(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,o=n[s++]||0,l=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|o>>6,h=o&63;e+=t[l]+t[c]+(s>n.length+1?"=":t[d])+(s>n.length?"=":t[h])}return e}function ga(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),o=t.indexOf(i.charAt(s++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(d))}return e}function _a(){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 He={md5:pa,sha256:fa,base64Encode:ma,base64Decode:ga,uuid:_a},$=new Map;async function Q(i,t={}){const{crossOrigin:e="anonymous"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function ya(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 Me(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return $.has(i)?$.get(i):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=s,o.defer=n,o.onload=()=>{$.set(i,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${i}`))},o.src=i,document.head.appendChild(o)})}async function Te(i,t={}){const{media:e="all"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function va(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 ba(i,t="image"){switch(t){case"image":return Q(i);case"script":return Me(i);case"stylesheet":case"style":return Te(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function xa(i){return $.has(i)}function Ea(){$.clear()}function ka(i){$.delete(i)}const Ie={loadImage:Q,loadImages:ya,loadScript:Me,loadStylesheet:Te,loadFont:va,preload:ba,isLoaded:xa,clearCache:Ea,clearCacheByUrl:ka},wa={string:oe,array:he,object:fe,number:_e,date:be,debounce:xe,throttle:Ee,validator:mt,crypto:He,preload:Ie};function Ca(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 Gt{constructor(){this.children={},this.keys=[]}}class ht{constructor(){this.root=new Gt}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new Gt),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class Ae{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new ht,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),o=Reflect.set(e,s,n,r),l=this.resolvePath(e,s);return this.notify(l,n,a),this.queueUpdate(l,n),o},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),d=Reflect.set(r,a,o,l),h=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(h,o,c),this.queueUpdate(h,o),d},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[g.path]?`${t[g.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((o,l)=>(o[l]||(o[l]={}),o[l]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=Ca(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":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new ht,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:o=null}=e,l=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,d=>{const h=this.persistedKeys.get(t);h&&(h.debounce>0?(h.timeout&&clearTimeout(h.timeout),h.timeout=setTimeout(()=>{this._persistSave(t,d,h.storage,{version:h.version,encrypt:h.encrypt,encryptionKey:h.encryptionKey})},h.debounce)):this._persistSave(t,d,h.storage,{version:h.version,encrypt:h.encrypt,encryptionKey:h.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=localStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),d=Reflect.set(r,a,o,l),h=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(h,o,c),this.queueUpdate(h,o),d},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(t=>{if(!this._isObserving){this._isObserving=!0;try{t.forEach(e=>{e.addedNodes.forEach(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new ht,this.updateQueue.clear(),this.snapshots=[]}}class ut{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 ze{constructor(){this.stores=new Map}createStore(t,e){const s=new ut(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof ut&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Pe{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function 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 Ae,Sa=new Pe,gt=new ze;function La(i,t){return gt.createStore(i,t)}function Da(i){return gt.getStore(i)}const M={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}},tt=[];function Qt(){if(typeof window<"u"&&window.kupolaConfig)try{yt(M,window.kupolaConfig),$e()}catch(i){console.warn("[Kupola] Failed to parse window.kupolaConfig:",i)}}function $e(){tt.forEach(i=>{try{i(M)}catch(t){console.warn("[Kupola] Error in config change listener:",t)}})}function Be(i){typeof i=="function"&&tt.push(i)}function Ha(i){const t=tt.indexOf(i);t>-1&&tt.splice(t,1)}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Qt):Qt());function Ma(i){yt(M,i),$e()}function lt(i){return i?Aa(M,i):M}function _t(){return M.paths.base+M.paths.icons.replace(/^\//,"")}function Ta(){return M.paths.base}function qe(){return M.theme.default}function Oe(){return M.theme.brand}function Ia(){return M.http}function U(){return M.ui}function Y(){return M.zIndex}function Z(){return M.security}function Fe(){return M.performance}function Ne(){return M.message}function Re(){return M.notification}function Ve(){return M.validation}function yt(i,t){for(const e in t)t[e]instanceof Object&&e in i&&i[e]instanceof Object?yt(i[e],t[e]):i[e]=t[e];return i}function Aa(i,t){return t.split(".").reduce((e,s)=>(e&&e[s])!==void 0?e[s]:void 0,i)}const Ke="kupola-theme",We="kupola-brand";Be(i=>{const t=document.querySelector("[data-theme-toggle]");if(t){const e=O();vt(t),G(e)}});const V=[{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 O(){return localStorage.getItem(Ke)||qe()}function G(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(Ke,i);const t=document.querySelector("[data-theme-toggle]");t&&(t.setAttribute("data-current-theme",i),vt(t))}function j(){return localStorage.getItem(We)||Oe()}function et(i){const t=V.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(We,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function vt(i){const t=i.querySelector(".theme-icon");if(t){const e=O(),s=_t();t.src=e==="dark"?s+"sun.svg":s+"moon.svg"}}function te(i){i.preventDefault();const e=O()==="dark"?"light":"dark";G(e)}function Ue(){const i=document.querySelector("[data-theme-toggle]"),t=O();G(t);const e=j();et(e),i&&(vt(i),i.removeEventListener("click",te),i.addEventListener("click",te));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",V.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=o.name,s.appendChild(l)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(o){o.stopPropagation()});function r(o){s&&n&&!s.contains(o.target)&&!n.contains(o.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");et(c),s&&(s.style.display="none")})})}function za(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",O()),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=_t();return t.src=O()==="dark"?e+"sun.svg":e+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(s){s.preventDefault();const r=O()==="dark"?"light":"dark";G(r)},i}function Pa(){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",V.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=a.name,i.appendChild(o)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",j()),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=V.find(a=>a.id===j()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=V.find(a=>a.id===j()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");et(l),i.style.display="none"})}),{toggleBtn:t,container:i}}function $a(i,t={}){const s=Z()?.sanitizeHtml||{};if(!s.enabled&&!t.force)return i;const n=t.allowedTags||s.allowedTags||[],r=t.allowedAttributes||s.allowedAttributes||{};if(typeof i!="string")return i;const o=new DOMParser().parseFromString(i,"text/html");return o.body.querySelectorAll("*").forEach(c=>{const d=c.tagName.toLowerCase();if(!n.includes(d)){c.remove();return}Array.from(c.attributes).forEach(h=>{const u=h.name.toLowerCase();(r[d]||[]).includes(u)||c.removeAttribute(h.name)})}),o.body.innerHTML}function Ba(i){if(typeof i!="string")return i;const t=document.createElement("div");return t.textContent=i,t.innerHTML}function qa(i){return typeof i!="string"?i:new DOMParser().parseFromString(i,"text/html").body.textContent||""}function Oa(i,t,e={}){const n=Z()?.maskData||{};if(!n.enabled&&!e.force||i==null)return i;const a=(e.patterns||n.patterns||{})[t];if(!a)return i;const o=typeof a.regex=="string"?new RegExp(a.regex):a.regex;return String(i).replace(o,a.replace)}function Fa(i,t){const s=Z()?.secureId||{},n=i||s.length||16,r=s.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(typeof crypto>"u"||!crypto.getRandomValues){let l="";for(let c=0;c<n;c++)l+=r[Math.floor(Math.random()*r.length)];return t?`${t}_${l}`:l}const a=new Uint32Array(n);crypto.getRandomValues(a);let o="";for(let l=0;l<n;l++)o+=r[a[l]%r.length];return t?`${t}_${o}`:o}class Ye{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(e)){const r=s.replace("ds-",""),a=this.initializers.get(r)||this.initializers.get(s);if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(e)){const r=s.replace("ds-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s);if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const E=new Ye,Na=[{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 Na)i.attr&&!E._dataAttrs.includes(i.attr)&&E._dataAttrs.push(i.attr),i.cls&&!E._cssClasses.includes(i.cls)&&E._cssClasses.push(i.cls);class 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 nt,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
|
-
<div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">
|
|
3
|
-
<div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>
|
|
4
|
-
<div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>
|
|
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 pt(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 Xe{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&&pt(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 o=E.get(e);if(o)try{await o(t);return}catch(l){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,l)}}let s=this.components.get(e);if(!s){try{s=await this.getAsync(e)}catch(o){console.error(`Failed to load component ${e}:`,o);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=s;n&&n.split(",").forEach(o=>{const l=this.mixins.get(o.trim());l&&pt(r,l)});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)),E.initialize(n).catch(()=>{});const r=E._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{E.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 o=this.instances.get(a);o&&(o.unmount(),this.instances.delete(a))}),E.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{E.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()}}exports.kupolaRegistry=null;typeof window<"u"&&(exports.kupolaRegistry=new Xe);function Ra(){if(Z().xssProtection&&typeof document<"u"){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild))}}async function ft(){if(typeof window<"u"){Ra();const i=lt();q.loadPersisted(),q.bind(),Ue(),i.components?.autoInit!==!1&&(await E.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ft):typeof window<"u"&&setTimeout(ft,0);function Va(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t)}function Ka(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t)}function Wa(i){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(i):Promise.resolve()}function Ua(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(i,t)}function Ya(i,...t){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(i,...t)}function Xa(i,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${i}"): options must be an object`);t.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t.componentClass):t.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t.lazy),t.init?E.register(i,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&E.register(i,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class bt{constructor(t={}){const e=lt();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||e.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||e.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(s=>(console.warn(`Missing translation: ${s}`),s)),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 N=new bt;function ja(i){return new bt(i)}function Ja(i,t={}){return N.t(i,t)}function Za(i,t,e={}){return N.n(i,t,e)}function Ga(i){return N.setLocale(i)}function Qa(){return N.getLocale()}function to(i,t={}){return N.formatDate(i,t)}function eo(i,t={}){return N.formatNumber(i,t)}function so(i,t,e={}){return N.formatCurrency(i,t,e)}class je{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,n={}){const{scope:r=null,once:a=!1,passive:o=!1,capture:l=!1}=n,c=this._generateId(),d={id:c,target:t,eventName:e,handler:s,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=u=>{a&&this.offById(c),s.call(t,u)};const h=this._getEventKey(t,e);return this._listeners.has(h)||this._listeners.set(h,[]),this._listeners.get(h).push(d),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,d.wrappedHandler,{passive:o,capture:l}),{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(o=>o.handler!==s);r.forEach(o=>{o.handler===s&&(t.removeEventListener(e,o.wrappedHandler),this._removeFromScope(o))}),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,o]of this._listeners)o.forEach(l=>{n.includes(l.id)&&r.add(l.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[o]=r.split(":");o===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 H=new je;function io(i,t,e,s){return H.on(i,t,e,s)}function no(i,t,e,s){return H.once(i,t,e,s)}function ro(i,t,e){H.off(i,t,e)}function ao(i,t,e){return H.emit(i,t,e)}function oo(i,t){return H.emitGlobal(i,t)}function lo(i){H.offByScope(i)}function co(i,t){H.offAll(i,t)}function ho(i,t){return H.getListenerCount(i,t)}class Je{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=U();this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.closeOnClick=e.closeOnClick!==void 0?e.closeOnClick:s.dropdown?.closeOnClick!==void 0?s.dropdown.closeOnClick:!0,this.appendToBody=e.appendToBody!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(s=>s.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this._triggerKeydownHandler=t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.menu&&this.menu.contains(t.target);!e&&!s&&this.hideMenu()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=e=>this._itemClickHandler(e),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,s=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const n=this.menu.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?(this.menu.style.top=`${t.top-n.height-4}px`,this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+n.width>s?(this.menu.style.left=`${t.right-n.width}px`,this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const n=e-t.bottom,r=t.top;n<menuRect.height&&r>n?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>s?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex,this._originalDisplay=this.menu.style.display;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=e,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){!this.menu||!this._originalParent||(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this.menu.style.display=this._originalDisplay||"",this._originalParent=null,console.log("[Dropdown] Menu restored from body"))}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this._itemClickHandler||(this._itemClickHandler=e=>{e.stopPropagation();const s=e.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(n=>n.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach((e,s)=>{if(e.type==="divider"){const n=document.createElement("div");n.className="ds-dropdown__divider",this.menu.appendChild(n)}else{const n=document.createElement("div");n.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),n.textContent=e.text||e.label||"",e.value!==void 0&&n.setAttribute("data-value",e.value),e.icon&&(n.innerHTML=e.icon+n.innerHTML),e.disabled&&n.classList.add("is-disabled"),n._dropdownItemClickHandler=r=>this._itemClickHandler(r),n.addEventListener("click",n._dropdownItemClickHandler),this.menu.appendChild(n)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function xt(i,t){i._kupolaDropdown&&i._kupolaDropdown.destroy();const e=new Je(i,t);e.init(),i._kupolaDropdown=e}function uo(i=document){i.querySelectorAll(".ds-dropdown").forEach(t=>{xt(t)})}function Et(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}function po(){document.querySelectorAll(".ds-dropdown").forEach(i=>{Et(i)})}E.register("dropdown",xt,Et);class Ze{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=e.appendToBody!==!1,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const 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=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.optionsEl&&this.optionsEl.contains(t.target);!e&&!s&&this.hideOptions()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const 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._optionClickHandler||(this._optionClickHandler=e=>{e.stopPropagation();const s=e.currentTarget;if(s.classList.contains("is-disabled"))return;const n=s.getAttribute("data-value");this.multiple?this._toggleMultiOption(n,s):this._selectSingleOption(n,s)}),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._selectOptionClickHandler=n=>this._optionClickHandler(n),s.addEventListener("click",s._selectOptionClickHandler),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._selectOptionClickHandler=e=>this._optionClickHandler(e),t.addEventListener("click",t._selectOptionClickHandler)})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=e,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){!this.optionsEl||!this._originalParent||(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,s=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const n=this.optionsEl.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?this.optionsEl.style.top=`${t.top-n.height-4}px`:this.optionsEl.style.top=`${t.bottom+4}px`,t.left+n.width>s?this.optionsEl.style.left=`${t.right-n.width}px`:this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(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.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function kt(i,t){const e=new Ze(i,t);e.init(),i._kupolaSelect=e}function fo(i=document){i.querySelectorAll(".ds-select").forEach(t=>{kt(t)})}function Ge(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}E.register("select",kt,Ge);class Qe{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=U(),n=s.datepicker?.weekStart!==void 0?s.datepicker.weekStart:1;this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart!==void 0?e.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=e.appendToBody!==!1,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&(this._endInputClickHandler=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this._endInputClickHandler)),this._documentClickListener=H.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),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;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,n>=a?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top=`${t.top-a-4}px`,this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(s=>{s!==this.calendarEl&&(s.style.display="none",s.setAttribute("hidden",""))}),e||(this.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){!this.element.contains(t.target)&&!this.calendarEl.contains(t.target)&&(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const t=Y().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){!this.calendarEl||!this._originalParent||(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(p=>{p._dayClickHandler&&p.removeEventListener("click",p._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",p=>{p.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",p=>{p.stopPropagation(),this.viewMode="months",this._renderCalendar()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.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>',o.addEventListener("click",p=>{p.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(p=>{const m=document.createElement("span");m.className="ds-datepicker__weekday",m.textContent=p,l.appendChild(m)}),t.appendChild(l);const d=document.createElement("div");d.className="ds-datepicker__days";const h=new Date(e,s,1).getDay(),u=new Date(e,s+1,0).getDate(),f=(h-this.weekStart+7)%7;for(let p=0;p<f;p++){const m=document.createElement("span");m.className="ds-datepicker__day ds-datepicker__day--empty",d.appendChild(m)}for(let p=1;p<=u;p++){const m=new Date(e,s,p),y=document.createElement("button");y.className="ds-datepicker__day",y.type="button",y.textContent=p,this._formatDate(m),this._isToday(m)&&y.classList.add("is-today"),this.range?((this._isSameDay(m,this.rangeStart)||this._isSameDay(m,this.rangeEnd))&&y.classList.add("is-selected"),this._isInRange(m)&&y.classList.add("is-in-range")):this._isSameDay(m,this.selectedDate)&&y.classList.add("is-selected"),this._isDateDisabled(m)&&(y.classList.add("is-disabled"),y.disabled=!0);const _=()=>this._selectDate(m);y.addEventListener("click",_),y._dayClickHandler=_,d.appendChild(y)}if(t.appendChild(d),this.showToday){const p=document.createElement("div");p.className="ds-datepicker__footer";const m=document.createElement("button");m.className="ds-datepicker__today-btn",m.type="button",m.textContent=this.todayText,m.addEventListener("click",_=>{_.stopPropagation(),this._goToToday()});const y=document.createElement("button");y.className="ds-datepicker__clear-btn",y.type="button",y.textContent=this.clearText,y.addEventListener("click",_=>{_.stopPropagation(),this._clearDate()}),p.appendChild(m),p.appendChild(y),t.appendChild(p)}}_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 o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.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>',o.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const d=s+c,h=document.createElement("button");h.className="ds-datepicker__year-cell",h.type="button",h.textContent=d,d===e&&h.classList.add("is-selected"),h.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setFullYear(d),this.viewMode="months",this._renderCalendar()}),l.appendChild(h)}t.appendChild(l)}_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",l=>{l.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",l=>{l.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",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),s.appendChild(n),s.appendChild(r),s.appendChild(a),t.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((l,c)=>{const d=document.createElement("button");d.className="ds-datepicker__month-cell",d.type="button",d.textContent=l,c===this.currentDate.getMonth()&&d.classList.add("is-selected"),d.addEventListener("click",h=>{h.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),o.appendChild(d)}),t.appendChild(o)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this.endInput&&this._endInputClickHandler&&this.endInput.removeEventListener("click",this._endInputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function wt(i,t){const e=new Qe(i,t);e.init(),i._kupolaDatepicker=e}function mo(i=document){i.querySelectorAll(".ds-datepicker").forEach(t=>{wt(t)})}function ts(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}E.register("datepicker",wt,ts);class es{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=H.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const 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
|
-
<div class="ds-timepicker__section-label">Hour</div>
|
|
8
|
-
<div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>
|
|
9
|
-
</div>`,t+=`<div class="ds-timepicker__section">
|
|
10
|
-
<div class="ds-timepicker__section-label">Min</div>
|
|
11
|
-
<div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>
|
|
12
|
-
</div>`,this.showSeconds&&(t+=`<div class="ds-timepicker__section">
|
|
13
|
-
<div class="ds-timepicker__section-label">Sec</div>
|
|
14
|
-
<div class="ds-timepicker__grid ds-timepicker__grid--second" data-type="second"></div>
|
|
15
|
-
</div>`),this.use12Hour&&(t+=`<div class="ds-timepicker__section ds-timepicker__section--ampm">
|
|
16
|
-
<div class="ds-timepicker__grid ds-timepicker__grid--ampm" data-type="ampm"></div>
|
|
17
|
-
</div>`),this.panelEl.innerHTML=`
|
|
18
|
-
<div class="ds-timepicker__header">
|
|
19
|
-
<div class="ds-timepicker__display">
|
|
20
|
-
<span class="ds-timepicker__display-hour">${String(this.selectedHour).padStart(2,"0")}</span>
|
|
21
|
-
<span class="ds-timepicker__separator">:</span>
|
|
22
|
-
<span class="ds-timepicker__display-minute">${String(this.selectedMinute).padStart(2,"0")}</span>
|
|
23
|
-
${this.showSeconds?'<span class="ds-timepicker__separator">:</span><span class="ds-timepicker__display-second">'+String(this.selectedSecond).padStart(2,"0")+"</span>":""}
|
|
24
|
-
${this.use12Hour?'<span class="ds-timepicker__display-ampm">'+(this.selectedHour>=12?"PM":"AM")+"</span>":""}
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
<div class="ds-timepicker__body">${t}</div>
|
|
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 Ct(i,t){const e=new es(i,t);e.init(),i._kupolaTimepicker=e}function go(i=document){i.querySelectorAll(".ds-timepicker").forEach(t=>{Ct(t)})}function ss(i){i._kupolaTimepicker&&(i._kupolaTimepicker.destroy(),i._kupolaTimepicker=null)}E.register("timepicker",Ct,ss);class is{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 o=a.touches?a.touches[0].clientX:a.clientX,l=a.touches?a.touches[0].clientY:a.clientY,c=this.track.getBoundingClientRect();let d;this.vertical?d=1-(l-c.top)/c.height:d=(o-c.left)/c.width,d=Math.max(0,Math.min(1,d));const h=parseFloat(this.input?.min||0),u=parseFloat(this.input?.max||100),f=parseFloat(this.input?.step||1);let p=h+d*(u-h);if(p=Math.round(p/f)*f,p=Math.max(h,Math.min(u,p)),e==="start"&&this.range&&this.inputEnd){const m=parseFloat(this.inputEnd.value);p>m&&(p=m)}if(e==="end"&&this.range&&this.input){const m=parseFloat(this.input.value);p<m&&(p=m)}e==="start"&&this.input?this.input.value=p:e==="end"&&this.inputEnd&&(this.inputEnd.value=p),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),o=parseFloat(this.input?.max||100),l=parseFloat(this.input?.step||1);let c=a+r*(o-a);if(c=Math.round(c/l)*l,this.range){const d=parseFloat(this.input?.value||0),h=parseFloat(this.inputEnd?.value||0),u=Math.abs(c-d),f=Math.abs(c-h);u<=f?this.input&&(this.input.value=Math.min(c,h)):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 o=parseFloat(s.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),o=Math.min(a,o+n);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),o=Math.max(r,o-n);break;case"Home":t.preventDefault(),o=r;break;case"End":t.preventDefault(),o=a;break;default:return}s.value=o,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 St(i,t){if(!i.__kupolaInitialized)try{const e=new is(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function ns(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function _o(){document.querySelectorAll(".ds-slider").forEach(i=>{St(i)})}E.register("slider",St,ns);class rs{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 Lt(i,t){if(i.__kupolaInitialized)return;const e=new rs(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function yo(i=document){i.querySelectorAll(".ds-carousel").forEach(t=>{Lt(t)})}function as(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}E.register("carousel",Lt,as);class os{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 os(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function ls(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function vo(){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)})}E.register("drawer",st,ls);class P{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");const s=U(),n=s.modal?.backdropClick!==void 0?s.modal.backdropClick:!0;this.fullscreen=e.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=e.closableOnMask!==void 0?e.closableOnMask:n,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=r=>{this.escClose&&r.key==="Escape"&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=r=>{this.closableOnMask&&r.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||(P._openCount=(P._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&&(P._openCount=Math.max(0,(P._openCount||0)-1),this._isOpen=!1,P._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&&(P._openCount=Math.max(0,(P._openCount||0)-1),this._isOpen=!1,P._openCount===0&&(document.body.style.overflow=""))}}P._openCount=0;function Dt(i={}){const{title:t="",content:e="",html:s=!1,width:n="480px",fullscreen:r=!1,showCancel:a=!0,showConfirm:o=!0,confirmText:l="OK",cancelText:c="Cancel",confirmClass:d="ds-btn--brand",cancelClass:h="ds-btn--ghost",closable:u=!0,maskClosable:f=!0,onConfirm:p,onCancel:m,onOpen:y,onClose:_,footer:b=null,size:x=U().defaultSize}=i,v=x==="sm"?"ds-btn--sm":x==="lg"?"ds-btn--lg":"",C=document.createElement("div");C.className="ds-modal-container";let S="";b!==null&&(typeof b=="string"?S=`<div class="ds-modal__footer">${b}</div>`:(o||a)&&(S=`<div class="ds-modal__footer">
|
|
30
|
-
${a?`<button class="ds-btn ${v} ${h}" data-modal-cancel>${c}</button>`:""}
|
|
31
|
-
${o?`<button class="ds-btn ${v} ${d}" data-modal-confirm>${l}</button>`:""}
|
|
32
|
-
</div>`)),C.innerHTML=`
|
|
33
|
-
<div class="ds-modal-mask">
|
|
34
|
-
<div class="ds-modal${r?" ds-modal--fullscreen":""}" style="${r?"":"max-width: "+n}">
|
|
35
|
-
<div class="ds-modal__header">
|
|
36
|
-
<span class="ds-modal__title"></span>
|
|
37
|
-
${u?`<button class="ds-modal__close" aria-label="Close">
|
|
38
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
39
|
-
<path d="M18 6L6 18M6 6l12 12"/>
|
|
40
|
-
</svg>
|
|
41
|
-
</button>`:""}
|
|
42
|
-
</div>
|
|
43
|
-
<div class="ds-modal__body"></div>
|
|
44
|
-
${S}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
`,document.body.appendChild(C);const w=new P(C,{fullscreen:r,closableOnMask:f}),A=C.querySelector(".ds-modal__title");A&&(A.textContent=t);const z=C.querySelector(".ds-modal__body");z&&(s?z.innerHTML=e:z.textContent=e);const D=C.querySelector("[data-modal-confirm]"),B=C.querySelector("[data-modal-cancel]");let jt=!1;const Jt=async()=>{if(p){D.disabled=!0,D.classList.add("is-loading");try{if(await p()===!1){D.disabled=!1,D.classList.remove("is-loading");return}}catch{D.disabled=!1,D.classList.remove("is-loading");return}}jt=!0,w.close()},Zt=()=>{m&&m(),w.close()};D&&D.addEventListener("click",Jt),B&&B.addEventListener("click",Zt);const Js=()=>{setTimeout(()=>{D&&D.removeEventListener("click",Jt),B&&B.removeEventListener("click",Zt),w.destroy(),C.remove(),_&&_(jt)},300)},Zs=w.close.bind(w);return w.close=()=>{Zs(),Js()},w.open(),y&&setTimeout(()=>y(),50),w}function bo(i){return typeof i=="string"&&(i={content:i}),Dt({...i,showCancel:!0,showConfirm:!0})}function xo(i){return typeof i=="string"&&(i={content:i}),Dt({...i,showCancel:!1,showConfirm:!0})}function Ht(i){if(i.__kupolaInitialized)return;const t=new P(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 Eo(){document.querySelectorAll(".ds-modal-container").forEach(i=>{Ht(i)})}E.register("modal",Ht,cs);class ko{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,o={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>'},l=document.createElement("div");l.className="ds-modal-container",l.innerHTML=`
|
|
48
|
-
<div class="ds-modal-mask">
|
|
49
|
-
<div class="ds-modal" style="max-width: 360px">
|
|
50
|
-
<div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">
|
|
51
|
-
<div class="ds-dialog__icon ds-dialog__icon--${e}">${o[e]}</div>
|
|
52
|
-
${s?'<div class="ds-dialog__title"></div>':""}
|
|
53
|
-
<div class="ds-dialog__content"></div>
|
|
54
|
-
<div class="ds-dialog__actions">
|
|
55
|
-
${e==="confirm"||a?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}
|
|
56
|
-
<button class="ds-btn ${e==="confirm"?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>
|
|
57
|
-
${e==="confirm"?"Confirm":"OK"}
|
|
58
|
-
</button>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
`,document.body.appendChild(l),s&&(l.querySelector(".ds-dialog__title").textContent=s),l.querySelector(".ds-dialog__content").textContent=n;const c=l.querySelector(".ds-modal-mask"),d=l.querySelector("[data-dialog-confirm]"),h=l.querySelector("[data-dialog-cancel]"),u=function(_){_.key==="Escape"&&(a&&a(),y())},f=function(_){_.target===c&&(a&&a(),y())},p=function(){r&&r(),y()},m=function(){a&&a(),y()},y=()=>{c.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",u),c.removeEventListener("click",f),d&&d.removeEventListener("click",p),h&&h.removeEventListener("click",m),setTimeout(()=>l.remove(),300)};return c.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",p),h&&h.addEventListener("click",m),c.addEventListener("click",f),document.addEventListener("keydown",u),{close:y}}}const wo={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 t=Re(),{title:e,message:s,type:n="normal",duration:r=t.duration,position:a=t.position}=i,o=document.createElement("div");o.className=`ds-notification__item ds-notification__item--${n}`;const l={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>'};o.innerHTML=`
|
|
64
|
-
<div class="ds-notification__icon ds-notification__icon--${n}">${l[n]}</div>
|
|
65
|
-
<div class="ds-notification__content">
|
|
66
|
-
${e?'<div class="ds-notification__title"></div>':""}
|
|
67
|
-
${s?'<div class="ds-notification__message"></div>':""}
|
|
68
|
-
</div>
|
|
69
|
-
<button class="ds-notification__close">
|
|
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
|
-
</button>
|
|
72
|
-
`,e&&(o.querySelector(".ds-notification__title").textContent=e),s&&(o.querySelector(".ds-notification__message").textContent=s);let c=document.querySelector(".ds-notification");if(!c){c=document.createElement("div"),c.className=`ds-notification ds-notification--${a}`;const d=Y().notification;c.style.zIndex=d,c.style.transform="translateZ(0)",document.body.appendChild(c)}c.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),o.querySelector(".ds-notification__close").addEventListener("click",()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)}),r>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},r)}};function Co(){}const So={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 s=Ne(),{duration:n=s.duration,position:r=s.position}=e,a=s.maxCount||5,o=document.createElement("div");o.className=`ds-message__item ds-message__item--${t}`;const l={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>'};o.innerHTML=`
|
|
73
|
-
<div class="ds-message__icon ds-message__icon--${t}">${l[t]}</div>
|
|
74
|
-
<div class="ds-message__content"></div>
|
|
75
|
-
`,o.querySelector(".ds-message__content").textContent=i;let c=document.querySelector(".ds-message");if(!c){c=document.createElement("div"),c.className=`ds-message ds-message--${r}`;const h=Y().message;c.style.zIndex=h,c.style.transform="translateZ(0)",document.body.appendChild(c)}const d=c.querySelectorAll(".ds-message__item");if(d.length>=a){const h=d[0];h.classList.remove("is-visible"),h.classList.add("is-exiting"),setTimeout(()=>h.remove(),300)}c.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),n>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},n)}};function Lo(){}function ee(i){return i?i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class hs{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 o=Array.from(a.target.files);this.addFiles(o),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 o=Array.from(a.dataTransfer.files);this.addFiles(o)};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(o=>o.trim()),n=t.type,r=t.name.toLowerCase();if(!s.some(o=>o.startsWith(".")?r.endsWith(o):o.includes("/")?o.endsWith("/*")?n.startsWith(o.replace("/*","")):n===o:!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
|
-
<div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">
|
|
77
|
-
${s}
|
|
78
|
-
</div>
|
|
79
|
-
<span class="ds-fileupload__filename">${this.truncateFilename(ee(t.name))}</span>
|
|
80
|
-
<span class="ds-fileupload__size">${this.formatSize(t.size)}</span>
|
|
81
|
-
<button class="ds-fileupload__remove" type="button" aria-label="Remove file">
|
|
82
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
83
|
-
<path d="M18 6L6 18"/>
|
|
84
|
-
<path d="M6 6l12 12"/>
|
|
85
|
-
</svg>
|
|
86
|
-
</button>
|
|
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="${ee(t.name)}">
|
|
89
|
-
<button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">
|
|
90
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
91
|
-
<path d="M18 6L6 18"/>
|
|
92
|
-
<path d="M6 6l12 12"/>
|
|
93
|
-
</svg>
|
|
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 Mt(i){if(i.__kupolaInitialized)return;const t=new hs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function ds(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Do(){document.querySelectorAll(".ds-fileupload").forEach(i=>{Mt(i)})}E.register("fileupload",Mt,ds);class us{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 o=n.classList.contains("is-active");(this.defaultExpanded==="all"||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(s))&&(o=!0),o?(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 l=()=>{if(a)return;const c=n.classList.contains("is-active");this.accordion&&!c&&this.headers.forEach((d,h)=>{h!==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",l),this.headers.push({header:e,item:n,content:r,clickHandler:l,isDisabled:a}),this._listeners.push({el:e,event:"click",handler:l})})}_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 Tt(i,t){if(i.__kupolaInitialized)return;const e=new us(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function ps(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ho(){document.querySelectorAll(".ds-collapse").forEach(i=>{Tt(i)})}E.register("collapse",Tt,ps);class fs{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,o=Math.max(s,n,r),l=Math.min(s,n,r);let c=0,d=0,h=o;const u=o-l;if(d=o===0?0:u/o,o!==l)switch(o){case s:c=((n-r)/u+(n<r?6:0))/6;break;case n:c=((r-s)/u+2)/6;break;case r:c=((s-n)/u+4)/6;break}this.hue=Math.round(c*360),this.saturation=Math.round(d*100),this.brightness=Math.round(h*100),this.alpha=Math.round(a*100)}_HSBToColorString(t,e,s,n=1){e/=100,s/=100,n/=100;const r=h=>(h+t/60)%6,a=h=>s*(1-e*Math.max(0,Math.min(r(h),4-r(h),1))),o=Math.round(a(5)*255),l=Math.round(a(3)*255),c=Math.round(a(1)*255);if(this.mode==="rgb")return n<1?`rgba(${o}, ${l}, ${c}, ${n.toFixed(2)})`:`rgb(${o}, ${l}, ${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=`#${o.toString(16).padStart(2,"0")}${l.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,o=n.clientY-r.top;this.saturation=Math.round(a/r.width*100),this.brightness=Math.round((1-o/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=H.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 It(i,t){const e=new fs(i,t);e.init(),i._kupolaColorPicker=e}function Mo(i=document){i.querySelectorAll(".ds-color-picker").forEach(t=>{It(t)})}function ms(i){i._kupolaColorPicker&&(i._kupolaColorPicker.destroy(),i._kupolaColorPicker=null)}E.register("color-picker",It,ms);class gs{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 o=typeof r=="string"?r:this._formatDate(r);return e>=a&&e<=o})}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 o=0;o<s;o++){const l=document.createElement("span");l.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(l)}const r=new Date,a=this._formatDate(r);for(let o=1;o<=n;o++){const l=new Date(t,e,o),c=document.createElement("button");c.className="ds-calendar__day",c.textContent=o;const d=this._formatDate(l);d===a&&c.classList.add("is-today"),this._isSameDay(l,this.selectedDate)&&c.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(l)&&c.classList.add("is-range-start"),this._isRangeEnd(l)&&c.classList.add("is-range-end"),this._isDateInRange(l)&&c.classList.add("is-in-range"));const h=this._getEventsForDate(l);if(h.length>0){c.classList.add("has-events");const f=document.createElement("span");f.className="ds-calendar__day-event",f.style.backgroundColor=h[0].color||"#007bff",c.appendChild(f)}const u=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(f=>f.classList.remove("is-selected")),c.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(l,this.rangeEnd)?(this.rangeStart=l,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(l<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=l):this.rangeEnd=l,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=l,this.onSelect&&this.onSelect({date:l,dateStr:d}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:l,dateStr:d},bubbles:!0}))),h.forEach(f=>{this.onEventClick&&this.onEventClick(f,l)}),this.render()};c.addEventListener("click",u),this._listeners.push({el:c,event:"click",handler:u}),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 o=new Date,l=this._formatDate(o);for(let c=0;c<7;c++){const d=new Date(n);d.setDate(n.getDate()+c);const h=document.createElement("button");h.className="ds-calendar__day ds-calendar__day--week";const u=document.createElement("span");u.className="ds-calendar__day-header",u.textContent=this.i18n.shortWeekdays[d.getDay()],h.appendChild(u);const f=document.createElement("span");f.className="ds-calendar__day-number",f.textContent=d.getDate(),h.appendChild(f);const p=this._formatDate(d);p===l&&h.classList.add("is-today"),this._isSameDay(d,this.selectedDate)&&h.classList.add("is-selected");const m=this._getEventsForDate(d);if(m.length>0){const _=document.createElement("span");_.className="ds-calendar__day-events",m.slice(0,3).forEach(b=>{const x=document.createElement("span");x.className="ds-calendar__day-event",x.style.backgroundColor=b.color||"#007bff",_.appendChild(x)}),h.appendChild(_)}const y=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(_=>_.classList.remove("is-selected")),h.classList.add("is-selected"),this.selectedDate=d,this.onSelect&&this.onSelect({date:d,dateStr:p}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:d,dateStr:p},bubbles:!0})),this.render()};h.addEventListener("click",y),this._listeners.push({el:h,event:"click",handler:y}),this.daysEl.appendChild(h)}}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 At(i,t){if(!i.__kupolaInitialized)try{const e=new gs(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function _s(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function To(){document.querySelectorAll(".ds-calendar").forEach(i=>{At(i)})}E.register("calendar",At,_s);class ys{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 zt(i,t){if(i.__kupolaInitialized)return;const e=new ys(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function vs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Io(){document.querySelectorAll(".ds-dynamic-tags").forEach(i=>{zt(i)})}E.register("dynamic-tags",zt,vs);class Pt{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
|
-
<button class="ds-image-preview__close" type="button" aria-label="Close preview">
|
|
97
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
98
|
-
<path d="M18 6L6 18"/>
|
|
99
|
-
<path d="M6 6l12 12"/>
|
|
100
|
-
</svg>
|
|
101
|
-
</button>
|
|
102
|
-
<div class="ds-image-preview__nav">
|
|
103
|
-
<button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--prev" type="button" aria-label="Previous image">
|
|
104
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
105
|
-
<polyline points="15 18 9 12 15 6"/>
|
|
106
|
-
</svg>
|
|
107
|
-
</button>
|
|
108
|
-
<button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--next" type="button" aria-label="Next image">
|
|
109
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
110
|
-
<polyline points="9 18 15 12 9 6"/>
|
|
111
|
-
</svg>
|
|
112
|
-
</button>
|
|
113
|
-
</div>
|
|
114
|
-
<div class="ds-image-preview__toolbar">
|
|
115
|
-
<button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom in" data-action="zoom-in">
|
|
116
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
117
|
-
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
118
|
-
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
119
|
-
</svg>
|
|
120
|
-
</button>
|
|
121
|
-
<button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom out" data-action="zoom-out">
|
|
122
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
123
|
-
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
124
|
-
</svg>
|
|
125
|
-
</button>
|
|
126
|
-
<button class="ds-image-preview__toolbar-btn" type="button" aria-label="Reset zoom" data-action="zoom-reset">
|
|
127
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
128
|
-
<path d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/>
|
|
129
|
-
<line x1="12" y1="5" x2="12" y2="19"/>
|
|
130
|
-
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
131
|
-
</svg>
|
|
132
|
-
</button>
|
|
133
|
-
<button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate left" data-action="rotate-left">
|
|
134
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
135
|
-
<polyline points="1 4 1 10 7 10"/>
|
|
136
|
-
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>
|
|
137
|
-
</svg>
|
|
138
|
-
</button>
|
|
139
|
-
<button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate right" data-action="rotate-right">
|
|
140
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
141
|
-
<polyline points="23 4 23 10 17 10"/>
|
|
142
|
-
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
|
|
143
|
-
</svg>
|
|
144
|
-
</button>
|
|
145
|
-
</div>
|
|
146
|
-
<div class="ds-image-preview__content">
|
|
147
|
-
<img src="" alt="" />
|
|
148
|
-
</div>
|
|
149
|
-
<div class="ds-image-preview__info">
|
|
150
|
-
<div class="ds-image-preview__title"></div>
|
|
151
|
-
<div class="ds-image-preview__meta"></div>
|
|
152
|
-
</div>
|
|
153
|
-
<div class="ds-image-preview__indicators"></div>
|
|
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",o=>{const l=a.getAttribute("data-action");this.handleToolbarAction(l)})}),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"),o=this.images[this.currentIndex];t.src=o.src,t.alt=o.alt||"",e.textContent=o.title||"",s.textContent=o.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((l,c)=>`
|
|
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(l=>{const c=()=>{this.goTo(parseInt(l.dataset.index))};l.addEventListener("click",c),l._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 K=null;function Ao(){K||(K=new Pt),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;K.show(t,e)})})}function zo(i,t=0){K||(K=new Pt),K.show(i,t)}class bs{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(o=>{o.nodeType===Node.TEXT_NODE&&e.push(o)}),e.forEach(o=>o.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 $t(i,t){if(i.__kupolaInitialized)return;const e=new bs(i,t);i.__kupolaInstance=e,i.__kupolaInitialized=!0}function xs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Po(){document.querySelectorAll(".ds-tag").forEach(i=>{$t(i)})}E.register("tag",$t,xs);class Es{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,o=performance.now(),l=0,c=d=>{const h=d-o,u=Math.min(h/a,1),f=1-Math.pow(1-u,3),p=l+(s-l)*f;let m;s>=1e6?m=(p/1e6).toFixed(1)+"M":s>=1e3?m=(p/1e3).toFixed(1)+"K":Number.isInteger(s)?m=Math.floor(p).toLocaleString():m=p.toFixed(2),this.valueElement.textContent=n+m+r,u<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),o=n.substring(r.index+r[0].length),l=parseFloat(r[0].replace(",","")),c=parseFloat(t),d=performance.now(),h=u=>{const f=u-d,p=Math.min(f/s,1),m=1-Math.pow(1-p,3),y=l+(c-l)*m;let _;c>=1e6?_=(y/1e6).toFixed(1)+"M":c>=1e3?_=(y/1e3).toFixed(1)+"K":Number.isInteger(c)?_=Math.floor(y).toLocaleString():_=y.toFixed(2),this.valueElement.textContent=a+_+o,p<1&&requestAnimationFrame(h)};requestAnimationFrame(h)}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(),o=l=>{const c=l-a,d=Math.min(c/s,1),h=1-Math.pow(1-d,3),u=n+(r-n)*h;this.progressFill.style.width=u+"%",d<1&&requestAnimationFrame(o)};requestAnimationFrame(o)}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 Bt(i){if(i.__kupolaInitialized)return;const t=new Es(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function ks(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function $o(){document.querySelectorAll(".ds-statcard").forEach(i=>{Bt(i)})}E.register("statcard",Bt,ks);class ws{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 _=1;_<r;_++)s.push(null);for(let _=new Date(this.startDate);_<=this.endDate;_.setDate(_.getDate()+1))s.push(new Date(_)),(_.getDay()===6||_.getTime()===this.endDate.getTime())&&(e.push(s),s=[]);const a=e.length,o=this.element.classList.contains("ds-heatmap--compact")?12:16,l=a*o,c=document.createElement("div");c.className="ds-heatmap__container";const d=document.createElement("div");d.className="ds-heatmap__labels-and-grid";const h=document.createElement("div");h.className="ds-heatmap__weekday-labels";const u=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(_=>{const b=document.createElement("div");b.className="ds-heatmap__weekday-label",b.textContent=_,b.style.height=u+"px",b.style.lineHeight=u+"px",h.appendChild(b)}),d.appendChild(h);const f=document.createElement("div");f.className="ds-heatmap__grid-container";const p=document.createElement("div");p.className="ds-heatmap__month-labels",p.style.width=l+"px";const m=this.getMonthLabels();m.forEach((_,b)=>{const x=document.createElement("div");x.className="ds-heatmap__month-label",x.textContent=_.label;const v=m[b+1];let C;v?C=Math.ceil((v.offset-_.offset)/7):C=a-Math.floor(_.offset/7),x.style.width=C*o+"px",p.appendChild(x)}),f.appendChild(p);const y=document.createElement("div");y.className="ds-heatmap__grid",e.forEach(_=>{const b=document.createElement("div");b.className="ds-heatmap__week-column",_.forEach(x=>{if(x===null){const v=document.createElement("div");v.className="ds-heatmap__cell",v.style.visibility="hidden",b.appendChild(v)}else{const v=this.getDataByDate(x),C=Math.max(...this.data.map(B=>B.value),1),S=this.getLevel(v,C),w=document.createElement("div");w.className="ds-heatmap__cell",w.dataset.date=this.formatDate(x),w.dataset.value=v,w.style.backgroundColor=this.getCellColor(S);const A=B=>this.showTooltip(B,x,v),z=()=>this.hideTooltip(),D=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(x),value:v})};w.addEventListener("mouseenter",A),w.addEventListener("mouseleave",z),w.addEventListener("click",D),this._listeners.push({el:w,event:"mouseenter",handler:A},{el:w,event:"mouseleave",handler:z},{el:w,event:"click",handler:D}),b.appendChild(w)}}),y.appendChild(b)}),f.appendChild(y),d.appendChild(f),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 o=document.createElement("div");o.className="ds-heatmap__legend-cell",o.style.backgroundColor=this.getCellColor(a),n.appendChild(o)}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
|
-
<div class="ds-heatmap__tooltip-date">${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日</div>
|
|
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 qt(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-heatmap-data");let e=[];if(t)try{e=JSON.parse(t)}catch{e=se()}else e=se();const s=new ws(i,{data:e,onCellClick:n=>{}});i.__kupolaInstance=s,i.__kupolaInitialized=!0}function Cs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Bo(){document.querySelectorAll(".ds-heatmap").forEach(i=>{qt(i)})}function se(){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"),l=s.getDay()===0||s.getDay()===6?Math.random()*20:Math.random()*50,c=Math.floor(l);i.push({date:`${n}-${r}-${a}`,value:c>0?c:Math.floor(Math.random()*30)+1})}return i}E.register("heatmap",qt,Cs);class Ss{constructor(t,e={}){this.element=t,this.tooltipEl=null,this.options=e;const s=U(),n=s.tooltip?.delay!==void 0?s.tooltip.delay:300;this.delay=e.delay!==void 0?e.delay:parseInt(t.getAttribute("data-tooltip-delay"))||n,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");if(!t)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;const e=Y().tooltip;this.tooltipEl.style.zIndex=e,this.tooltipEl.style.transform="translateZ(0)",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 Ot(i,t){const e=new Ss(i,t);e.init(),i._kupolaTooltip=e}function qo(i=document){i.querySelectorAll("[data-tooltip]").forEach(t=>{Ot(t)})}function Ls(i){i._kupolaTooltip&&(i._kupolaTooltip.destroy(),i._kupolaTooltip=null)}E.register("tooltip",Ot,Ls);class Ds{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 o=a.name||a.id,l=this.parseRules(a.getAttribute("data-validate")),c=this.getValue(a);for(const[d,h]of Object.entries(l))if((this.customValidators[d]||this.validators[d])?.(c,h))this.clearError(a);else{s[o]=this.getErrorMessage(d,h,a),this.showError(a,s[o]),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 l of r)await this.validateInputAsync(l)||(a=!0);const o={};return r.forEach(l=>{const c=l.name||l.id,d=l.parentElement.querySelector(".ds-input__error");d&&(o[c]=d.textContent)}),this.formStates[s]={valid:!a,errors:o,errorCount:Object.keys(o).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 o=this.customAsyncValidators[r]||this.asyncValidators[r];if(o)try{if(!await o(n,a,t))return this.showError(t,this.getErrorMessage(r,a,t)),!1}catch(l){return this.showError(t,l.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 Ds;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=>{const e=Ve(),s=e.trigger||"blur",n=()=>{e.showErrors&&setTimeout(()=>{const l=document.activeElement;if(l&&l.closest(".ds-select"))return;I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)},50)};(s==="blur"||s==="both")&&t.addEventListener("blur",n);const r=(l,c)=>{let d;return(...h)=>{clearTimeout(d),d=setTimeout(()=>l(...h),c)}},a=Fe(),o=r(()=>{if(!e.showErrors)return;const l=I.getValue(t);l.length>0||t.classList.contains("ds-input--error")?I.validateInput(t)&&l&&I.showSuccess(t):I.removeStatusIcon(t)},a.debounceDelay);(s==="input"||s==="both")&&t.addEventListener("input",o),t.addEventListener("keyup",l=>{l.key==="Enter"&&I.validateInput(t)&&t.value.trim()&&I.showSuccess(t)})})})}));class Hs{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
|
-
<div class="ds-virtual-list__item-content">
|
|
161
|
-
<div class="ds-virtual-list__item-icon">
|
|
162
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
163
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
164
|
-
<polyline points="14 2 14 8 20 8"/>
|
|
165
|
-
<line x1="16" y1="13" x2="8" y2="13"/>
|
|
166
|
-
<line x1="16" y1="17" x2="8" y2="17"/>
|
|
167
|
-
<polyline points="10 9 9 9 8 9"/>
|
|
168
|
-
</svg>
|
|
169
|
-
</div>
|
|
170
|
-
<div>
|
|
171
|
-
<div class="ds-virtual-list__item-title">${t.title||t.name||`Item ${e+1}`}</div>
|
|
172
|
-
<div class="ds-virtual-list__item-subtitle">${t.subtitle||"Subtitle"}</div>
|
|
173
|
-
</div>
|
|
174
|
-
</div>
|
|
175
|
-
`}init(){this.createStructure(),this.update(),this.bindEvents()}createStructure(){this.element.innerHTML=`
|
|
176
|
-
<div class="ds-virtual-list__scrollbar">
|
|
177
|
-
<div class="ds-virtual-list__scrollbar-track">
|
|
178
|
-
<div class="ds-virtual-list__scrollbar-thumb"></div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
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 o="",l=0;if(this.useDynamicHeight)l=this.getItemPositions()[n]?.start||0;else{const c=t?this.itemWidth:this.itemHeight;l=n*c}a.forEach((c,d)=>{const h=n+d,u=c[this.keyField]||h,f=this.selectedKey===u,p=this.getItemSize(h);o+=this._buildItemHtml(c,h,u,f,p,l,t),l+=p}),this.container.innerHTML=o,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,o){const l=n?" is-selected":"",c=this.renderItem(t,e);return o?`<div class="ds-virtual-list__item${l}" 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${l}" 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,o=n/(e-s||1)*a;this.scrollbarThumb.style.height=r+"px",this.scrollbarThumb.style.top=o+"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 o=this.dragStartTop+a;o=Math.max(0,Math.min(o,r)),this.scrollbarThumb.style.top=o+"px";const l=o/r*(s-e||0);this.element.scrollTop=l}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 ie(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 Ms(i){if(i.__kupolaInitialized)return;const t=i.getAttribute("data-virtual-list");let e=[];if(t)try{e=JSON.parse(t)}catch{e=ie(1e3)}else e=ie(1e3);const s=new Hs(i,{data:e,onItemClick:n=>{},onItemSelect: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}E.register("virtual-list",Ms,Ts);const Oo='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"',Ft={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 Nt(i,t=16,e="0 0 24 24"){const s=Ft[i];return s?`<svg ${Oo.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=Nt(e,s,n),t.classList.add("icon")})}const Fo={svg:Nt,render:it,PATHS:Ft};typeof document<"u"&&(document.readyState!=="loading"?it():document.addEventListener("DOMContentLoaded",()=>it()));class Is{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 Rt(i){if(i.__kupolaInitialized)return;const t=new Is(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function As(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function No(){document.querySelectorAll(".ds-countdown").forEach(t=>{Rt(t)})}E.register("countdown",Rt,As);class zs{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 Vt(i){if(!i.__kupolaInitialized)try{const t=new zs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function Ps(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function Ro(){document.querySelectorAll(".ds-number-input").forEach(i=>{Vt(i)})}E.register("number-input",Vt,Ps);class $s{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=H.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=H.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=H.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=H.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 o=this.container.querySelector(".ds-slider-captcha__target");if(o&&(o.style.left=this.targetX+s+e/2+"px",o.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",o.style.display="block"),this.hasDistractor){const l=this.container.querySelector(".ds-slider-captcha__target--distractor");l&&(l.style.left=this.distractorX+s+e/2+"px",l.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",l.style.display="block")}else{const l=this.container.querySelector(".ds-slider-captcha__target--distractor");l&&(l.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 l=this.trackData[this.trackData.length-1],c=this.currentX-l.x,d=n-l.t;if(d>0&&(r=c/d,this.trackData.length>1)){const h=this.trackData[this.trackData.length-2],u=l.t-h.t;if(u>0){const f=(l.x-h.x)/u;a=r-f}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:n,v:r,a});const o=this.container.querySelector(".ds-slider-captcha__point-count");o&&(o.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 h=this.trackData[d].x-this.trackData[d-1].x,u=this.trackData[d].t-this.trackData[d-1].t;u>0&&u<500&&n.push(h/u)}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 o=!1;for(const d of this.trackData)if(Math.abs(d.y)>2){o=!0;break}if(!o&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const l=this.trackData[this.trackData.length-1].t;if(l<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(l>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((h,u)=>h+u,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 Bs(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{const t=new $s(i);t.init(),i._kupolaSlideCaptcha=t})}function qs(i){i._kupolaSlideCaptcha&&(i._kupolaSlideCaptcha.destroy(),i._kupolaSlideCaptcha=null)}function Os(){document.querySelectorAll(".ds-slider-captcha").forEach(i=>{qs(i)})}E.register("slide-captcha",Bs,Os);class Fs{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 l=this.errorMessages[n];typeof l=="function"&&(l=l(a)),e.push(l)}}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(o=>{o.selected=a.includes(o.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 Ns(i){const t=document.querySelectorAll(i||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const s=new Fs(e);e._kupolaForm=s}),t.length}function Vo(i){return i._kupolaForm}function Ko(i){const t=i._kupolaForm;return t?t.validate():!1}E.register("form-validation",Ns);class Rs{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 Wo=new Rs;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 Kt{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 F extends Error{constructor(t,e,s){super(t),this.name="DependsError",this.code=e,this.cause=s,this.timestamp=Date.now()}}let ct=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null;function Uo(i){if(!i||typeof i.fetch!="function")throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");ct=i.fetch.bind(i)}function Yo(){return ct}function Xo(){ct=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(){Wo.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(t){throw new F("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,o=r+a;return await new Promise(l=>setTimeout(l,o)),this._fetchWithRetry(t,e+1)}const n=s instanceof F?s:new F(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 Ks 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;const s=lt("http");s?.baseURL&&!e.startsWith("http://")&&!e.startsWith("https://")&&(e=s.baseURL+e.replace(/^\//,""));for(const u in t)e=e.replace(`:${u}`,encodeURIComponent(t[u]));const n=[];for(const[u,f]of Object.entries(this.queryParams||{}))n.push(`${encodeURIComponent(u)}=${encodeURIComponent(f)}`);for(const u in t)this.config.source.includes(`:${u}`)||n.push(`${encodeURIComponent(u)}=${encodeURIComponent(t[u])}`);n.length>0&&(e+=(e.includes("?")?"&":"?")+n.join("&"));const r=s?.headers||{},a={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...r,...this.headers}};s?.withCredentials&&(a.credentials="include"),["POST","PUT","PATCH"].includes(a.method)&&(a.body=JSON.stringify(t));const o=ct;if(!o)throw new F("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const l=await o(e,a),c=typeof l.ok=="boolean"?l.ok:l.status>=200&&l.status<300,d=typeof l.status=="number"?l.status:0;if(!c)throw new F(`HTTP ${d}`,"HTTP_ERROR");return typeof l.json=="function"?await l.json():l.data!==void 0?l.data:l}}class Wt 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 Ws 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 Us extends R{async fetch(t){return await this.config.source(t)}}class Ys extends R{async fetch(){return this.config.source}}class Ut 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 F("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 F("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 Yt(i,t){const e=i.source;return typeof e=="function"?new Us(i,t):typeof e=="string"&&(e.startsWith("ws://")||e.startsWith("wss://"))?new Ut(i,t):typeof e=="string"&&(e.startsWith("/")||e.startsWith("http"))?new Ks(i,t):typeof e=="string"&&e.startsWith("localStorage:")?new Wt(i,t):typeof e=="string"&&e.startsWith("route:")?new Ws(i,t):new Ys(i,t)}function jo(i,t){const e={},s=new Kt,n=[];for(const r in t){let p=function(){return ne(i)},a=t[r];typeof a=="string"&&(a={source:a});const o={...a,cacheKey:a.cacheKey||`${r}-${JSON.stringify(ne(i))}`},l=Yt(o,s),c=T(null),d=T(!0),h=T(null),u=T(null);let f=0;async function m(){const b=++f;d.value=!0,h.value=null;try{const x=await l.getValue(p());if(b!==f)return;c.value=x,u.value=Date.now()}catch(x){if(b!==f)return;h.value=x.message||"Unknown error"}finally{b===f&&(d.value=!1)}}m();const y=l.subscribe(()=>{const b=s.getStale(l.cacheKey);b!=null&&(c.value=b,u.value=Date.now())});n.push(y);const _=Object.keys(i);_.length>0&&_.forEach(b=>{const x=i[b];if(x&&typeof x=="object"&&"value"in x&&x._subscribers){const v=()=>{l.invalidate(),m()};x._subscribers.add(v),n.push(()=>x._subscribers.delete(v))}}),e[r]={data:c,loading:d,error:h,lastUpdated:u,refresh(){return l.invalidate(),m()},setValue(b){l instanceof Wt&&(l.setValue(b),c.value=b)},send(b){l instanceof Ut&&l.send(b)},_source:l}}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 Jo(i){const t=new Kt,e=Yt(i,t),s=T(null),n=T(!0),r=T(null);let a=0;async function o(){const l=++a;n.value=!0,r.value=null;try{const c=await e.getValue(i.params||{});if(l!==a)return;s.value=c}catch(c){if(l!==a)return;r.value=c.message||"Unknown error"}finally{l===a&&(n.value=!1)}}return o(),e.subscribe(()=>{const l=t.getStale(e.cacheKey);l!=null&&(s.value=l)}),{data:s,loading:n,error:r,refresh(){return e.invalidate(),o()}}}function ne(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 Zo(){}class Xs{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 o=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,o))}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 o=r[a.key];return o!=null&&String(o).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(l=>{const c=r[l.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],o=s[n.key],l=0;if(r?.sorter?l=r.sorter(a,o,n.order):a==null?l=1:o==null?l=-1:typeof a=="number"&&typeof o=="number"?l=n.order==="asc"?a-o:o-a:l=n.order==="asc"?String(a).localeCompare(String(o)):String(o).localeCompare(String(a)),l!==0)return l}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,o)=>{const l=a[this.rowKey]??o,c=this._selectedKeys.has(l),d=this._expandedKeys.has(l),h=this._renderDataRow(a,o,l,c,r,n);if(e.appendChild(h),this.expandable&&d){const u=document.createElement("tr");u.className="kupola-table-expand-row";const f=document.createElement("td"),p=this.columns.length+(this.selection?1:0)+1;f.colSpan=p,f.className="kupola-table-expand-content";const m=this.expandable(a);typeof m=="string"?f.innerHTML=m:m instanceof HTMLElement&&f.appendChild(m),u.appendChild(f),e.appendChild(u)}})}return e}_renderDataRow(t,e,s,n,r,a){const o=document.createElement("tr");return o.setAttribute("data-row-key",s),n&&o.classList.add("kupola-table-row-selected"),this.draggable&&(o.draggable=!0,o.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(o,s,n),this.expandable&&this._renderExpandCell(o,s),this.columns.forEach((l,c)=>{if(r.has(`${e}-${c}`))return;const d=this._renderDataCell(t,e,s,l,c,r,a);o.appendChild(d)}),this.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",l=>{l.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,l)})),o}_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,o){const l=document.createElement("td");n.align&&(l.style.textAlign=n.align),n.fixed&&(l.setAttribute("data-fixed",n.fixed),l.classList.add(`kupola-table-fixed-${n.fixed}`));const c=o.get(`${e}-${r}`);if(c){c.rowSpan>1&&(l.rowSpan=c.rowSpan),c.colSpan>1&&(l.colSpan=c.colSpan);for(let h=0;h<(c.rowSpan||1);h++)for(let u=0;u<(c.colSpan||1);u++)h===0&&u===0||a.add(`${e+h}-${r+u}`)}this.tree&&r===0&&t._level>0&&this._renderTreeIndent(l,t);const d=this._editingCell&&this._editingCell.rowKey===s&&this._editingCell.colKey===n.key;if(d)l.appendChild(this._renderEditCell(n,t));else if(n.render){const h=n.render(t[n.key],t,e);typeof h=="string"?l.innerHTML=h:h instanceof HTMLElement&&l.appendChild(h)}else l.textContent=t[n.key]??"";return this.editable&&!d&&n.editable!==!1&&(l.classList.add("kupola-table-editable-cell"),l.addEventListener("dblclick",()=>this._startEdit(s,n.key,t[n.key]))),l}_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 o=document.createElement("tr");o.className="kupola-table-virtual-spacer-bottom",o.style.height="0px",e.appendChild(o);const l=this.element.querySelector(".kupola-table-container");return l&&(l.style.maxHeight=this.virtualScroll.maxHeight||"400px",l.style.overflowY="auto",this._scrollHandler&&l.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),l.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 o=a.scrollTop,l=a.clientHeight,c=Math.max(0,Math.floor(o/e)-s),d=Math.min(t.length,Math.ceil((o+l)/e)+s);n.querySelectorAll(".kupola-table-virtual-row").forEach(p=>p.remove());const u=document.createDocumentFragment();for(let p=c;p<d;p++){const m=t[p],y=m[this.rowKey]??p,_=this._renderDataRow(m,p,y,this._selectedKeys.has(y),new Set,new Map);_.classList.add("kupola-table-virtual-row"),_.style.height=e+"px",u.appendChild(_)}r.style.height=c*e+"px";const f=n.querySelector(".kupola-table-virtual-spacer-bottom");f&&(f.style.height=(t.length-d)*e+"px"),r.after(u)}_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 l=document.createElement("select");l.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),l.appendChild(d)}),l.addEventListener("change",()=>{this._editBuffer[t.key]=l.value}),s.appendChild(l)}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 o=document.createElement("button");return o.className="kupola-table-edit-cancel",o.textContent="✗",o.type="button",o.addEventListener("click",()=>this._cancelEdit()),r.appendChild(a),r.appendChild(o),s.appendChild(r),n.addEventListener("keydown",l=>{l.key==="Enter"&&this._saveEdit(e,t),l.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,o=r.offsetWidth,l=d=>{const h=Math.max(50,o+(d.clientX-a));r.style.width=h+"px";const u=this.columns.find(f=>f.key===n);u&&(u.width=h),this.onColumnResize&&this.onColumnResize(n,h)},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),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"]'),o=this.columns.indexOf(n);let l=(this.selection?40:0)+(this.expandable?40:0);for(let c=0;c<o;c++)this.columns[c].fixed==="left"&&(l+=this.columns[c]._resolvedWidth||120);r.forEach(c=>{c.textContent.startsWith(n.title||n.key)&&(c.style.position="sticky",c.style.left=l+"px",c.style.zIndex="2",n._resolvedWidth=c.offsetWidth)}),a.forEach(c=>{c.style.position="sticky",c.style.left=l+"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 o=document.createElement("select");o.className="kupola-table-page-size",this._pageSizes.forEach(l=>{const c=document.createElement("option");c.value=l,c.textContent=`${l} 条/页`,l===this._pageSize&&(c.selected=!0),o.appendChild(c)}),o.addEventListener("change",()=>{this._pageSize=parseInt(o.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(o)}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(o=>{if(o==="..."){const l=document.createElement("span");l.className="kupola-table-page-ellipsis",l.textContent="...",s.appendChild(l)}else{const l=this._createPageBtn(o,()=>this._goToPage(o));o===this._currentPage&&l.classList.add("active"),s.appendChild(l)}});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 h=c[d.key];return h==null&&(h=""),h=String(h).replace(/"/g,'""'),`"${h}"`}).join(",")),r="\uFEFF"+[s.join(","),...n].join(`
|
|
183
|
-
`),a=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=t,l.click(),URL.revokeObjectURL(o)}_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 Xt(i,t){return new Xs(i,t)}function Go(){document.querySelectorAll("[data-kupola-table]").forEach(i=>{const t=i.getAttribute("data-kupola-table");let e={};if(t)try{e=JSON.parse(t)}catch{}Xt(i,e)})}E.register("table",Xt);class js{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(o=>{const l=document.createElement("option");l.value=o,l.textContent=`${o} 条/页`,o===this._pageSize&&(l.selected=!0),a.appendChild(l)}),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 o=document.createElement("span");o.className="kupola-pagination-ellipsis",o.textContent="···",s.appendChild(o)}else{const o=this._btn(a,()=>this.setCurrent(a));a===this._current&&o.classList.add("active"),s.appendChild(o)}});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 o=a.querySelector("input");o.addEventListener("change",()=>{const l=parseInt(o.value);l>=1&&l<=e&&this.setCurrent(l)}),o.addEventListener("keydown",l=>{if(l.key==="Enter"){const c=parseInt(o.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 re=!1;function Qo(){if(re||typeof document>"u")return;const i=document.createElement("style");i.textContent=`
|
|
184
|
-
.kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
185
|
-
.kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }
|
|
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; }
|
|
187
|
-
.kupola-pagination-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }
|
|
188
|
-
.kupola-pagination-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }
|
|
189
|
-
.kupola-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
190
|
-
.kupola-pagination-ellipsis { padding: 0 4px; color: #999; user-select: none; }
|
|
191
|
-
.kupola-pagination-total { color: #666; font-size: 14px; }
|
|
192
|
-
.kupola-pagination-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }
|
|
193
|
-
.kupola-pagination-simple-info { padding: 0 8px; font-size: 14px; color: #333; }
|
|
194
|
-
.kupola-pagination-jumper { font-size: 14px; color: #666; }
|
|
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
|
-
.kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }
|
|
197
|
-
`,document.head.appendChild(i),re=!0}function tl(i,t){return Qo(),new js(i,t)}let ae=!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 sl 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 il 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
|
-
<button class="ds-collapse__header">
|
|
199
|
-
<span>${n}</span>
|
|
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
|
-
</button>
|
|
202
|
-
<div class="ds-collapse__body"><div class="ds-collapse__content">${r}</div></div>
|
|
203
|
-
`,t.appendChild(a)}),this.innerHTML="",this.appendChild(t)}}class nl extends HTMLElement{static get observedAttributes(){return["title"]}}class rl 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 al 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
|
-
<div class="ds-dialog">
|
|
205
|
-
<div class="ds-dialog__head">
|
|
206
|
-
<span class="ds-dialog__title">${t}</span>
|
|
207
|
-
<button class="ds-dialog__close" aria-label="Close">
|
|
208
|
-
<svg class="icon" 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>
|
|
209
|
-
</button>
|
|
210
|
-
</div>
|
|
211
|
-
<div class="ds-dialog__body"></div>
|
|
212
|
-
<div class="ds-dialog__foot"></div>
|
|
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 o=e.querySelector(".ds-dialog__close");o&&o.addEventListener("click",()=>this.close()),e.addEventListener("click",l=>{l.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 ol(){if(ae||typeof customElements>"u")return;ae=!0;const i=[["k-dropdown",el],["k-tooltip",sl],["k-collapse",il],["k-collapse-item",nl],["k-drawer",rl],["k-modal",al]];for(const[t,e]of i)customElements.get(t)||customElements.define(t,e)}exports.BRAND_OPTIONS=V;exports.CacheEntry=Vs;exports.CacheManager=Kt;exports.Calendar=gs;exports.Carousel=rs;exports.Collapse=us;exports.ColorPicker=fs;exports.ComponentInitializerRegistry=Ye;exports.Countdown=Is;exports.Datepicker=Qe;exports.DependsError=F;exports.DependsSource=R;exports.Dialog=ko;exports.Drawer=os;exports.Dropdown=Je;exports.DynamicTags=ys;exports.FetchedSource=Ks;exports.FileUpload=hs;exports.FunctionSource=Us;exports.GlobalEvents=je;exports.Heatmap=ws;exports.Icons=Fo;exports.ImagePreview=Pt;exports.KupolaComponent=J;exports.KupolaComponentRegistry=Xe;exports.KupolaDataBind=Ae;exports.KupolaEventBus=Pe;exports.KupolaForm=Fs;exports.KupolaI18n=bt;exports.KupolaLifecycle=nt;exports.KupolaPagination=js;exports.KupolaStore=ut;exports.KupolaStoreManager=ze;exports.KupolaTable=Xs;exports.KupolaUtils=wa;exports.KupolaValidator=Ds;exports.Message=So;exports.Modal=P;exports.Notification=wo;exports.NumberInput=zs;exports.PATHS=Ft;exports.RouteSource=Ws;exports.Scheduler=Rs;exports.Select=Ze;exports.SlideCaptcha=$s;exports.Slider=is;exports.StatCard=Es;exports.StaticSource=Ys;exports.StorageSource=Wt;exports.Tag=bs;exports.Timepicker=es;exports.Tooltip=Ss;exports.VirtualList=Hs;exports.WebSocketSource=Ut;exports.alertModal=xo;exports.applyMixin=pt;exports.arrayUtils=he;exports.bootstrapComponents=Wa;exports.cleanupAllDropdowns=po;exports.cleanupAllSlideCaptchas=Os;exports.cleanupCalendar=_s;exports.cleanupCarousel=as;exports.cleanupCollapse=ps;exports.cleanupColorPicker=ms;exports.cleanupCountdown=As;exports.cleanupDatepicker=ts;exports.cleanupDrawer=ls;exports.cleanupDropdown=Et;exports.cleanupDynamicTags=vs;exports.cleanupFileUpload=ds;exports.cleanupHeatmap=Cs;exports.cleanupModal=cs;exports.cleanupNumberInput=Ps;exports.cleanupSelect=Ge;exports.cleanupSlideCaptcha=qs;exports.cleanupSlider=ns;exports.cleanupStatCard=ks;exports.cleanupTag=xs;exports.cleanupTimepicker=ss;exports.cleanupTooltip=Ls;exports.cleanupVirtualList=Ts;exports.clearCache=Zo;exports.configureHttpClient=Uo;exports.confirmModal=bo;exports.createBrandPicker=Pa;exports.createI18n=ja;exports.createLifecycle=ti;exports.createModal=Dt;exports.createSource=Yt;exports.createStore=La;exports.createThemeToggle=za;exports.cryptoUtils=He;exports.dateUtils=be;exports.debounce=xe;exports.defineComponent=Xa;exports.defineMixin=Ua;exports.emit=ao;exports.emitGlobal=oo;exports.escapeHtml=Ba;exports.formatCurrency=so;exports.formatDate=to;exports.formatNumber=eo;exports.generateSecureId=Fa;exports.getBasePath=Ta;exports.getBrand=j;exports.getConfig=lt;exports.getDefaultBrand=Oe;exports.getDefaultTheme=qe;exports.getFormInstance=Vo;exports.getHttpClient=Yo;exports.getHttpConfig=Ia;exports.getIconsPath=_t;exports.getListenerCount=ho;exports.getLocale=Qa;exports.getMessageConfig=Ne;exports.getNotificationConfig=Re;exports.getPerformanceConfig=Fe;exports.getSecurityConfig=Z;exports.getStore=Da;exports.getTheme=O;exports.getUiConfig=U;exports.getValidationConfig=Ve;exports.globalEvents=H;exports.initAllTables=Go;exports.initCalendar=At;exports.initCalendars=To;exports.initCarousel=Lt;exports.initCarousels=yo;exports.initCollapse=Tt;exports.initCollapses=Ho;exports.initColorPicker=It;exports.initColorPickers=Mo;exports.initCountdown=Rt;exports.initCountdowns=No;exports.initDatepicker=wt;exports.initDatepickers=mo;exports.initDrawer=st;exports.initDrawers=vo;exports.initDropdown=xt;exports.initDropdowns=uo;exports.initDynamicTags=zt;exports.initDynamicTagsAll=Io;exports.initFileUpload=Mt;exports.initFileUploads=Do;exports.initFormValidation=Ns;exports.initHeatmap=qt;exports.initHeatmaps=Bo;exports.initImagePreview=Ao;exports.initMessages=Lo;exports.initModal=Ht;exports.initModals=Eo;exports.initNotifications=Co;exports.initNumberInput=Vt;exports.initNumberInputs=Ro;exports.initPagination=tl;exports.initSelect=kt;exports.initSelects=fo;exports.initSlideCaptchas=Bs;exports.initSlider=St;exports.initSliders=_o;exports.initStatCard=Bt;exports.initStatCards=$o;exports.initTable=Xt;exports.initTag=$t;exports.initTags=Po;exports.initTheme=Ue;exports.initTimepicker=Ct;exports.initTimepickers=go;exports.initTooltip=Ot;exports.initTooltips=qo;exports.initVirtualList=Ms;exports.kupolaBootstrap=ft;exports.kupolaData=q;exports.kupolaEvents=Sa;exports.kupolaI18n=N;exports.kupolaInitializer=E;exports.kupolaLifecycle=Qs;exports.kupolaStoreManager=gt;exports.maskData=Oa;exports.n=Za;exports.numberUtils=_e;exports.objectUtils=fe;exports.off=ro;exports.offAll=co;exports.offByScope=lo;exports.offConfigChange=Ha;exports.on=io;exports.onConfigChange=Be;exports.once=no;exports.preloadUtils=Ie;exports.ref=T;exports.registerComponent=Va;exports.registerLazyComponent=Ka;exports.registerWebComponents=ol;exports.renderIcon=it;exports.resetHttpClient=Xo;exports.sanitizeHtml=$a;exports.setBrand=et;exports.setConfig=Ma;exports.setLocale=Ga;exports.setTheme=G;exports.showImagePreview=zo;exports.stringUtils=oe;exports.stripHtml=qa;exports.svg=Nt;exports.t=Ja;exports.throttle=Ee;exports.useDeps=jo;exports.useMixin=Ya;exports.useQuery=Jo;exports.validateForm=Ko;exports.validator=I;exports.validatorUtils=mt;
|
|
215
|
-
//# sourceMappingURL=kupola.cjs.js.map
|
|
1
|
+
"use strict";class t{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(t=>{this.allPhases.push(`before${t.charAt(0).toUpperCase()+t.slice(1)}`),this.allPhases.push(t),this.allPhases.push(`after${t.charAt(0).toUpperCase()+t.slice(1)}`)}),this.allPhases.forEach(t=>{this.hooks.set(t,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this.i=null}o(t){const s=this.transitions.get(this.state);if(!s||!s.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}l(t){this.o(t),this.state=t,this.stateHistory.push(t)}u(t){const s=this.hooks.get(t);s&&s.forEach(t=>{t.resolved=!1})}on(t,s,i={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const e=this.hooks.get(t);return e.push({handler:s,priority:i.priority||0,depends:i.depends||[],name:i.name||s.name||`anonymous_${e.length}`}),e.sort((t,s)=>s.priority-t.priority),()=>{const t=e.findIndex(t=>t.handler===s);t>-1&&e.splice(t,1)}}async p(t,s){if(t&&0!==t.length)for(const i of t){const t=this.hooks.get(s).find(t=>t.name===i);t&&!t.resolved&&(await t.handler(),t.resolved=!0)}}async emit(t,...s){if("destroyed"===this.state&&"error"!==t)return;const i=this.hooks.get(t);if(!i||0===i.length)return;const e=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(e);const n=performance.now();try{for(const n of i){await this.p(n.depends,t);const i=performance.now();let h,o;try{h=n.handler(...s),h instanceof Promise&&await h,n.resolved=!0}catch(i){o=i,"error"!==t&&await this.m({phase:t,hook:n.name,error:i,args:s})}const r=performance.now()-i;this.trace.push({emitId:e,phase:t,hookName:n.name,duration:r,status:o?"error":"success",error:o?o.message:null,timestamp:Date.now()})}performance.now()}finally{this.pendingHooks.delete(e)}}async runPhase(t,...s){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const i=this.phaseStateMap[t];if(i)if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${i.from}`);const e=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,n=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this.u(e),this.u(t),this.u(n),this.allPhases.includes(e)&&await this.emit(e,...s),await this.emit(t,...s),i&&this.l(i.to),this.allPhases.includes(n)&&await this.emit(n,...s)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _(){return new Promise(t=>{if("complete"===document.readyState||"interactive"===document.readyState)return void t();const s=()=>{document.removeEventListener("DOMContentLoaded",s),window.removeEventListener("load",s),t()};document.addEventListener("DOMContentLoaded",s),window.addEventListener("load",s)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._(),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(t=>{t.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const s=this.hooks.get(t);return s&&s.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.i=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",s=>"function"==typeof t?t(s):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async m(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors)return;if(await this.emit("error",t),"function"==typeof this.i)try{await this.i(t)}catch(t){}const s=this.hooks.get("errorBoundary");if(s&&s.length>0)for(const i of s)try{const s=i.handler(t);if(s instanceof Promise&&await s,"handled"===s)return}catch(t){}}}const s=new t("app");const i=new Set(["__proto__","prototype","constructor"]);function e(t){return i.has(t)}const n={trim:function(t){return t?t.trim():""},trimLeft:function(t){return t?t.replace(/^\s+/,""):""},trimRight:function(t){return t?t.replace(/\s+$/,""):""},toUpperCase:function(t){return t?t.toUpperCase():""},toLowerCase:function(t){return t?t.toLowerCase():""},capitalize:function(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""},camelize:function(t){return t?t.replace(/-(\w)/g,(t,s)=>s?s.toUpperCase():""):""},hyphenate:function(t){return t?t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart:function(t,s,i=" "){return(String(t)||"").padStart(s,i)},padEnd:function(t,s,i=" "){return(String(t)||"").padEnd(s,i)},truncate:function(t,s,i="..."){return!t||t.length<=s?t||"":t.slice(0,s)+i},replaceAll:function(t,s,i){return t?t.split(s).join(i):""},format:function(t,s){return t?t.replace(/\{\{(\w+)\}\}/g,(t,i)=>void 0!==s[i]?s[i]:`{{${i}}}`):""},startsWith:function(t,s){return(t||"").startsWith(s)},endsWith:function(t,s){return(t||"").endsWith(s)},includes:function(t,s){return(t||"").includes(s)},repeat:function(t,s){return(t||"").repeat(s)},reverse:function(t){return(t||"").split("").reverse().join("")},countOccurrences:function(t,s){return t&&s?t.split(s).length-1:0},escapeHtml:function(t){if(!t)return"";const s=document.createElement("div");return s.textContent=t,s.innerHTML},unescapeHtml:function(t){if(!t)return"";const s=document.createElement("div");return s.innerHTML=t,s.textContent},generateRandom:function(t=8){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let e=0;e<t;e++)i+=s.charAt(Math.floor(62*Math.random()));return i},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=16*Math.random()|0;return("x"===t?s:3&s|8).toString(16)})}};function h(t){return t?t.reduce((t,s)=>t+(Number(s)||0),0):0}const o={isArray:function(t){return Array.isArray(t)},isEmpty:function(t){return!t||0===t.length},size:function(t){return t?t.length:0},first:function(t,s){return t&&t.length>0?t[0]:s},last:function(t,s){return t&&t.length>0?t[t.length-1]:s},get:function(t,s,i){return t&&void 0!==t[s]?t[s]:i},slice:function(t,s,i){return t?t.slice(s,i):[]},concat:function(...t){return t.reduce((t,s)=>t.concat(s||[]),[])},join:function(t,s=","){return t?t.join(s):""},indexOf:function(t,s,i=0){if(!t)return-1;if(Number.isNaN(s)){for(let s=i;s<t.length;s++)if(Number.isNaN(t[s]))return s;return-1}return t.indexOf(s,i)},lastIndexOf:function(t,s,i){if(!t)return-1;if(Number.isNaN(s)){for(let s=void 0!==i?i:t.length-1;s>=0;s--)if(Number.isNaN(t[s]))return s;return-1}return t.lastIndexOf(s,i)},includes:function(t,s){return!!t&&t.includes(s)},push:function(t,...s){return t&&t.push(...s),t},pop:function(t){return t?t.pop():void 0},shift:function(t){return t?t.shift():void 0},unshift:function(t,...s){return t&&t.unshift(...s),t},remove:function(t,s){if(!t)return t;const i=Number.isNaN(s)?t.findIndex(t=>Number.isNaN(t)):t.indexOf(s);return i>-1&&t.splice(i,1),t},removeAt:function(t,s){return!t||s<0||s>=t.length||t.splice(s,1),t},insert:function(t,s,i){return t?(t.splice(s,0,i),t):t},reverse:function(t){return t?t.slice().reverse():[]},sort:function(t,s){return t?t.slice().sort(s):[]},sortBy:function(t,s,i="asc"){return t?t.slice().sort((t,e)=>{const n="object"==typeof t?t[s]:t,h="object"==typeof e?e[s]:e;return n<h?"asc"===i?-1:1:n>h?"asc"===i?1:-1:0}):[]},filter:function(t,s){return t?t.filter(s):[]},map:function(t,s){return t?t.map(s):[]},reduce:function(t,s,i){return t?t.reduce(s,i):i},forEach:function(t,s){t&&t.forEach(s)},every:function(t,s){return!t||t.every(s)},some:function(t,s){return!!t&&t.some(s)},find:function(t,s){return t?t.find(s):void 0},findIndex:function(t,s){return t?t.findIndex(s):-1},flat:function(t,s=1){return t?t.flat(s):[]},flattenDeep:function t(s){return s?s.reduce((s,i)=>Array.isArray(i)?s.concat(t(i)):s.concat(i),[]):[]},unique:function(t){return t?[...new Set(t)]:[]},uniqueBy:function(t,s){if(!t)return[];const i=new Set;return t.filter(t=>{const e="object"==typeof t?t[s]:t;return!i.has(e)&&(i.add(e),!0)})},chunk:function(t,s){if(!t||s<=0)return[];const i=[];for(let e=0;e<t.length;e+=s)i.push(t.slice(e,e+s));return i},shuffle:function(t){if(!t)return[];const s=t.slice();for(let t=s.length-1;t>0;t--){const i=Math.floor(Math.random()*(t+1));[s[t],s[i]]=[s[i],s[t]]}return s},sum:h,average:function(t){return t&&0!==t.length?h(t)/t.length:0},max:function(t){return t&&t.length>0?Math.max(...t):-1/0},min:function(t){return t&&t.length>0?Math.min(...t):1/0},intersection:function(...t){return 0===t.length?[]:t.reduce((t,s)=>t.filter(t=>s&&s.includes(t)))},union:function(...t){return[...new Set(t.flat().filter(Boolean))]},difference:function(t,s){return t?t.filter(t=>!s||!s.includes(t)):[]},zip:function(...t){if(0===t.length)return[];const s=Math.max(...t.map(t=>t?t.length:0));return Array.from({length:s},(s,i)=>t.map(t=>t&&t[i]))}};function r(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}const a={isObject:r,isEmpty:function(t){return!t||"object"!=typeof t||0===Object.keys(t).length},keys:function(t){return t?Object.keys(t):[]},values:function(t){return t?Object.values(t):[]},entries:function(t){return t?Object.entries(t):[]},has:function(t,s){return!!t&&Object.prototype.hasOwnProperty.call(t,s)},get:function(t,s,i){if(!t)return i;const n=s.split(".");return n.some(e)?i:n.reduce((t,s)=>t&&t[s],t)??i},set:function(t,s,i){if(!t||"object"!=typeof t)return t;const n=s.split(".");if(n.some(e))return t;const h=n.pop();let o=t;return n.forEach(t=>{o[t]&&"object"==typeof o[t]||(o[t]={}),o=o[t]}),o[h]=i,t},pick:function(t,s){return t?s.reduce((s,i)=>(void 0!==t[i]&&(s[i]=t[i]),s),{}):{}},omit:function(t,s){return t?Object.keys(t).reduce((i,e)=>(s.includes(e)||(i[e]=t[e]),i),{}):{}},merge:function t(...s){return s.reduce((s,i)=>(i&&"object"==typeof i&&Object.keys(i).forEach(n=>{e(n)||(r(i[n])&&r(s[n])?s[n]=t(s[n],i[n]):s[n]=i[n])}),s),{})},clone:function(t){return t?JSON.parse(JSON.stringify(t)):t},deepClone:function t(s,i=new WeakMap){if(!s||"object"!=typeof s)return s;if(i.has(s))return i.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const e=new Map;return i.set(s,e),s.forEach((s,n)=>e.set(n,t(s,i))),e}if(s instanceof Set){const e=new Set;return i.set(s,e),s.forEach(s=>e.add(t(s,i))),e}if(Array.isArray(s)){const e=[];return i.set(s,e),s.forEach(s=>e.push(t(s,i))),e}const n={};return i.set(s,n),Object.keys(s).forEach(h=>{e(h)||(n[h]=t(s[h],i))}),n},forEach:function(t,s){t&&Object.keys(t).forEach(i=>s(t[i],i,t))},map:function(t,s){if(!t)return{};const i={};return Object.keys(t).forEach(e=>{i[e]=s(t[e],e,t)}),i},filter:function(t,s){if(!t)return{};const i={};return Object.keys(t).forEach(e=>{s(t[e],e,t)&&(i[e]=t[e])}),i},reduce:function(t,s,i){return t?Object.keys(t).reduce((i,e)=>s(i,t[e],e,t),i):i},toArray:function(t){return t?Object.keys(t).map(s=>({key:s,value:t[s]})):[]},fromArray:function(t,s,i){return t?t.reduce((t,e)=>{const n="object"==typeof e?e[s]:e,h=i?e[i]:e;return void 0!==n&&(t[n]=h),t},{}):{}},size:function(t){return t?Object.keys(t).length:0},invert:function(t){if(!t)return{};const s={};return Object.keys(t).forEach(i=>{s[t[i]]=i}),s},isEqual:function t(s,i){if(s===i)return!0;if(!s||!i||"object"!=typeof s||"object"!=typeof i)return!1;const e=Object.keys(s),n=Object.keys(i);return e.length===n.length&&e.every(e=>t(s[e],i[e]))},freeze:function t(s){return s?(Object.freeze(s),Object.keys(s).forEach(i=>{"object"==typeof s[i]&&t(s[i])}),s):s},seal:function(t){return t?Object.seal(t):t}};function c(t){return"number"==typeof t&&!isNaN(t)}function l(...t){return t.flat().filter(c).reduce((t,s)=>t+s,0)}function d(t=0,s=1){return Math.random()*(s-t)+t}const u={isNumber:c,isInteger:function(t){return Number.isInteger(t)},isFloat:function(t){return c(t)&&!Number.isInteger(t)},isPositive:function(t){return c(t)&&t>0},isNegative:function(t){return c(t)&&t<0},isZero:function(t){return c(t)&&0===t},clamp:function(t,s,i){return c(t)?Math.min(Math.max(t,s),i):t},round:function(t,s=0){if(!c(t))return t;const i=Math.pow(10,s);return Math.round(t*i)/i},floor:function(t){return c(t)?Math.floor(t):t},ceil:function(t){return c(t)?Math.ceil(t):t},abs:function(t){return c(t)?Math.abs(t):t},min:function(...t){const s=t.filter(c);return s.length>0?Math.min(...s):void 0},max:function(...t){const s=t.filter(c);return s.length>0?Math.max(...s):void 0},sum:l,average:function(...t){const s=t.flat().filter(c);return s.length>0?l(s)/s.length:0},random:d,randomInt:function(t,s){return Math.floor(d(t,s+1))},format:function(t,s=2){return c(t)?t.toFixed(s):String(t)},formatCurrency:function(t,s="CNY",i=2){return c(t)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:s,minimumFractionDigits:i,maximumFractionDigits:i}).format(t):String(t)},formatPercent:function(t,s=0){return c(t)?`${(100*t).toFixed(s)}%`:String(t)},toFixed:function(t,s=0){return c(t)?t.toFixed(s):String(t)},toPrecision:function(t,s=6){return c(t)?t.toPrecision(s):String(t)},isNaN:function(t){return Number.isNaN(t)},isFinite:function(t){return Number.isFinite(t)},parseInt:function(t,s=10){return Number.parseInt(t,s)},parseFloat:function(t){return Number.parseFloat(t)},toNumber:function(t,s=0){const i=Number(t);return isNaN(i)?s:i},safeDivide:function(t,s,i=0){return c(t)&&c(s)&&0!==s?t/s:i},safeMultiply:function(...t){return t.reduce((t,s)=>c(t)&&c(s)?t*s:0,1)}};function p(){return Date.now()}function f(){const t=new Date;return t.setHours(0,0,0,0),t}function m(t){return t instanceof Date&&!isNaN(t.getTime())}function g(t){return m(t)}function y(t,s){if(!m(t)||!m(s))return 0;const i=new Date(t);i.setHours(0,0,0,0);const e=new Date(s);return e.setHours(0,0,0,0),Math.floor((i.getTime()-e.getTime())/864e5)}function _(t,s=1){if(!m(t))return t;const i=new Date(t),e=i.getDay(),n=e>=s?e-s:e+(7-s);return i.setDate(i.getDate()-n),i.setHours(0,0,0,0),i}const v={now:p,today:f,tomorrow:function(){const t=f();return t.setDate(t.getDate()+1),t},yesterday:function(){const t=f();return t.setDate(t.getDate()-1),t},isDate:m,isValid:g,parse:function(t){const s=new Date(t);return g(s)?s:null},format:function(t,s="YYYY-MM-DD HH:mm:ss"){if(!m(t))return"";const i=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),h=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0"),a=String(t.getMilliseconds()).padStart(3,"0"),c=["日","一","二","三","四","五","六"][t.getDay()];return s.replace("YYYY",i).replace("MM",e).replace("DD",n).replace("HH",h).replace("mm",o).replace("ss",r).replace("SSS",a).replace("D",t.getDate()).replace("M",t.getMonth()+1).replace("H",t.getHours()).replace("m",t.getMinutes()).replace("s",t.getSeconds()).replace("W",c)},toISO:function(t){return m(t)?t.toISOString():""},toUTC:function(t){return m(t)?new Date(t.toUTCString()):null},addDays:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setDate(i.getDate()+s),i},addHours:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setHours(i.getHours()+s),i},addMinutes:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setMinutes(i.getMinutes()+s),i},addSeconds:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setSeconds(i.getSeconds()+s),i},diffDays:y,diffHours:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/36e5):0},diffMinutes:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/6e4):0},diffSeconds:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/1e3):0},isToday:function(t){return!!m(t)&&0===y(t,f())},isYesterday:function(t){return!!m(t)&&-1===y(t,f())},isTomorrow:function(t){return!!m(t)&&1===y(t,f())},isFuture:function(t){return!!m(t)&&t.getTime()>p()},isPast:function(t){return!!m(t)&&t.getTime()<p()},isLeapYear:function(t){if(!m(t))return!1;const s=t.getFullYear();return s%4==0&&(s%100!=0||s%400==0)},getDaysInMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():0},getWeekOfYear:function(t){if(!m(t))return 0;const s=new Date(t.getFullYear(),0,1),i=t.getTime()-s.getTime();return Math.ceil(i/6048e5)},getQuarter:function(t){return m(t)?Math.ceil((t.getMonth()+1)/3):0},startOfDay:function(t){if(!m(t))return t;const s=new Date(t);return s.setHours(0,0,0,0),s},endOfDay:function(t){if(!m(t))return t;const s=new Date(t);return s.setHours(23,59,59,999),s},startOfMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth(),1):t},endOfMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59,999):t},startOfWeek:_,endOfWeek:function(t,s=1){if(!m(t))return t;const i=_(t,s),e=new Date(i);return e.setDate(e.getDate()+6),e.setHours(23,59,59,999),e},getAge:function(t){if(!m(t))return 0;const s=new Date;let i=s.getFullYear()-t.getFullYear();return(s.getMonth()<t.getMonth()||s.getMonth()===t.getMonth()&&s.getDate()<t.getDate())&&i--,Math.max(0,i)},fromNow:function(t){if(!m(t))return"";const s=p()-t.getTime(),i=6e4,e=36e5,n=24*e,h=7*n,o=30*n,r=365*n;return s<i?"刚刚":s<e?`${Math.floor(s/i)}分钟前`:s<n?`${Math.floor(s/e)}小时前`:s<h?`${Math.floor(s/n)}天前`:s<o?`${Math.floor(s/h)}周前`:s<r?`${Math.floor(s/o)}个月前`:`${Math.floor(s/r)}年前`}};function x(t,s,i={}){let e=null,n=null,h=null,o=0;const r=i.leading||!1,a=!1!==i.trailing;function c(){t.apply(h,n)}function l(){e=null,a&&n&&c(),n=null,h=null}return function(...t){n=t,h=this,o=Date.now(),e?(clearTimeout(e),e=setTimeout(l,Math.max(0,s-(Date.now()-o)))):(o=Date.now(),r?(e=setTimeout(l,s),c()):e=setTimeout(l,s))}}function b(t,s,i={}){let e=!1;const n=i.trailing||!1;let h=null,o=null;function r(){t.apply(o,h),h=null,o=null}return function(...t){e?n&&(h=t,o=this):(e=!0,h=t,o=this,r(),setTimeout(()=>{e=!1,n&&h&&r()},s))}}function w(t){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(t||"")}function k(t){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t||"")}function M(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t||"")}function $(t){const s=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(t||"");return!!s&&s.slice(1).every(t=>parseInt(t)>=0&&parseInt(t)<=255)}function S(t){const s=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(t||"");if(!s)return!1;const[,i,e,n,h]=s;return parseInt(i)>=0&&parseInt(i)<=255&&parseInt(e)>=0&&parseInt(e)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(h)>=0&&parseFloat(h)<=1}function C(t,s){return(t||"").includes(s)}const T={isEmail:function(t){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t||"")},isPhone:function(t){return/^1[3-9]\d{9}$/.test(t||"")},isURL:function(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(t||"")},isIPv4:w,isIPv6:k,isIP:function(t){return w(t)||k(t)},isIDCard:function(t){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(t||"")},isPassport:function(t){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(t||"")},isCreditCard:function(t){const s=t.replace(/\s/g,"");if(!/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/.test(s))return!1;let i=0,e=!1;for(let t=s.length-1;t>=0;t--){let n=parseInt(s[t],10);e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0},isHexColor:M,isRGB:$,isRGBA:S,isColor:function(t){return M(t)||$(t)||S(t)},isDate:function(t){return!isNaN(new Date(t).getTime())},isJSON:function(t){try{return JSON.parse(t),!0}catch{return!1}},isEmpty:function(t){return!t||""===t.trim()},isWhitespace:function(t){return/^\s+$/.test(t||"")},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},isInteger:function(t){return/^-?\d+$/.test(t||"")},isFloat:function(t){return/^-?\d+\.\d+$/.test(t||"")},isPositive:function(t){const s=parseFloat(t);return!isNaN(s)&&s>0},isNegative:function(t){const s=parseFloat(t);return!isNaN(s)&&s<0},isAlpha:function(t){return/^[a-zA-Z]+$/.test(t||"")},isAlphaNumeric:function(t){return/^[a-zA-Z0-9]+$/.test(t||"")},isChinese:function(t){return/^[\u4e00-\u9fa5]+$/.test(t||"")},isLength:function(t,s,i){const e=(t||"").length;return e>=s&&(void 0===i||e<=i)},minLength:function(t,s){return(t||"").length>=s},maxLength:function(t,s){return(t||"").length<=s},matches:function(t,s){return s instanceof RegExp&&s.test(t||"")},equals:function(t,s){return String(t)===String(s)},contains:C,notContains:function(t,s){return!C(t,s)},isArray:function(t){return Array.isArray(t)},arrayLength:function(t,s,i){const e=t?t.length:0;return e>=s&&(void 0===i||e<=i)},arrayMinLength:function(t,s){return!!t&&t.length>=s},arrayMaxLength:function(t,s){return!!t&&t.length<=s},isObject:function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},hasKeys:function(t,s){return!!(t&&s&&Array.isArray(s))&&s.every(s=>Object.prototype.hasOwnProperty.call(t,s))},validate:function(t,s){const i={};return Object.keys(s).forEach(e=>{const n=t[e],h=s[e],o=[];h.forEach(s=>{if("string"==typeof s){const[t,...i]=s.split(":");T[t](n,...i)||o.push(t)}else if("function"==typeof s){const i=s(n,t);!0!==i&&o.push(i||"validation_failed")}}),o.length>0&&(i[e]=o)}),{valid:0===Object.keys(i).length,errors:i}}};const E={md5:function(t){const s=t?String(t):"",i=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(t,s){return t<<s|t>>>32-s}function h(t,s){const[h,o,r,a]=s,c=[];for(let s=0;s<16;s++)c[s]=255&t.charCodeAt(4*s)|(255&t.charCodeAt(4*s+1))<<8|(255&t.charCodeAt(4*s+2))<<16|(255&t.charCodeAt(4*s+3))<<24;let l=h,d=o,u=r,p=a;for(let t=0;t<64;t++){let s,h;const o=Math.floor(t/16),r=t%16;0===o?(s=d&u|~d&p,h=r):1===o?(s=p&d|~p&u,h=(5*r+1)%16):2===o?(s=d^u^p,h=(3*r+5)%16):(s=u^(d|~p),h=7*r%16);const a=p;p=u,u=d,d+=n(l+s+i[t]+c[h]&4294967295,e[o][t%4]),l=a}return[h+l&4294967295,o+d&4294967295,r+u&4294967295,a+p&4294967295]}const o=function(t){const s=8*t.length;for(t+="";t.length%64!=56;)t+="\0";const i=4294967295&s,e=s>>>32&4294967295;for(let s=0;s<4;s++)t+=String.fromCharCode(i>>>8*s&255);for(let s=0;s<4;s++)t+=String.fromCharCode(e>>>8*s&255);return t}(s);let r=[1732584193,4023233417,2562383102,271733878];for(let t=0;t<o.length;t+=64)r=h(o.substring(t,t+64),r);let a="";return r.forEach(t=>{for(let s=0;s<4;s++)a+=(t>>>8*s&255).toString(16).padStart(2,"0")}),a},sha256:function(t){const s=t?String(t):"",i=[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 e(t,s){return t>>>s|t<<32-s}function n(t,s){const n=[];for(let s=0;s<16;s++)n[s]=255&t.charCodeAt(4*s)|(255&t.charCodeAt(4*s+1))<<8|(255&t.charCodeAt(4*s+2))<<16|(255&t.charCodeAt(4*s+3))<<24;for(let t=16;t<64;t++){const s=e(n[t-15],7)^e(n[t-15],18)^n[t-15]>>>3,i=e(n[t-2],17)^e(n[t-2],19)^n[t-2]>>>10;n[t]=n[t-16]+s+n[t-7]+i&4294967295}let[h,o,r,a,c,l,d,u]=s;for(let t=0;t<64;t++){const s=u+(e(c,6)^e(c,11)^e(c,25))+(c&l^~c&d)+i[t]+n[t]&4294967295,p=h&o^h&r^o&r;u=d,d=l,l=c,c=a+s&4294967295,a=r,r=o,o=h,h=s+((e(h,2)^e(h,13)^e(h,22))+p&4294967295)&4294967295}return[s[0]+h&4294967295,s[1]+o&4294967295,s[2]+r&4294967295,s[3]+a&4294967295,s[4]+c&4294967295,s[5]+l&4294967295,s[6]+d&4294967295,s[7]+u&4294967295]}const h=function(t){const s=8*t.length;for(t+="";t.length%64!=56;)t+="\0";const i=4294967295&s,e=s>>>32&4294967295;for(let s=0;s<4;s++)t+=String.fromCharCode(e>>>8*s&255);for(let s=0;s<4;s++)t+=String.fromCharCode(i>>>8*s&255);return t}(s);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let t=0;t<h.length;t+=64)o=n(h.substring(t,t+64),o);let r="";return o.forEach(t=>{for(let s=3;s>=0;s--)r+=(t>>>8*s&255).toString(16).padStart(2,"0")}),r},base64Encode:function(t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",e=0;const n=t?t.split("").map(t=>t.charCodeAt(0)):[];for(;e<n.length;){const t=n[e++],h=n[e++]||0,o=n[e++]||0,r=(15&h)<<2|o>>6,a=63&o;i+=s[t>>2]+s[(3&t)<<4|h>>4]+(e>n.length+1?"=":s[r])+(e>n.length?"=":s[a])}return i},base64Decode:function(t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",e=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");e<t.length;){const n=s.indexOf(t.charAt(e++)),h=s.indexOf(t.charAt(e++)),o=s.indexOf(t.charAt(e++)),r=s.indexOf(t.charAt(e++)),a=n<<2|h>>4,c=(15&h)<<4|o>>2,l=(3&o)<<6|r;i+=String.fromCharCode(a),64!==o&&(i+=String.fromCharCode(c)),64!==r&&(i+=String.fromCharCode(l))}return i},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=16*Math.random()|0;return("x"===t?s:3&s|8).toString(16)})}},D=new Map;async function I(t,s={}){const{crossOrigin:i="anonymous"}=s;return D.has(t)?D.get(t):new Promise((s,e)=>{const n=new Image;n.crossOrigin=i,n.onload=()=>{D.set(t,n),s(n)},n.onerror=()=>{e(new Error(`Failed to load image: ${t}`))},n.src=t})}async function O(t,s={}){const{type:i="text/javascript",async:e=!0,defer:n=!1}=s;return D.has(t)?D.get(t):new Promise((s,h)=>{const o=document.createElement("script");o.type=i,o.async=e,o.defer=n,o.onload=()=>{D.set(t,o),s(o)},o.onerror=()=>{o.remove(),h(new Error(`Failed to load script: ${t}`))},o.src=t,document.head.appendChild(o)})}async function A(t,s={}){const{media:i="all"}=s;return D.has(t)?D.get(t):new Promise((s,e)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=t,n.media=i,n.onload=()=>{D.set(t,n),s(n)},n.onerror=()=>{n.remove(),e(new Error(`Failed to load stylesheet: ${t}`))},document.head.appendChild(n)})}const F={loadImage:I,loadImages:async function(t,s={}){const{parallel:i=!0}=s;if(i)return Promise.all(t.map(t=>I(t,s)));const e=[];for(const i of t)e.push(await I(i,s));return e},loadScript:O,loadStylesheet:A,loadFont:async function(t,s,i={}){const{weight:e="normal",style:n="normal"}=i,h=new FontFace(t,`url(${s})`,{weight:e,style:n});try{return await h.load(),document.fonts.add(h),h}catch(s){throw new Error(`Failed to load font: ${t}`)}},preload:async function(t,s="image"){switch(s){case"image":return I(t);case"script":return O(t);case"stylesheet":case"style":return A(t);default:throw new Error(`Unsupported preload type: ${s}`)}},isLoaded:function(t){return D.has(t)},clearCache:function(){D.clear()},clearCacheByUrl:function(t){D.delete(t)}},z={string:n,array:o,object:a,number:u,date:v,debounce:x,throttle:b,validator:T,crypto:E,preload:F};class j{constructor(){this.children={},this.keys=[]}}class R{constructor(){this.root=new j}insert(t){let s=this.root;const i=t.split(".");i.forEach((e,n)=>{s.children[e]||(s.children[e]=new j),s=s.children[e],n===i.length-1&&s.keys.push(t)})}getSubKeys(t){let s=this.root;const i=t.split("."),e=[];for(let t=0;t<i.length;t++){const n=i[t];if(!s.children[n])break;s=s.children[n];const h=t=>{t.keys.length>0&&e.push(...t.keys),Object.values(t.children).forEach(t=>h(t))};h(s)}return[...new Set(e)]}getParentKeys(t){const s=t.split("."),i=[];for(let t=1;t<=s.length;t++){const e=s.slice(0,t).join(".");i.push(e)}return i}}const P=Symbol("reactive_parent"),L=Symbol("reactive_path"),N=Symbol("reactive_is_reactive");class B{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new R,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this.k=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(t,s,i)=>{if("__raw__"===s)return t;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,s):e},set:(t,s,i,e)=>{const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=this.resolvePath(t,s);return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{const i=Reflect.get(t,s,receiver),e=Reflect.deleteProperty(t,s),n=this.resolvePath(t,s);return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e}};this.data=new Proxy(this.rawData,t),this.data.M=null,this.data.$=""}wrapReactive(t,s){if(t[N])return t;if(this.k.has(t))return this.k.get(t);const i=new Proxy(t,{get:(t,s,i)=>{if("__raw__"===s)return t;if(s===P||"__parent__"===s)return t[P];if(s===L||"__path__"===s)return t[L];if(s===N||"__isReactive__"===s)return!0;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[L]}${t[L]?".":""}${s}`):e},set:(t,s,i,e)=>{if(s===P||s===L||s===N||"__parent__"===s||"__path__"===s||"__isReactive__"===s)return!0;const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=`${t[L]}${t[L]?".":""}${s}`;return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{if(s===P||s===L||s===N)return!1;const i=Reflect.get(t,s),e=Reflect.deleteProperty(t,s),n=`${t[L]}${t[L]?".":""}${s}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e},has:(t,s)=>"__raw__"===s||s===P||s===L||s===N||"__parent__"===s||"__path__"===s||"__isReactive__"===s||s in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==P&&t!==L&&t!==N),getOwnPropertyDescriptor:(t,s)=>s===P||s===L||s===N?{configurable:!1,enumerable:!1,writable:!1,value:t[s]}:Reflect.getOwnPropertyDescriptor(t,s)});return t[P]=t,t[L]=s,t[N]=!0,this.k.set(t,i),Object.keys(t).forEach(i=>{t[i]&&"object"==typeof t[i]&&!Array.isArray(t[i])&&(t[i]=this.wrapReactive(t[i],`${s}${s?".":""}${i}`))}),i}resolvePath(t,s){return t[L]?`${t[L]}.${s}`:s}queueUpdate(t,s){this.updateQueue.set(t,s),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((s,i)=>{t.add(i),this.updateElementsDirect(i,s);this.pathTrie.getSubKeys(i).forEach(s=>{if(!t.has(s)){const i=this.get(s);this.updateElementsDirect(s,i),t.add(s)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,s){this.elements[t]&&this.elements[t].forEach(t=>{this.updateElement(t,s)})}processComputed(){Object.keys(this.computedProperties).forEach(t=>{this.computedProperties[t].deps.some(t=>this.updateQueue.has(t)||this.pathTrie.getSubKeys(t).some(t=>this.updateQueue.has(t)))&&this.updateComputedProperty(t)})}set(t,s,i=!1){const e=this.get(t);"object"==typeof t?(Object.assign(this.rawData,t),Object.keys(t).forEach(s=>{i||(this.notify(s,t[s],e?.[s]),this.queueUpdate(s,t[s]))})):(t.includes(".")?this.setNested(t,s):this.rawData[t]=s,i||(this.notify(t,s,e),this.queueUpdate(t,s))),i||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((t,s)=>t?.[s],this.rawData)}setNested(t,s){const i=t.split("."),e=i.pop(),n=i.reduce((t,s)=>(t[s]||(t[s]={}),t[s]),this.rawData),h=n[e];n[e]=s,this.notify(t,s,h),this.queueUpdate(t,s)}observe(t,s){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(s)}unobserve(t,s){this.observers[t]&&(this.observers[t]=this.observers[t].filter(t=>t!==s))}notify(t,s,i){this.observers[t]&&this.observers[t].forEach(t=>{try{t(s,i)}catch(t){}}),this.observers["*"]?.forEach(e=>{try{e(t,s,i)}catch(t){}})}updateElement(t,s){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(i=>{const e=i.split(":"),n=e[0].trim(),h=e[1]?.trim();switch(n){case"text":t.textContent!==String(s??"")&&(t.textContent=s??"");break;case"html":const i=function(t){if(!t)return"";let s=String(t);const i=/<\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 e;do{e=s,s=s.replace(i,"")}while(s!==e);return s=s.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),s=s.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),s=s.replace(/expression\s*\([^)]*\)/gi,""),s}(s);t.innerHTML!==i&&(t.innerHTML=i);break;case"value":"checkbox"===t.type?t.checked!==!!s&&(t.checked=!!s):t.value!==String(s??"")&&(t.value=s??"");break;case"checked":t.checked!==!!s&&(t.checked=!!s);break;case"disabled":t.disabled!==!!s&&(t.disabled=!!s);break;case"hidden":const e=s?"none":"";t.style.display!==e&&(t.style.display=e);break;case"class":h&&(s?t.classList.add(h):t.classList.remove(h));break;case"style":h&&t.style[h]!==String(s??"")&&(t.style[h]=s??"");break;case"attr":if(h){t.getAttribute(h)!==String(s??"")&&t.setAttribute(h,s??"")}break;case"src":t.src!==String(s??"")&&(t.src=s??"");break;case"href":t.href!==String(s??"")&&(t.href=s??"");break;case"placeholder":t.placeholder!==String(s??"")&&(t.placeholder=s??"")}})}computed(t,s,i){this.computedProperties[t]={deps:s,callback:i},s.forEach(t=>{this.pathTrie.insert(t)}),this.updateComputedProperty(t)}updateComputedProperty(t){const s=this.computedProperties[t];if(s)try{const i=s.deps.map(t=>this.get(t)),e=s.callback(...i);this.set(t,e,!0)}catch(t){}}load(t){Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])?this.rawData[s]=this.wrapReactive(t[s],s):this.rawData[s]=t[s],this.queueUpdate(s,this.rawData[s])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new R,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,s={}){const{storage:i="local",debounce:e=0,version:n=1,encrypt:h=!1,encryptionKey:o=null}=s,r="session"===i?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:r,debounce:e,timeout:null,version:n,encrypt:h,encryptionKey:o});const a=this.get(t);void 0!==a&&this.S(t,a,r,{version:n,encrypt:h,encryptionKey:o}),this.observe(t,s=>{const i=this.persistedKeys.get(t);i&&(i.debounce>0?(i.timeout&&clearTimeout(i.timeout),i.timeout=setTimeout(()=>{this.S(t,s,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey})},i.debounce)):this.S(t,s,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey}))})}S(t,s,i,e={}){try{const{version:n=1,encrypt:h=!1,encryptionKey:o=null}=e,r={value:s,version:n,timestamp:Date.now()};let a=JSON.stringify(r);h&&o&&(a=this.C(a,o)),this.T(i),i.setItem(`kupola:${t}`,a)}catch(e){if("QuotaExceededError"===e.name&&i===localStorage)try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:s,version:1}))}catch(t){}}}T(t){try{const s="kupola:__storage_test__";t.setItem(s,"test"),t.removeItem(s)}catch(s){"QuotaExceededError"===s.name&&this.D(t)}}D(t){const s=Date.now();for(let i=0;i<t.length;i++){const e=t.key(i);if(e?.startsWith("kupola:"))try{const i=JSON.parse(t.getItem(e));i.timestamp&&s-i.timestamp>2592e6&&t.removeItem(e)}catch(s){t.removeItem(e)}}}C(t,s){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,s).toString():t}I(t,s){if(!window.CryptoJS)return t;try{return window.CryptoJS.AES.decrypt(t,s).toString(window.CryptoJS.enc.Utf8)}catch(s){return t}}unpersist(t){const s=this.persistedKeys.get(t);s&&(s.timeout&&clearTimeout(s.timeout),s.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const s={},{encryptionKey:i=null}=t;for(let e=0;e<localStorage.length;e++){const n=localStorage.key(e);if(n?.startsWith("kupola:")){const e=n.replace("kupola:","");try{const h=localStorage.getItem(n);let o;if(i){const t=this.I(h,i);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;s[e]=void 0!==o.value?o.value:o}catch(t){}}}for(let e=0;e<sessionStorage.length;e++){const n=sessionStorage.key(e);if(n?.startsWith("kupola:")){const e=n.replace("kupola:","");try{const h=sessionStorage.getItem(n);let o;if(i){const t=this.I(h,i);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;s[e]=void 0!==o.value?o.value:o}catch(t){}}}return Object.keys(s).length>0&&this.load(s),s}O(t){if("function"==typeof structuredClone)try{return structuredClone(t)}catch(t){}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this.O(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(0===this.snapshots.length)return!1;const s=t>=0?t:this.snapshots.length-1,i=this.snapshots[s];return!!i&&(this.rawData=this.O(i),this.createReactiveData(),Object.keys(this.rawData).forEach(t=>{this.queueUpdate(t,this.rawData[t])}),this.processComputed(),!0)}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const s={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const i=t.getAttribute("data-bind");if(!i)return;const e=i.split(":"),n=e[1]?.trim();n&&("checkbox"===t.type?(s[n]||(s[n]=[]),t.checked&&s[n].push(t.value)):"radio"===t.type?t.checked&&(s[n]=t.value):s[n]=t.value)}),s}fillForm(t,s){Object.keys(s).forEach(i=>{t.querySelectorAll('[data-bind*=":'+i+'"]').forEach(t=>{"checkbox"===t.type?t.checked=Array.isArray(s[i])?s[i].includes(t.value):!!s[i]:"radio"===t.type?t.checked=t.value===s[i]:t.value=s[i]??""})})}createReactive(t,s=""){if(t[N])return t;if(this.k.has(t))return this.k.get(t);const i={get:(t,s,i)=>{if("__raw__"===s)return t;if(s===P||"__parent__"===s)return t[P];if(s===L||"__path__"===s)return t[L];if(s===N||"__isReactive__"===s)return!0;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[L]}${t[L]?".":""}${s}`):e},set:(t,s,i,e)=>{if(s===P||s===L||s===N||"__parent__"===s||"__path__"===s||"__isReactive__"===s)return!0;const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=`${t[L]}${t[L]?".":""}${s}`;return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{if(s===P||s===L||s===N)return!1;const i=Reflect.get(t,s),e=Reflect.deleteProperty(t,s),n=`${t[L]}${t[L]?".":""}${s}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e},has:(t,s)=>"__raw__"===s||s===P||s===L||s===N||"__parent__"===s||"__path__"===s||"__isReactive__"===s||s in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==P&&t!==L&&t!==N),getOwnPropertyDescriptor:(t,s)=>s===P||s===L||s===N?{configurable:!1,enumerable:!1,writable:!1,value:t[s]}:Reflect.getOwnPropertyDescriptor(t,s)},e=new Proxy(t,i);return t[P]=t,t[L]=s,t[N]=!0,this.k.set(t,e),Object.keys(t).forEach(i=>{t[i]&&"object"==typeof t[i]&&!Array.isArray(t[i])&&(t[i]=this.wrapReactive(t[i],`${s}${s?".":""}${i}`))}),e}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this.A(t)}),this.F||(this.j=!1,this.F=new MutationObserver(t=>{if(!this.j){this.j=!0;try{t.forEach(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.querySelectorAll("[data-bind]").forEach(t=>this.A(t)),t.hasAttribute&&t.hasAttribute("data-bind")&&this.A(t)}})})}finally{this.j=!1}}}),this.F.observe(document.body,{childList:!0,subtree:!0}))}A(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const i=s[1]?.trim();if(i){if(this.pathTrie.insert(i),this.elements[i]||(this.elements[i]=[]),this.elements[i].includes(t)||this.elements[i].push(t),"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const s=t.R;s&&t.removeEventListener("input",s);const e=()=>{const s="checkbox"===t.type?t.checked:t.value;i.includes(".")?this.setNested(i,s):this.set(i,s)};t.R=e,t.addEventListener("input",e)}void 0!==this.rawData[i]&&this.updateElement(t,this.rawData[i])}}destroy(){this.F&&(this.F.disconnect(),this.F=null),Object.values(this.elements).forEach(t=>{t.forEach(t=>{const s=t.R;s&&(t.removeEventListener("input",s),delete t.R)})}),this.persistedKeys.forEach((t,s)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new R,this.updateQueue.clear(),this.snapshots=[]}}class H{constructor(t,s={}){this.name=t,this.P=`__store_${t}__`;const i=s.state?s.state():{};this.getters=s.getters||{},this.actions=s.actions||{},this.mutations=s.mutations||{},this.observers={},J?(J.set(this.P,i),this.state=J.data?.[this.P]||J.createReactive(i,this.P),J.observe(this.P,t=>{this.notify(t)})):this.state=i,this.L(),this.N()}L(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}N(){Object.keys(this.actions).forEach(t=>{this[t]=(...s)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...s)})}commit(t,s){const i=this.mutations[t];i&&i(this.state,s)}dispatch(t,s){const i=this.actions[t];if(i)return i({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},s)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(s=>s!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(s=>{try{s(t)}catch(t){}}),J&&J.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,s)=>(t[s]=this[s],t),{})}}}class V{constructor(){this.stores=new Map}createStore(t,s){const i=new H(t,s);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof H&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class U{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,s){return this.events[t]||(this.events[t]=[]),this.events[t].push(s),s}off(t,s){this.events[t]&&(this.events[t]=this.events[t].filter(t=>t!==s))}emit(t,s){this.events[t]&&this.events[t].forEach(t=>{try{t(s)}catch(t){}}),this.events["*"]?.forEach(i=>{try{i(t,s)}catch(t){}})}once(t,s){const i=e=>{s(e),this.off(t,i)};return this.on(t,i),i}delegate(t,s,i){if(!this.delegatedEvents[s]){this.delegatedEvents[s]=[];const t=t=>{this.delegatedEvents[s].forEach(({selector:s,cb:i})=>{(t.target.matches(s)||t.target.closest(s))&&i(t)})};document.addEventListener(s,t),this.eventListeners[s]=t}return this.delegatedEvents[s].push({selector:t,cb:i}),i}undelegate(t,s){if(this.delegatedEvents[s]&&(this.delegatedEvents[s]=this.delegatedEvents[s].filter(s=>s.selector!==t),0===this.delegatedEvents[s].length)){const t=this.eventListeners[s];t&&(document.removeEventListener(s,t),delete this.eventListeners[s]),delete this.delegatedEvents[s]}}destroy(){Object.entries(this.eventListeners).forEach(([t,s])=>{document.removeEventListener(t,s)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function q(t=null){const s={B:t,H:new Set};return Object.defineProperty(s,"value",{configurable:!0,enumerable:!0,get:()=>s.B,set(t){t!==s.B&&(s.B=t,s.H.forEach(s=>s(t)))}}),s.subscribe=t=>(s.H.add(t),{unsubscribe(){s.H.delete(t)}}),s}const J=new B,K=new U,W=new V;const Y={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}},Z=[];function G(){if("undefined"!=typeof window&&window.kupolaConfig)try{dt(Y,window.kupolaConfig),X()}catch(t){}}function X(){Z.forEach(t=>{try{t(Y)}catch(t){}})}function Q(t){"function"==typeof t&&Z.push(t)}function tt(t){return t?function(t,s){return s.split(".").reduce((t,s)=>void 0!==(t&&t[s])?t[s]:void 0,t)}(Y,t):Y}function st(){return Y.paths.base+Y.paths.icons.replace(/^\//,"")}function it(){return Y.theme.default}function et(){return Y.theme.brand}function nt(){return Y.ui}function ht(){return Y.zIndex}function ot(){return Y.security}function rt(){return Y.performance}function at(){return Y.message}function ct(){return Y.notification}function lt(){return Y.validation}function dt(t,s){for(const i in s)s[i]instanceof Object&&i in t&&t[i]instanceof Object?dt(t[i],s[i]):t[i]=s[i];return t}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",G):G());const ut="kupola-theme",pt="kupola-brand";Q(t=>{const s=document.querySelector("[data-theme-toggle]");if(s){const t=mt();vt(s),gt(t)}});const ft=[{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 mt(){return localStorage.getItem(ut)||it()}function gt(t){if("dark"!==t&&"light"!==t)return;var s=document.documentElement;s.hasAttribute("data-kupola-theme-preloaded")&&(s.style.removeProperty("--bg-base-default"),s.style.removeProperty("--text-default"),s.removeAttribute("data-kupola-theme-preloaded")),s.setAttribute("data-theme",t),localStorage.setItem(ut,t);const i=document.querySelector("[data-theme-toggle]");i&&(i.setAttribute("data-current-theme",t),vt(i))}function yt(){return localStorage.getItem(pt)||et()}function _t(t){const s=ft.find(s=>s.id===t);if(!s)return;document.documentElement.setAttribute("data-brand",t),localStorage.setItem(pt,t);const i=document.querySelector("[data-brand-toggle]");if(i){i.setAttribute("data-current-brand",t);const e=i.querySelector(".brand-icon");e&&(e.style.backgroundColor=s.color);const n=i.querySelector(".brand-name");n&&(n.textContent=s.name)}document.querySelectorAll("[data-brand-btn]").forEach(s=>{s.getAttribute("data-brand-btn")===t?s.classList.add("is-active"):s.classList.remove("is-active")})}function vt(t){const s=t.querySelector(".theme-icon");if(s){const t=mt(),i=st();s.src="dark"===t?i+"sun.svg":i+"moon.svg"}}function xt(t){t.preventDefault();gt("dark"===mt()?"light":"dark")}function bt(){var t=document.documentElement;t.hasAttribute("data-kupola-theme-preloaded")&&(t.style.removeProperty("--bg-base-default"),t.style.removeProperty("--text-default"),t.removeAttribute("data-kupola-theme-preloaded"));const s=document.querySelector("[data-theme-toggle]");gt(mt());_t(yt()),s&&(vt(s),s.removeEventListener("click",xt),s.addEventListener("click",xt));let i=document.getElementById("brand-picker");i||(i=document.createElement("div"),i.id="brand-picker",i.style.position="fixed",i.style.top="64px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",ft.forEach(t=>{const s=document.createElement("button");s.setAttribute("data-brand-btn",t.id),s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="60px",s.style.backgroundColor=t.color,s.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.color)?"#0C0C0D":"#FFFFFF",s.style.fontWeight="500",s.style.borderRadius="4px",s.style.border="none",s.style.cursor="pointer",s.style.margin="0",s.style.padding="0",s.textContent=t.name,i.appendChild(s)}),document.body.appendChild(i));const e=document.querySelector("[data-brand-toggle]");function n(t){i&&e&&(i.contains(t.target)||e.contains(t.target)||(i.style.display="none",document.removeEventListener("click",n,!0)))}e&&i&&(e.onclick=function(t){t.stopPropagation(),t.preventDefault();const s="none"===i.style.display;i.style.display=s?"grid":"none",s?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(t){t.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",s=>{s.stopPropagation();_t(t.getAttribute("data-brand-btn")),i&&(i.style.display="none")})})}class wt{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this.V=["data-component"],this.U=[],this.q=null}register(t,s,i=null,e={}){this.initializers.set(t,s),i&&this.cleanupFunctions.set(t,i),e.dataAttribute&&!this.V.includes(e.dataAttribute)&&(this.V.push(e.dataAttribute),this.q=null),e.cssClass&&!this.U.includes(e.cssClass)&&(this.U.push(e.cssClass),this.q=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)}J(){if(null!==this.q)return this.q;const t=this.V.map(t=>`[${t}]`);for(const s of this.U)t.push(`.${s}`);return this.q=t.join(", "),this.q}async initialize(t){if(this.processedElements.has(t))return;for(const s of this.V){const i=t.getAttribute(s);if(null!==i){const e=i||s.replace("data-",""),n=this.initializers.get(e)||this.initializers.get(s.replace("data-",""));if(n){try{await n(t),this.processedElements.add(t)}catch(t){}return}}}const s=t.className;if("string"==typeof s)for(const i of this.U){if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(s)){const s=i.replace("ds-",""),e=this.initializers.get(s)||this.initializers.get(i);if(e){try{await e(t),this.processedElements.add(t)}catch(t){}return}}}}cleanup(t){for(const s of this.V){const i=t.getAttribute(s);if(null!==i){const e=i||s.replace("data-",""),n=this.cleanupFunctions.get(e)||this.cleanupFunctions.get(s.replace("data-",""));if(n){try{n(t)}catch(t){}return void this.processedElements.delete(t)}}}const s=t.className;if("string"==typeof s)for(const i of this.U){if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(s)){const s=i.replace("ds-",""),e=this.cleanupFunctions.get(s)||this.cleanupFunctions.get(i);if(e){try{e(t)}catch(t){}return void this.processedElements.delete(t)}}}}async initializeAll(t=document){const s=this.J();if(!s)return;const i=t.querySelectorAll(s),e=[];i.forEach(t=>{this.processedElements.has(t)||e.push(this.initialize(t))}),await Promise.all(e)}}const kt=new wt,Mt=[{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 t of Mt)t.attr&&!kt.V.includes(t.attr)&&kt.V.push(t.attr),t.cls&&!kt.U.includes(t.cls)&&kt.U.push(t.cls);class $t{constructor(s){this.element=s,this.isMounted=!1,this.isDestroyed=!1,this.props=this.K(),this.state={},this.slots=this.W(),this.Y={},this.Z=[],this.lifecycle=new t,this.setupContext=null}K(){const t={};for(const s of this.element.attributes)if(s.name.startsWith("data-prop-")){const i=s.name.replace("data-prop-","");let e=s.value;try{e=JSON.parse(e)}catch(t){}t[i]=e}return t}W(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const i=s.getAttribute("data-slot")||"default";t[i]=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,s){if((this.Y[t]||[]).forEach(t=>{try{t(s)}catch(t){}}),this.element){const i=new CustomEvent(`kupola:${t}`,{detail:s,bubbles:!0,cancelable:!0});this.element.dispatchEvent(i)}}$on(t,s){return this.Y[t]||(this.Y[t]=[]),this.Y[t].push(s),s}$off(t,s){this.Y[t]&&(this.Y[t]=this.Y[t].filter(t=>t!==s))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?.G()}catch(s){this.lifecycle&&"function"==typeof this.lifecycle.m&&await this.lifecycle.m({phase:"update",hook:"setProps",error:s,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?.G()}catch(s){this.lifecycle&&"function"==typeof this.lifecycle.m&&await this.lifecycle.m({phase:"update",hook:"setState",error:s,args:[t]})}}async mount(){if(!this.isMounted&&!this.isDestroyed)try{if(this.X(),await this.lifecycle.bootstrap(),"function"==typeof this.setup){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?.tt()}catch(t){if(this.lifecycle&&"function"==typeof this.lifecycle.m&&await this.lifecycle.m({phase:"mount",hook:"component",error:t,args:[]}),"function"==typeof this.renderError)try{this.renderError(t)}catch(t){}else this.element.innerHTML=`\n <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">\n <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>\n <div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>\n </div>\n `}}X(){if(this.st)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let s=Object.getPrototypeOf(this);const i=new Set;for(;s&&s.constructor!==Object&&s.constructor!==$t;){for(const[e,n]of Object.entries(t))i.has(e)||s.hasOwnProperty(e)&&(Array.isArray(n)?n.forEach(t=>{"render"===e&&this.lifecycle.on(t,()=>this.render?.())}):"renderError"===e?this.lifecycle.on(n,t=>(this.renderError(t.error),"handled")):this.lifecycle.on(n,()=>this[e]?.()),i.add(e));s=Object.getPrototypeOf(s)}this.st=!0}async unmount(){if(this.isMounted&&!this.isDestroyed)try{this.setupContext?.it(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(t){this.lifecycle&&"function"==typeof this.lifecycle.m&&await this.lifecycle.m({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function St(t,s){Object.keys(s).forEach(i=>{if("constructor"!==i)if("function"==typeof s[i]){const e=t.prototype[i];t.prototype[i]=e?function(...t){return s[i].apply(this,t),e.apply(this,t)}:s[i]}else t.prototype[i]=s[i]})}class Ct{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,s){if(!(s.prototype instanceof $t))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,s)}registerLazy(t,s){this.lazyComponents.set(t,s)}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 s=this.components.get(t)||this.loadedComponents.get(t);if(s)return s;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const i=this.lazyComponents.get(t);if(!i)throw new Error(`Component ${t} not found`);const e=(async()=>{try{const s=await i(),e=s.default||s;if(!(e.prototype instanceof $t))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,e),e}catch(s){throw this.loadingPromises.delete(t),s}})();return this.loadingPromises.set(t,e),e}defineMixin(t,s){this.mixins.set(t,s)}useMixin(t,...s){s.forEach(s=>{const i=this.mixins.get(s);i&&St(t,i)})}async bootstrap(t=document){await this.et(t),this.nt(t)}async et(t){const s=t.querySelectorAll("[data-component]"),i=[];s.forEach(t=>{i.push(this.ht(t))}),await Promise.all(i)}async ht(t){if(!t.ot&&!t.rt){t.rt=!0;try{const s=t.getAttribute("data-component");if(s){const i=kt.get(s);if(i)try{return void await i(t)}catch(t){}}let i=this.components.get(s);if(!i){try{i=await this.getAsync(s)}catch(t){return}if(!t.isConnected)return}const e=t.getAttribute("data-mixins"),n=i;e&&e.split(",").forEach(t=>{const s=this.mixins.get(t.trim());s&&St(n,s)});const h=new n(t);t.ot=h,this.instances.set(t,h),h.mount()}finally{t.rt=!1}}}nt(t){this.observer||(this.observer=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.hasAttribute("data-component")&&this.ht(t).catch(t=>{}),this.et(t).catch(t=>{}),kt.initialize(t).catch(()=>{});const s=kt.J();s&&t.querySelectorAll?.(s).forEach(t=>{kt.initialize(t).catch(()=>{})})}}),t.removedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const s=this.instances.get(t);s&&(s.unmount(),this.instances.delete(t)),t.querySelectorAll("[data-component]").forEach(t=>{const s=this.instances.get(t);s&&(s.unmount(),this.instances.delete(t))}),kt.cleanup(t),t.querySelectorAll?.("*").forEach(t=>{kt.cleanup(t)})}})})}),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()}}async function Tt(){if("undefined"!=typeof window){!function(){if(ot().xssProtection&&"undefined"!=typeof document){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild))}}();const t=tt();J.loadPersisted(),J.bind(),bt(),!1!==t.components?.autoInit&&(await kt.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}exports.kupolaRegistry=null,"undefined"!=typeof window&&(exports.kupolaRegistry=new Ct),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Tt):"undefined"!=typeof window&&setTimeout(Tt,0);class Et{constructor(t={}){const s=tt();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||s.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||s.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(t=>t),this.ct()}ct(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(t=>{const s=t.dataset.kupolaI18n;if(s)try{const i=JSON.parse(t.textContent);this.addLocale(s,i)}catch(t){}});const t=document.documentElement.lang;t&&this.locales[t]&&(this.currentLocale=t)}addLocale(t,s){this.locales[t]||(this.locales[t]={}),this.lt(this.locales[t],s)}lt(t,s){for(const i of Object.keys(s))s[i]instanceof Object&&i in t?this.lt(t[i],s[i]):t[i]=s[i]}setLocale(t){return!!this.locales[t]&&(this.currentLocale=t,document.documentElement.lang=t,this.dt(),!0)}getLocale(){return this.currentLocale}t(t,s={}){let i=this.ut(t,this.currentLocale);return i||(i=this.ut(t,this.fallbackLocale)),i?this.ft(i,s):this.missingHandler(t)}ut(t,s){if(!this.locales[s])return null;const i=t.split(this.delimiter);let e=this.locales[s];for(const t of i){if(!e||"object"!=typeof e||!(t in e))return null;e=e[t]}return"string"==typeof e?e:null}ft(t,s){return t.replace(/\{(\w+)\}/g,(t,i)=>void 0!==s[i]?s[i]:t)}n(t,s,i={}){const e=this.t(t,{...i,count:s});if(!e)return e;const n=e.split("|");return 1===n.length?e.replace("{count}",s):2===n.length?1===s?n[0]:n[1]:n.length>=3?0===s?n[0]:1===s?n[1]:n[2]:e}dt(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,s){try{const i=await fetch(s),e=await i.json();return this.addLocale(t,e),!0}catch(t){return!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,s={}){const i=s.locale||this.currentLocale,e="string"==typeof t?new Date(t):t;return new Intl.DateTimeFormat(i,s).format(e)}formatNumber(t,s={}){const i=s.locale||this.currentLocale;return new Intl.NumberFormat(i,s).format(t)}formatCurrency(t,s,i={}){const e=i.locale||this.currentLocale;return new Intl.NumberFormat(e,{style:"currency",currency:s,...i}).format(t)}formatRelativeTime(t,s,i={}){const e=i.locale||this.currentLocale;return new Intl.RelativeTimeFormat(e,i).format(t,s)}}const Dt=new Et;class It{constructor(){this.gt=new Map,this.yt=new Map}on(t,s,i,e={}){const{scope:n=null,once:h=!1,passive:o=!1,capture:r=!1}=e,a=this._t(),c={id:a,target:t,eventName:s,handler:i,scope:n,once:h,wrappedHandler:null};c.wrappedHandler=s=>{h&&this.offById(a),i.call(t,s)};const l=this.vt(t,s);return this.gt.has(l)||this.gt.set(l,[]),this.gt.get(l).push(c),n&&(this.yt.has(n)||this.yt.set(n,[]),this.yt.get(n).push(a)),t.addEventListener(s,c.wrappedHandler,{passive:o,capture:r}),{unsubscribe:()=>this.offById(a)}}once(t,s,i,e={}){return this.on(t,s,i,{...e,once:!0})}off(t,s,i){const e=this.vt(t,s);if(!this.gt.has(e))return;const n=this.gt.get(e),h=n.filter(t=>t.handler!==i);n.forEach(e=>{e.handler===i&&(t.removeEventListener(s,e.wrappedHandler),this.xt(e))}),0===h.length?this.gt.delete(e):this.gt.set(e,h)}offById(t){for(const[s,i]of this.gt){const e=i.findIndex(s=>s.id===t);if(-1!==e){const t=i[e];return t.target.removeEventListener(t.eventName,t.wrappedHandler),i.splice(e,1),0===i.length&&this.gt.delete(s),this.xt(t),!0}}return!1}offByScope(t){if(!this.yt.has(t))return;this.yt.get(t).forEach(t=>{this.offById(t)}),this.yt.delete(t)}offAll(t,s=null){if(s){const i=this.vt(t,s);if(!this.gt.has(i))return;this.gt.get(i).forEach(i=>{t.removeEventListener(s,i.wrappedHandler),this.xt(i)}),this.gt.delete(i)}else for(const[s,i]of this.gt){const[e]=s.split(":");this.bt(t)===e&&(i.forEach(s=>{t.removeEventListener(s.eventName,s.wrappedHandler),this.xt(s)}),this.gt.delete(s))}}emit(t,s,i={}){const e=new CustomEvent(s,{detail:i,bubbles:!0,cancelable:!0});return t.dispatchEvent(e),e}emitGlobal(t,s={}){return this.emit(document,t,s)}emitToScope(t,s,i={}){if(!this.yt.has(t))return;const e=this.yt.get(t),n=new Set;for(const[t,s]of this.gt)s.forEach(t=>{e.includes(t.id)&&n.add(t.target)});n.forEach(t=>{this.emit(t,s,i)})}getListenerCount(t,s=null){if(s){const i=this.vt(t,s);return this.gt.has(i)?this.gt.get(i).length:0}let i=0;const e=this.bt(t);for(const[t,s]of this.gt){const[n]=t.split(":");n===e&&(i+=s.length)}return i}getScopeListenerCount(t){return this.yt.has(t)?this.yt.get(t).length:0}hasListeners(t,s=null){return this.getListenerCount(t,s)>0}vt(t,s){return`${this.bt(t)}:${s}`}bt(t){return t===document?"document":t===window?"window":t===document.body?"body":(t.wt||(t.wt=this._t()),t.wt)}_t(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}xt(t){if(!t.scope||!this.yt.has(t.scope))return;const s=this.yt.get(t.scope),i=s.indexOf(t.id);-1!==i&&(s.splice(i,1),0===s.length&&this.yt.delete(t.scope))}destroy(){for(const[t,s]of this.gt)s.forEach(t=>{t.target.removeEventListener(t.eventName,t.wrappedHandler)});this.gt.clear(),this.yt.clear()}}const Ot=new It;class At{constructor(t,s={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const i=nt();this.triggerMode=s.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=s.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=s.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==s.keyboardNav,this.autoPosition=!1!==s.autoPosition,this.closeOnClick=void 0!==s.closeOnClick?s.closeOnClick:void 0===i.dropdown?.closeOnClick||i.dropdown.closeOnClick,this.appendToBody=!1!==s.appendToBody,this.onSelect=s.onSelect||null,this.onShow=s.onShow||null,this.onHide=s.onHide||null,this.isOpen=!1,this.focusIndex=-1,this.kt=null,this.Mt=null,this.$t=null,this.St=null,this.Ct=null,this.Tt=null,this.Et=null,this.Dt=null,this.It=null,this.Ot=null,this.At=null,this.Ft=null,this.zt=null,this.jt=null}init(){this.trigger&&this.menu&&(this.element.Rt||(this.Dt=t=>{t.stopPropagation();const s=t.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))},this.Pt(),this.Ct=t=>{t.stopPropagation(),this.disabled||this.toggleMenu()},this.Ft=()=>{this.disabled||"hover"!==this.triggerMode||(clearTimeout(this.Mt),this.kt=setTimeout(()=>this.showMenu(),this.hoverDelay))},this.zt=()=>{"hover"===this.triggerMode&&(clearTimeout(this.kt),this.Mt=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this.Ot=()=>{this.disabled||"hover"!==this.triggerMode||clearTimeout(this.Mt)},this.At=()=>{"hover"===this.triggerMode&&(this.Mt=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this.It=t=>{if(!this.isOpen||this.disabled)return;const s=this.Lt();if(s.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,s.length-1),this.Nt(s);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.Nt(s);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&s[this.focusIndex]&&s[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this.Nt(s);break;case"End":t.preventDefault(),this.focusIndex=s.length-1,this.Nt(s)}},"hover"===this.triggerMode?(this.trigger.addEventListener("mouseenter",this.Ft),this.trigger.addEventListener("mouseleave",this.zt),this.menu.addEventListener("mouseenter",this.Ot),this.menu.addEventListener("mouseleave",this.At)):this.trigger.addEventListener("click",this.Ct),this.jt=t=>{this.disabled||"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this.jt),document.addEventListener("keydown",this.It),this.Tt=t=>{if(!this.isOpen)return;const s=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);s||i||this.hideMenu()},this.Et=Ot.on(document,"click",this.Tt,{scope:this.scope}),this.menu.style.display="none",this.element.Rt=!0))}Pt(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.Bt=t=>this.Dt(t),t.addEventListener("click",t.Bt)})}Lt(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}Nt(t){t.forEach(t=>t.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}Ht(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),s=window.innerHeight,i=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const e=this.menu.getBoundingClientRect(),n=s-t.bottom,h=t.top;n<e.height&&h>n?(this.menu.style.top=t.top-e.height-4+"px",this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+e.width>i?(this.menu.style.left=t.right-e.width+"px",this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const e=s-t.bottom,n=t.top;e<menuRect.height&&n>e?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>i?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this.Vt(),this.Ut()),this.menu.style.display="block",this.Ht(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this.qt(),this.Jt()),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})))}Vt(){if(!this.menu)return;this.$t=this.menu.parentNode,this.St=this.menu.style.position,this.Kt=this.menu.style.top,this.Wt=this.menu.style.left,this.Yt=this.menu.style.right,this.Zt=this.menu.style.bottom,this.Gt=this.menu.style.marginBottom,this.Xt=this.menu.style.width,this.Qt=this.menu.style.transform,this.ts=this.menu.style.zIndex,this.ss=this.menu.style.display;const t=this.element.getBoundingClientRect(),s=ht().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=s,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}qt(){this.menu&&this.$t&&(this.$t.appendChild(this.menu),this.menu.style.position=this.St||"",this.menu.style.top=this.Kt||"",this.menu.style.left=this.Wt||"",this.menu.style.right=this.Yt||"",this.menu.style.bottom=this.Zt||"",this.menu.style.marginBottom=this.Gt||"",this.menu.style.width=this.Xt||"",this.menu.style.zIndex=this.ts||"",this.menu.style.transform=this.Qt||"",this.menu.style.display=this.ss||"",this.$t=null)}Ut(){this.es=()=>{this.hideMenu()},window.addEventListener("scroll",this.es,!0)}Jt(){this.es&&(window.removeEventListener("scroll",this.es,!0),this.es=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this.Dt||(this.Dt=t=>{t.stopPropagation();const s=t.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.Bt&&t.removeEventListener("click",t.Bt)}),this.menu.innerHTML="",t.forEach((t,s)=>{if("divider"===t.type){const t=document.createElement("div");t.className="ds-dropdown__divider",this.menu.appendChild(t)}else{const s=document.createElement("div");s.className="ds-dropdown__item"+(t.disabled?" is-disabled":"")+(t.active?" is-selected":""),s.textContent=t.text||t.label||"",void 0!==t.value&&s.setAttribute("data-value",t.value),t.icon&&(s.innerHTML=t.icon+s.innerHTML),t.disabled&&s.classList.add("is-disabled"),s.Bt=t=>this.Dt(t),s.addEventListener("click",s.Bt),this.menu.appendChild(s)}})}destroy(){this.element.Rt&&(clearTimeout(this.kt),clearTimeout(this.Mt),this.trigger&&(this.Ct&&this.trigger.removeEventListener("click",this.Ct),this.Ft&&this.trigger.removeEventListener("mouseenter",this.Ft),this.zt&&this.trigger.removeEventListener("mouseleave",this.zt),this.jt&&this.trigger.removeEventListener("keydown",this.jt)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.Bt&&t.removeEventListener("click",t.Bt)}),this.Ot&&this.menu.removeEventListener("mouseenter",this.Ot),this.At&&this.menu.removeEventListener("mouseleave",this.At)),this.It&&document.removeEventListener("keydown",this.It),this.Et&&this.Et.unsubscribe?this.Et.unsubscribe():this.Tt&&document.removeEventListener("click",this.Tt),this.appendToBody&&this.$t&&this.qt(),this.Tt=null,this.Et=null,this.Ct=null,this.Dt=null,this.It=null,this.Ot=null,this.At=null,this.Ft=null,this.zt=null,this.jt=null,this.element.Rt=!1)}}function Ft(t,s){t.ns&&t.ns.destroy();const i=new At(t,s);i.init(),t.ns=i}function zt(t){t.ns&&(t.ns.destroy(),t.ns=null)}kt.register("dropdown",Ft,zt);class jt{constructor(t,s={}){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=s.multiple||t.hasAttribute("data-select-multiple"),this.searchable=s.searchable||t.hasAttribute("data-select-search"),this.clearable=s.clearable||t.hasAttribute("data-select-clear"),this.placeholder=s.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=s.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=s.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=s.remoteMethod||null,this.onChange=s.onChange||null,this.appendToBody=!1!==s.appendToBody,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this.$t=null,this.St=null,this.Ct=null,this.Tt=null,this.Et=null,this.hs=null,this.It=null}init(){this.trigger&&this.optionsEl&&(this.element.Rt||(this.rs(),this.searchable&&this.cs(),this.clearable&&this.ls(),this.multiple&&this.ds(),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.hs=t=>{t.stopPropagation();const s=t.currentTarget;if(s.classList.contains("is-disabled"))return;const i=s.getAttribute("data-value");this.multiple?this.us(i,s):this.ps(i,s)},this.fs(),this.Ct=t=>{t.stopPropagation(),this.disabled||this.toggleOptions()},this.trigger.addEventListener("click",this.Ct),this.It=t=>{if(!this.isOpen||this.disabled)return;const s=this.gs();if(s.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,s.length-1),this.ys(s);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.ys(s);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&s[this.focusIndex]&&s[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus()}},document.addEventListener("keydown",this.It),this.Tt=t=>{if(!this.isOpen)return;const s=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);s||i||this.hideOptions()},this.Et=Ot.on(document,"click",this.Tt,{scope:this.scope}),this._s(),this.optionsEl.style.display="none",this.element.Rt=!0))}rs(){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]}cs(){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.vs()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}ls(){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",t=>{t.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}ds(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}vs(){const t=this.searchInput.value.toLowerCase().trim();this.remoteMethod?this.remoteMethod(t,t=>{this.xs(t)}):(this.filteredOptions=this.allOptions.filter(s=>s.text.toLowerCase().includes(t)),this.allOptions.forEach(t=>{const s=this.filteredOptions.includes(t);t.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(t=>{const s=t.getAttribute("data-group"),i=this.filteredOptions.some(t=>t.group===s);t.style.display=i?"":"none"}),this.focusIndex=-1)}xs(t){this.hs||(this.hs=t=>{t.stopPropagation();const s=t.currentTarget;if(s.classList.contains("is-disabled"))return;const i=s.getAttribute("data-value");this.multiple?this.us(i,s):this.ps(i,s)}),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.bs&&t.removeEventListener("click",t.bs),t.remove()}),t.forEach(t=>{const s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",t.value),s.textContent=t.text||t.label,t.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(t.value)&&s.classList.add("is-selected"),s.bs=t=>this.hs(t),s.addEventListener("click",s.bs),this.optionsEl.appendChild(s)}),this.allOptions=t.map(t=>({el:this.optionsEl.querySelector(`[data-value="${t.value}"]`),value:t.value,text:t.text||t.label,group:"",disabled:!!t.disabled})),this.filteredOptions=[...this.allOptions]}ps(t,s){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(s.textContent.trim()),this.ks(),this.hideOptions(),this.Ms(),this.$s()}us(t,s){if(this.selectedValues.has(t))this.selectedValues.delete(t),s.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),s.classList.add("is-selected")}this.Ss(),this.Cs(),this.ks(),this.Ms(),this.$s()}Ss(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const s=this.allOptions.find(s=>s.value===t);if(!s)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=s.text;const e=document.createElement("button");e.className="ds-select__tag-close",e.type="button",e.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.addEventListener("click",s=>{s.stopPropagation(),this.selectedValues.delete(t);const i=this.optionsEl.querySelector(`[data-value="${t}"]`);i&&i.classList.remove("is-selected"),this.Ss(),this.Cs(),this.ks(),this.Ms(),this.$s()}),i.appendChild(e),this.tagsWrap.appendChild(i)}))}Cs(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;0===t?(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 0===this.selectedValues.size&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}Ms(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}ks(){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]||"")}$s(){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}))}_s(){if(this.nativeSelect)if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const s=this.optionsEl.querySelector(`[data-value="${t.value}"]`);s&&s.classList.add("is-selected")}),this.Ss(),this.Cs();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.Ms()}fs(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.bs=t=>this.hs(t),t.addEventListener("click",t.bs)})}gs(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>"none"!==t.style.display&&!t.classList.contains("is-disabled"))}ys(t){t.forEach(t=>t.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this.Ts(),this.Ut()),this.optionsEl.style.display="block",this.Es(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this.Ds(),this.Jt()),this.searchInput&&(this.searchInput.value="",this.vs()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}Ut(){this.es=()=>{this.hideOptions()},window.addEventListener("scroll",this.es,!0)}Jt(){this.es&&(window.removeEventListener("scroll",this.es,!0),this.es=null)}Ts(){if(!this.optionsEl)return;this.$t=this.optionsEl.parentNode,this.St=this.optionsEl.style.position,this.Kt=this.optionsEl.style.top,this.Wt=this.optionsEl.style.left,this.Yt=this.optionsEl.style.right,this.Xt=this.optionsEl.style.width,this.Qt=this.optionsEl.style.transform,this.ts=this.optionsEl.style.zIndex;const t=this.element.getBoundingClientRect(),s=ht().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=s,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}Ds(){this.optionsEl&&this.$t&&(this.$t.appendChild(this.optionsEl),this.optionsEl.style.position=this.St||"",this.optionsEl.style.top=this.Kt||"",this.optionsEl.style.left=this.Wt||"",this.optionsEl.style.right=this.Yt||"",this.optionsEl.style.width=this.Xt||"",this.optionsEl.style.zIndex=this.ts||"",this.optionsEl.style.transform=this.Qt||"",this.$t=null)}Es(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),s=window.innerHeight,i=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const e=this.optionsEl.getBoundingClientRect(),n=s-t.bottom,h=t.top;n<e.height&&h>n?this.optionsEl.style.top=t.top-e.height-4+"px":this.optionsEl.style.top=`${t.bottom+4}px`,t.left+e.width>i?this.optionsEl.style.left=t.right-e.width+"px":this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this.Ss(),this.Cs(),this.ks(),this.Ms(),this.$s()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const s=this.allOptions.find(s=>s.value===t);return s?{value:s.value,text:s.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(t=>this.selectedValues.add(t)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.classList.toggle("is-selected",this.selectedValues.has(t.getAttribute("data-value")))}),this.Ss(),this.Cs()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(s=>{const i=s.getAttribute("data-value")===t;s.classList.toggle("is-selected",i),i&&this.updateValue(s.textContent.trim())})),this.ks(),this.Ms()}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.Rt&&(this.trigger&&this.Ct&&this.trigger.removeEventListener("click",this.Ct),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.bs&&t.removeEventListener("click",t.bs)}),this.It&&document.removeEventListener("keydown",this.It),this.Et&&this.Et.unsubscribe?this.Et.unsubscribe():this.Tt&&document.removeEventListener("click",this.Tt),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this.$t&&this.Ds(),this.Tt=null,this.Et=null,this.Ct=null,this.hs=null,this.It=null,this.element.Rt=!1)}}function Rt(t,s){const i=new jt(t,s);i.init(),t.Is=i}function Pt(t){t.Is&&(t.Is.destroy(),t.Is=null)}kt.register("select",Rt,Pt);class Lt{constructor(t,s={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const i=nt(),e=void 0!==i.datepicker?.weekStart?i.datepicker.weekStart:1;this.format=s.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=s.range||t.hasAttribute("data-datepicker-range"),this.minDate=s.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=s.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=s.disabledDate||null,this.weekStart=void 0!==s.weekStart?s.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||e,this.appendToBody=!1!==s.appendToBody,this.placeholder=s.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==s.showToday,this.showWeekNumber=s.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=s.onChange||null,this.months=s.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=s.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=s.todayText||"Today",this.clearText=s.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.Os=null,this.As=null,this.Fs=null,this.Tt=null,this.$t=null,this.Et=null,this.zs=null,this.js=null,this.It=null}init(){if(this.calendarEl&&!this.element.Rt){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");2===t.length&&(this.rangeStart=this.Rs(t[0].trim()),this.rangeEnd=this.Rs(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this.Rs(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.Os=t=>this.toggleCalendar(t),this.As=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this.Os),this.input&&this.input.addEventListener("click",this.As),this.endInput&&(this.Fs=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this.Fs)),this.Et=Ot.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this.js=Ot.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this.It=t=>{"Escape"===t.key&&"block"===this.calendarEl.style.display&&this.hideCalendar(t)},document.addEventListener("keydown",this.It),this.element.Rt=!0,this.Ps()}}Rs(t){if(!t)return null;const s=t.split("-");return 3===s.length?new Date(parseInt(s[0]),parseInt(s[1])-1,parseInt(s[2])):null}Ls(t){if(!t)return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",s).replace("MM",i).replace("DD",e)}Ns(t){if(this.minDate){if(t<("string"==typeof this.minDate?this.Rs(this.minDate):this.minDate))return!0}if(this.maxDate){if(t>("string"==typeof this.maxDate?this.Rs(this.maxDate):this.maxDate))return!0}return!!this.disabledDate&&this.disabledDate(t)}Bs(t){const s=new Date;return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}Hs(t,s){return!(!t||!s)&&(t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate())}Vs(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const s=t.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),e=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return s>=i&&s<=e}calculatePosition(){const t=this.element.getBoundingClientRect(),s=this.calendarEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,e=t.top,n=s.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,i>=n?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):e>=n?(this.calendarEl.style.top=t.top-n-4+"px",this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):i>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):e>=n?(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 s="block"===this.calendarEl.style.display;document.querySelectorAll(".ds-datepicker__calendar").forEach(t=>{t!==this.calendarEl&&(t.style.display="none",t.setAttribute("hidden",""))}),s||(this.appendToBody&&(this.Us(),this.Ut()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||this.calendarEl.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this.qs(),this.Jt()))}Ut(){this.es=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this.es,!0)}Jt(){this.es&&(window.removeEventListener("scroll",this.es,!0),this.es=null)}Us(){if(!this.calendarEl)return;this.$t=this.calendarEl.parentNode,this.St=this.calendarEl.style.position,this.Kt=this.calendarEl.style.top,this.Wt=this.calendarEl.style.left,this.Xt=this.calendarEl.style.width,this.Qt=this.calendarEl.style.transform,this.ts=this.calendarEl.style.zIndex;const t=ht().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}qs(){this.calendarEl&&this.$t&&(this.$t.appendChild(this.calendarEl),this.calendarEl.style.position=this.St||"",this.calendarEl.style.top=this.Kt||"",this.calendarEl.style.left=this.Wt||"",this.calendarEl.style.width=this.Xt||"",this.calendarEl.style.zIndex=this.ts||"",this.calendarEl.style.transform=this.Qt||"",this.$t=null)}resizeHandler(){"block"===this.calendarEl.style.display&&this.calculatePosition()}Ps(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.Js&&t.removeEventListener("click",t.Js)}),"years"===this.viewMode)return void this.Ks();if("months"===this.viewMode)return void this.Ws();const s=this.currentDate.getFullYear(),i=this.currentDate.getMonth();t.innerHTML="";const e=document.createElement("div");e.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",t=>{t.stopPropagation(),this.Ys()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${s} ${this.months[i]}`,h.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",this.Ps()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.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>',o.addEventListener("click",t=>{t.stopPropagation(),this.Zs()}),e.appendChild(n),e.appendChild(h),e.appendChild(o),t.appendChild(e);const r=document.createElement("div");r.className="ds-datepicker__weekdays";[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(t=>{const s=document.createElement("span");s.className="ds-datepicker__weekday",s.textContent=t,r.appendChild(s)}),t.appendChild(r);const a=document.createElement("div");a.className="ds-datepicker__days";const c=new Date(s,i,1).getDay(),l=new Date(s,i+1,0).getDate(),d=(c-this.weekStart+7)%7;for(let t=0;t<d;t++){const t=document.createElement("span");t.className="ds-datepicker__day ds-datepicker__day--empty",a.appendChild(t)}for(let t=1;t<=l;t++){const e=new Date(s,i,t),n=document.createElement("button");n.className="ds-datepicker__day",n.type="button",n.textContent=t,this.Ls(e),this.Bs(e)&&n.classList.add("is-today"),this.range?((this.Hs(e,this.rangeStart)||this.Hs(e,this.rangeEnd))&&n.classList.add("is-selected"),this.Vs(e)&&n.classList.add("is-in-range")):this.Hs(e,this.selectedDate)&&n.classList.add("is-selected"),this.Ns(e)&&(n.classList.add("is-disabled"),n.disabled=!0);const h=()=>this.Gs(e);n.addEventListener("click",h),n.Js=h,a.appendChild(n)}if(t.appendChild(a),this.showToday){const s=document.createElement("div");s.className="ds-datepicker__footer";const i=document.createElement("button");i.className="ds-datepicker__today-btn",i.type="button",i.textContent=this.todayText,i.addEventListener("click",t=>{t.stopPropagation(),this.Xs()});const e=document.createElement("button");e.className="ds-datepicker__clear-btn",e.type="button",e.textContent=this.clearText,e.addEventListener("click",t=>{t.stopPropagation(),this.Qs()}),s.appendChild(i),s.appendChild(e),t.appendChild(s)}}Ks(){const t=this.calendarEl;t.innerHTML="";const s=this.currentDate.getFullYear(),i=s-6,e=document.createElement("div");e.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",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this.Ps()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${i} - ${i+11}`,h.addEventListener("click",t=>{t.stopPropagation()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.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>',o.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this.Ps()}),e.appendChild(n),e.appendChild(h),e.appendChild(o),t.appendChild(e);const r=document.createElement("div");r.className="ds-datepicker__years-grid";for(let t=0;t<12;t++){const e=i+t,n=document.createElement("button");n.className="ds-datepicker__year-cell",n.type="button",n.textContent=e,e===s&&n.classList.add("is-selected"),n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(e),this.viewMode="months",this.Ps()}),r.appendChild(n)}t.appendChild(r)}Ws(){const t=this.calendarEl;t.innerHTML="";const s=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const e=document.createElement("button");e.className="ds-datepicker__nav ds-datepicker__nav--prev",e.type="button",e.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>',e.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this.Ps()});const n=document.createElement("button");n.className="ds-datepicker__title",n.type="button",n.textContent=s,n.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="years",this.Ps()});const h=document.createElement("button");h.className="ds-datepicker__nav ds-datepicker__nav--next",h.type="button",h.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>',h.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this.Ps()}),i.appendChild(e),i.appendChild(n),i.appendChild(h),t.appendChild(i);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((t,s)=>{const i=document.createElement("button");i.className="ds-datepicker__month-cell",i.type="button",i.textContent=t,s===this.currentDate.getMonth()&&i.classList.add("is-selected"),i.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(s),this.viewMode="days",this.Ps()}),o.appendChild(i)}),t.appendChild(o)}Gs(t){if(!this.Ns(t)){if(!this.range)return this.selectedDate=t,this.input&&(this.input.value=this.Ls(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this.$s();if(this.isSelectingEnd&&this.rangeStart)return this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this.Ls(this.rangeStart)),this.endInput&&(this.endInput.value=this.Ls(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this.$s();this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0,this.Ps()}}$s(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this.Ls(this.rangeStart),endStr:this.Ls(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this.Ls(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this.Ls(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}Ys(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.Ps()}Zs(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.Ps()}Xs(){const t=new Date;this.currentDate=new Date(t),this.Ns(t)?this.Ps():this.Gs(t)}Qs(){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.$s()}setDate(t){const s="string"==typeof t?this.Rs(t):t;s&&(this.selectedDate=s,this.currentDate=new Date(s),this.input&&(this.input.value=this.Ls(s)),this.Ps())}getDate(){return this.selectedDate}setRange(t,s){this.rangeStart="string"==typeof t?this.Rs(t):t,this.rangeEnd="string"==typeof s?this.Rs(s):s,this.input&&(this.input.value=this.Ls(this.rangeStart)),this.endInput&&(this.endInput.value=this.Ls(this.rangeEnd)),this.Ps()}destroy(){this.element.Rt&&(this.icon&&this.Os&&this.icon.removeEventListener("click",this.Os),this.input&&this.As&&this.input.removeEventListener("click",this.As),this.endInput&&this.Fs&&this.endInput.removeEventListener("click",this.Fs),this.It&&document.removeEventListener("keydown",this.It),this.Et&&this.Et.unsubscribe?this.Et.unsubscribe():this.Tt&&document.removeEventListener("click",this.Tt),this.js&&this.js.unsubscribe?this.js.unsubscribe():this.zs&&window.removeEventListener("resize",this.zs),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.Js&&t.removeEventListener("click",t.Js)}),this.appendToBody&&this.$t&&this.qs(),this.Tt=null,this.zs=null,this.Et=null,this.js=null,this.Os=null,this.As=null,this.Fs=null,this.It=null,this.element.Rt=!1)}}function Nt(t,s){const i=new Lt(t,s);i.init(),t.ti=i}function Bt(t){t.ti&&(t.ti.destroy(),t.ti=null)}kt.register("datepicker",Nt,Bt);class Ht{constructor(t,s={}){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=s.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=s.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=s.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=s.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=s.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=s.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=s.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=s.disabledTime||null,this.placeholder=s.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=s.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=s.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this.si=null,this.Tt=null,this.Et=null,this.zs=null,this.js=null,this.It=null}init(){this.element.Rt||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this.ii(),this.si=t=>{t.stopPropagation(),this.panelEl&&"block"===this.panelEl.style.display?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this.si),this.Et=Ot.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this.js=Ot.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this.It=t=>{"Escape"===t.key&&this.panelEl&&"block"===this.panelEl.style.display&&this.hideTimepicker()},document.addEventListener("keydown",this.It),this.element.Rt=!0)}ii(){const t=this.input.value.trim();if(!t)return;const s=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(s)return this.selectedHour=parseInt(s[1])%12,"PM"===s[4].toUpperCase()&&(this.selectedHour+=12),this.selectedMinute=parseInt(s[2]),void(this.selectedSecond=s[3]?parseInt(s[3]):0);const i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}ei(t,s,i){if(this.disabledTime)return this.disabledTime(t,s,i);const e=3600*t+60*s+i;if(this.minTime){const t=this.minTime.split(":");if(e<3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}if(this.maxTime){const t=this.maxTime.split(":");if(e>3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}return!1}ni(){let t=this.selectedHour,s=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const e=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")} ${e}`:`${t}:${String(s).padStart(2,"0")} ${e}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(s).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),s=this.panelEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,e=t.top,n=s.height||320;i>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):e>=n?(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)return this.panelEl.style.display="block",this.hi(),void this.calculatePosition();this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Hour</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>\n </div>',t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Min</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>\n </div>',this.showSeconds&&(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Sec</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--second" data-type="second"></div>\n </div>'),this.use12Hour&&(t+='<div class="ds-timepicker__section ds-timepicker__section--ampm">\n <div class="ds-timepicker__grid ds-timepicker__grid--ampm" data-type="ampm"></div>\n </div>'),this.panelEl.innerHTML=`\n <div class="ds-timepicker__header">\n <div class="ds-timepicker__display">\n <span class="ds-timepicker__display-hour">${String(this.selectedHour).padStart(2,"0")}</span>\n <span class="ds-timepicker__separator">:</span>\n <span class="ds-timepicker__display-minute">${String(this.selectedMinute).padStart(2,"0")}</span>\n ${this.showSeconds?'<span class="ds-timepicker__separator">:</span><span class="ds-timepicker__display-second">'+String(this.selectedSecond).padStart(2,"0")+"</span>":""}\n ${this.use12Hour?'<span class="ds-timepicker__display-ampm">'+(this.selectedHour>=12?"PM":"AM")+"</span>":""}\n </div>\n </div>\n <div class="ds-timepicker__body">${t}</div>\n ${this.clearable?'<div class="ds-timepicker__footer"><button class="ds-timepicker__clear-btn" type="button">Clear</button></div>':""}\n `,this.element.appendChild(this.panelEl),this.oi(),this.ri(),this.showSeconds&&this.ai(),this.use12Hour&&this.ci(),this.clearable){const t=this.panelEl.querySelector(".ds-timepicker__clear-btn");t&&t.addEventListener("click",t=>{t.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",t=>t.stopPropagation()),this.hi(),setTimeout(()=>{this.calculatePosition(),this.li()},0)}oi(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;for(let s=this.use12Hour?1:0;s<(this.use12Hour?13:24);s+=this.hourStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{let t=s;this.use12Hour&&(t=12===s?this.isPM?12:0:this.isPM?s+12:s),this.selectedHour=t,this.di(),this.pi("hour",s),this.fi()}),t.appendChild(i)}}ri(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let s=0;s<60;s+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{this.selectedMinute=s,this.di(),this.pi("minute",s),this.fi()}),t.appendChild(i)}}ai(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let s=0;s<60;s+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{this.selectedSecond=s,this.di(),this.pi("second",s),this.fi()}),t.appendChild(i)}}ci(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(s=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=s,i.dataset.value=s,i.addEventListener("click",()=>{this.isPM="PM"===s,this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this.di(),t.querySelectorAll(".ds-timepicker__item").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.fi()}),t.appendChild(i)})}di(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),s=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),e=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const s=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(s).padStart(2,"0")}s&&(s.textContent=String(this.selectedMinute).padStart(2,"0")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),e&&(e.textContent=this.selectedHour>=12?"PM":"AM")}hi(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this.pi("hour",t),this.pi("minute",this.selectedMinute),this.pi("second",this.selectedSecond);const s=this.panelEl.querySelector('[data-type="ampm"]');s&&s.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected","PM"===t.dataset.value==this.selectedHour>=12)}),this.di()}pi(t,s){const i=this.panelEl.querySelector(`[data-type="${t}"]`);i&&i.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected",parseInt(t.dataset.value)===s)})}li(){["hour","minute","second"].forEach(t=>{const s=this.panelEl.querySelector(`[data-type="${t}"]`);if(!s)return;const i=s.querySelector(".is-selected");i&&i.scrollIntoView({block:"center"})})}fi(){this.input.value=this.ni()}hideTimepicker(t){this.panelEl&&"block"===this.panelEl.style.display&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this.ni(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this.ni()})))}resizeHandler(){this.panelEl&&"block"===this.panelEl.style.display&&this.calculatePosition()}setTime(t,s,i){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,s)),this.selectedSecond=Math.max(0,Math.min(59,i||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this.ni()),this.panelEl&&this.hi()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.Rt&&(this.inputWrap&&this.si&&this.inputWrap.removeEventListener("click",this.si),this.Et&&this.Et.unsubscribe?this.Et.unsubscribe():this.Tt&&document.removeEventListener("click",this.Tt),this.js&&this.js.unsubscribe?this.js.unsubscribe():this.zs&&window.removeEventListener("resize",this.zs),this.It&&document.removeEventListener("keydown",this.It),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this.si=null,this.Tt=null,this.Et=null,this.zs=null,this.js=null,this.It=null,this.element.Rt=!1)}}function Vt(t,s){const i=new Ht(t,s);i.init(),t.mi=i}function Ut(t){t.mi&&(t.mi.destroy(),t.mi=null)}kt.register("timepicker",Vt,Ut);class qt{constructor(t,s={}){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=s.range||t.hasAttribute("data-slider-range"),this.vertical=s.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=s.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=!1!==s.showTooltip,this.showMarks=s.marks||t.hasAttribute("data-slider-marks"),this.markStep=s.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=s.tooltipFormat||(t=>t),this.onChange=s.onChange||null,this.onInput=s.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.gt=[],this.gi=!1,this.yi=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this._i(),this.xi(),this.updateSlider()}_i(){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.bi()}bi(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),s=parseFloat(this.input?.max||100);for(let i=t;i<=s;i+=this.markStep){const e=document.createElement("div");e.className="ds-slider__mark";const n=(i-t)/(s-t)*100;this.vertical?e.style.bottom=n+"%":e.style.left=n+"%";const h=document.createElement("span");h.className="ds-slider__mark-label",h.textContent=i,e.appendChild(h),this.marksEl.appendChild(e)}this.element.appendChild(this.marksEl)}xi(){if(this.input){const t=()=>this.updateSlider(),s=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",s),this.gt.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:s})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this.gt.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this.wi(this.thumbStart,"start"),this.thumbEnd&&this.wi(this.thumbEnd,"end"),this.track){const t=t=>{this.disabled||this.ki(t)};this.track.addEventListener("click",t),this.gt.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=t=>this.Mi(t,"start");this.thumbStart.addEventListener("keydown",t),this.gt.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=t=>this.Mi(t,"end");this.thumbEnd.addEventListener("keydown",t),this.gt.push({el:this.thumbEnd,event:"keydown",handler:t})}}wi(t,s){const i=t=>{this.disabled||(t.preventDefault(),this.gi=!0,this.yi=s,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("touchend",n))},e=t=>{if(!this.gi)return;t.preventDefault();const i=t.touches?t.touches[0].clientX:t.clientX,e=t.touches?t.touches[0].clientY:t.clientY,n=this.track.getBoundingClientRect();let h;h=this.vertical?1-(e-n.top)/n.height:(i-n.left)/n.width,h=Math.max(0,Math.min(1,h));const o=parseFloat(this.input?.min||0),r=parseFloat(this.input?.max||100),a=parseFloat(this.input?.step||1);let c=o+h*(r-o);if(c=Math.round(c/a)*a,c=Math.max(o,Math.min(r,c)),"start"===s&&this.range&&this.inputEnd){const t=parseFloat(this.inputEnd.value);c>t&&(c=t)}if("end"===s&&this.range&&this.input){const t=parseFloat(this.input.value);c<t&&(c=t)}"start"===s&&this.input?this.input.value=c:"end"===s&&this.inputEnd&&(this.inputEnd.value=c),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:h})},n=()=>{this.gi=!1,this.yi=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",e),document.removeEventListener("touchend",n),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!1}),this.gt.push({el:t,event:"mousedown",handler:i},{el:t,event:"touchstart",handler:i})}ki(t){if(t.target.classList.contains("ds-slider__thumb"))return;const s=this.track.getBoundingClientRect(),i=t.clientX,e=t.clientY;let n;n=this.vertical?1-(e-s.top)/s.height:(i-s.left)/s.width,n=Math.max(0,Math.min(1,n));const h=parseFloat(this.input?.min||0),o=parseFloat(this.input?.max||100),r=parseFloat(this.input?.step||1);let a=h+n*(o-h);if(a=Math.round(a/r)*r,this.range){const t=parseFloat(this.input?.value||0),s=parseFloat(this.inputEnd?.value||0);Math.abs(a-t)<=Math.abs(a-s)?this.input&&(this.input.value=Math.min(a,s)):this.inputEnd&&(this.inputEnd.value=Math.max(a,t))}else this.input&&(this.input.value=a);this.updateSlider()}Mi(t,s){if(this.disabled)return;const i="start"===s?this.input:this.inputEnd;if(!i)return;const e=parseFloat(i.step||1),n=parseFloat(i.min||0),h=parseFloat(i.max||100);let o=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),o=Math.min(h,o+e);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),o=Math.max(n,o-e);break;case"Home":t.preventDefault(),o=n;break;case"End":t.preventDefault(),o=h;break;default:return}i.value=o,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),s=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const i=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0),n=(i-t)/(s-t)*100,h=(e-t)/(s-t)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=h-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=h-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=h+"%":this.thumbEnd.style.left=h+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(e)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(e)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",e)}else{const i=this.input?.value||0,e=(i-t)/(s-t)*100;this.vertical?this.fill.style.height=`${e}%`:this.fill.style.width=`${e}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=e+"%":this.thumbStart.style.left=e+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(i))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(i))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.element.setAttribute("aria-valuenow",i)}}destroy(){this.gt?.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=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,s){this.input&&(this.input.value=t),void 0!==s&&this.inputEnd&&(this.inputEnd.value=s),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 Jt(t,s){if(!t.Rt)try{const i=new qt(t,s);t.ot=i,t.Rt=!0}catch(t){}}function Kt(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("slider",Jt,Kt);class Wt{constructor(t,s={}){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=s.mode||t.getAttribute("data-carousel-mode")||"slide",this.vertical=s.vertical||t.hasAttribute("data-carousel-vertical"),this.autoPlay=!1!==s.autoPlay,this.interval=s.interval||parseInt(t.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=s.transitionDuration||parseInt(t.getAttribute("data-carousel-duration"))||500,this.loop=!1!==s.loop,this.pauseOnHover=!1!==s.pauseOnHover,this.swipe=!1!==s.swipe,this.swipeThreshold=s.swipeThreshold||50,this.keyboardNav=s.keyboardNav||t.hasAttribute("data-carousel-keyboard"),this.onChange=s.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.$i=()=>{this.pauseOnHover&&this.stopAutoPlay()},this.Si=()=>{this.pauseOnHover&&this.autoPlay&&this.startAutoPlay()},this.init()}init(){this.Ci=()=>this.prev(),this.Ti=()=>this.next(),this.Ei=()=>this.toggleAutoPlay(),this.Di=[],this.prevBtn&&this.prevBtn.addEventListener("click",this.Ci),this.nextBtn&&this.nextBtn.addEventListener("click",this.Ti),this.indicators.forEach((t,s)=>{const i=()=>this.goTo(s);this.Di.push(i),t.addEventListener("click",i)}),this.autoBtn&&this.autoBtn.addEventListener("click",this.Ei),this.swipe&&(this.Ii=t=>this.Oi(t),this.Ai=t=>this.Fi(t),this.zi=()=>this.ji(),this.element.addEventListener("touchstart",this.Ii,{passive:!0}),this.element.addEventListener("touchmove",this.Ai,{passive:!1}),this.element.addEventListener("touchend",this.zi)),this.keyboardNav&&(this.It=t=>{this.element.contains(document.activeElement)&&("ArrowLeft"===t.key||"ArrowUp"===t.key?(t.preventDefault(),this.prev()):"ArrowRight"!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.next()))},this.element.addEventListener("keydown",this.It)),"fade"===this.mode&&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.$i),this.element.addEventListener("mouseleave",this.Si)}goTo(t){if(this.isTransitioning)return;if(t<0||t>=this.totalItems)return;this.isTransitioning=!0;const s=this.currentIndex;if(this.currentIndex=t,"fade"===this.mode)this.items.forEach((s,i)=>{s.style.opacity=i===t?"1":"0",s.style.zIndex=i===t?"1":"0"});else if(this.vertical){const s=100*-t;this.track.style.transform=`translateY(${s}%)`}else{const s=100*-t;this.track.style.transform=`translateX(${s}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:t,prevIndex:s,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:t,prevIndex:s,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,s)=>{t.classList.toggle("is-active",s===this.currentIndex)}),this.loop||(this.prevBtn&&(this.prevBtn.disabled=0===this.currentIndex),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()}Oi(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.Ri=!0)}Fi(t){if(!this.isSwiping)return;this.touchDeltaX=t.touches[0].clientX-this.touchStartX,this.touchDeltaY=t.touches[0].clientY-this.touchStartY;const s=Math.abs(this.touchDeltaX);s>Math.abs(this.touchDeltaY)&&s>10&&t.preventDefault()}ji(){if(!this.isSwiping)return;this.isSwiping=!1;const t=Math.abs(this.touchDeltaX),s=Math.abs(this.touchDeltaY);t>this.swipeThreshold&&t>s&&(this.touchDeltaX>0?this.prev():this.next()),this.Ri&&(this.startAutoPlay(),this.Ri=!1)}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this.$i),this.element.removeEventListener("mouseleave",this.Si),this.prevBtn&&this.Ci&&this.prevBtn.removeEventListener("click",this.Ci),this.nextBtn&&this.Ti&&this.nextBtn.removeEventListener("click",this.Ti),this.autoBtn&&this.Ei&&this.autoBtn.removeEventListener("click",this.Ei),this.indicators.forEach((t,s)=>{const i=this.Di[s];i&&t.removeEventListener("click",i)}),this.Ii&&this.element.removeEventListener("touchstart",this.Ii),this.Ai&&this.element.removeEventListener("touchmove",this.Ai),this.zi&&this.element.removeEventListener("touchend",this.zi),this.It&&this.element.removeEventListener("keydown",this.It),this.Ci=null,this.Ti=null,this.Ei=null,this.Di=null}}function Yt(t,s){if(t.Rt)return;const i=new Wt(t,s);t.ot=i,t.Rt=!0}function Zt(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("carousel",Yt,Zt);class Gt{constructor(t,s={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=s.placement||t.getAttribute("data-drawer-placement")||"right",this.width=s.width||t.getAttribute("data-drawer-width")||"400px",this.height=s.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=!1!==s.escClose,this.maskClosable=!1!==s.maskClosable,this.showMask=!1!==s.showMask,this.onOpen=s.onOpen||null,this.onClose=s.onClose||null,this.onBeforeClose=s.onBeforeClose||null,this.It=null,this.xi()}xi(){const t=this.mask?.querySelector(".ds-drawer__close"),s=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),i=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{if(this.onBeforeClose){if(!1===this.onBeforeClose())return}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=t=>{this.maskClosable&&t.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),s&&s.addEventListener("click",this.closeDrawer),i&&i.addEventListener("click",this.closeDrawer),this.escClose&&(this.It=t=>{"Escape"===t.key&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this.It)),this.gt=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer},{el:i,event:"click",handler:this.closeDrawer}].filter(t=>t.el)}Pi(){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}`),"left"===this.placement||"right"===this.placement?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.gt?.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.It&&document.removeEventListener("keydown",this.It),this.gt=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this.Pi(),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 Xt(t,s){if(t.Rt)return;const i=new Gt(t,s);t.ot=i,t.Rt=!0}function Qt(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("drawer",Xt,Qt);class ts{constructor(t,s={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close");const i=nt(),e=void 0===i.modal?.backdropClick||i.modal.backdropClick;this.fullscreen=s.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=void 0!==s.closableOnMask?s.closableOnMask:e,this.escClose=!1!==s.escClose,this.width=s.width||t.getAttribute("data-modal-width")||"",this.center=!1!==s.center,this.onBeforeOpen=s.onBeforeOpen||null,this.onBeforeClose=s.onBeforeClose||null,this.onOpened=s.onOpened||null,this.onClosed=s.onClosed||null,this.Li=!1,this.It=t=>{this.escClose&&"Escape"===t.key&&this.isVisible()&&this.close()},this.Ni=()=>this.close(),this.Bi=t=>{this.closableOnMask&&t.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this.Ni),this.mask&&this.mask.addEventListener("click",this.Bi),document.addEventListener("keydown",this.It),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){if(this.onBeforeOpen){if(!1===this.onBeforeOpen())return}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.Li||(ts.Hi=(ts.Hi||0)+1,this.Li=!0),document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0}))}close(){if(this.onBeforeClose){if(!1===this.onBeforeClose())return}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.Li&&(ts.Hi=Math.max(0,(ts.Hi||0)-1),this.Li=!1,0===ts.Hi&&(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.It),this.closeBtn&&this.closeBtn.removeEventListener("click",this.Ni),this.mask&&this.mask.removeEventListener("click",this.Bi),this.Li&&(ts.Hi=Math.max(0,(ts.Hi||0)-1),this.Li=!1,0===ts.Hi&&(document.body.style.overflow=""))}}function ss(t={}){const{title:s="",content:i="",html:e=!1,width:n="480px",fullscreen:h=!1,showCancel:o=!0,showConfirm:r=!0,confirmText:a="OK",cancelText:c="Cancel",confirmClass:l="ds-btn--brand",cancelClass:d="ds-btn--ghost",closable:u=!0,maskClosable:p=!0,onConfirm:f,onCancel:m,onOpen:g,onClose:y,footer:_=null,size:v=nt().defaultSize}=t,x="sm"===v?"ds-btn--sm":"lg"===v?"ds-btn--lg":"",b=document.createElement("div");b.className="ds-modal-container";let w="";null!==_&&("string"==typeof _?w=`<div class="ds-modal__footer">${_}</div>`:(r||o)&&(w=`<div class="ds-modal__footer">\n ${o?`<button class="ds-btn ${x} ${d}" data-modal-cancel>${c}</button>`:""}\n ${r?`<button class="ds-btn ${x} ${l}" data-modal-confirm>${a}</button>`:""}\n </div>`)),b.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${h?" ds-modal--fullscreen":""}" style="${h?"":"max-width: "+n}">\n <div class="ds-modal__header">\n <span class="ds-modal__title"></span>\n ${u?'<button class="ds-modal__close" aria-label="Close">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>':""}\n </div>\n <div class="ds-modal__body"></div>\n ${w}\n </div>\n </div>\n `,document.body.appendChild(b);const k=new ts(b,{fullscreen:h,closableOnMask:p}),M=b.querySelector(".ds-modal__title");M&&(M.textContent=s);const $=b.querySelector(".ds-modal__body");$&&(e?$.innerHTML=i:$.textContent=i);const S=b.querySelector("[data-modal-confirm]"),C=b.querySelector("[data-modal-cancel]");let T=!1;const E=async()=>{if(f){S.disabled=!0,S.classList.add("is-loading");try{if(!1===await f())return S.disabled=!1,void S.classList.remove("is-loading")}catch(t){return S.disabled=!1,void S.classList.remove("is-loading")}}T=!0,k.close()},D=()=>{m&&m(),k.close()};S&&S.addEventListener("click",E),C&&C.addEventListener("click",D);const I=k.close.bind(k);return k.close=()=>{I(),setTimeout(()=>{S&&S.removeEventListener("click",E),C&&C.removeEventListener("click",D),k.destroy(),b.remove(),y&&y(T)},300)},k.open(),g&&setTimeout(()=>g(),50),k}function is(t){if(t.Rt)return;const s=new ts(t);t.ot=s,t.Rt=!0}function es(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}ts.Hi=0,kt.register("modal",is,es);const ns={normal:function(t){this.show({...t,type:"normal"})},success:function(t){this.show({...t,type:"success"})},error:function(t){this.show({...t,type:"error"})},warning:function(t){this.show({...t,type:"warning"})},info:function(t){this.show({...t,type:"info"})},show:function(t){const s=ct(),{title:i,message:e,type:n="normal",duration:h=s.duration,position:o=s.position}=t,r=document.createElement("div");r.className=`ds-notification__item ds-notification__item--${n}`;r.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${n}">${{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>'}[n]}</div>\n <div class="ds-notification__content">\n ${i?'<div class="ds-notification__title"></div>':""}\n ${e?'<div class="ds-notification__message"></div>':""}\n </div>\n <button class="ds-notification__close">\n <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>\n </button>\n `,i&&(r.querySelector(".ds-notification__title").textContent=i),e&&(r.querySelector(".ds-notification__message").textContent=e);let a=document.querySelector(".ds-notification");if(!a){a=document.createElement("div"),a.className=`ds-notification ds-notification--${o}`;const t=ht().notification;a.style.zIndex=t,a.style.transform="translateZ(0)",document.body.appendChild(a)}a.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)}),h>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},h)}};const hs={normal:function(t,s={}){this.show(t,"normal",s)},success:function(t,s={}){this.show(t,"success",s)},error:function(t,s={}){this.show(t,"error",s)},warning:function(t,s={}){this.show(t,"warning",s)},info:function(t,s={}){this.show(t,"info",s)},show:function(t,s="normal",i={}){const e=at(),{duration:n=e.duration,position:h=e.position}=i,o=e.maxCount||5,r=document.createElement("div");r.className=`ds-message__item ds-message__item--${s}`;r.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${s}">${{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>'}[s]}</div>\n <div class="ds-message__content"></div>\n `,r.querySelector(".ds-message__content").textContent=t;let a=document.querySelector(".ds-message");if(!a){a=document.createElement("div"),a.className=`ds-message ds-message--${h}`;const t=ht().message;a.style.zIndex=t,a.style.transform="translateZ(0)",document.body.appendChild(a)}const c=a.querySelectorAll(".ds-message__item");if(c.length>=o){const t=c[0];t.classList.remove("is-visible"),t.classList.add("is-exiting"),setTimeout(()=>t.remove(),300)}a.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};function os(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class rs{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.gt=[],this.init()}init(){this.bindEvents()}bindEvents(){const t=t=>{t.target===this.input||this.input.contains(t.target)||this.input.click()},s=t=>{const s=Array.from(t.target.files);this.addFiles(s),t.target.value=""},i=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.add("is-dragging")},e=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging")},n=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging");const s=Array.from(t.dataTransfer.files);this.addFiles(s)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",s),this.dropzone.addEventListener("dragover",i),this.dropzone.addEventListener("dragleave",e),this.dropzone.addEventListener("drop",n),this.gt.push({el:this.dropzone,event:"click",handler:t},{el:this.input,event:"change",handler:s},{el:this.dropzone,event:"dragover",handler:i},{el:this.dropzone,event:"dragleave",handler:e},{el:this.dropzone,event:"drop",handler:n})}addFiles(t){t.forEach(t=>{this.maxCount>0&&this.files.length>=this.maxCount?this.showError(`Maximum ${this.maxCount} files allowed`):this.isValidFile(t)&&(this.files.push(t),this.renderFileItem(t),this.showPreview(t))}),this.dispatchChange()}isValidFile(t){const s=this.input.getAttribute("accept");if(s&&""!==s){const i=s.split(",").map(t=>t.trim()),e=t.type,n=t.name.toLowerCase();if(!i.some(t=>t.startsWith(".")?n.endsWith(t):!t.includes("/")||(t.endsWith("/*")?e.startsWith(t.replace("/*","")):e===t)))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)}renderFileItem(t){const s=document.createElement("div");s.className="ds-fileupload__item",s.dataset.filename=t.name;const i=this.getFileIcon(t.type);s.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${i}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(os(t.name))}</span>\n <span class="ds-fileupload__size">${this.formatSize(t.size)}</span>\n <button class="ds-fileupload__remove" type="button" aria-label="Remove file">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const e=s.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,s)};e.addEventListener("click",n),this.gt.push({el:e,event:"click",handler:n}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(s)}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,s=20){if(t.length<=s)return t;const i=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,s-i.length-3)+"..."+i}formatSize(t){if(0===t)return"0 B";const s=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,s)).toFixed(1))+" "+["B","KB","MB","GB"][s]}removeFile(t,s){this.files=this.files.filter(s=>s!==t),s&&s.remove(),0===this.files.length&&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 s=document.createElement("div");s.className="ds-fileupload__error",s.textContent=t,s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),this.dropzone.appendChild(s),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 s=new FileReader;s.onload=s=>{const i=document.createElement("div");i.className="ds-fileupload__preview-item",i.innerHTML=`\n <img src="${s.target.result}" alt="${os(t.name)}">\n <button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const e=i.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),i.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};e.addEventListener("click",n),this.gt.push({el:e,event:"click",handler:n}),this.preview.appendChild(i)},s.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 s=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");s.className="ds-fileupload__progress-bar",s.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(s),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const s=100;let i=0;Math.max(1,Math.floor(t.size/s));const e=setInterval(()=>{i++;const t=Math.min(100,Math.floor(i/s*100));this.updateProgress(t),i>=s&&(clearInterval(e),this.updateProgress(100))},Math.max(50,Math.floor(50)));return e}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function as(t){if(t.Rt)return;const s=new rs(t);t.ot=s,t.Rt=!0}function cs(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("fileupload",as,cs);class ls{constructor(t,s={}){this.element=t,this.headers=[],this.gt=[],this.accordion=s.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=s.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=s.disabledItems||[],this.defaultExpanded=s.defaultExpanded||[],this.Vi()}Vi(){this.element.querySelectorAll(".ds-collapse__header").forEach((t,s)=>{const i=t.closest(".ds-collapse__item"),e=t.nextElementSibling;if(!i||!e||!e.classList.contains("ds-collapse__content"))return;const n=i.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(s);n&&i.classList.add("is-disabled");let h=i.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(s))&&(h=!0),h?(i.classList.add("is-active"),e.style.height=e.scrollHeight+"px",e.style.overflow="hidden",setTimeout(()=>{i.classList.contains("is-active")&&(e.style.height="auto",e.style.overflow="visible")},this.animationDuration)):(i.classList.remove("is-active"),e.style.height="0",e.style.overflow="hidden");const o=()=>{if(n)return;const t=i.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,i)=>{i!==s&&t.item.classList.contains("is-active")&&this.Ui(t)}),t?this.Ui({item:i,content:e}):this.qi({item:i,content:e}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:s,expanded:!t,item:i},bubbles:!0}))};t.addEventListener("click",o),this.headers.push({header:t,item:i,content:e,clickHandler:o,isDisabled:n}),this.gt.push({el:t,event:"click",handler:o})})}qi(t){const{item:s,content:i}=t;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",s.classList.add("is-active");const e=()=>{i.removeEventListener("transitionend",e),s.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",e),this.gt.push({el:i,event:"transitionend",handler:e})}Ui(t){const{item:s,content:i}=t;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",s.classList.remove("is-active");const e=()=>{i.removeEventListener("transitionend",e),i.style.transition=""};i.addEventListener("transitionend",e),this.gt.push({el:i,event:"transitionend",handler:e})}destroy(){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=null,this.headers=null,this.element=null}toggle(t){const s=this.headers[t];s&&!s.isDisabled&&s.clickHandler()}expand(t){const s=this.headers[t];!s||s.item.classList.contains("is-active")||s.isDisabled||(this.accordion&&this.headers.forEach((s,i)=>{i!==t&&s.item.classList.contains("is-active")&&this.Ui(s)}),this.qi(s))}collapse(t){const s=this.headers[t];s&&s.item.classList.contains("is-active")&&this.Ui(s)}expandAll(){this.accordion||this.headers.forEach((t,s)=>{t.item.classList.contains("is-active")||t.isDisabled||this.qi(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this.Ui(t)})}getExpandedIndices(){return this.headers.map((t,s)=>t.item.classList.contains("is-active")?s:-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 ds(t,s){if(t.Rt)return;const i=new ls(t,s);t.ot=i,t.Rt=!0}function us(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("collapse",ds,us);class ps{constructor(t,s={}){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=s,this.value=s.value||"#007bff",this.showAlpha=!1!==s.showAlpha,this.mode=s.mode||"hex",this.previousColors=s.previousColors||this.Ji(),this.previousColorsLimit=s.previousColorsLimit||12,this.Ct=null,this.Tt=null,this.Et=null,this.Ki=null,this.Wi=null,this.Yi=null,this.Zi=null,this.Gi=null,this.Xi=null,this.Qi=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this.te(this.value)}Ji(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}se(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}ie(t){const s=this.previousColors.indexOf(t);-1!==s&&this.previousColors.splice(s,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this.se(),this.ee()}te(t){const s=t.replace(/^#/,""),i=parseInt(s.substring(0,2),16)/255,e=parseInt(s.substring(2,4),16)/255,n=parseInt(s.substring(4,6),16)/255,h=8===s.length?parseInt(s.substring(6,8),16)/255:1,o=Math.max(i,e,n),r=Math.min(i,e,n);let a=0,c=0,l=o;const d=o-r;if(c=0===o?0:d/o,o!==r)switch(o){case i:a=((e-n)/d+(e<n?6:0))/6;break;case e:a=((n-i)/d+2)/6;break;case n:a=((i-e)/d+4)/6}this.hue=Math.round(360*a),this.saturation=Math.round(100*c),this.brightness=Math.round(100*l),this.alpha=Math.round(100*h)}ne(t,s,i,e=1){s/=100,i/=100,e/=100;const n=s=>(s+t/60)%6,h=t=>i*(1-s*Math.max(0,Math.min(n(t),4-n(t),1))),o=Math.round(255*h(5)),r=Math.round(255*h(3)),a=Math.round(255*h(1));if("rgb"===this.mode)return e<1?`rgba(${o}, ${r}, ${a}, ${e.toFixed(2)})`:`rgb(${o}, ${r}, ${a})`;if("hsl"===this.mode)return e<1?`hsla(${t}, ${Math.round(100*s)}%, ${Math.round(100*i)}%, ${e.toFixed(2)})`:`hsl(${t}, ${Math.round(100*s)}%, ${Math.round(100*i)}%)`;const c=`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;return e<1?c+Math.round(255*e).toString(16).padStart(2,"0"):c}ee(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(s=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=s,i.setAttribute("data-color",s),i.addEventListener("click",this.Ki),t.appendChild(i)}))}he(){const t=this.panel.querySelector(".ds-color-picker__hue"),s=this.panel.querySelector(".ds-color-picker__sv"),i=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%))"),s&&(s.style.background=`hsl(${this.hue}, 100%, 50%)`),i&&this.showAlpha&&(i.value=this.alpha,i.style.background=`linear-gradient(to right, transparent, ${this.ne(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel)return;if(this.element.Rt)return;this.Ct=t=>{t.stopPropagation(),this.togglePanel()},this.Ki=t=>{const s=t.currentTarget.getAttribute("data-color");this.updateColor(s),this.hidePanel()},this.Wi=t=>{const s=t.target.value;this.oe(s)&&this.updateColor(s)},this.Yi=t=>{this.alpha=parseInt(t.target.value),this.re()},this.Zi=t=>{const s=t.currentTarget;this.mode=s.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>t.classList.remove("is-active")),s.classList.add("is-active"),this.di()},this.Gi=t=>{this.hue=parseInt(t.target.value),this.he(),this.re()},this.Xi=t=>{const s=t.currentTarget.getBoundingClientRect(),i=t.clientX-s.left,e=t.clientY-s.top;this.saturation=Math.round(i/s.width*100),this.brightness=Math.round(100*(1-e/s.height)),this.re()},this.Tt=t=>{this.element.contains(t.target)||this.hidePanel()},this.trigger.addEventListener("click",this.Ct),this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.addEventListener("click",this.Ki),t.ae=this.Ki}),this.customInput&&(this.customInput.addEventListener("input",this.Wi),this.customInput.ce=this.Wi);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this.Gi);const s=this.panel.querySelector(".ds-color-picker__sv");s&&(s.addEventListener("click",this.Xi),s.addEventListener("mousemove",t=>{1===t.buttons&&this.Xi(t)}));const i=this.panel.querySelector(".ds-color-picker__alpha");i&&this.showAlpha&&i.addEventListener("input",this.Yi),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.addEventListener("click",this.Zi),t.getAttribute("data-mode")===this.mode&&t.classList.add("is-active")}),this.Et=Ot.on(document,"click",this.Tt,{scope:this.scope}),this.ee(),this.he(),this.di(),this.element.Rt=!0}oe(t){const s=(new Option).style;return s.color=t,""!==s.color}re(){const t=this.ne(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this.di(),this.ie(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}}))}di(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this.he()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this.oe(t)&&(this.value=t,this.te(t),this.di(),this.ie(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){"hex"!==t&&"rgb"!==t&&"hsl"!==t||(this.mode=t,this.di())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this.re()}getAlpha(){return this.alpha}destroy(){if(!this.element.Rt)return;this.trigger&&this.Ct&&this.trigger.removeEventListener("click",this.Ct),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.ae&&t.removeEventListener("click",t.ae)}),this.customInput&&this.Wi&&this.customInput.removeEventListener("input",this.Wi);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this.Gi&&t.removeEventListener("input",this.Gi);const s=this.panel?.querySelector(".ds-color-picker__sv");s&&this.Xi&&(s.removeEventListener("click",this.Xi),s.removeEventListener("mousemove",this.Xi));const i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this.Yi&&i.removeEventListener("input",this.Yi),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.removeEventListener("click",this.Zi)}),this.Et&&this.Et.unsubscribe?this.Et.unsubscribe():this.Tt&&document.removeEventListener("click",this.Tt),this.Tt=null,this.Et=null,this.Ct=null,this.Ki=null,this.Wi=null,this.Yi=null,this.Zi=null,this.Gi=null,this.Xi=null,this.Qi=null,this.element.Rt=!1}}function fs(t,s){const i=new ps(t,s);i.init(),t.le=i}function ms(t){t.le&&(t.le.destroy(),t.le=null)}kt.register("color-picker",fs,ms);class gs{constructor(t,s={}){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.gt=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=s.selectedDate?new Date(s.selectedDate):null,this.rangeStart=s.rangeStart?new Date(s.rangeStart):null,this.rangeEnd=s.rangeEnd?new Date(s.rangeEnd):null,this.isRangeMode=s.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=s.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=s.events||[],this.i18n=s.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=s.onSelect||null,this.onRangeSelect=s.onRangeSelect||null,this.onChange=s.onChange||null,this.onEventClick=s.onEventClick||null,this.Vi()}Vi(){this.render();const t=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.dt()},s=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.dt()},i=()=>{this.currentDate=new Date,this.render(),this.dt()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this.gt.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",s),this.gt.push({el:this.nextBtn,event:"click",handler:s})),this.todayBtn&&(this.todayBtn.addEventListener("click",i),this.gt.push({el:this.todayBtn,event:"click",handler:i}))}dt(){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}))}Ls(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}Hs(t,s){return!(!t||!s)&&this.Ls(t)===this.Ls(s)}de(t){if(!this.rangeStart||!this.rangeEnd)return!1;const s=this.Ls(t),i=this.Ls(this.rangeStart),e=this.Ls(this.rangeEnd);return s>=i&&s<=e}ue(t){return this.Hs(t,this.rangeStart)}pe(t){return this.Hs(t,this.rangeEnd)}fe(t){const s=this.Ls(t);return this.events.filter(t=>{const i=t.date||t.start,e=t.end;if(!i)return!1;const n="string"==typeof i?i:this.Ls(i);if(!e)return n===s;const h="string"==typeof e?e:this.Ls(e);return s>=n&&s<=h})}render(){const t=this.currentDate.getFullYear(),s=this.currentDate.getMonth();"week"===this.viewMode?this.me(t,s):this.ge(t,s)}ge(t,s){this.titleEl.textContent=`${t} ${this.i18n.months[s]}`;const i=new Date(t,s,1).getDay(),e=new Date(t,s+1,0).getDate();this.daysEl.innerHTML="";for(let t=0;t<i;t++){const t=document.createElement("span");t.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(t)}const n=new Date,h=this.Ls(n);for(let i=1;i<=e;i++){const e=new Date(t,s,i),n=document.createElement("button");n.className="ds-calendar__day",n.textContent=i;const o=this.Ls(e);o===h&&n.classList.add("is-today"),this.Hs(e,this.selectedDate)&&n.classList.add("is-selected"),this.isRangeMode&&(this.ue(e)&&n.classList.add("is-range-start"),this.pe(e)&&n.classList.add("is-range-end"),this.de(e)&&n.classList.add("is-in-range"));const r=this.fe(e);if(r.length>0){n.classList.add("has-events");const t=document.createElement("span");t.className="ds-calendar__day-event",t.style.backgroundColor=r[0].color||"#007bff",n.appendChild(t)}const a=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),n.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this.Hs(e,this.rangeEnd)?(this.rangeStart=e,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(e<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=e):this.rangeEnd=e,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=e,this.onSelect&&this.onSelect({date:e,dateStr:o}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:e,dateStr:o},bubbles:!0}))),r.forEach(t=>{this.onEventClick&&this.onEventClick(t,e)}),this.render()};n.addEventListener("click",a),this.gt.push({el:n,event:"click",handler:a}),this.daysEl.appendChild(n)}}me(t,s){const i=this.currentDate.getDay(),e=new Date(t,s,this.currentDate.getDate()-i+(0===i?-6:1)),n=e,h=new Date(e);h.setDate(e.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[h.getMonth()]} ${h.getDate()} ${t}`,this.daysEl.innerHTML="";const o=new Date,r=this.Ls(o);for(let t=0;t<7;t++){const s=new Date(e);s.setDate(e.getDate()+t);const i=document.createElement("button");i.className="ds-calendar__day ds-calendar__day--week";const n=document.createElement("span");n.className="ds-calendar__day-header",n.textContent=this.i18n.shortWeekdays[s.getDay()],i.appendChild(n);const h=document.createElement("span");h.className="ds-calendar__day-number",h.textContent=s.getDate(),i.appendChild(h);const o=this.Ls(s);o===r&&i.classList.add("is-today"),this.Hs(s,this.selectedDate)&&i.classList.add("is-selected");const a=this.fe(s);if(a.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",a.slice(0,3).forEach(s=>{const i=document.createElement("span");i.className="ds-calendar__day-event",i.style.backgroundColor=s.color||"#007bff",t.appendChild(i)}),i.appendChild(t)}const c=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.selectedDate=s,this.onSelect&&this.onSelect({date:s,dateStr:o}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:s,dateStr:o},bubbles:!0})),this.render()};i.addEventListener("click",c),this.gt.push({el:i,event:"click",handler:c}),this.daysEl.appendChild(i)}}destroy(){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=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.dt()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,s){this.rangeStart=t?new Date(t):null,this.rangeEnd=s?new Date(s):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(s=>s.id!==t),this.render()}setViewMode(t){"month"!==t&&"week"!==t||(this.viewMode=t,this.render(),this.dt())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.dt()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.dt()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this.dt()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this.dt()}goToToday(){this.currentDate=new Date,this.render(),this.dt()}goToDate(t){this.currentDate=new Date(t),this.render(),this.dt()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this.dt()}}function ys(t,s){if(!t.Rt)try{const i=new gs(t,s);t.ot=i,t.Rt=!0}catch(t){}}function _s(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("calendar",ys,_s);class vs{constructor(t,s={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this.gt=[],this.maxCount=s.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=!1!==s.allowDuplicates,this.color=s.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 s=t.querySelector(".ds-dynamic-tags__remove");if(s){const i=s=>{s.stopPropagation(),t.remove(),this.dispatchChange()};s.addEventListener("click",i),this.gt.push({el:s,event:"click",handler:i})}}),this.input){const t=()=>{const t=this.input.value.trim();if(!t)return;if(!this.allowDuplicates&&this.hasTag(t))return void(this.input.value="");if(this.getTags().length>=this.maxCount)return this.input.value="",void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const s=this.createTag(t);this.element.insertBefore(s,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},s=s=>{"Enter"===s.key&&(s.preventDefault(),s.stopPropagation(),t())};this.input.addEventListener("keydown",s),this.gt.push({el:this.input,event:"keydown",handler:s});const i=()=>{this.input.focus()};this.element.addEventListener("click",i),this.gt.push({el:this.element,event:"click",handler:i})}}createTag(t){const s=document.createElement("span");s.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(t);s.appendChild(i);const e=document.createElement("button");e.className="ds-dynamic-tags__remove",e.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>',s.appendChild(e);const n=t=>{t.stopPropagation(),s.remove(),this.dispatchChange()};return e.addEventListener("click",n),this.gt.push({el:e,event:"click",handler:n}),s}hasTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of s)if(i.textContent.trim()===t)return!0;return!1}addTag(t,s){if(!t||!this.input)return;if(!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount)return void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const i=this.createTag(t);if(s){const t=["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"];t.forEach(t=>i.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${s}`)&&i.classList.add(`ds-dynamic-tags__tag--${s}`)}this.element.insertBefore(i,this.input),this.dispatchChange()}removeTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];s&&(s.remove(),this.dispatchChange())}removeTagByValue(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of s)if(i.textContent.trim()===t)return i.remove(),void this.dispatchChange()}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(s=>{t.push(s.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(s=>{const i=Array.from(s.classList).find(t=>t.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:s.textContent.trim(),color:i})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(t=>{"string"==typeof t?this.addTag(t):t&&"object"==typeof t&&t.value&&this.addTag(t.value,t.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.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=null,this.input=null,this.element=null}}function xs(t,s){if(t.Rt)return;const i=new vs(t,s);t.ot=i,t.Rt=!0}function bs(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("dynamic-tags",xs,bs);class ws{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='\n <button class="ds-image-preview__close" type="button" aria-label="Close preview">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n <div class="ds-image-preview__nav">\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--prev" type="button" aria-label="Previous image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="15 18 9 12 15 6"/>\n </svg>\n </button>\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--next" type="button" aria-label="Next image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="9 18 15 12 9 6"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__toolbar">\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom in" data-action="zoom-in">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom out" data-action="zoom-out">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Reset zoom" data-action="zoom-reset">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/>\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate left" data-action="rotate-left">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="1 4 1 10 7 10"/>\n <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate right" data-action="rotate-right">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="23 4 23 10 17 10"/>\n <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__content">\n <img src="" alt="" />\n </div>\n <div class="ds-image-preview__info">\n <div class="ds-image-preview__title"></div>\n <div class="ds-image-preview__meta"></div>\n </div>\n <div class="ds-image-preview__indicators"></div>\n ',document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const t=this.overlay.querySelector(".ds-image-preview__close"),s=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),i=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this.ye=()=>this.prev(),this._e=()=>this.next(),t.addEventListener("click",this.closeHandler),s.addEventListener("click",this.ye),i.addEventListener("click",this._e);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",s=>{const i=t.getAttribute("data-action");this.handleToolbarAction(i)})});this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",t=>{t.preventDefault(),t.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)}}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)}}handleOverlayClick(t){t.target===this.overlay&&this.close()}show(t,s=0){this.images=t,this.currentIndex=Math.min(Math.max(s,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"),s=this.overlay.querySelector(".ds-image-preview__title"),i=this.overlay.querySelector(".ds-image-preview__meta"),e=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),h=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),o=this.images[this.currentIndex];t.src=o.src,t.alt=o.alt||"",s.textContent=o.title||"",i.textContent=o.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,h.disabled=this.currentIndex===this.images.length-1,e.innerHTML=this.images.map((t,s)=>`\n <button class="ds-image-preview__indicator${s===this.currentIndex?" is-active":""}" type="button" data-index="${s}" aria-label="Go to image ${s+1}"></button>\n `).join(""),e.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{const s=()=>{this.goTo(parseInt(t.dataset.index))};t.addEventListener("click",s),t.ve=s})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{t.ve&&t.removeEventListener("click",t.ve)});const s=this.overlay?.querySelector(".ds-image-preview__close"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),e=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");s&&s.removeEventListener("click",this.closeHandler),i&&this.ye&&i.removeEventListener("click",this.ye),e&&this._e&&e.removeEventListener("click",this._e),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let ks=null;class Ms{constructor(t,s={}){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.gt=[],this.color=s.color||t.getAttribute("data-tag-color")||"default",this.size=s.size||t.getAttribute("data-tag-size")||"default",this.checkable=s.checkable||t.hasAttribute("data-tag-checkable"),this.checked=s.checked||t.hasAttribute("data-tag-checked"),this.editable=s.editable||t.hasAttribute("data-tag-editable"),this.maxLength=s.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this.xe(),this.closeBtn){const t=t=>{t.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.gt.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=t=>{t.target!==this.checkbox&&t.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this.gt.push({el:this.element,event:"click",handler:t}),this.checkbox){const t=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",t),this.gt.push({el:this.checkbox,event:"change",handler:t})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this.gt.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const t=()=>{this.endEdit()},s=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};this.editInput.addEventListener("blur",t),this.editInput.addEventListener("keydown",s),this.gt.push({el:this.editInput,event:"blur",handler:t}),this.gt.push({el:this.editInput,event:"keydown",handler:s})}}}xe(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],s=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(t=>this.element.classList.remove(t)),s.forEach(t=>this.element.classList.remove(t)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),s.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 s=[];this.element.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE&&s.push(t)}),s.forEach(t=>t.remove());const i=this.element.querySelector(".ds-tag__close"),e=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),h=i||e||n||null;this.element.insertBefore(document.createTextNode(t),h),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.xe())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this.xe())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this.xe(),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.xe(),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 s=document.createElement("input");s.type="text",s.className="ds-tag__input",s.value=t,s.maxLength=this.maxLength,this.editInput=s;const i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(s,i);const e=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};s.addEventListener("blur",e),s.addEventListener("keydown",n),this.gt.push({el:s,event:"blur",handler:e}),this.gt.push({el:s,event:"keydown",handler:n})}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.xe()}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.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function $s(t,s){if(t.Rt)return;const i=new Ms(t,s);t.ot=i,t.Rt=!0}function Ss(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("tag",$s,Ss);class Cs{constructor(t){this.element=t,this.valueElement=t.querySelector(".ds-statcard__value"),this.progressFill=t.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this.be=null,this.init()}init(){this.animateValue(),this.animateProgress(),this.be=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this.be.observe(this.element)}animateValue(){if(!this.valueElement)return;const t=this.valueElement.textContent,s=t.match(/[\d.,]+/);if(!s)return;const i=parseFloat(s[0].replace(",","")),e=t.substring(0,s.index),n=t.substring(s.index+s[0].length),h=performance.now(),o=t=>{const s=t-h,r=Math.min(s/1500,1),a=1-Math.pow(1-r,3),c=0+(i-0)*a;let l;l=i>=1e6?(c/1e6).toFixed(1)+"M":i>=1e3?(c/1e3).toFixed(1)+"K":Number.isInteger(i)?Math.floor(c).toLocaleString():c.toFixed(2),this.valueElement.textContent=e+l+n,r<1&&requestAnimationFrame(o)};requestAnimationFrame(o)}animateProgress(){if(!this.progressFill)return;const t=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=t}updateValue(t,s={}){if(!this.valueElement)return;const i=s.duration||800,e=this.valueElement.textContent,n=e.match(/[\d.,]+/);if(!n)return void(this.valueElement.textContent=t);const h=e.substring(0,n.index),o=e.substring(n.index+n[0].length),r=parseFloat(n[0].replace(",","")),a=parseFloat(t),c=performance.now(),l=t=>{const s=t-c,e=Math.min(s/i,1),n=1-Math.pow(1-e,3),d=r+(a-r)*n;let u;u=a>=1e6?(d/1e6).toFixed(1)+"M":a>=1e3?(d/1e3).toFixed(1)+"K":Number.isInteger(a)?Math.floor(d).toLocaleString():d.toFixed(2),this.valueElement.textContent=h+u+o,e<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}updateProgress(t,s={}){if(!this.progressFill)return;const i=s.duration||600,e=parseFloat(this.progressFill.style.width||"0"),n=Math.min(Math.max(t,0),100),h=performance.now(),o=t=>{const s=t-h,r=Math.min(s/i,1),a=1-Math.pow(1-r,3),c=e+(n-e)*a;this.progressFill.style.width=c+"%",r<1&&requestAnimationFrame(o)};requestAnimationFrame(o)}setTrend(t,s){const i=this.element.querySelector(".ds-statcard__trend");if(!i)return;i.className=`ds-statcard__trend ds-statcard__trend--${t}`;const e="up"===t?'<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>':"down"===t?'<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>';i.innerHTML=e+s}destroy(){this.be&&(this.be.disconnect(),this.be=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function Ts(t){if(t.Rt)return;const s=new Cs(t);t.ot=s,t.Rt=!0}function Es(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("statcard",Ts,Es);class Ds{constructor(t,s={}){this.element=t,this.data=s.data||[],this.startDate=s.startDate||this.getOneYearAgo(),this.endDate=s.endDate||new Date,this.cellSize=s.cellSize||14,this.onCellClick=s.onCellClick||null,this.tooltip=null,this.baseColor=s.color||t.getAttribute("data-color")||"#22c55e",this.gt=[],this.init()}getOneYearAgo(){const t=new Date;return t.setFullYear(t.getFullYear()-1),t}init(){this.render(),this.createTooltip()}getDataByDate(t){const s=this.formatDate(t),i=this.data.find(t=>t.date===s);return i?i.value:0}formatDate(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}getLevel(t,s){if(0===t)return 0;s&&0!==s||(s=Math.max(...this.data.map(t=>t.value),1));const i=t/s;return i<.2?1:i<.4?2:i<.6?3:i<.8?4:5}hexToRgb(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:{r:34,g:197,b:94}}getCellColor(t){const s=this.hexToRgb(this.baseColor);if(0===t)return"rgba(0, 0, 0, 0.1)";const i=[.2,.4,.6,.8,1][t-1];return`rgba(${s.r}, ${s.g}, ${s.b}, ${i})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],s=[];let i=-1;for(let e=new Date(this.startDate);e<=this.endDate;e.setDate(e.getDate()+1)){const n=e.getMonth(),h=e.getDate();n!==i&&1===h&&(s.push({month:n,label:t[n],offset:Math.floor((e-this.startDate)/864e5)}),i=n)}return s}getWeekCount(){let t=0;const s=new Date(this.startDate).getDay();for(let s=new Date(this.startDate);s<=this.endDate;s.setDate(s.getDate()+1))0===s.getDay()&&t++;return 0!==s&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const s=[];let i=[];const e=new Date(this.startDate).getDay();for(let t=1;t<e;t++)i.push(null);for(let t=new Date(this.startDate);t<=this.endDate;t.setDate(t.getDate()+1))i.push(new Date(t)),6!==t.getDay()&&t.getTime()!==this.endDate.getTime()||(s.push(i),i=[]);const n=s.length,h=this.element.classList.contains("ds-heatmap--compact")?12:16,o=n*h,r=document.createElement("div");r.className="ds-heatmap__container";const a=document.createElement("div");a.className="ds-heatmap__labels-and-grid";const c=document.createElement("div");c.className="ds-heatmap__weekday-labels";const l=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(t=>{const s=document.createElement("div");s.className="ds-heatmap__weekday-label",s.textContent=t,s.style.height=l+"px",s.style.lineHeight=l+"px",c.appendChild(s)}),a.appendChild(c);const d=document.createElement("div");d.className="ds-heatmap__grid-container";const u=document.createElement("div");u.className="ds-heatmap__month-labels",u.style.width=o+"px";const p=this.getMonthLabels();p.forEach((t,s)=>{const i=document.createElement("div");i.className="ds-heatmap__month-label",i.textContent=t.label;const e=p[s+1];let o;o=e?Math.ceil((e.offset-t.offset)/7):n-Math.floor(t.offset/7),i.style.width=o*h+"px",u.appendChild(i)}),d.appendChild(u);const f=document.createElement("div");f.className="ds-heatmap__grid",s.forEach(t=>{const s=document.createElement("div");s.className="ds-heatmap__week-column",t.forEach(t=>{if(null===t){const t=document.createElement("div");t.className="ds-heatmap__cell",t.style.visibility="hidden",s.appendChild(t)}else{const i=this.getDataByDate(t),e=Math.max(...this.data.map(t=>t.value),1),n=this.getLevel(i,e),h=document.createElement("div");h.className="ds-heatmap__cell",h.dataset.date=this.formatDate(t),h.dataset.value=i,h.style.backgroundColor=this.getCellColor(n);const o=s=>this.showTooltip(s,t,i),r=()=>this.hideTooltip(),a=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(t),value:i})};h.addEventListener("mouseenter",o),h.addEventListener("mouseleave",r),h.addEventListener("click",a),this.gt.push({el:h,event:"mouseenter",handler:o},{el:h,event:"mouseleave",handler:r},{el:h,event:"click",handler:a}),s.appendChild(h)}}),f.appendChild(s)}),d.appendChild(f),a.appendChild(d),r.appendChild(a),t.appendChild(r),this.renderLegend(t)}renderLegend(t){const s=document.createElement("div");s.className="ds-heatmap__legend";const i=document.createElement("span");i.className="ds-heatmap__legend-label",i.textContent="少";const e=document.createElement("div");e.className="ds-heatmap__legend-cells";for(let t=0;t<=5;t++){const s=document.createElement("div");s.className="ds-heatmap__legend-cell",s.style.backgroundColor=this.getCellColor(t),e.appendChild(s)}const n=document.createElement("span");n.className="ds-heatmap__legend-label",n.textContent="多",s.appendChild(i),s.appendChild(e),s.appendChild(n),t.appendChild(s)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(t,s,i){const e=t.target.getBoundingClientRect();this.tooltip.innerHTML=`\n <div class="ds-heatmap__tooltip-date">${s.getFullYear()}年${s.getMonth()+1}月${s.getDate()}日</div>\n <div class="ds-heatmap__tooltip-value">${i} contributions</div>\n `,this.tooltip.style.left=Math.min(e.left+e.width/2-75,window.innerWidth-150-16)+"px",this.tooltip.style.top=e.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(t){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=[],this.data=t,this.render()}setDateRange(t,s){this.startDate=t,this.endDate=s,this.render()}destroy(){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function Is(t){if(t.Rt)return;const s=t.getAttribute("data-heatmap-data");let i=[];if(s)try{i=JSON.parse(s)}catch(t){i=As()}else i=As();const e=new Ds(t,{data:i,onCellClick:t=>{}});t.ot=e,t.Rt=!0}function Os(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}function As(){const t=[],s=new Date,i=new Date;i.setFullYear(i.getFullYear()-1);for(let e=new Date(i);e<=s;e.setDate(e.getDate()+1)){const s=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0"),h=0===e.getDay()||6===e.getDay()?20*Math.random():50*Math.random(),o=Math.floor(h);t.push({date:`${s}-${i}-${n}`,value:o>0?o:Math.floor(30*Math.random())+1})}return t}kt.register("heatmap",Is,Os);class Fs{constructor(t,s={}){this.element=t,this.tooltipEl=null,this.options=s;const i=nt(),e=void 0!==i.tooltip?.delay?i.tooltip.delay:300;this.delay=void 0!==s.delay?s.delay:parseInt(t.getAttribute("data-tooltip-delay"))||e,this.hideDelay=s.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=s.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=s.html||t.hasAttribute("data-tooltip-html"),this.theme=s.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=s.position||t.getAttribute("data-tooltip-position")||"top",this.animation=!1!==s.animation,this.mouseFollow=s.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this.we=null,this.ke=null,this.Me=null,this.$e=null,this.ve=null,this.Se=null,this.Ce=null,this.Te=null,this.isVisible=!1}init(){this.element.Rt||(this.we=()=>{this.delay>0?this.Me=setTimeout(()=>this.show(),this.delay):this.show()},this.ke=()=>{this.Me&&(clearTimeout(this.Me),this.Me=null),this.hideDelay>0?this.$e=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this.ve=()=>{this.isVisible?this.hide():this.show()},this.Te=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const s=this.tooltipEl.getBoundingClientRect();let i=t.clientX+10,e=t.clientY+10;const n=window.innerWidth,h=window.innerHeight;i+s.width>n&&(i=t.clientX-s.width-10),e+s.height>h&&(e=t.clientY-s.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${e}px`},"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.addEventListener("mouseenter",this.we),this.element.addEventListener("mouseleave",this.ke),this.mouseFollow&&this.element.addEventListener("mousemove",this.Te)),"click"===this.trigger&&(this.element.addEventListener("click",this.ve),document.addEventListener("click",t=>{!this.isVisible||this.element.contains(t.target)||this.tooltipEl?.contains(t.target)||this.hide()})),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.addEventListener("focus",this.we),this.element.addEventListener("blur",this.ke)),this.element.Rt=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");if(!t)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;const s=ht().tooltip;this.tooltipEl.style.zIndex=s,this.tooltipEl.style.transform="translateZ(0)",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.Ee(),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()}Ee(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),s=this.tooltipEl.getBoundingClientRect(),i=window.innerWidth,e=window.innerHeight;let n,h;switch(this.position){case"bottom":n=t.left+t.width/2-s.width/2,h=t.bottom+8;break;case"right":n=t.right+8,h=t.top+t.height/2-s.height/2;break;case"left":n=t.left-s.width-8,h=t.top+t.height/2-s.height/2;break;default:n=t.left+t.width/2-s.width/2,h=t.top-s.height-8}n<8&&(n=8),n+s.width>i&&(n=i-s.width-8),h<8&&(h=8),h+s.height>e&&(h=e-s.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${h}px`,this.tooltipEl.style.position="fixed"}updateContent(t,s=!1){this.element.setAttribute("data-tooltip",t),s?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=s,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this.Ee())}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.Ee()))}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.Te)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this.Te))}destroy(){this.element.Rt&&(this.Me&&(clearTimeout(this.Me),this.Me=null),this.$e&&(clearTimeout(this.$e),this.$e=null),"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.removeEventListener("mouseenter",this.we),this.element.removeEventListener("mouseleave",this.ke)),"click"===this.trigger&&this.element.removeEventListener("click",this.ve),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.removeEventListener("focus",this.we),this.element.removeEventListener("blur",this.ke)),this.mouseFollow&&this.element.removeEventListener("mousemove",this.Te),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this.we=null,this.ke=null,this.ve=null,this.Te=null,this.element.Rt=!1)}}function zs(t,s){const i=new Fs(t,s);i.init(),t.De=i}function js(t){t.De&&(t.De.destroy(),t.De=null)}kt.register("tooltip",zs,js);class Rs{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,s){this.customValidators[t]=s}addAsyncValidator(t,s){this.customAsyncValidators[t]=s}validate(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,i={},e=t.querySelectorAll("[data-validate]");let n=!1;return e.forEach(t=>{const s=t.name||t.id,e=this.parseRules(t.getAttribute("data-validate")),h=this.getValue(t);for(const[o,r]of Object.entries(e)){const e=this.customValidators[o]||this.validators[o],a=e?.(h,r);if(!a){i[s]=this.getErrorMessage(o,r,t),this.showError(t,i[s]),n=!0;break}this.clearError(t)}}),this.formStates[s]={valid:!n,errors:i,errorCount:Object.keys(i).length},this.updateFormState(t),!n}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 s=t.closest(".ds-select"),i=s.querySelector(".ds-select__value")||s.querySelector(".ds-select__trigger span");return i?i.textContent.trim():""}if(t.closest(".ds-fileupload")){const s=t.closest(".ds-fileupload").Ie;return s&&s.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const s=this.parseRules(t.getAttribute("data-validate")),i=this.getValue(t);for(const[e,n]of Object.entries(s)){const s=this.customValidators[e]||this.validators[e],h=s?.(i,n);if(!h)return this.showError(t,this.getErrorMessage(e,n,t)),!1}return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let s=!0;return t.forEach(t=>{this.validate(t)||(s=!1)}),s}async validateAsync(t,s={}){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,e=s.group,n=e?t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`):t.querySelectorAll("[data-validate]");let h=!1;for(const t of n){await this.validateInputAsync(t)||(h=!0)}const o={};return n.forEach(t=>{const s=t.name||t.id,i=t.parentElement.querySelector(".ds-input__error");i&&(o[s]=i.textContent)}),this.formStates[i]={valid:!h,errors:o,errorCount:Object.keys(o).length},this.updateFormState(t),!h}async validateInputAsync(t){const s=this.parseRules(t.getAttribute("data-validate")),i=this.parseRules(t.getAttribute("data-validate-async")||""),e=this.getValue(t);for(const[i,n]of Object.entries(s)){const s=this.customValidators[i]||this.validators[i],h=s?.(e,n);if(!h)return this.showError(t,this.getErrorMessage(i,n,t)),!1}for(const[s,n]of Object.entries(i)){const i=this.customAsyncValidators[s]||this.asyncValidators[s];if(i)try{if(!await i(e,n,t))return this.showError(t,this.getErrorMessage(s,n,t)),!1}catch(s){return this.showError(t,s.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,s){const i=t.querySelectorAll(`[data-validate][data-validate-group="${s}"]`);let e=!1;for(const t of i){await this.validateInputAsync(t)||(e=!0)}return!e}getGroups(t){const s=new Set;return t.querySelectorAll("[data-validate-group]").forEach(t=>{s.add(t.getAttribute("data-validate-group"))}),Array.from(s)}getFormState(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[s]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const s=this.getFormState(t);s.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")),s.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),s.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),s.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>t.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>{t.hasAttribute("data-permanent-disabled")||(t.disabled=!1)}));const i=t.querySelector(".ds-form__status");i&&(s.errorCount>0?(i.textContent=`${s.errorCount} ${1===s.errorCount?"error":"errors"} found`,i.classList.add("ds-form__status--error")):(i.textContent="All fields are valid",i.classList.remove("ds-form__status--error")))}setFormLoading(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].loading=s,this.updateFormState(t)}setFormSubmitting(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].submitting=s,this.updateFormState(t)}setFormDisabled(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].disabled=s,this.updateFormState(t)}resetForm(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(t=>{t.classList.remove("ds-input--error");const s=t.parentElement?.querySelector(".ds-input__error");s&&(s.textContent="")}),this.updateFormState(t)}parseRules(t){const s={};return t.split("|").forEach(t=>{const[i,e]=t.split(":");s[i]=e?e.split(","):[]}),s}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,[s]){return t.length>=parseInt(s)}validateMaxLength(t,[s]){return t.length<=parseInt(s)}validatePattern(t,[s]){return new RegExp(s).test(t)}validateMin(t,[s]){return parseFloat(t)>=parseFloat(s)}validateMax(t,[s]){return parseFloat(t)<=parseFloat(s)}validateEqualTo(t,[s]){const i=document.getElementById(s);return i&&t===i.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,s){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let i=t.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),t.parentElement.appendChild(i)),i.textContent=s,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:s}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const s=t.parentElement.querySelector(".ds-input__error");s&&s.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 s=document.createElement("span");s.className="ds-input__status-icon ds-input__status-icon--success",s.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(s)}removeStatusIcon(t){const s=t.parentElement.querySelector(".ds-input__status-icon");s&&s.remove()}getErrorMessage(t,s,i){const e=i.getAttribute(`data-message-${t}`);if(e)return e;return{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${s[0]} characters`,maxLength:`Maximum length is ${s[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${s[0]}`,max:`Maximum value is ${s[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 Ps=new Rs;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(t=>{t.addEventListener("submit",async s=>{const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;if(Ps.submitting.has(i))return void s.preventDefault();s.preventDefault();let e;if(e=null!==t.querySelector("[data-validate-async]")?await Ps.validateAsync(t):Ps.validate(t),e){Ps.submitting.add(i);const s=t.querySelector('button[type="submit"]');if(s){const t=s.textContent;s.setAttribute("data-original-text",t),s.textContent="Submitting...",s.disabled=!0}try{const s=t.getAttribute("data-on-submit");s&&window[s]?await window[s](t):t.submit()}finally{Ps.submitting.delete(i),s&&(s.textContent=s.getAttribute("data-original-text")||"Submit",s.disabled=!1)}}else{const s=t.querySelector(".ds-input--error");s&&s.focus()}}),t.querySelectorAll("[data-validate]").forEach(t=>{const s=lt(),i=s.trigger||"blur",e=()=>{s.showErrors&&setTimeout(()=>{const s=document.activeElement;if(s&&s.closest(".ds-select"))return;Ps.validateInput(t)&&t.value.trim()&&Ps.showSuccess(t)},50)};"blur"!==i&&"both"!==i||t.addEventListener("blur",e);const n=((t,s)=>{let i;return(...e)=>{clearTimeout(i),i=setTimeout(()=>t(...e),s)}})(()=>{if(!s.showErrors)return;const i=Ps.getValue(t);if(i.length>0||t.classList.contains("ds-input--error")){Ps.validateInput(t)&&i&&Ps.showSuccess(t)}else Ps.removeStatusIcon(t)},rt().debounceDelay);"input"!==i&&"both"!==i||t.addEventListener("input",n),t.addEventListener("keyup",s=>{if("Enter"===s.key){Ps.validateInput(t)&&t.value.trim()&&Ps.showSuccess(t)}})})})}));class Ls{constructor(t,s={}){this.element=t,this.data=s.data||[],this.itemHeight=s.itemHeight||48,this.itemWidth=s.itemWidth||200,this.bufferSize=s.bufferSize||5,this.renderItem=s.renderItem||this.defaultRenderItem,this.onItemClick=s.onItemClick||null,this.onItemSelect=s.onItemSelect||null,this.onScroll=s.onScroll||null,this.onScrollEnd=s.onScrollEnd||null,this.selectedKey=s.selectedKey||null,this.keyField=s.keyField||"id",this.useDynamicHeight=s.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=s.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,s){return`\n <div class="ds-virtual-list__item-content">\n <div class="ds-virtual-list__item-icon">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>\n <polyline points="14 2 14 8 20 8"/>\n <line x1="16" y1="13" x2="8" y2="13"/>\n <line x1="16" y1="17" x2="8" y2="17"/>\n <polyline points="10 9 9 9 8 9"/>\n </svg>\n </div>\n <div>\n <div class="ds-virtual-list__item-title">${t.title||t.name||`Item ${s+1}`}</div>\n <div class="ds-virtual-list__item-subtitle">${t.subtitle||"Subtitle"}</div>\n </div>\n </div>\n `}init(){this.createStructure(),this.update(),this.bindEvents()}createStructure(){this.element.innerHTML='\n <div class="ds-virtual-list__scrollbar">\n <div class="ds-virtual-list__scrollbar-track">\n <div class="ds-virtual-list__scrollbar-thumb"></div>\n </div>\n </div>\n <div class="ds-virtual-list__container"></div>\n ',this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this.es=t=>this.handleScroll(t),this.Oe=t=>this.handleThumbDragStart(t),this.Ae=t=>this.handleThumbDragMove(t),this.Fe=()=>this.handleThumbDragEnd(),this.ze=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.es),this.scrollbarThumb.addEventListener("mousedown",this.Oe),document.addEventListener("mousemove",this.Ae),document.addEventListener("mouseup",this.Fe),this.element.addEventListener("wheel",this.ze,{passive:!1}),this.gt=[{el:this.element,event:"scroll",handler:this.es},{el:this.scrollbarThumb,event:"mousedown",handler:this.Oe},{el:document,event:"mousemove",handler:this.Ae},{el:document,event:"mouseup",handler:this.Fe},{el:this.element,event:"wheel",handler:this.ze}]}handleScroll(t){const s=this.element.classList.contains("ds-virtual-list--horizontal"),i=s?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:i,isHorizontal:s,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"),s=t?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:s,isHorizontal:t,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(t){const s=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 s?this.itemWidth:this.itemHeight}getItemPositions(){const t=[];let s=0;return this.data.forEach((i,e)=>{const n=this.getItemSize(e);t.push({start:s,end:s+n,size:n}),s+=n}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((t,s,i)=>t+this.getItemSize(i),0);const t=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*t}getIndexAtOffset(t){if(this.useDynamicHeight){const s=this.getItemPositions();for(let i=0;i<s.length;i++)if(t>=s[i].start&&t<s[i].end)return i;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"),s=t?this.element.scrollLeft:this.element.scrollTop,i=t?this.element.clientWidth:this.element.clientHeight,e=Math.max(0,this.getIndexAtOffset(s)-this.bufferSize);let n=Math.min(this.data.length-1,this.getIndexAtOffset(s+i)+this.bufferSize);n<e&&(n=e),this.startIndex=e,this.endIndex=n;const h=this.data.slice(e,n+1);let o="",r=0;if(this.useDynamicHeight){const t=this.getItemPositions();r=t[e]?.start||0}else{const s=t?this.itemWidth:this.itemHeight;r=e*s}h.forEach((s,i)=>{const n=e+i,h=s[this.keyField]||n,a=this.selectedKey===h,c=this.getItemSize(n);o+=this.je(s,n,h,a,c,r,t),r+=c}),this.container.innerHTML=o,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(t=>{t.addEventListener("click",()=>this.handleItemClick(t))})}je(t,s,i,e,n,h,o){const r=e?" is-selected":"",a=this.renderItem(t,s);return o?`<div class="ds-virtual-list__item${r}" style="position: absolute; top: 0; left: ${h}px; width: ${n}px; height: 100%;" data-index="${s}" data-key="${i}">${a}</div>`:`<div class="ds-virtual-list__item${r}" style="position: absolute; top: ${h}px; left: 0; right: 0; height: ${n}px;" data-index="${s}" data-key="${i}">${a}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(s=>{const i=parseInt(s.dataset.index),e=this.data[i][this.keyField]||i,n=s.offsetHeight;n!==this.getItemSize(i)&&(this.dynamicHeightCache.set(e,n),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const s=parseInt(t.dataset.index),i=t.dataset.key,e=this.data[s];this.onItemClick&&this.onItemClick({item:e,index:s,key:i}),this.onItemSelect&&this.select(i)}select(t){if(this.selectedKey=t,this.onItemSelect){const s=this.data.findIndex(s=>s[this.keyField]===t);-1!==s&&this.onItemSelect({item:this.data[s],index:s,key:t})}this.renderVisibleItems()}updateScrollbar(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),s=this.getTotalSize(),i=t?this.element.clientWidth:this.element.clientHeight,e=t?this.element.scrollLeft:this.element.scrollTop;if(t)return void(this.scrollbarThumb.style.display="none");const n=Math.max(20,i/s*i),h=e/(s-i||1)*(i-n);this.scrollbarThumb.style.height=n+"px",this.scrollbarThumb.style.top=h+"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 s=this.element.clientHeight,i=this.getTotalSize(),e=s-(parseFloat(this.scrollbarThumb.style.height)||s),n=t.clientY-this.dragStartY;let h=this.dragStartTop+n;h=Math.max(0,Math.min(h,e)),this.scrollbarThumb.style.top=h+"px";const o=h/e*(i-s||0);this.element.scrollTop=o}handleThumbDragEnd(){this.isDragging=!1}update(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),s=this.getTotalSize();t?(this.container.style.width=s+"px",this.container.style.height="100%"):(this.container.style.height=s+"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,s){this.data.splice(t,0,s),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(t,s="smooth"){const i=this.element.classList.contains("ds-virtual-list--horizontal");let e=0;if(this.useDynamicHeight){const s=this.getItemPositions();e=s[t]?.start||0}else{e=t*(i?this.itemWidth:this.itemHeight)}i?this.element.scrollTo({left:e,behavior:s}):this.element.scrollTo({top:e,behavior:s})}scrollToKey(t,s="smooth"){const i=this.data.findIndex(s=>s[this.keyField]===t);-1!==i&&this.scrollTo(i,s)}scrollToTop(t="smooth"){const s=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[s?"left":"top"]:0,behavior:t})}scrollToBottom(t="smooth"){const s=this.element.classList.contains("ds-virtual-list--horizontal"),i=this.getTotalSize(),e=s?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[s?"left":"top"]:i-e,behavior:t})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((t,s)=>({item:t,index:this.startIndex+s,key:t[this.keyField]||this.startIndex+s}))}getItemIndex(t){return this.data.findIndex(s=>s[this.keyField]===t)}getItem(t){const s=this.getItemIndex(t);return-1!==s?this.data[s]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.gt?.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this.gt=null,this.es=null,this.Oe=null,this.Ae=null,this.Fe=null,this.ze=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function Ns(t=1e3){const s=[],i=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let e=1;e<=t;e++){const t=Math.floor(Math.random()*i.length),n=Math.floor(1e4*Math.random());s.push({id:e,title:`${i[t]} ${n}`,subtitle:`Last modified ${Math.floor(30*Math.random())} days ago`,type:i[t].toLowerCase()})}return s}function Bs(t){if(t.Rt)return;const s=t.getAttribute("data-virtual-list");let i=[];if(s)try{i=JSON.parse(s)}catch(t){i=Ns(1e3)}else i=Ns(1e3);const e=new Ls(t,{data:i,onItemClick:t=>{},onItemSelect:t=>{}});t.ot=e,t.Rt=!0}function Hs(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("virtual-list",Bs,Hs);const Vs={check:'<polyline points="4 12 10 18 20 6"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',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"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"chevron-left":'<polyline points="15 6 9 12 15 18"/>'},Us={...Vs},qs={core:Vs,interface:{search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',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"/>',"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"/>',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"/>',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"/>',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"/>'},navigation:{"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"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-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"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>'},action:{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"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',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"/>',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"/>',"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"/>'},status:{"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"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-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"/>',"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"/>',"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"/>',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"/>'},user:{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"/>',"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"/>',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"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>'},media:{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"/>',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"/>',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"/>'},data:{table:'<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"/>',"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"/>',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"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',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"/>',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"/>'},file:{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"/>',"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"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>'},time:{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"/>'},misc:{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"/>',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"/>',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"/>',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"/>',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-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"/>',"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"/>',"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)"/>',"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"/>',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"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',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"/>',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"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',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"/>',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"/>',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 Js(t,s=16,i="0 0 24 24"){const e=Us[t];if(!e)return"";return`<svg ${'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"'.replace('width="16"',`width="${s}"`).replace('height="16"',`height="${s}"`).replace('viewBox="0 0 24 24"',`viewBox="${i}"`)}>${e}</svg>`}function Ks(t=document){t.querySelectorAll("[data-icon]").forEach(t=>{const s=t.getAttribute("data-icon"),i=+t.getAttribute("data-size")||16,e=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=Js(s,i,e),t.classList.add("icon")})}const Ws={svg:Js,render:Ks,PATHS:Us,registerIcons:function(t){Object.assign(Us,t)},registerGroup:function(t){const s=qs[t];return!!s&&(Object.assign(Us,s),!0)},registerAllGroups:function(){Object.values(qs).forEach(t=>{Object.assign(Us,t)})},iconGroups:qs};"undefined"!=typeof document&&("loading"!==document.readyState?Ks():document.addEventListener("DOMContentLoaded",()=>Ks()));class Ys{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 s=parseInt(this.element.getAttribute("data-hours"))||0,i=parseInt(this.element.getAttribute("data-minutes"))||0,e=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*s+60*i+e)}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(),s=this.endTime-t;if(s<=0)return this.stop(),this.displayTime(0,0,0),void this.dispatchComplete();const i=Math.floor(s%864e5/36e5),e=Math.floor(s%36e5/6e4),n=Math.floor(s%6e4/1e3);this.displayTime(i,e,n)}displayTime(t,s,i){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(s).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(i).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=1e3*t,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 Zs(t){if(t.Rt)return;const s=new Ys(t);t.ot=s,t.Rt=!0}function Gs(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("countdown",Zs,Gs);class Xs{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.gt=[],!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),s=()=>this.updateValue(this.step),i=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",s),this.inputEl.addEventListener("input",i),this.gt.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:s},{el:this.inputEl,event:"input",handler:i})}updateValue(t){let s=parseInt(this.inputEl.value)||0;s+=t,s<this.min&&(s=this.min),s>this.max&&(s=this.max),this.inputEl.value=s,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,s){this.min=t,this.max=s,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this.gt.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.gt=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Qs(t){if(!t.Rt)try{const s=new Xs(t);t.ot=s,t.Rt=!0}catch(t){}}function ti(t){if(!t.Rt||!t.ot)return;t.ot.destroy(),t.ot=null,t.Rt=!1}kt.register("number-input",Qs,ti);class si{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="circle"!==this.shape,this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this.Re=null,this.Te=null,this.Pe=null,this.Ii=null,this.Ai=null,this.zi=null,this.Le=null,this.Ne=null,this.Be=null,this.He=null}init(){this.track&&this.btn&&(this.container.Ve||(this.Re=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.Te=t=>{if(!this.isDragging)return;t.preventDefault();const s=this.track.offsetWidth-this.btn.offsetWidth-8;let i=t.clientX-this.startX;i<0&&(i=0),i>s&&(i=s),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/s*100+"%"),this.collectTrack(t.clientX,t.clientY)},this.Pe=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.Ii=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.Ai=t=>{if(!this.isDragging)return;t.preventDefault();const s=this.track.offsetWidth-this.btn.offsetWidth-8;let i=t.touches[0].clientX-this.startX;i<0&&(i=0),i>s&&(i=s),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/s*100+"%"),this.collectTrack(t.touches[0].clientX,t.touches[0].clientY)},this.zi=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this.Re),this.Le=Ot.on(document,"mousemove",this.Te,{scope:this.scope}),this.Ne=Ot.on(document,"mouseup",this.Pe,{scope:this.scope}),this.Be=Ot.on(document,"touchmove",this.Ai,{scope:this.scope,passive:!1}),this.He=Ot.on(document,"touchend",this.zi,{scope:this.scope}),this.btn.addEventListener("touchstart",this.Ii,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container.Ve=!0,this.loadCaptcha()))}generateTarget(){const t=this.track.offsetWidth,s=this.btn.offsetWidth,i=.35*t,e=.85*t-s,n=.6*t;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);if(this.hasDistractor){Math.random()>.5?(this.targetX=Math.floor(i+Math.random()*(n-i-s)),this.distractorX=Math.floor(n+Math.random()*(e-n))):(this.targetX=Math.floor(n+Math.random()*(e-n)),this.distractorX=Math.floor(i+Math.random()*(n-i-s)))}else this.targetX=Math.floor(i+Math.random()*(e-i));const h=this.container.querySelector(".ds-slider-captcha__target");if(h&&(h.style.left=this.targetX+14+s/2+"px",h.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",h.style.display="block"),this.hasDistractor){const t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.style.left=this.distractorX+14+s/2+"px",t.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",t.style.display="block")}else{const t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.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,s){const i=Date.now()-this.startTime;let e=0,n=0;if(this.trackData.length>0){const t=this.trackData[this.trackData.length-1],s=this.currentX-t.x,h=i-t.t;if(h>0&&(e=s/h,this.trackData.length>1)){const s=this.trackData[this.trackData.length-2],i=t.t-s.t;if(i>0){n=e-(t.x-s.x)/i}}}this.trackData.push({x:this.currentX,y:s-this.startY,t:i,v:e,a:n});const h=this.container.querySelector(".ds-slider-captcha__point-count");h&&(h.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,s=this.hasDistractor?Math.abs(t-this.distractorX):1/0,i=Math.abs(t-this.targetX);if(this.hasDistractor&&s<i&&s<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(i>this.config.tolerance)return{passed:!1,msg:"验证失败"};const e=[];for(let t=1;t<this.trackData.length;t++){const s=this.trackData[t].x-this.trackData[t-1].x,i=this.trackData[t].t-this.trackData[t-1].t;i>0&&i<500&&e.push(s/i)}if(e.length<3)return{passed:!1,msg:"验证失败"};if(Math.max(...e)-Math.min(...e)<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let n=!1;for(const t of this.trackData)if(Math.abs(t.y)>2){n=!0;break}if(!n&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const h=this.trackData[this.trackData.length-1].t;if(h<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(h>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const o=[];for(let t=1;t<e.length;t++)o.push(Math.abs(e[t]-e[t-1]));if(o.length>2){if(o.reduce((t,s)=>t+s,0)/o.length<.05)return{passed:!1,msg:"验证失败"}}return{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 t=this.container.querySelector(".ds-slider-captcha__target");t&&(t.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 i=this.container.getAttribute("data-on-verified");i&&"function"==typeof window[i]&&window[i](this.container)}else{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");if("auto"===this.container.getAttribute("data-err-refresh"))setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const t=this.container.querySelector(".ds-slider-captcha__target");t&&(t.style.display="none");const s=this.container.querySelector(".ds-slider-captcha__target--distractor");s&&(s.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}}},300))}destroy(){this.container.Ve&&(this.btn&&this.Re&&this.btn.removeEventListener("mousedown",this.Re),this.btn&&this.Ii&&this.btn.removeEventListener("touchstart",this.Ii),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.Le&&this.Le.unsubscribe?this.Le.unsubscribe():this.Te&&document.removeEventListener("mousemove",this.Te),this.Ne&&this.Ne.unsubscribe?this.Ne.unsubscribe():this.Pe&&document.removeEventListener("mouseup",this.Pe),this.Be&&this.Be.unsubscribe?this.Be.unsubscribe():this.Ai&&document.removeEventListener("touchmove",this.Ai),this.He&&this.He.unsubscribe?this.He.unsubscribe():this.zi&&document.removeEventListener("touchend",this.zi),this.container.Ve=!1)}}function ii(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{const s=new si(t);s.init(),t.Ue=s})}function ei(t){t.Ue&&(t.Ue.destroy(),t.Ue=null)}function ni(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{ei(t)})}kt.register("slide-captcha",ii,ni);class hi{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this.qe=null,this.Je=new Map,this.Vi()}Vi(){this.Ke(),this.We(),this.xi()}Ke(){this.validators={required:t=>"string"==typeof t?""!==t.trim():Array.isArray(t)?t.length>0:null!=t,email:t=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},phone:t=>{if(!t)return!0;return/^1[3-9]\d{9}$/.test(t)},url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>!t||!isNaN(parseFloat(t))&&isFinite(t),minlength:(t,s)=>!t||t.length>=parseInt(s),maxlength:(t,s)=>!t||t.length<=parseInt(s),min:(t,s)=>!t||parseFloat(t)>=parseFloat(s),max:(t,s)=>!t||parseFloat(t)<=parseFloat(s),pattern:(t,s)=>{if(!t)return!0;return new RegExp(s).test(t)},equalTo:(t,s)=>{const i=document.getElementById(s);return!i||t===i.value}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}We(){this.form.querySelectorAll("input, select, textarea").forEach(t=>{t.hasAttribute("data-kupola-ignore")||this.fields.push(t)})}xi(){this.qe=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this.qe),this.fields.forEach(t=>{const s=()=>this.validateField(t),i=()=>this.clearError(t);this.Je.set(t,{blur:s,input:i}),t.addEventListener("blur",s),t.addEventListener("input",i)})}validate(){let t=!0;return this.fields.forEach(s=>{this.validateField(s)||(t=!1)}),t}validateField(t){const s=this.Ye(t);return s.length>0?(this.showError(t,s[0]),!1):(this.clearError(t),!0)}Ye(t){const s=[],i=this.Ze(t);for(const[e,n]of Object.entries(this.validators)){const h=t.getAttribute(`data-${e}`);if(null!==h){if(!n(i,h)){let t=this.errorMessages[e];"function"==typeof t&&(t=t(h)),s.push(t)}}}return s}Ze(t){const s=t.type;if("checkbox"===s)return t.checked;if("radio"===s){const s=t.name,i=this.form.querySelector(`input[name="${s}"]:checked`);return i?i.value:null}return"select-multiple"===s?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,s){this.clearError(t);const i=document.createElement("span");i.className="ds-form-error",i.textContent=s,t.classList.add("ds-form-field--error");const e=t.parentElement;e.classList.contains("ds-form-field")?e.appendChild(i):t.parentNode.insertBefore(i,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const s=t.parentElement.querySelector(".ds-form-error");s&&s.remove()}addValidator(t,s,i){this.validators[t]=s,this.errorMessages[t]=i}getData(){const t={};return this.fields.forEach(s=>{const i=s.name;if(!i)return;const e=this.Ze(s);"checkbox"===s.type?(t[i]||(t[i]=[]),s.checked&&t[i].push(s.value)):"radio"===s.type?!t[i]&&s.checked&&(t[i]=s.value):t[i]=e}),t}setData(t){Object.keys(t).forEach(s=>{this.form.querySelectorAll(`[name="${s}"]`).forEach(i=>{const e=i.type;if("checkbox"===e){const e=Array.isArray(t[s])?t[s]:[t[s]];i.checked=e.includes(i.value)}else if("radio"===e)i.checked=i.value===t[s];else if("select-multiple"===e){const e=Array.isArray(t[s])?t[s]:[t[s]];Array.from(i.options).forEach(t=>{t.selected=e.includes(t.value)})}else i.value=t[s]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this.qe&&this.form&&this.form.removeEventListener("submit",this.qe),this.Je.forEach((t,s)=>{s.removeEventListener("blur",t.blur),s.removeEventListener("input",t.input)}),this.qe=null,this.Je.clear(),this.Je=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function oi(t){const s=document.querySelectorAll(t||".ds-form");return s.forEach(t=>{if(t.Ge)return;const s=new hi(t);t.Ge=s}),s.length}kt.register("form-validation",oi);class ri{constructor(){this.Xe=new Set,this.Qe=!1,this.tn=0,this.sn=10}schedule(t){this.Xe.add(t),this.Qe||(this.Qe=!0,queueMicrotask(()=>this.en()))}en(){if(this.tn>=this.sn)return this.Xe.clear(),void(this.Qe=!1);const t=Array.from(this.Xe);this.Xe.clear(),this.Qe=!1,this.tn++;const s=new Set;for(const i of t)if(!s.has(i)){s.add(i);try{i()}catch(t){}}this.tn--}}const ai=new ri;class ci{constructor(t,s){this.data=t,this.createdAt=Date.now(),this.ttl=s}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class li{constructor(){this.nn=new Map}get(t){const s=this.nn.get(t);return s||null}set(t,s,i=6e4){this.nn.set(t,new ci(s,i))}has(t){return this.nn.has(t)}delete(t){this.nn.delete(t)}clear(){this.nn.clear()}getStale(t){const s=this.nn.get(t);return s?s.data:null}}class di extends Error{constructor(t,s,i){super(t),this.name="DependsError",this.code=s,this.cause=i,this.timestamp=Date.now()}}let ui="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;class pi{constructor(t,s){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=s,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 s=this.subscribers.indexOf(t);s>-1&&this.subscribers.splice(s,1)}}notify(){ai.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(t){}})})}async fetch(t){throw new di("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const s=this.cache.get(this.cacheKey);return s&&s.isFresh?s.data:s&&s.isStale?(this.hn(t),s.data):this.rn(t)}async rn(t,s=0){try{const s=await this.fetch(t);return this.cache.set(this.cacheKey,s,this.staleTime),this.notify(),s}catch(i){if(s<this.retryCount){const i=this.retryDelay*Math.pow(2,s),e=i+Math.random()*i*.5;return await new Promise(t=>setTimeout(t,e)),this.rn(t,s+1)}const e=i instanceof di?i:new di(i.message||"Fetch failed","FETCH_ERROR",i);if(this.onError)try{this.onError(e)}catch(t){}throw e}}async hn(t){try{await this.rn(t)}catch(t){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class fi extends pi{constructor(t,s){super(t,s),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let s=this.config.source;const i=tt("http");!i?.baseURL||s.startsWith("http://")||s.startsWith("https://")||(s=i.baseURL+s.replace(/^\//,""));for(const i in t)s=s.replace(`:${i}`,encodeURIComponent(t[i]));const e=[];for(const[t,s]of Object.entries(this.queryParams||{}))e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);for(const s in t)this.config.source.includes(`:${s}`)||e.push(`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`);e.length>0&&(s+=(s.includes("?")?"&":"?")+e.join("&"));const n=i?.headers||{},h={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...n,...this.headers}};i?.withCredentials&&(h.credentials="include"),["POST","PUT","PATCH"].includes(h.method)&&(h.body=JSON.stringify(t));const o=ui;if(!o)throw new di("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const r=await o(s,h),a="boolean"==typeof r.ok?r.ok:r.status>=200&&r.status<300,c="number"==typeof r.status?r.status:0;if(!a)throw new di(`HTTP ${c}`,"HTTP_ERROR");return"function"==typeof r.json?await r.json():void 0!==r.data?r.data:r}}class mi extends pi{constructor(t,s){super(t,s),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=!1!==t.sync,this.sync&&"undefined"!=typeof window&&(this.an=t=>{t.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this.an))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(null===t)return this.defaultValue;try{return JSON.parse(t)}catch(s){return t}}catch(t){return this.defaultValue}}setValue(t){const s="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(this.storageKey,s),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this.an&&window.removeEventListener("storage",this.an)}}class gi extends pi{constructor(t,s){super(t,s),this.paramName=t.source.replace("route:","")}async fetch(){if("undefined"==typeof window)return"";const t=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));if(t)return decodeURIComponent(t[1]);return new URLSearchParams(location.search).get(this.paramName)||""}}class yi extends pi{async fetch(t){return await this.config.source(t)}}class _i extends pi{async fetch(){return this.config.source}}class vi extends pi{constructor(t,s){super(t,s),this.ws=null,this.reconnect=!1!==t.reconnect,this.reconnectDelay=t.reconnectDelay||3e3,this.cn=0,this.ln=t.maxReconnectDelay||3e4,this.messageHandler=null,this.dn=!1,this.un=!1}async fetch(){return new Promise((t,s)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this.dn=!0,this.cn=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=t=>{let s;try{s=JSON.parse(t.data)}catch(i){s=t.data}this.cache.set(this.cacheKey,s,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=t=>{this.dn||s(new di("WebSocket connection failed","WS_ERROR",t))},this.ws.onclose=()=>{if(this.dn=!1,this.reconnect&&!this.un){const t=this.reconnectDelay*Math.pow(2,this.cn),s=Math.random()*t*.3,i=Math.min(t+s,this.ln);this.cn++,setTimeout(()=>{this.un||this.fetch().catch(()=>{})},i)}}}catch(t){s(new di("WebSocket creation failed","WS_ERROR",t))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("string"==typeof t?t:JSON.stringify(t))}destroy(){this.un=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function xi(t,s){const i=t.source;return"function"==typeof i?new yi(t,s):"string"==typeof i&&(i.startsWith("ws://")||i.startsWith("wss://"))?new vi(t,s):"string"==typeof i&&(i.startsWith("/")||i.startsWith("http"))?new fi(t,s):"string"==typeof i&&i.startsWith("localStorage:")?new mi(t,s):"string"==typeof i&&i.startsWith("route:")?new gi(t,s):new _i(t,s)}function bi(t){const s={};for(const i in t){const e=t[i];s[i]=e&&"object"==typeof e&&"value"in e?e.value:e}return s}class wi{constructor(t,s={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=s,this.columns=(s.columns||[]).map((t,s)=>({...t,pn:s})),this.rowKey=s.rowKey||"id",this.fn=[],this.mn=!1,this.striped=!1!==s.striped,this.bordered=s.bordered||!1,this.hoverable=!1!==s.hoverable,this.compact=s.compact||!1,this.emptyText=s.emptyText||"暂无数据",this.loadingText=s.loadingText||"加载中...",this.multiSort=s.multiSort||!1,this.gn=[],this.yn="",this._n=!1!==s.pagination,this.vn=s.pageSizes||[10,20,50,100],this.xn=s.pageSize||10,this.bn=1,this.wn=0,this.selection=s.selection||null,this.kn=new Set,this.selectionColumnTitle=s.selectionColumnTitle||"",this.expandable=s.expandable||null,this.Mn=new Set,this.expandColumnTitle=s.expandColumnTitle||"",this.editable=s.editable||!1,this.$n=null,this.Sn={},this.resizable=s.resizable||!1,this.draggable=s.draggable||!1,this.Cn=null,this.tree=s.tree||null,this.Tn=new Set,s.tree?.defaultExpandAll&&(this.En=!0),this.virtualScroll=s.virtualScroll||null,this.Dn=null,this.es=null,this.In=[],this.On=null,this.An=[],this.mergeCells=s.mergeCells||null,this.onSort=s.onSort||null,this.onPageChange=s.onPageChange||null,this.onRowClick=s.onRowClick||null,this.onFilter=s.onFilter||null,this.onSelect=s.onSelect||null,this.onExpand=s.onExpand||null,this.onEditSave=s.onEditSave||null,this.onEditCancel=s.onEditCancel||null,this.onRowDragEnd=s.onRowDragEnd||null,this.onColumnResize=s.onColumnResize||null,this.sortKey=q(null),this.sortOrder=q(null),this.currentPage=q(1),this.filterText=q(""),this.selectedKeys=q([]),this.Vi()}Vi(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&"object"==typeof t&&"value"in t?(this.fn=Array.isArray(t.value)?t.value:[],t.subscribe&&this.An.push(t.subscribe(t=>{this.fn=Array.isArray(t)?t:[],this.wn=this.fn.length,this.render()}))):Array.isArray(t)?this.fn=t:this.fn=[],this.tree&&this.En&&this.Fn(this.fn),this.wn=this.zn(this.fn).length,this.render()}setLoading(t){t&&"object"==typeof t&&"value"in t?(this.mn=t.value,t.subscribe&&this.An.push(t.subscribe(t=>{this.mn=t,this.render()}))):this.mn=!!t,this.render()}Fn(t,s=0,i=null){const e=this.tree?.childrenKey||"children",n=[];for(const h of t){const t=h[this.rowKey];n.push({...h,jn:s,Rn:i,Pn:!(!h[e]||!h[e].length)}),h[e]&&h[e].length&&n.push(...this.Fn(h[e],s+1,t))}return n}zn(t){return this.tree?this.Ln(t,0):t}Ln(t,s){const i=this.tree?.childrenKey||"children",e=[];for(const n of t){const t=n[this.rowKey];e.push({...n,jn:s,Pn:!(!n[i]||!n[i].length)}),n[i]&&n[i].length&&this.Tn.has(t)&&e.push(...this.Ln(n[i],s+1))}return e}getProcessedData(){let t=(this.tree,[...this.fn]);if(this.yn){const s=this.yn.toLowerCase();t=this.tree?this.Nn(t,s):t.filter(t=>this.columns.some(i=>{const e=t[i.key];return null!=e&&String(e).toLowerCase().includes(s)}))}this.gn.length>0&&(t=this.tree?this.Bn(t):this.Hn(t));const s=this.tree?this.Ln(t):t;this.wn=s.length;let i=s;if(this._n&&this.xn>0){const t=(this.bn-1)*this.xn;i=s.slice(t,t+this.xn)}return i}Nn(t,s){const i=this.tree?.childrenKey||"children";return t.reduce((t,e)=>{const n=e[i]?this.Nn(e[i],s):[];return(this.columns.some(t=>{const i=e[t.key];return null!=i&&String(i).toLowerCase().includes(s)})||n.length>0)&&(t.push({...e,[i]:n}),n.length>0&&this.Tn.add(e[this.rowKey])),t},[])}Hn(t){return[...t].sort((t,s)=>{for(const i of this.gn){const e=this.columns.find(t=>t.key===i.key);let n=t[i.key],h=s[i.key],o=0;if(o=e?.sorter?e.sorter(n,h,i.order):null==n?1:null==h?-1:"number"==typeof n&&"number"==typeof h?"asc"===i.order?n-h:h-n:"asc"===i.order?String(n).localeCompare(String(h)):String(h).localeCompare(String(n)),0!==o)return o}return 0})}Bn(t){const s=this.Hn(t),i=this.tree?.childrenKey||"children";return s.map(t=>t[i]?.length?{...t,[i]:this.Bn(t[i])}:t)}render(){const t=this.getProcessedData(),s=this.element;s.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&s.appendChild(this.Vn());const i=document.createElement("div");i.className="kupola-table-container";const e=document.createElement("table");e.className=this.Un(),e.appendChild(this.qn()),this.virtualScroll?e.appendChild(this.Jn(t)):e.appendChild(this.Kn(t)),i.appendChild(e),s.appendChild(i),this._n&&this.wn>0&&s.appendChild(this.Wn()),this.resizable&&this.Yn(),this.draggable&&this.Zn(),this.Gn()}qn(){const t=document.createElement("thead"),s=document.createElement("tr");if(this.selection&&this.Xn(s),this.expandable){const t=document.createElement("th");t.className="kupola-table-col-expand",s.appendChild(t)}return this.columns.forEach(t=>{const i=this.Qn(t);s.appendChild(i)}),t.appendChild(s),t}Xn(t){const s=document.createElement("th");if(s.className="kupola-table-col-selection","checkbox"===this.selection){const t=document.createElement("input");t.type="checkbox";const i=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=i.length>0&&i.every(t=>this.kn.has(t)),t.addEventListener("change",()=>t.checked?this.selectAll():this.deselectAll()),s.appendChild(t)}t.appendChild(s)}Qn(t){const s=document.createElement("th");if(s.textContent=t.title||t.key,t.width&&(s.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(s.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(s.style.textAlign=t.align),t.fixed&&s.setAttribute("data-fixed",t.fixed),t.sortable&&this.th(s,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const i=document.createElement("span");i.className="kupola-table-resize-handle",i.setAttribute("data-col-key",t.key),s.appendChild(i)}return s}th(t,s){t.classList.add("kupola-table-sortable");const i=this.gn.find(t=>t.key===s.key);i&&t.classList.add(`kupola-table-sort-${i.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this.sh(s.key)});const e=document.createElement("span");e.className="kupola-table-sort-icon",e.textContent=i?this.multiSort?` ${this.gn.indexOf(i)+1}${"asc"===i.order?"▲":"▼"}`:"asc"===i.order?" ▲":" ▼":" ⇅",t.appendChild(e)}Kn(t){const s=document.createElement("tbody");if(this.mn)s.appendChild(this.ih(this.loadingText,"kupola-table-loading"));else if(0===t.length)s.appendChild(this.ih(this.emptyText,"kupola-table-empty"));else{const i=this.mergeCells?this.mergeCells(t):[],e=new Map;i.forEach(t=>e.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,i)=>{const h=t[this.rowKey]??i,o=this.kn.has(h),r=this.Mn.has(h),a=this.eh(t,i,h,o,n,e);if(s.appendChild(a),this.expandable&&r){const i=document.createElement("tr");i.className="kupola-table-expand-row";const e=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;e.colSpan=n,e.className="kupola-table-expand-content";const h=this.expandable(t);"string"==typeof h?e.innerHTML=h:h instanceof HTMLElement&&e.appendChild(h),i.appendChild(e),s.appendChild(i)}})}return s}eh(t,s,i,e,n,h){const o=document.createElement("tr");return o.setAttribute("data-row-key",i),e&&o.classList.add("kupola-table-row-selected"),this.draggable&&(o.draggable=!0,o.classList.add("kupola-table-draggable")),this.selection&&this.nh(o,i,e),this.expandable&&this.hh(o,i),this.columns.forEach((e,r)=>{if(n.has(`${s}-${r}`))return;const a=this.oh(t,s,i,e,r,n,h);o.appendChild(a)}),this.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",i=>{i.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,s,i)})),o}nh(t,s,i){const e=document.createElement("td");e.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=i,n.addEventListener("change",()=>{"radio"===this.selection?(this.kn.clear(),this.kn.add(s)):i?this.kn.delete(s):this.kn.add(s),this.selectedKeys.value=[...this.kn],this.onSelect&&this.onSelect([...this.kn],this.getSelectedRows()),this.render()}),e.appendChild(n),t.appendChild(e)}hh(t,s){const i=document.createElement("td");i.className="kupola-table-col-expand";const e=document.createElement("button");e.className="kupola-table-expand-btn",e.textContent=this.Mn.has(s)?"▼":"▶",e.type="button",e.addEventListener("click",()=>this.rh(s)),i.appendChild(e),t.appendChild(i)}oh(t,s,i,e,n,h,o){const r=document.createElement("td");e.align&&(r.style.textAlign=e.align),e.fixed&&(r.setAttribute("data-fixed",e.fixed),r.classList.add(`kupola-table-fixed-${e.fixed}`));const a=o.get(`${s}-${n}`);if(a){a.rowSpan>1&&(r.rowSpan=a.rowSpan),a.colSpan>1&&(r.colSpan=a.colSpan);for(let t=0;t<(a.rowSpan||1);t++)for(let i=0;i<(a.colSpan||1);i++)0===t&&0===i||h.add(`${s+t}-${n+i}`)}this.tree&&0===n&&t.jn>0&&this.ah(r,t);const c=this.$n&&this.$n.rowKey===i&&this.$n.colKey===e.key;if(c)r.appendChild(this.dh(e,t));else if(e.render){const i=e.render(t[e.key],t,s);"string"==typeof i?r.innerHTML=i:i instanceof HTMLElement&&r.appendChild(i)}else r.textContent=t[e.key]??"";return this.editable&&!c&&!1!==e.editable&&(r.classList.add("kupola-table-editable-cell"),r.addEventListener("dblclick",()=>this.uh(i,e.key,t[e.key]))),r}ah(t,s){const i=document.createElement("span");if(i.className="kupola-table-tree-indent",i.style.paddingLeft=20*s.jn+"px",t.appendChild(i),s.Pn){const i=document.createElement("button");i.className="kupola-table-tree-toggle",i.textContent=this.Tn.has(s[this.rowKey])?"▼":"▶",i.type="button",i.addEventListener("click",t=>{t.stopPropagation(),this.ph(s[this.rowKey])}),t.appendChild(i)}else{const s=document.createElement("span");s.className="kupola-table-tree-toggle-placeholder",t.appendChild(s)}}ih(t,s){const i=document.createElement("tr"),e=document.createElement("td");return e.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),e.className=s,e.textContent=t,i.appendChild(e),i}Jn(t){const s=document.createElement("tbody"),{rowHeight:i=40,overscan:e=5}=this.virtualScroll,n=t.length*i;if(this.mn)return this.Kn(t);if(0===t.length)return this.Kn(t);const h=document.createElement("tr");h.className="kupola-table-virtual-spacer-top",h.style.height="0px",s.appendChild(h),this.fh={data:t,rowHeight:i,overscan:e,totalHeight:n,tbody:s,topSpacer:h},this.mh();const o=document.createElement("tr");o.className="kupola-table-virtual-spacer-bottom",o.style.height="0px",s.appendChild(o);const r=this.element.querySelector(".kupola-table-container");return r&&(r.style.maxHeight=this.virtualScroll.maxHeight||"400px",r.style.overflowY="auto",this.es&&r.removeEventListener("scroll",this.es),this.es=()=>this.mh(),r.addEventListener("scroll",this.es)),s}mh(){if(!this.fh)return;const{data:t,rowHeight:s,overscan:i,tbody:e,topSpacer:n}=this.fh,h=this.element.querySelector(".kupola-table-container");if(!h)return;const o=h.scrollTop,r=h.clientHeight,a=Math.max(0,Math.floor(o/s)-i),c=Math.min(t.length,Math.ceil((o+r)/s)+i);e.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const l=document.createDocumentFragment();for(let i=a;i<c;i++){const e=t[i],n=e[this.rowKey]??i,h=this.eh(e,i,n,this.kn.has(n),new Set,new Map);h.classList.add("kupola-table-virtual-row"),h.style.height=s+"px",l.appendChild(h)}n.style.height=a*s+"px";const d=e.querySelector(".kupola-table-virtual-spacer-bottom");d&&(d.style.height=(t.length-c)*s+"px"),n.after(l)}dh(t,s){const i=document.createElement("div");i.className="kupola-table-edit-cell";const e=document.createElement("input");if(e.type=t.editType||"text",e.className="ds-input kupola-table-edit-input",e.value=this.Sn[t.key]??s[t.key]??"",t.editOptions){const s=document.createElement("select");s.className="ds-input kupola-table-edit-input",t.editOptions.forEach(t=>{const i=document.createElement("option");i.value="object"==typeof t?t.value:t,i.textContent="object"==typeof t?t.label:t,String(i.value)===String(e.value)&&(i.selected=!0),s.appendChild(i)}),s.addEventListener("change",()=>{this.Sn[t.key]=s.value}),i.appendChild(s)}else e.addEventListener("input",()=>{this.Sn[t.key]=e.value}),i.appendChild(e);const n=document.createElement("div");n.className="kupola-table-edit-actions";const h=document.createElement("button");h.className="kupola-table-edit-save",h.textContent="✓",h.type="button",h.addEventListener("click",()=>this.gh(s,t));const o=document.createElement("button");return o.className="kupola-table-edit-cancel",o.textContent="✗",o.type="button",o.addEventListener("click",()=>this.yh()),n.appendChild(h),n.appendChild(o),i.appendChild(n),e.addEventListener("keydown",i=>{"Enter"===i.key&&this.gh(s,t),"Escape"===i.key&&this.yh()}),setTimeout(()=>e.focus?.(),0),i}uh(t,s,i){this.$n={rowKey:t,colKey:s},this.Sn={[s]:i},this.render()}gh(t,s){const i=this.Sn[s.key];this.onEditSave?this.onEditSave(t,s.key,i,this.fn):t[s.key]=i,this.$n=null,this.Sn={},this.render()}yh(){this.onEditCancel&&this.onEditCancel(this.$n),this.$n=null,this.Sn={},this.render()}sh(t){if(this.multiSort){const s=this.gn.findIndex(s=>s.key===t);if(s>=0){const t=this.gn[s];"asc"===t.order?t.order="desc":this.gn.splice(s,1)}else this.gn.push({key:t,order:"asc"})}else{const s=this.gn.find(s=>s.key===t);s?"asc"===s.order?s.order="desc":this.gn=[]:this.gn=[{key:t,order:"asc"}]}this.sortKey.value=this.gn.map(t=>t.key).join(","),this.sortOrder.value=this.gn.map(t=>t.order).join(","),this.bn=1,this.onSort&&this.onSort(this.gn),this.render()}rh(t){this.Mn.has(t)?this.Mn.delete(t):this.Mn.add(t),this.onExpand&&this.onExpand(t,this.Mn.has(t)),this.render()}ph(t){this.Tn.has(t)?this.Tn.delete(t):this.Tn.add(t),this.render()}selectRow(t){this.kn.add(t),this._h(),this.render()}deselectRow(t){this.kn.delete(t),this._h(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this.kn.add(t[this.rowKey])),this._h(),this.render()}deselectAll(){this.kn.clear(),this._h(),this.render()}invertSelection(){this.getProcessedData().forEach(t=>{const s=t[this.rowKey];this.kn.has(s)?this.kn.delete(s):this.kn.add(s)}),this._h(),this.render()}getSelectedKeys(){return[...this.kn]}getSelectedRows(){return(this.tree?this.Fn(this.fn):this.fn).filter(t=>this.kn.has(t[this.rowKey]))}_h(){this.selectedKeys.value=[...this.kn]}Yn(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{t.addEventListener("mousedown",s=>{s.preventDefault();const i=t.getAttribute("data-col-key"),e=t.parentElement,n=s.clientX,h=e.offsetWidth,o=t=>{const s=Math.max(50,h+(t.clientX-n));e.style.width=s+"px";const o=this.columns.find(t=>t.key===i);o&&(o.width=s),this.onColumnResize&&this.onColumnResize(i,s)},r=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.In.push(r)})})}Zn(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(t=>{t.addEventListener("dragstart",s=>{this.Cn={fromKey:t.getAttribute("data-row-key")},t.classList.add("kupola-table-dragging"),s.dataTransfer.effectAllowed="move"}),t.addEventListener("dragover",s=>{s.preventDefault(),s.dataTransfer.dropEffect="move",t.classList.add("kupola-table-drag-over")}),t.addEventListener("dragleave",()=>t.classList.remove("kupola-table-drag-over")),t.addEventListener("drop",s=>this.xh(s,t)),t.addEventListener("dragend",()=>{t.classList.remove("kupola-table-dragging"),this.Cn=null})})}xh(t,s){if(t.preventDefault(),s.classList.remove("kupola-table-drag-over"),!this.Cn)return;const i=s.getAttribute("data-row-key");if(this.Cn.fromKey===i)return;const e=this.fn.findIndex(t=>String(t[this.rowKey])===this.Cn.fromKey),n=this.fn.findIndex(t=>String(t[this.rowKey])===i);if(e>=0&&n>=0){const[t]=this.fn.splice(e,1);this.fn.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,e,n,this.fn),this.render()}}Gn(){const t=this.columns.filter(t=>"left"===t.fixed);this.selection,this.expandable,t.forEach(t=>{const s=this.element.querySelectorAll('th[data-fixed="left"]'),i=this.element.querySelectorAll('td[data-fixed="left"]'),e=this.columns.indexOf(t);let n=(this.selection?40:0)+(this.expandable?40:0);for(let t=0;t<e;t++)"left"===this.columns[t].fixed&&(n+=this.columns[t].bh||120);s.forEach(s=>{s.textContent.startsWith(t.title||t.key)&&(s.style.position="sticky",s.style.left=n+"px",s.style.zIndex="2",t.bh=s.offsetWidth)}),i.forEach(t=>{t.style.position="sticky",t.style.left=n+"px",t.style.zIndex="1",t.style.background="inherit"})});let s=0;[...this.columns].filter(t=>"right"===t.fixed).reverse().forEach(t=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(t=>{t.style.position="sticky",t.style.right=s+"px",t.style.zIndex="1"}),s+=t.bh||t.width||120})}Vn(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const s=document.createElement("input");s.type="text",s.className="ds-input kupola-table-filter-input",s.placeholder=this.options.filterPlaceholder||"搜索...",s.value=this.yn,s.addEventListener("input",()=>{clearTimeout(this.On),this.On=setTimeout(()=>{this.yn=s.value,this.bn=1,this.filterText.value=this.yn,this.onFilter&&this.onFilter(this.yn),this.render()},300)}),t.appendChild(s)}const s=document.createElement("div");if(s.className="kupola-table-toolbar-right",this.selection&&this.kn.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`已选 ${this.kn.size} 项`,s.appendChild(t);const i=document.createElement("button");i.className="ds-btn ds-btn--sm",i.textContent="反选",i.type="button",i.addEventListener("click",()=>this.invertSelection()),s.appendChild(i)}if(this.options.showExport){const t=document.createElement("button");t.className="ds-btn ds-btn--sm ds-btn--secondary",t.textContent="导出 CSV",t.type="button",t.addEventListener("click",()=>this.exportCSV()),s.appendChild(t)}const i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this.wn} 条`,s.appendChild(i),t.appendChild(s),t}Wn(){const t=Math.ceil(this.wn/this.xn);if(t<=1)return document.createElement("div");const s=document.createElement("div");if(s.className="kupola-table-pagination",this.options.showPageSize){const t=document.createElement("select");t.className="kupola-table-page-size",this.vn.forEach(s=>{const i=document.createElement("option");i.value=s,i.textContent=`${s} 条/页`,s===this.xn&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>{this.xn=parseInt(t.value),this.bn=1,this.currentPage.value=1,this.render()}),s.appendChild(t)}const i=document.createElement("div");i.className="kupola-table-pages";const e=this.wh("‹",()=>this.kh(this.bn-1));e.disabled=this.bn<=1,i.appendChild(e),this.Mh(this.bn,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",i.appendChild(t)}else{const s=this.wh(t,()=>this.kh(t));t===this.bn&&s.classList.add("active"),i.appendChild(s)}});const n=this.wh("›",()=>this.kh(this.bn+1));n.disabled=this.bn>=t,i.appendChild(n),s.appendChild(i);const h=document.createElement("span");return h.className="kupola-table-page-info",h.textContent=`${this.bn} / ${t}`,s.appendChild(h),s}wh(t,s){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=t,i.type="button",i.addEventListener("click",s),i}kh(t){const s=Math.ceil(this.wn/this.xn);t<1||t>s||(this.bn=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this.xn),this.render())}Mh(t,s){if(s<=7)return Array.from({length:s},(t,s)=>s+1);const i=[];if(t<=3){for(let t=1;t<=5;t++)i.push(t);i.push("...",s)}else if(t>=s-2){i.push(1,"...");for(let t=s-4;t<=s;t++)i.push(t)}else{i.push(1,"...");for(let s=t-1;s<=t+1;s++)i.push(s);i.push("...",s)}return i}exportCSV(t="export.csv"){const s=this.getProcessedData(),i=this.columns.map(t=>t.title||t.key),e=s.map(t=>this.columns.map(s=>{let i=t[s.key];return null==i&&(i=""),i=String(i).replace(/"/g,'""'),`"${i}"`}).join(",")),n="\ufeff"+[i.join(","),...e].join("\n"),h=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(h),r=document.createElement("a");r.href=o,r.download=t,r.click(),URL.revokeObjectURL(o)}Un(){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.bn,pageSize:this.xn,total:this.wn}}setColumns(t){this.columns=t.map((t,s)=>({...t,pn:s})),this.render()}destroy(){if(this.es){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this.es),this.es=null}this.On&&(clearTimeout(this.On),this.On=null),this.In.forEach(t=>t()),this.In=[],this.An.forEach(t=>t.unsubscribe()),this.An=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this.fn=[],this.fh=null,this.Cn=null,this.$n=null,this.Sn={}}}function ki(t,s){return new wi(t,s)}kt.register("table",ki);class Mi{constructor(t,s={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=s,this.$h=s.current||1,this.wn=s.total||0,this.xn=s.pageSize||10,this.Sh=s.maxPages||7,this.Ch=!1!==s.showTotal,this.Th=s.showSizeChanger||!1,this.vn=s.pageSizes||[10,20,50,100],this.Eh=s.simple||!1,this.current=q(this.$h),this.total=q(this.wn),this.onChange=s.onChange||null,this.onPageSizeChange=s.onPageSizeChange||null,this.Vi()}Vi(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this.wn/this.xn))}setCurrent(t){(t=Math.max(1,Math.min(t,this.totalPages)))!==this.$h&&(this.$h=t,this.current.value=t,this.onChange&&this.onChange(t,this.xn),this.render())}setTotal(t){t&&"object"==typeof t&&"value"in t?(this.wn=t.value||0,t.H?.add(t=>{this.wn=t||0,this.$h>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this.wn=t,this.total.value=this.wn,this.render()}setPageSize(t){this.xn=t,this.$h=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this.$h),this.render()}render(){const t=this.element;t.innerHTML="",this.wn<=0||(this.Eh?this.Dh(t):this.Ih(t))}Dh(t){const s=this.totalPages,i=this.Oh("‹",()=>this.setCurrent(this.$h-1));i.disabled=this.$h<=1,t.appendChild(i);const e=document.createElement("span");e.className="kupola-pagination-simple-info",e.textContent=`${this.$h} / ${s}`,t.appendChild(e);const n=this.Oh("›",()=>this.setCurrent(this.$h+1));n.disabled=this.$h>=s,t.appendChild(n)}Ih(t){const s=this.totalPages;if(this.Ch){const s=document.createElement("span");s.className="kupola-pagination-total",s.textContent=`共 ${this.wn} 条`,t.appendChild(s)}if(this.Th){const s=document.createElement("select");s.className="kupola-pagination-size",this.vn.forEach(t=>{const i=document.createElement("option");i.value=t,i.textContent=`${t} 条/页`,t===this.xn&&(i.selected=!0),s.appendChild(i)}),s.addEventListener("change",()=>this.setPageSize(parseInt(s.value))),t.appendChild(s)}const i=document.createElement("div");i.className="kupola-pagination-pages";const e=this.Oh("‹",()=>this.setCurrent(this.$h-1));e.disabled=this.$h<=1,i.appendChild(e),this.Mh().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",i.appendChild(t)}else{const s=this.Oh(t,()=>this.setCurrent(t));t===this.$h&&s.classList.add("active"),i.appendChild(s)}});const n=this.Oh("›",()=>this.setCurrent(this.$h+1));if(n.disabled=this.$h>=s,i.appendChild(n),t.appendChild(i),s>10){const i=document.createElement("span");i.className="kupola-pagination-jumper",i.innerHTML='跳至 <input type="number" min="1" max="'+s+'" value="'+this.$h+'"> 页';const e=i.querySelector("input");e.addEventListener("change",()=>{const t=parseInt(e.value);t>=1&&t<=s&&this.setCurrent(t)}),e.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(e.value);t>=1&&t<=s&&this.setCurrent(t)}}),t.appendChild(i)}}Oh(t,s){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=t,i.type="button",i.addEventListener("click",s),i}Mh(){const t=this.totalPages,s=this.Sh;if(t<=s)return Array.from({length:t},(t,s)=>s+1);const i=[],e=Math.floor(s/2);if(this.$h<=e+1){for(let t=1;t<=s-2;t++)i.push(t);i.push("...",t)}else if(this.$h>=t-e){i.push(1,"...");for(let e=t-s+3;e<=t;e++)i.push(e)}else{i.push(1,"...");for(let t=this.$h-e+2;t<=this.$h+e-2;t++)i.push(t);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let $i=!1;let Si=!1;class Ci extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this.Ah()}Ah(){const t=this.querySelector('[slot="trigger"]'),s=this.querySelectorAll('[slot="item"]'),i=document.createElement("div");i.className="ds-dropdown",i.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),i.appendChild(t));const e=document.createElement("div");e.className="ds-dropdown__menu",s.forEach(t=>{t.className="ds-dropdown__item",e.appendChild(t)}),i.appendChild(e),this.innerHTML="",this.appendChild(i)}attributeChangedCallback(t,s,i){if("open"===t){const t=this.querySelector(".ds-dropdown__menu");t&&(t.style.display=null!==i?"block":"")}}}class Ti 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,s,i){if("title"===t){const t=this.firstElementChild;t&&t.setAttribute("data-title",i||"")}}}class Ei extends HTMLElement{connectedCallback(){this.Ah()}Ah(){const t=document.createElement("div");t.className="ds-collapse",t.setAttribute("data-collapse","");this.querySelectorAll("k-collapse-item").forEach(s=>{const i=s.getAttribute("title")||"",e=s.innerHTML,n=document.createElement("div");n.className="ds-collapse__item",n.innerHTML=`\n <button class="ds-collapse__header">\n <span>${i}</span>\n <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>\n </button>\n <div class="ds-collapse__body"><div class="ds-collapse__content">${e}</div></div>\n `,t.appendChild(n)}),this.innerHTML="",this.appendChild(t)}}class Di extends HTMLElement{static get observedAttributes(){return["title"]}}class Ii extends HTMLElement{static get observedAttributes(){return["position","open"]}connectedCallback(){this.Ah()}Ah(){const t=this.getAttribute("position")||"left",s=document.createElement("div");s.className=`ds-drawer ds-drawer--${t}`,s.setAttribute("data-drawer",""),s.innerHTML=this.innerHTML,this.innerHTML="",this.appendChild(s)}attributeChangedCallback(t,s,i){if("open"===t){const t=this.querySelector(".ds-drawer");t&&t.classList.toggle("is-open",null!==i)}}}class Oi extends HTMLElement{static get observedAttributes(){return["title","open"]}connectedCallback(){this.Ah()}Ah(){const t=this.getAttribute("title")||"",s=document.createElement("div");s.className="ds-backdrop",s.style.display="none",s.innerHTML=`\n <div class="ds-dialog">\n <div class="ds-dialog__head">\n <span class="ds-dialog__title">${t}</span>\n <button class="ds-dialog__close" aria-label="Close">\n <svg class="icon" 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>\n </button>\n </div>\n <div class="ds-dialog__body"></div>\n <div class="ds-dialog__foot"></div>\n </div>\n `;const i=s.querySelector(".ds-dialog__body"),e=this.querySelector('[slot="body"]');e&&i.appendChild(e);const n=s.querySelector(".ds-dialog__foot"),h=this.querySelector('[slot="footer"]');h&&n.appendChild(h);const o=s.querySelector(".ds-dialog__close");o&&o.addEventListener("click",()=>this.close()),s.addEventListener("click",t=>{t.target===s&&this.close()}),this.innerHTML="",this.appendChild(s)}attributeChangedCallback(t,s,i){if("open"===t){const t=this.querySelector(".ds-backdrop");t&&(t.style.display=null!==i?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}exports.BRAND_OPTIONS=ft,exports.CacheEntry=ci,exports.CacheManager=li,exports.Calendar=gs,exports.Carousel=Wt,exports.Collapse=ls,exports.ColorPicker=ps,exports.ComponentInitializerRegistry=wt,exports.Countdown=Ys,exports.Datepicker=Lt,exports.DependsError=di,exports.DependsSource=pi,exports.Dialog=class{static normal(t={}){return this.Fh({type:"normal",...t})}static success(t={}){return this.Fh({type:"success",...t})}static warning(t={}){return this.Fh({type:"warning",...t})}static error(t={}){return this.Fh({type:"error",...t})}static info(t={}){return this.Fh({type:"info",...t})}static confirm(t={}){return this.Fh({type:"confirm",...t})}static Fh(t){const{type:s="normal",title:i="",content:e="",onConfirm:n,onCancel:h}=t,o={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>'},r=document.createElement("div");r.className="ds-modal-container",r.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal" style="max-width: 360px">\n <div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">\n <div class="ds-dialog__icon ds-dialog__icon--${s}">${o[s]}</div>\n ${i?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===s||h?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}\n <button class="ds-btn ${"confirm"===s?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>\n ${"confirm"===s?"Confirm":"OK"}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,document.body.appendChild(r),i&&(r.querySelector(".ds-dialog__title").textContent=i),r.querySelector(".ds-dialog__content").textContent=e;const a=r.querySelector(".ds-modal-mask"),c=r.querySelector("[data-dialog-confirm]"),l=r.querySelector("[data-dialog-cancel]"),d=function(t){"Escape"===t.key&&(h&&h(),m())},u=function(t){t.target===a&&(h&&h(),m())},p=function(){n&&n(),m()},f=function(){h&&h(),m()},m=()=>{a.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",d),a.removeEventListener("click",u),c&&c.removeEventListener("click",p),l&&l.removeEventListener("click",f),setTimeout(()=>r.remove(),300)};return a.classList.add("is-visible"),document.body.style.overflow="hidden",c&&c.addEventListener("click",p),l&&l.addEventListener("click",f),a.addEventListener("click",u),document.addEventListener("keydown",d),{close:m}}},exports.Drawer=Gt,exports.Dropdown=At,exports.DynamicTags=vs,exports.FetchedSource=fi,exports.FileUpload=rs,exports.FunctionSource=yi,exports.GlobalEvents=It,exports.Heatmap=Ds,exports.Icons=Ws,exports.ImagePreview=ws,exports.KupolaComponent=$t,exports.KupolaComponentRegistry=Ct,exports.KupolaDataBind=B,exports.KupolaEventBus=U,exports.KupolaForm=hi,exports.KupolaI18n=Et,exports.KupolaLifecycle=t,exports.KupolaPagination=Mi,exports.KupolaStore=H,exports.KupolaStoreManager=V,exports.KupolaTable=wi,exports.KupolaUtils=z,exports.KupolaValidator=Rs,exports.Message=hs,exports.Modal=ts,exports.Notification=ns,exports.NumberInput=Xs,exports.PATHS=Us,exports.RouteSource=gi,exports.Scheduler=ri,exports.Select=jt,exports.SlideCaptcha=si,exports.Slider=qt,exports.StatCard=Cs,exports.StaticSource=_i,exports.StorageSource=mi,exports.Tag=Ms,exports.Timepicker=Ht,exports.Tooltip=Fs,exports.VirtualList=Ls,exports.WebSocketSource=vi,exports.alertModal=function(t){return"string"==typeof t&&(t={content:t}),ss({...t,showCancel:!1,showConfirm:!0})},exports.applyMixin=St,exports.arrayUtils=o,exports.bootstrapComponents=function(t){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(t):Promise.resolve()},exports.cleanupAllDropdowns=function(){document.querySelectorAll(".ds-dropdown").forEach(t=>{zt(t)})},exports.cleanupAllSlideCaptchas=ni,exports.cleanupCalendar=_s,exports.cleanupCarousel=Zt,exports.cleanupCollapse=us,exports.cleanupColorPicker=ms,exports.cleanupCountdown=Gs,exports.cleanupDatepicker=Bt,exports.cleanupDrawer=Qt,exports.cleanupDropdown=zt,exports.cleanupDynamicTags=bs,exports.cleanupFileUpload=cs,exports.cleanupHeatmap=Os,exports.cleanupModal=es,exports.cleanupNumberInput=ti,exports.cleanupSelect=Pt,exports.cleanupSlideCaptcha=ei,exports.cleanupSlider=Kt,exports.cleanupStatCard=Es,exports.cleanupTag=Ss,exports.cleanupTimepicker=Ut,exports.cleanupTooltip=js,exports.cleanupVirtualList=Hs,exports.clearCache=function(){},exports.configureHttpClient=function(t){if(!t||"function"!=typeof t.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");ui=t.fetch.bind(t)},exports.confirmModal=function(t){return"string"==typeof t&&(t={content:t}),ss({...t,showCancel:!0,showConfirm:!0})},exports.createBrandPicker=function(){const t=document.createElement("div");t.id="brand-picker-auto",t.style.position="fixed",t.style.top="56px",t.style.right="16px",t.style.zIndex="9998",t.style.display="none",t.style.padding="12px",t.style.width="200px",t.style.gridTemplateColumns="repeat(3, 1fr)",t.style.gap="6px",t.style.backgroundColor="var(--bg-base-secondary)",t.style.border="1px solid var(--border-neutral-l1)",t.style.borderRadius="8px",t.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",t.style.overflow="hidden",ft.forEach(s=>{const i=document.createElement("button");i.setAttribute("data-brand-btn",s.id),i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.height="60px",i.style.backgroundColor=s.color,i.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(s.color)?"#0C0C0D":"#FFFFFF",i.style.fontWeight="500",i.style.borderRadius="4px",i.style.border="none",i.style.cursor="pointer",i.style.margin="0",i.style.padding="0",i.textContent=s.name,t.appendChild(i)}),document.body.appendChild(t);const s=document.createElement("button");s.setAttribute("data-brand-toggle",""),s.setAttribute("data-current-brand",yt()),s.className="ds-btn ds-btn--ghost ds-btn--sm",s.style.position="fixed",s.style.top="16px",s.style.right="56px",s.style.zIndex="9999",s.style.display="flex",s.style.alignItems="center",s.style.gap="6px";const i=document.createElement("span");i.className="brand-icon",i.style.width="12px",i.style.height="12px",i.style.borderRadius="50%",i.style.backgroundColor=ft.find(t=>t.id===yt()).color;const e=document.createElement("span");function n(i){t.contains(i.target)||s.contains(i.target)||(t.style.display="none",document.removeEventListener("click",n,!0))}return e.className="brand-name",e.style.fontSize="11px",e.textContent=ft.find(t=>t.id===yt()).name,s.appendChild(i),s.appendChild(e),document.body.appendChild(s),s.onclick=function(s){s.stopPropagation(),s.preventDefault();const i="none"===t.style.display;t.style.display=i?"grid":"none",i?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},t.onclick=function(t){t.stopPropagation()},t.querySelectorAll("[data-brand-btn]").forEach(s=>{s.addEventListener("click",i=>{i.stopPropagation();_t(s.getAttribute("data-brand-btn")),t.style.display="none"})}),{toggleBtn:s,container:t}},exports.createI18n=function(t){return new Et(t)},exports.createLifecycle=function(s="app"){return new t(s)},exports.createModal=ss,exports.createSource=xi,exports.createStore=function(t,s){return W.createStore(t,s)},exports.createThemeToggle=function(){const t=document.createElement("button");t.setAttribute("data-theme-toggle",""),t.setAttribute("data-current-theme",mt()),t.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",t.style.position="fixed",t.style.top="16px",t.style.right="16px",t.style.zIndex="9999";const s=document.createElement("img");s.className="theme-icon";const i=st();return s.src="dark"===mt()?i+"sun.svg":i+"moon.svg",s.width=14,s.height=14,s.alt="Toggle theme",t.appendChild(s),document.body.appendChild(t),t.onclick=function(t){t.preventDefault();gt("dark"===mt()?"light":"dark")},t},exports.cryptoUtils=E,exports.dateUtils=v,exports.debounce=x,exports.defineComponent=function(t,s){if(!s||"object"!=typeof s)throw new Error(`defineComponent("${t}"): options must be an object`);s.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(t,s.componentClass):s.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(t,s.lazy),s.init?kt.register(t,s.init,s.cleanup||null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass}):(s.dataAttribute||s.cssClass)&&kt.register(t,()=>{},null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass})},exports.defineMixin=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(t,s)},exports.emit=function(t,s,i){return Ot.emit(t,s,i)},exports.emitGlobal=function(t,s){return Ot.emitGlobal(t,s)},exports.escapeHtml=function(t){if("string"!=typeof t)return t;const s=document.createElement("div");return s.textContent=t,s.innerHTML},exports.formatCurrency=function(t,s,i={}){return Dt.formatCurrency(t,s,i)},exports.formatDate=function(t,s={}){return Dt.formatDate(t,s)},exports.formatNumber=function(t,s={}){return Dt.formatNumber(t,s)},exports.generateSecureId=function(t,s){const i=ot(),e=i?.secureId||{},n=t||e.length||16,h=e.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if("undefined"==typeof crypto||!crypto.getRandomValues){let t="";for(let s=0;s<n;s++)t+=h[Math.floor(Math.random()*h.length)];return s?`${s}_${t}`:t}const o=new Uint32Array(n);crypto.getRandomValues(o);let r="";for(let t=0;t<n;t++)r+=h[o[t]%h.length];return s?`${s}_${r}`:r},exports.getBasePath=function(){return Y.paths.base},exports.getBrand=yt,exports.getConfig=tt,exports.getDefaultBrand=et,exports.getDefaultTheme=it,exports.getFormInstance=function(t){return t.Ge},exports.getHttpClient=function(){return ui},exports.getHttpConfig=function(){return Y.http},exports.getIconsPath=st,exports.getListenerCount=function(t,s){return Ot.getListenerCount(t,s)},exports.getLocale=function(){return Dt.getLocale()},exports.getMessageConfig=at,exports.getNotificationConfig=ct,exports.getPerformanceConfig=rt,exports.getSecurityConfig=ot,exports.getStore=function(t){return W.getStore(t)},exports.getTheme=mt,exports.getUiConfig=nt,exports.getValidationConfig=lt,exports.globalEvents=Ot,exports.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const s=t.getAttribute("data-kupola-table");let i={};if(s)try{i=JSON.parse(s)}catch(t){}ki(t,i)})},exports.initCalendar=ys,exports.initCalendars=function(){document.querySelectorAll(".ds-calendar").forEach(t=>{ys(t)})},exports.initCarousel=Yt,exports.initCarousels=function(t=document){t.querySelectorAll(".ds-carousel").forEach(t=>{Yt(t)})},exports.initCollapse=ds,exports.initCollapses=function(){document.querySelectorAll(".ds-collapse").forEach(t=>{ds(t)})},exports.initColorPicker=fs,exports.initColorPickers=function(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{fs(t)})},exports.initCountdown=Zs,exports.initCountdowns=function(){document.querySelectorAll(".ds-countdown").forEach(t=>{Zs(t)})},exports.initDatepicker=Nt,exports.initDatepickers=function(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{Nt(t)})},exports.initDrawer=Xt,exports.initDrawers=function(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const s=t.getAttribute("data-drawer"),i=document.getElementById(s);i&&(Xt(i,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),i.ot?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const s=t.parentElement;s&&Xt(s)})},exports.initDropdown=Ft,exports.initDropdowns=function(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{Ft(t)})},exports.initDynamicTags=xs,exports.initDynamicTagsAll=function(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{xs(t)})},exports.initFileUpload=as,exports.initFileUploads=function(){document.querySelectorAll(".ds-fileupload").forEach(t=>{as(t)})},exports.initFormValidation=oi,exports.initHeatmap=Is,exports.initHeatmaps=function(){document.querySelectorAll(".ds-heatmap").forEach(t=>{Is(t)})},exports.initImagePreview=function(){ks||(ks=new ws),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const s=JSON.parse(t.getAttribute("data-image-preview")),i=parseInt(t.getAttribute("data-image-index"))||0;ks.show(s,i)})})},exports.initMessages=function(){},exports.initModal=is,exports.initModals=function(){document.querySelectorAll(".ds-modal-container").forEach(t=>{is(t)})},exports.initNotifications=function(){},exports.initNumberInput=Qs,exports.initNumberInputs=function(){document.querySelectorAll(".ds-number-input").forEach(t=>{Qs(t)})},exports.initPagination=function(t,s){return function(){if($i||"undefined"==typeof document)return;const t=document.createElement("style");t.textContent="\n .kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }\n .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; }\n .kupola-pagination-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }\n .kupola-pagination-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }\n .kupola-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }\n .kupola-pagination-ellipsis { padding: 0 4px; color: #999; user-select: none; }\n .kupola-pagination-total { color: #666; font-size: 14px; }\n .kupola-pagination-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }\n .kupola-pagination-simple-info { padding: 0 8px; font-size: 14px; color: #333; }\n .kupola-pagination-jumper { font-size: 14px; color: #666; }\n .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; }\n .kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }\n ",document.head.appendChild(t),$i=!0}(),new Mi(t,s)},exports.initSelect=Rt,exports.initSelects=function(t=document){t.querySelectorAll(".ds-select").forEach(t=>{Rt(t)})},exports.initSlideCaptchas=ii,exports.initSlider=Jt,exports.initSliders=function(){document.querySelectorAll(".ds-slider").forEach(t=>{Jt(t)})},exports.initStatCard=Ts,exports.initStatCards=function(){document.querySelectorAll(".ds-statcard").forEach(t=>{Ts(t)})},exports.initTable=ki,exports.initTag=$s,exports.initTags=function(){document.querySelectorAll(".ds-tag").forEach(t=>{$s(t)})},exports.initTheme=bt,exports.initTimepicker=Vt,exports.initTimepickers=function(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{Vt(t)})},exports.initTooltip=zs,exports.initTooltips=function(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{zs(t)})},exports.initVirtualList=Bs,exports.kupolaBootstrap=Tt,exports.kupolaData=J,exports.kupolaEvents=K,exports.kupolaI18n=Dt,exports.kupolaInitializer=kt,exports.kupolaLifecycle=s,exports.kupolaStoreManager=W,exports.maskData=function(t,s,i={}){const e=ot(),n=e?.maskData||{};if(!n.enabled&&!i.force)return t;if(null==t)return t;const h=(i.patterns||n.patterns||{})[s];if(!h)return t;const o="string"==typeof h.regex?new RegExp(h.regex):h.regex;return String(t).replace(o,h.replace)},exports.n=function(t,s,i={}){return Dt.n(t,s,i)},exports.numberUtils=u,exports.objectUtils=a,exports.off=function(t,s,i){Ot.off(t,s,i)},exports.offAll=function(t,s){Ot.offAll(t,s)},exports.offByScope=function(t){Ot.offByScope(t)},exports.offConfigChange=function(t){const s=Z.indexOf(t);s>-1&&Z.splice(s,1)},exports.on=function(t,s,i,e){return Ot.on(t,s,i,e)},exports.onConfigChange=Q,exports.once=function(t,s,i,e){return Ot.once(t,s,i,e)},exports.preloadUtils=F,exports.ref=q,exports.registerComponent=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.register(t,s)},exports.registerLazyComponent=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(t,s)},exports.registerWebComponents=function(){if(Si||"undefined"==typeof customElements)return;Si=!0;const t=[["k-dropdown",Ci],["k-tooltip",Ti],["k-collapse",Ei],["k-collapse-item",Di],["k-drawer",Ii],["k-modal",Oi]];for(const[s,i]of t)customElements.get(s)||customElements.define(s,i)},exports.renderIcon=Ks,exports.resetHttpClient=function(){ui="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null},exports.sanitizeHtml=function(t,s={}){const i=ot(),e=i?.sanitizeHtml||{};if(!e.enabled&&!s.force)return t;const n=s.allowedTags||e.allowedTags||[],h=s.allowedAttributes||e.allowedAttributes||{};if("string"!=typeof t)return t;const o=(new DOMParser).parseFromString(t,"text/html");return o.body.querySelectorAll("*").forEach(t=>{const s=t.tagName.toLowerCase();n.includes(s)?Array.from(t.attributes).forEach(i=>{const e=i.name.toLowerCase();(h[s]||[]).includes(e)||t.removeAttribute(i.name)}):t.remove()}),o.body.innerHTML},exports.setBrand=_t,exports.setConfig=function(t){dt(Y,t),X()},exports.setLocale=function(t){return Dt.setLocale(t)},exports.setTheme=gt,exports.showImagePreview=function(t,s=0){ks||(ks=new ws),ks.show(t,s)},exports.stringUtils=n,exports.stripHtml=function(t){return"string"!=typeof t?t:(new DOMParser).parseFromString(t,"text/html").body.textContent||""},exports.svg=Js,exports.t=function(t,s={}){return Dt.t(t,s)},exports.throttle=b,exports.useDeps=function(t,s){const i={},e=new li,n=[];for(const h in s){let o=s[h];"string"==typeof o&&(o={source:o});const r=xi({...o,cacheKey:o.cacheKey||`${h}-${JSON.stringify(bi(t))}`},e),a=q(null),c=q(!0),l=q(null),d=q(null);let u=0;async function p(){const s=++u;c.value=!0,l.value=null;try{const i=await r.getValue(bi(t));if(s!==u)return;a.value=i,d.value=Date.now()}catch(t){if(s!==u)return;l.value=t.message||"Unknown error"}finally{s===u&&(c.value=!1)}}p();const f=r.subscribe(()=>{const t=e.getStale(r.cacheKey);null!=t&&(a.value=t,d.value=Date.now())});n.push(f);const m=Object.keys(t);m.length>0&&m.forEach(s=>{const i=t[s];if(i&&"object"==typeof i&&"value"in i&&i.H){const t=()=>{r.invalidate(),p()};i.H.add(t),n.push(()=>i.H.delete(t))}}),i[h]={data:a,loading:c,error:l,lastUpdated:d,refresh:()=>(r.invalidate(),p()),setValue(t){r instanceof mi&&(r.setValue(t),a.value=t)},send(t){r instanceof vi&&r.send(t)},zh:r}}return i.jh=()=>{if(n.forEach(t=>t()),window.__kupolaDepInstances){const t=window.__kupolaDepInstances.indexOf(i);-1!==t&&window.__kupolaDepInstances.splice(t,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(i),i},exports.useMixin=function(t,...s){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(t,...s)},exports.useQuery=function(t){const s=new li,i=xi(t,s),e=q(null),n=q(!0),h=q(null);let o=0;async function r(){const s=++o;n.value=!0,h.value=null;try{const n=await i.getValue(t.params||{});if(s!==o)return;e.value=n}catch(t){if(s!==o)return;h.value=t.message||"Unknown error"}finally{s===o&&(n.value=!1)}}return r(),i.subscribe(()=>{const t=s.getStale(i.cacheKey);null!=t&&(e.value=t)}),{data:e,loading:n,error:h,refresh:()=>(i.invalidate(),r())}},exports.validateForm=function(t){const s=t.Ge;return!!s&&s.validate()},exports.validator=Ps,exports.validatorUtils=T;
|