@kupola/kupola 1.3.1 → 1.4.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.
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Kupola={})}(this,function(e){"use strict";class t{constructor(e="app"){this.scope=e,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(e){const t=this.transitions.get(this.state);if(!t||!t.includes(e))throw new Error(`Invalid state transition: ${this.state} -> ${e}`);return!0}_updateState(e){this._validateTransition(e),this.state=e,this.stateHistory.push(e)}_resetResolved(e){const t=this.hooks.get(e);t&&t.forEach(e=>{e.resolved=!1})}on(e,t,i={}){if(!this.allPhases.includes(e))throw new Error(`Unknown lifecycle phase: ${e}`);const s=this.hooks.get(e);return s.push({handler:t,priority:i.priority||0,depends:i.depends||[],name:i.name||t.name||`anonymous_${s.length}`}),s.sort((e,t)=>t.priority-e.priority),()=>{const e=s.findIndex(e=>e.handler===t);e>-1&&s.splice(e,1)}}async _resolveDepends(e,t){if(e&&0!==e.length)for(const i of e){const e=this.hooks.get(t).find(e=>e.name===i);e&&!e.resolved&&(await e.handler(),e.resolved=!0)}}async emit(e,...t){if("destroyed"===this.state&&"error"!==e)return;const i=this.hooks.get(e);if(!i||0===i.length)return;const s=`${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(s);const n=performance.now();try{for(const n of i){await this._resolveDepends(n.depends,e);const i=performance.now();let a,r;try{a=n.handler(...t),a instanceof Promise&&await a,n.resolved=!0}catch(i){r=i,console.error(`[KupolaLifecycle] Error in ${e} hook "${n.name}":`,i),"error"!==e&&await this._handleError({phase:e,hook:n.name,error:i,args:t})}const o=performance.now()-i;this.trace.push({emitId:s,phase:e,hookName:n.name,duration:o,status:r?"error":"success",error:r?r.message:null,timestamp:Date.now()})}const a=performance.now()-n;console.debug(`[KupolaLifecycle] ${e} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(s)}}async runPhase(e,...t){if(!this.basePhases.includes(e))throw new Error(`Unknown base phase: ${e}`);const i=this.phaseStateMap[e];if(i)if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${e} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${e} from state ${this.state}, expected ${i.from}`);const s=`before${e.charAt(0).toUpperCase()+e.slice(1)}`,n=`after${e.charAt(0).toUpperCase()+e.slice(1)}`;this._resetResolved(s),this._resetResolved(e),this._resetResolved(n),this.allPhases.includes(s)&&await this.emit(s,...t),await this.emit(e,...t),i&&this._updateState(i.to),this.allPhases.includes(n)&&await this.emit(n,...t)}async bootstrap(...e){await this.runPhase("bootstrap",...e)}async _waitForDOMReady(){return new Promise(e=>{if("complete"===document.readyState||"interactive"===document.readyState)return void e();const t=()=>{document.removeEventListener("DOMContentLoaded",t),window.removeEventListener("load",t),e()};document.addEventListener("DOMContentLoaded",t),window.addEventListener("load",t)})}async mount(...e){await this.runPhase("mount",...e)}async mountWithDOMReady(...e){await this._waitForDOMReady(),await this.runPhase("mount",...e)}async update(...e){await this.runPhase("update",...e)}async unmount(...e){await this.runPhase("unmount",...e)}async destroy(...e){await this.runPhase("destroy",...e),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(e){return this.hooks.get(e)||[]}hasHandlers(e){const t=this.hooks.get(e);return t&&t.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(e){return this.state===e}onError(e){return this._onErrorCallback=e,this.on("error",e)}setErrorBoundary(e){return this.errorBoundary=e,this.on("errorBoundary",t=>"function"==typeof e?e(t):null)}setMaxErrors(e){this.maxErrors=e}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(e){if(this.errorCount++,this.lastError=e.error,this.errorCount>=this.maxErrors)return void console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);if(await this.emit("error",e),"function"==typeof this._onErrorCallback)try{await this._onErrorCallback(e)}catch(e){console.error("[KupolaLifecycle] Error in onError callback:",e)}const t=this.hooks.get("errorBoundary");if(t&&t.length>0)for(const i of t)try{const t=i.handler(e);if(t instanceof Promise&&await t,"handled"===t)return void console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${i.name}"`)}catch(e){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${i.name}":`,e)}console.error(`[KupolaLifecycle] Unhandled error in ${e.phase}:`,e.error)}}class i{constructor(){this.plugins=new Map,this.enabledPlugins=new Set,this.pluginHooks=new Map}register(e,i){this.plugins.has(e)&&console.warn(`Plugin ${e} already registered, overriding`),this.plugins.set(e,{...i,name:e,enabled:!1,instance:null,lifecycle:new t(`plugin:${e}`)})}async enable(e){const t=this.plugins.get(e);if(!t)throw new Error(`Plugin ${e} not found`);if(!t.enabled)try{await t.lifecycle.bootstrap(),t.install&&(t.instance=await t.install()),t.enabled=!0,this.enabledPlugins.add(e),await t.lifecycle.mount(),t.hooks&&this._registerPluginHooks(e,t.hooks),console.log(`Plugin ${e} enabled`)}catch(t){throw console.error(`Failed to enable plugin ${e}:`,t),t}}async disable(e){const t=this.plugins.get(e);if(t&&t.enabled)try{await t.lifecycle.unmount(),t.uninstall&&await t.uninstall(t.instance),t.hooks&&this._unregisterPluginHooks(e),t.enabled=!1,this.enabledPlugins.delete(e),t.instance=null,await t.lifecycle.destroy(),console.log(`Plugin ${e} disabled`)}catch(t){throw console.error(`Failed to disable plugin ${e}:`,t),t}}get(e){const t=this.plugins.get(e);return t?.instance||null}getAll(){const e={};return this.plugins.forEach((t,i)=>{e[i]={name:t.name,enabled:t.enabled,instance:t.instance,state:t.lifecycle.getState()}}),e}getEnabled(){const e={};return this.enabledPlugins.forEach(t=>{const i=this.plugins.get(t);i&&(e[t]=i.instance)}),e}async enableAll(){const e=[];this.plugins.forEach((t,i)=>{e.push(this.enable(i))}),await Promise.all(e)}async disableAll(){const e=[];this.enabledPlugins.forEach(t=>{e.push(this.disable(t))}),await Promise.all(e)}_registerPluginHooks(e,t){this.pluginHooks.has(e)||this.pluginHooks.set(e,[]);const i=this.pluginHooks.get(e);Object.keys(t).forEach(s=>{const n="undefined"!=typeof window&&window.kupolaLifecycle?.on(s,t[s],{name:`${e}:${s}`});n&&i.push({phase:s,unsubscribe:n})})}_unregisterPluginHooks(e){const t=this.pluginHooks.get(e);t&&(t.forEach(({unsubscribe:e})=>{e&&e()}),this.pluginHooks.delete(e))}}const s=new t("app"),n=new i;function a(e="app"){return new t(e)}"undefined"!=typeof window&&(window.KupolaLifecycle=t,window.KupolaPluginManager=i,window.kupolaLifecycle=s,window.kupolaPluginManager=n,window.createLifecycle=a);const r={string:{trim:e=>e?e.trim():"",trimLeft:e=>e?e.replace(/^\s+/,""):"",trimRight:e=>e?e.replace(/\s+$/,""):"",toUpperCase:e=>e?e.toUpperCase():"",toLowerCase:e=>e?e.toLowerCase():"",capitalize:e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",camelize:e=>e?e.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():""):"",hyphenate:e=>e?e.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):"",padStart:(e,t,i=" ")=>(String(e)||"").padStart(t,i),padEnd:(e,t,i=" ")=>(String(e)||"").padEnd(t,i),truncate:(e,t,i="...")=>!e||e.length<=t?e||"":e.slice(0,t)+i,replaceAll:(e,t,i)=>e?e.split(t).join(i):"",format:(e,t)=>e?e.replace(/\{\{(\w+)\}\}/g,(e,i)=>void 0!==t[i]?t[i]:`{{${i}}}`):"",startsWith:(e,t)=>(e||"").startsWith(t),endsWith:(e,t)=>(e||"").endsWith(t),includes:(e,t)=>(e||"").includes(t),repeat:(e,t)=>(e||"").repeat(t),reverse:e=>(e||"").split("").reverse().join(""),countOccurrences:(e,t)=>e&&t?e.split(t).length-1:0,escapeHtml(e){if(!e)return"";const t=document.createElement("div");return t.textContent=e,t.innerHTML},unescapeHtml(e){if(!e)return"";const t=document.createElement("div");return t.innerHTML=e,t.textContent},generateRandom(e=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let s=0;s<e;s++)i+=t.charAt(Math.floor(62*Math.random()));return i},generateUUID:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},array:{isArray:e=>Array.isArray(e),isEmpty:e=>!e||0===e.length,size:e=>e?e.length:0,first:(e,t)=>e&&e.length>0?e[0]:t,last:(e,t)=>e&&e.length>0?e[e.length-1]:t,get:(e,t,i)=>e&&void 0!==e[t]?e[t]:i,slice:(e,t,i)=>e?e.slice(t,i):[],concat:(...e)=>e.reduce((e,t)=>e.concat(t||[]),[]),join:(e,t=",")=>e?e.join(t):"",indexOf:(e,t,i=0)=>e?e.indexOf(t,i):-1,lastIndexOf:(e,t,i)=>e?e.lastIndexOf(t,i):-1,includes:(e,t)=>!!e&&e.includes(t),push:(e,...t)=>(e&&e.push(...t),e),pop:e=>e?e.pop():void 0,shift:e=>e?e.shift():void 0,unshift:(e,...t)=>(e&&e.unshift(...t),e),remove(e,t){if(!e)return e;const i=e.indexOf(t);return i>-1&&e.splice(i,1),e},removeAt:(e,t)=>(!e||t<0||t>=e.length||e.splice(t,1),e),insert:(e,t,i)=>e?(e.splice(t,0,i),e):e,reverse:e=>e?e.slice().reverse():[],sort:(e,t)=>e?e.slice().sort(t):[],sortBy:(e,t,i="asc")=>e?e.slice().sort((e,s)=>{const n="object"==typeof e?e[t]:e,a="object"==typeof s?s[t]:s;return n<a?"asc"===i?-1:1:n>a?"asc"===i?1:-1:0}):[],filter:(e,t)=>e?e.filter(t):[],map:(e,t)=>e?e.map(t):[],reduce:(e,t,i)=>e?e.reduce(t,i):i,forEach(e,t){e&&e.forEach(t)},every:(e,t)=>!e||e.every(t),some:(e,t)=>!!e&&e.some(t),find:(e,t)=>e?e.find(t):void 0,findIndex:(e,t)=>e?e.findIndex(t):-1,flat:(e,t=1)=>e?e.flat(t):[],flattenDeep(e){return e?e.reduce((e,t)=>Array.isArray(t)?e.concat(this.flattenDeep(t)):e.concat(t),[]):[]},unique:e=>e?[...new Set(e)]:[],uniqueBy(e,t){if(!e)return[];const i=new Set;return e.filter(e=>{const s="object"==typeof e?e[t]:e;return!i.has(s)&&(i.add(s),!0)})},chunk(e,t){if(!e||t<=0)return[];const i=[];for(let s=0;s<e.length;s+=t)i.push(e.slice(s,s+t));return i},shuffle(e){if(!e)return[];const t=e.slice();for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t},sum:e=>e?e.reduce((e,t)=>e+(Number(t)||0),0):0,average(e){return e&&0!==e.length?this.sum(e)/e.length:0},max:e=>e&&e.length>0?Math.max(...e):-1/0,min:e=>e&&e.length>0?Math.min(...e):1/0,intersection:(...e)=>0===e.length?[]:e.reduce((e,t)=>e.filter(e=>t&&t.includes(e))),union:(...e)=>[...new Set(e.flat().filter(Boolean))],difference:(e,t)=>e?e.filter(e=>!t||!t.includes(e)):[],zip(...e){if(0===e.length)return[];const t=Math.max(...e.map(e=>e?e.length:0));return Array.from({length:t},(t,i)=>e.map(e=>e&&e[i]))}},object:{isObject:e=>null!==e&&"object"==typeof e&&!Array.isArray(e),isEmpty:e=>!e||"object"!=typeof e||0===Object.keys(e).length,keys:e=>e?Object.keys(e):[],values:e=>e?Object.values(e):[],entries:e=>e?Object.entries(e):[],has:(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),get(e,t,i){if(!e)return i;return t.split(".").reduce((e,t)=>e&&e[t],e)||i},set(e,t,i){if(!e||"object"!=typeof e)return e;const s=t.split("."),n=s.pop();let a=e;return s.forEach(e=>{a[e]||(a[e]={}),a=a[e]}),a[n]=i,e},pick:(e,t)=>e?t.reduce((t,i)=>(void 0!==e[i]&&(t[i]=e[i]),t),{}):{},omit:(e,t)=>e?Object.keys(e).reduce((i,s)=>(t.includes(s)||(i[s]=e[s]),i),{}):{},merge(...e){return e.reduce((e,t)=>(t&&"object"==typeof t&&Object.keys(t).forEach(i=>{this.isObject(t[i])&&this.isObject(e[i])?e[i]=this.merge(e[i],t[i]):e[i]=t[i]}),e),{})},clone:e=>e?JSON.parse(JSON.stringify(e)):e,deepClone(e,t=new WeakMap){if(!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map){const i=new Map;return t.set(e,i),e.forEach((e,s)=>i.set(s,this.deepClone(e,t))),i}if(e instanceof Set){const i=new Set;return t.set(e,i),e.forEach(e=>i.add(this.deepClone(e,t))),i}if(Array.isArray(e)){const i=[];return t.set(e,i),e.forEach(e=>i.push(this.deepClone(e,t))),i}const i={};return t.set(e,i),Object.keys(e).forEach(s=>{i[s]=this.deepClone(e[s],t)}),i},forEach(e,t){e&&Object.keys(e).forEach(i=>t(e[i],i,e))},map(e,t){if(!e)return{};const i={};return Object.keys(e).forEach(s=>{i[s]=t(e[s],s,e)}),i},filter(e,t){if(!e)return{};const i={};return Object.keys(e).forEach(s=>{t(e[s],s,e)&&(i[s]=e[s])}),i},reduce:(e,t,i)=>e?Object.keys(e).reduce((i,s)=>t(i,e[s],s,e),i):i,toArray:e=>e?Object.keys(e).map(t=>({key:t,value:e[t]})):[],fromArray:(e,t,i)=>e?e.reduce((e,s)=>{const n="object"==typeof s?s[t]:s,a=i?s[i]:s;return void 0!==n&&(e[n]=a),e},{}):{},size:e=>e?Object.keys(e).length:0,invert(e){if(!e)return{};const t={};return Object.keys(e).forEach(i=>{t[e[i]]=i}),t},isEqual(e,t){if(e===t)return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const i=Object.keys(e),s=Object.keys(t);return i.length===s.length&&i.every(i=>this.isEqual(e[i],t[i]))},freeze(e){return e?(Object.freeze(e),Object.keys(e).forEach(t=>{"object"==typeof e[t]&&this.freeze(e[t])}),e):e},seal:e=>e?Object.seal(e):e},number:{isNumber:e=>"number"==typeof e&&!isNaN(e),isInteger:e=>Number.isInteger(e),isFloat(e){return this.isNumber(e)&&!Number.isInteger(e)},isPositive(e){return this.isNumber(e)&&e>0},isNegative(e){return this.isNumber(e)&&e<0},isZero(e){return this.isNumber(e)&&0===e},clamp(e,t,i){return this.isNumber(e)?Math.min(Math.max(e,t),i):e},round(e,t=0){if(!this.isNumber(e))return e;const i=Math.pow(10,t);return Math.round(e*i)/i},floor(e){return this.isNumber(e)?Math.floor(e):e},ceil(e){return this.isNumber(e)?Math.ceil(e):e},abs(e){return this.isNumber(e)?Math.abs(e):e},min(...e){const t=e.filter(this.isNumber);return t.length>0?Math.min(...t):void 0},max(...e){const t=e.filter(this.isNumber);return t.length>0?Math.max(...t):void 0},sum(...e){return e.flat().filter(this.isNumber).reduce((e,t)=>e+t,0)},average(...e){const t=e.flat().filter(this.isNumber);return t.length>0?this.sum(t)/t.length:0},random:(e=0,t=1)=>Math.random()*(t-e)+e,randomInt(e,t){return Math.floor(this.random(e,t+1))},format(e,t=2){return this.isNumber(e)?e.toFixed(t):String(e)},formatCurrency(e,t="CNY",i=2){if(!this.isNumber(e))return String(e);return new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:i,maximumFractionDigits:i}).format(e)},formatPercent(e,t=0){return this.isNumber(e)?`${(100*e).toFixed(t)}%`:String(e)},toFixed(e,t=0){return this.isNumber(e)?e.toFixed(t):String(e)},toPrecision(e,t=6){return this.isNumber(e)?e.toPrecision(t):String(e)},isNaN:e=>Number.isNaN(e),isFinite:e=>Number.isFinite(e),parseInt:(e,t=10)=>Number.parseInt(e,t),parseFloat:e=>Number.parseFloat(e),toNumber(e,t=0){const i=Number(e);return isNaN(i)?t:i},safeDivide(e,t,i=0){return this.isNumber(e)&&this.isNumber(t)&&0!==t?e/t:i},safeMultiply(...e){return e.reduce((e,t)=>this.isNumber(e)&&this.isNumber(t)?e*t:0,1)}},date:{now:()=>Date.now(),today(){const e=new Date;return e.setHours(0,0,0,0),e},tomorrow(){const e=this.today();return e.setDate(e.getDate()+1),e},yesterday(){const e=this.today();return e.setDate(e.getDate()-1),e},isDate:e=>e instanceof Date&&!isNaN(e.getTime()),isValid(e){return this.isDate(e)},parse(e){const t=new Date(e);return this.isValid(t)?t:null},format(e,t="YYYY-MM-DD HH:mm:ss"){if(!this.isDate(e))return"";const i=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0"),a=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),l=String(e.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][e.getDay()];return t.replace("YYYY",i).replace("MM",s).replace("DD",n).replace("HH",a).replace("mm",r).replace("ss",o).replace("SSS",l).replace("D",e.getDate()).replace("M",e.getMonth()+1).replace("H",e.getHours()).replace("m",e.getMinutes()).replace("s",e.getSeconds()).replace("W",d)},toISO(e){return this.isDate(e)?e.toISOString():""},toUTC(e){return this.isDate(e)?new Date(e.toUTCString()):null},addDays(e,t){if(!this.isDate(e))return e;const i=new Date(e);return i.setDate(i.getDate()+t),i},addHours(e,t){if(!this.isDate(e))return e;const i=new Date(e);return i.setHours(i.getHours()+t),i},addMinutes(e,t){if(!this.isDate(e))return e;const i=new Date(e);return i.setMinutes(i.getMinutes()+t),i},addSeconds(e,t){if(!this.isDate(e))return e;const i=new Date(e);return i.setSeconds(i.getSeconds()+t),i},diffDays(e,t){if(!this.isDate(e)||!this.isDate(t))return 0;const i=this.today(),s=this.today();return i.setTime(e.getTime()),s.setTime(t.getTime()),Math.floor((i.getTime()-s.getTime())/864e5)},diffHours(e,t){return this.isDate(e)&&this.isDate(t)?Math.floor((e.getTime()-t.getTime())/36e5):0},diffMinutes(e,t){return this.isDate(e)&&this.isDate(t)?Math.floor((e.getTime()-t.getTime())/6e4):0},diffSeconds(e,t){return this.isDate(e)&&this.isDate(t)?Math.floor((e.getTime()-t.getTime())/1e3):0},isToday(e){return!!this.isDate(e)&&0===this.diffDays(e,this.today())},isYesterday(e){return!!this.isDate(e)&&-1===this.diffDays(e,this.today())},isTomorrow(e){return!!this.isDate(e)&&1===this.diffDays(e,this.today())},isFuture(e){return!!this.isDate(e)&&e.getTime()>this.now()},isPast(e){return!!this.isDate(e)&&e.getTime()<this.now()},isLeapYear(e){if(!this.isDate(e))return!1;const t=e.getFullYear();return t%4==0&&(t%100!=0||t%400==0)},getDaysInMonth(e){if(!this.isDate(e))return 0;const t=e.getFullYear(),i=e.getMonth();return new Date(t,i+1,0).getDate()},getWeekOfYear(e){if(!this.isDate(e))return 0;const t=new Date(e.getFullYear(),0,1),i=e.getTime()-t.getTime();return Math.ceil(i/6048e5)},getQuarter(e){return this.isDate(e)?Math.ceil((e.getMonth()+1)/3):0},startOfDay(e){if(!this.isDate(e))return e;const t=new Date(e);return t.setHours(0,0,0,0),t},endOfDay(e){if(!this.isDate(e))return e;const t=new Date(e);return t.setHours(23,59,59,999),t},startOfMonth(e){return this.isDate(e)?new Date(e.getFullYear(),e.getMonth(),1):e},endOfMonth(e){return this.isDate(e)?new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999):e},startOfWeek(e,t=1){if(!this.isDate(e))return e;const i=new Date(e),s=i.getDay(),n=s>=t?s-t:s+(7-t);return i.setDate(i.getDate()-n),i.setHours(0,0,0,0),i},endOfWeek(e,t=1){if(!this.isDate(e))return e;const i=this.startOfWeek(e,t),s=new Date(i);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s},getAge(e){if(!this.isDate(e))return 0;const t=new Date;let i=t.getFullYear()-e.getFullYear();return(t.getMonth()<e.getMonth()||t.getMonth()===e.getMonth()&&t.getDate()<e.getDate())&&i--,Math.max(0,i)},fromNow(e){if(!this.isDate(e))return"";const t=this.now()-e.getTime(),i=6e4,s=36e5,n=24*s,a=7*n,r=30*n,o=365*n;return t<i?"刚刚":t<s?`${Math.floor(t/i)}分钟前`:t<n?`${Math.floor(t/s)}小时前`:t<a?`${Math.floor(t/n)}天前`:t<r?`${Math.floor(t/a)}周前`:t<o?`${Math.floor(t/r)}个月前`:`${Math.floor(t/o)}年前`}},debounce(e,t,i={}){let s=null,n=null,a=null,r=0;const o=i.leading||!1,l=!1!==i.trailing;function d(){e.apply(a,n)}function h(){s=null,l&&n&&d(),n=null,a=null}return function(...e){n=e,a=this,r=Date.now(),s?(clearTimeout(s),s=setTimeout(h,function(){const e=Date.now()-r;return Math.max(0,t-e)}())):(r=Date.now(),o?(s=setTimeout(h,t),d()):s=setTimeout(h,t))}},throttle(e,t,i={}){let s=!1;const n=i.trailing||!1;let a=null,r=null;function o(){e.apply(r,a),a=null,r=null}return function(...e){s?n&&(a=e,r=this):(s=!0,a=e,r=this,o(),setTimeout(()=>{s=!1,n&&a&&o()},t))}},validator:{isEmail:e=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e||""),isPhone:e=>/^1[3-9]\d{9}$/.test(e||""),isURL:e=>/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(e||""),isIPv4:e=>/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e||""),isIPv6:e=>/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(e||""),isIP(e){return this.isIPv4(e)||this.isIPv6(e)},isIDCard:e=>/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(e||""),isPassport:e=>/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(e||""),isCreditCard(e){const t=e.replace(/\s/g,"");if(!/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/.test(t))return!1;let i=0,s=!1;for(let e=t.length-1;e>=0;e--){let n=parseInt(t[e],10);s&&(n*=2,n>9&&(n-=9)),i+=n,s=!s}return i%10==0},isHexColor:e=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e||""),isRGB(e){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(e||"");return!!t&&t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255)},isRGBA(e){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(e||"");if(!t)return!1;const[,i,s,n,a]=t;return parseInt(i)>=0&&parseInt(i)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(a)>=0&&parseFloat(a)<=1},isColor(e){return this.isHexColor(e)||this.isRGB(e)||this.isRGBA(e)},isDate:e=>!isNaN(new Date(e).getTime()),isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},isEmpty:e=>!e||""===e.trim(),isWhitespace:e=>/^\s+$/.test(e||""),isNumber:e=>!isNaN(parseFloat(e))&&isFinite(e),isInteger:e=>/^-?\d+$/.test(e||""),isFloat:e=>/^-?\d+\.\d+$/.test(e||""),isPositive(e){const t=parseFloat(e);return!isNaN(t)&&t>0},isNegative(e){const t=parseFloat(e);return!isNaN(t)&&t<0},isAlpha:e=>/^[a-zA-Z]+$/.test(e||""),isAlphaNumeric:e=>/^[a-zA-Z0-9]+$/.test(e||""),isChinese:e=>/^[\u4e00-\u9fa5]+$/.test(e||""),isLength(e,t,i){const s=(e||"").length;return s>=t&&(void 0===i||s<=i)},minLength:(e,t)=>(e||"").length>=t,maxLength:(e,t)=>(e||"").length<=t,matches:(e,t)=>t instanceof RegExp&&t.test(e||""),equals:(e,t)=>String(e)===String(t),contains:(e,t)=>(e||"").includes(t),notContains(e,t){return!this.contains(e,t)},isArray:e=>Array.isArray(e),arrayLength(e,t,i){const s=e?e.length:0;return s>=t&&(void 0===i||s<=i)},arrayMinLength:(e,t)=>!!e&&e.length>=t,arrayMaxLength:(e,t)=>!!e&&e.length<=t,isObject:e=>null!==e&&"object"==typeof e&&!Array.isArray(e),hasKeys:(e,t)=>!!(e&&t&&Array.isArray(t))&&t.every(t=>Object.prototype.hasOwnProperty.call(e,t)),validate(e,t){const i={};return Object.keys(t).forEach(s=>{const n=e[s],a=t[s],r=[];a.forEach(t=>{if("string"==typeof t){const[e,...i]=t.split(":");this[e](n,...i)||r.push(e)}else if("function"==typeof t){const i=t(n,e);!0!==i&&r.push(i||"validation_failed")}}),r.length>0&&(i[s]=r)}),{valid:0===Object.keys(i).length,errors:i}}},crypto:{md5(e){const t=e?String(e):"",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],s=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(e,t){return e<<t|e>>>32-t}function a(e,t){const[a,r,o,l]=t,d=[];for(let t=0;t<16;t++)d[t]=255&e.charCodeAt(4*t)|(255&e.charCodeAt(4*t+1))<<8|(255&e.charCodeAt(4*t+2))<<16|(255&e.charCodeAt(4*t+3))<<24;let h=a,c=r,u=o,p=l;for(let e=0;e<64;e++){let t,a;const r=Math.floor(e/16),o=e%16;0===r?(t=c&u|~c&p,a=o):1===r?(t=p&c|~p&u,a=(5*o+1)%16):2===r?(t=c^u^p,a=(3*o+5)%16):(t=u^(c|~p),a=7*o%16);const l=p;p=u,u=c,c+=n(h+t+i[e]+d[a]&4294967295,s[r][e%4]),h=l}return[a+h&4294967295,r+c&4294967295,o+u&4294967295,l+p&4294967295]}const r=function(e){const t=8*e.length;for(e+="€";e.length%64!=56;)e+="\0";const i=4294967295&t,s=t>>>32&4294967295;for(let t=0;t<4;t++)e+=String.fromCharCode(i>>>8*t&255);for(let t=0;t<4;t++)e+=String.fromCharCode(s>>>8*t&255);return e}(t);let o=[1732584193,4023233417,2562383102,271733878];for(let e=0;e<r.length;e+=64)o=a(r.substring(e,e+64),o);let l="";return o.forEach(e=>{for(let t=0;t<4;t++)l+=(e>>>8*t&255).toString(16).padStart(2,"0")}),l},sha256(e){const t=e?String(e):"",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 s(e,t){return e>>>t|e<<32-t}function n(e,t){const n=[];for(let t=0;t<16;t++)n[t]=255&e.charCodeAt(4*t)|(255&e.charCodeAt(4*t+1))<<8|(255&e.charCodeAt(4*t+2))<<16|(255&e.charCodeAt(4*t+3))<<24;for(let e=16;e<64;e++){const t=s(n[e-15],7)^s(n[e-15],18)^n[e-15]>>>3,i=s(n[e-2],17)^s(n[e-2],19)^n[e-2]>>>10;n[e]=n[e-16]+t+n[e-7]+i&4294967295}let[a,r,o,l,d,h,c,u]=t;for(let e=0;e<64;e++){const t=u+(s(d,6)^s(d,11)^s(d,25))+(d&h^~d&c)+i[e]+n[e]&4294967295,p=a&r^a&o^r&o;u=c,c=h,h=d,d=l+t&4294967295,l=o,o=r,r=a,a=t+((s(a,2)^s(a,13)^s(a,22))+p&4294967295)&4294967295}return[t[0]+a&4294967295,t[1]+r&4294967295,t[2]+o&4294967295,t[3]+l&4294967295,t[4]+d&4294967295,t[5]+h&4294967295,t[6]+c&4294967295,t[7]+u&4294967295]}const a=function(e){const t=8*e.length;for(e+="€";e.length%64!=56;)e+="\0";const i=4294967295&t,s=t>>>32&4294967295;for(let t=0;t<4;t++)e+=String.fromCharCode(s>>>8*t&255);for(let t=0;t<4;t++)e+=String.fromCharCode(i>>>8*t&255);return e}(t);let r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let e=0;e<a.length;e+=64)r=n(a.substring(e,e+64),r);let o="";return r.forEach(e=>{for(let t=3;t>=0;t--)o+=(e>>>8*t&255).toString(16).padStart(2,"0")}),o},base64Encode(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",s=0;const n=e?e.split("").map(e=>e.charCodeAt(0)):[];for(;s<n.length;){const e=n[s++],a=n[s++]||0,r=n[s++]||0,o=(15&a)<<2|r>>6,l=63&r;i+=t[e>>2]+t[(3&e)<<4|a>>4]+(s>n.length+1?"=":t[o])+(s>n.length?"=":t[l])}return i},base64Decode(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",s=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");s<e.length;){const n=t.indexOf(e.charAt(s++)),a=t.indexOf(e.charAt(s++)),r=t.indexOf(e.charAt(s++)),o=t.indexOf(e.charAt(s++)),l=n<<2|a>>4,d=(15&a)<<4|r>>2,h=(3&r)<<6|o;i+=String.fromCharCode(l),64!==r&&(i+=String.fromCharCode(d)),64!==o&&(i+=String.fromCharCode(h))}return i},uuid:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},preload:{cache:new Map,async loadImage(e,t={}){const{crossOrigin:i="anonymous"}=t;return this.cache.has(e)?this.cache.get(e):new Promise((t,s)=>{const n=new Image;n.crossOrigin=i,n.onload=()=>{this.cache.set(e,n),t(n)},n.onerror=()=>{s(new Error(`Failed to load image: ${e}`))},n.src=e})},async loadImages(e,t={}){const{parallel:i=!0}=t;if(i)return Promise.all(e.map(e=>this.loadImage(e,t)));const s=[];for(const i of e)s.push(await this.loadImage(i,t));return s},async loadScript(e,t={}){const{type:i="text/javascript",async:s=!0,defer:n=!1}=t;return this.cache.has(e)?this.cache.get(e):new Promise((t,a)=>{const r=document.createElement("script");r.type=i,r.async=s,r.defer=n,r.onload=()=>{this.cache.set(e,r),t(r)},r.onerror=()=>{r.remove(),a(new Error(`Failed to load script: ${e}`))},r.src=e,document.head.appendChild(r)})},async loadStylesheet(e,t={}){const{media:i="all"}=t;return this.cache.has(e)?this.cache.get(e):new Promise((t,s)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=e,n.media=i,n.onload=()=>{this.cache.set(e,n),t(n)},n.onerror=()=>{n.remove(),s(new Error(`Failed to load stylesheet: ${e}`))},document.head.appendChild(n)})},async loadFont(e,t,i={}){const{weight:s="normal",style:n="normal"}=i,a=new FontFace(e,`url(${t})`,{weight:s,style:n});try{return await a.load(),document.fonts.add(a),a}catch(t){throw new Error(`Failed to load font: ${e}`)}},async preload(e,t="image"){switch(t){case"image":return this.loadImage(e);case"script":return this.loadScript(e);case"stylesheet":case"style":return this.loadStylesheet(e);default:throw new Error(`Unsupported preload type: ${t}`)}},isLoaded(e){return this.cache.has(e)},clearCache(){this.cache.clear()},clearCacheByUrl(e){this.cache.delete(e)}}};"undefined"!=typeof window&&(window.KupolaUtils=r,window.kupolaUtils=r);class o{constructor(){this.children={},this.keys=[]}}class l{constructor(){this.root=new o}insert(e){let t=this.root;const i=e.split(".");i.forEach((s,n)=>{t.children[s]||(t.children[s]=new o),t=t.children[s],n===i.length-1&&t.keys.push(e)})}getSubKeys(e){let t=this.root;const i=e.split("."),s=[];for(let e=0;e<i.length;e++){const n=i[e];if(!t.children[n])break;t=t.children[n];const a=e=>{e.keys.length>0&&s.push(...e.keys),Object.values(e.children).forEach(e=>a(e))};a(t)}return[...new Set(s)]}getParentKeys(e){const t=e.split("."),i=[];for(let e=1;e<=t.length;e++){const s=t.slice(0,e).join(".");i.push(s)}return i}}const d=Symbol("reactive_parent"),h=Symbol("reactive_path"),c=Symbol("reactive_is_reactive");class u{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new l,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const e={get:(e,t,i)=>{if("__raw__"===t)return e;const s=Reflect.get(e,t,i);return s&&"object"==typeof s&&!Array.isArray(s)?this.wrapReactive(s,t):s},set:(e,t,i,s)=>{const n=Reflect.get(e,t,s),a=Reflect.set(e,t,i,s),r=this.resolvePath(e,t);return this.notify(r,i,n),this.queueUpdate(r,i),a},deleteProperty:(e,t)=>{const i=Reflect.get(e,t,receiver),s=Reflect.deleteProperty(e,t),n=this.resolvePath(e,t);return this.notify(n,void 0,i),this.queueUpdate(n,void 0),s}};this.data=new Proxy(this.rawData,e),this.data.__parent__=null,this.data.__path__=""}wrapReactive(e,t){if(e[c])return e;if(this._proxyCache.has(e))return this._proxyCache.get(e);const i=new Proxy(e,{get:(e,t,i)=>{if("__raw__"===t)return e;if(t===d||"__parent__"===t)return e[d];if(t===h||"__path__"===t)return e[h];if(t===c||"__isReactive__"===t)return!0;const s=Reflect.get(e,t,i);return s&&"object"==typeof s&&!Array.isArray(s)?this.wrapReactive(s,`${e[h]}${e[h]?".":""}${t}`):s},set:(e,t,i,s)=>{if(t===d||t===h||t===c||"__parent__"===t||"__path__"===t||"__isReactive__"===t)return!0;const n=Reflect.get(e,t,s),a=Reflect.set(e,t,i,s),r=`${e[h]}${e[h]?".":""}${t}`;return this.notify(r,i,n),this.queueUpdate(r,i),a},deleteProperty:(e,t)=>{if(t===d||t===h||t===c)return!1;const i=Reflect.get(e,t),s=Reflect.deleteProperty(e,t),n=`${e[h]}${e[h]?".":""}${t}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),s},has:(e,t)=>"__raw__"===t||t===d||t===h||t===c||"__parent__"===t||"__path__"===t||"__isReactive__"===t||t in e,ownKeys:e=>Reflect.ownKeys(e).filter(e=>e!==d&&e!==h&&e!==c),getOwnPropertyDescriptor:(e,t)=>t===d||t===h||t===c?{configurable:!1,enumerable:!1,writable:!1,value:e[t]}:Reflect.getOwnPropertyDescriptor(e,t)});return e[d]=e,e[h]=t,e[c]=!0,this._proxyCache.set(e,i),Object.keys(e).forEach(i=>{e[i]&&"object"==typeof e[i]&&!Array.isArray(e[i])&&(e[i]=this.wrapReactive(e[i],`${t}${t?".":""}${i}`))}),i}resolvePath(e,t){return e[h]?`${e[h]}.${t}`:t}queueUpdate(e,t){this.updateQueue.set(e,t),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const e=new Set;this.updateQueue.forEach((t,i)=>{e.add(i),this.updateElementsDirect(i,t);this.pathTrie.getSubKeys(i).forEach(t=>{if(!e.has(t)){const i=this.get(t);this.updateElementsDirect(t,i),e.add(t)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(e,t){this.elements[e]&&this.elements[e].forEach(e=>{this.updateElement(e,t)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(e=>this.updateQueue.has(e)||this.pathTrie.getSubKeys(e).some(e=>this.updateQueue.has(e)))&&this.updateComputedProperty(e)})}set(e,t,i=!1){const s=this.get(e);"object"==typeof e?(Object.assign(this.rawData,e),Object.keys(e).forEach(t=>{i||(this.notify(t,e[t],s?.[t]),this.queueUpdate(t,e[t]))})):(e.includes(".")?this.setNested(e,t):this.rawData[e]=t,i||(this.notify(e,t,s),this.queueUpdate(e,t))),i||this.processComputed()}get(e){if(e)return e.includes(".")?this.getNested(e):this.rawData[e]}getNested(e){if(e)return e.split(".").reduce((e,t)=>e?.[t],this.rawData)}setNested(e,t){const i=e.split("."),s=i.pop(),n=i.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),this.rawData),a=n[s];n[s]=t,this.notify(e,t,a),this.queueUpdate(e,t)}observe(e,t){this.observers[e]||(this.observers[e]=[]),this.observers[e].push(t)}unobserve(e,t){this.observers[e]&&(this.observers[e]=this.observers[e].filter(e=>e!==t))}notify(e,t,i){this.observers[e]&&this.observers[e].forEach(s=>{try{s(t,i)}catch(t){console.error(`Observer error for ${e}:`,t)}}),this.observers["*"]?.forEach(s=>{try{s(e,t,i)}catch(e){console.error("Wildcard observer error:",e)}})}updateElement(e,t){const i=e.getAttribute("data-bind");if(!i)return;i.split("|").forEach(i=>{const s=i.split(":"),n=s[0].trim(),a=s[1]?.trim();switch(n){case"text":e.textContent!==String(t??"")&&(e.textContent=t??"");break;case"html":const i=(r=t)?String(r).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi,"").replace(/<embed\b[^>]*\/?>/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""):"";e.innerHTML!==i&&(e.innerHTML=i);break;case"value":"checkbox"===e.type?e.checked!==!!t&&(e.checked=!!t):e.value!==String(t??"")&&(e.value=t??"");break;case"checked":e.checked!==!!t&&(e.checked=!!t);break;case"disabled":e.disabled!==!!t&&(e.disabled=!!t);break;case"hidden":const s=t?"none":"";e.style.display!==s&&(e.style.display=s);break;case"class":a&&(t?e.classList.add(a):e.classList.remove(a));break;case"style":a&&e.style[a]!==String(t??"")&&(e.style[a]=t??"");break;case"attr":if(a){e.getAttribute(a)!==String(t??"")&&e.setAttribute(a,t??"")}break;case"src":e.src!==String(t??"")&&(e.src=t??"");break;case"href":e.href!==String(t??"")&&(e.href=t??"");break;case"placeholder":e.placeholder!==String(t??"")&&(e.placeholder=t??"")}var r})}computed(e,t,i){this.computedProperties[e]={deps:t,callback:i},t.forEach(e=>{this.pathTrie.insert(e)}),this.updateComputedProperty(e)}updateComputedProperty(e){const t=this.computedProperties[e];if(t)try{const i=t.deps.map(e=>this.get(e)),s=t.callback(...i);this.set(e,s,!0)}catch(t){console.error(`Computed error for ${e}:`,t)}}load(e){Object.keys(e).forEach(t=>{e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])?this.rawData[t]=this.wrapReactive(e[t],t):this.rawData[t]=e[t],this.queueUpdate(t,this.rawData[t])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new l,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(e,t={}){const{storage:i="local",debounce:s=0,version:n=1,encrypt:a=!1,encryptionKey:r=null}=t,o="session"===i?sessionStorage:localStorage;this.persistedKeys.set(e,{storage:o,debounce:s,timeout:null,version:n,encrypt:a,encryptionKey:r});const l=this.get(e);void 0!==l&&this._persistSave(e,l,o,{version:n,encrypt:a,encryptionKey:r}),this.observe(e,t=>{const i=this.persistedKeys.get(e);i&&(i.debounce>0?(i.timeout&&clearTimeout(i.timeout),i.timeout=setTimeout(()=>{this._persistSave(e,t,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey})},i.debounce)):this._persistSave(e,t,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey}))})}_persistSave(e,t,i,s={}){try{const{version:n=1,encrypt:a=!1,encryptionKey:r=null}=s,o={value:t,version:n,timestamp:Date.now()};let l=JSON.stringify(o);a&&r&&(l=this._encrypt(l,r)),this._ensureStorageCapacity(i),i.setItem(`kupola:${e}`,l)}catch(s){if(console.warn(`Failed to persist key ${e}:`,s),"QuotaExceededError"===s.name&&i===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${e}`);try{sessionStorage.setItem(`kupola:${e}`,JSON.stringify({value:t,version:1}))}catch(t){console.warn(`sessionStorage also failed for key ${e}:`,t)}}}}_ensureStorageCapacity(e){try{const t="kupola:__storage_test__";e.setItem(t,"test"),e.removeItem(t)}catch(t){"QuotaExceededError"===t.name&&this._cleanupOldStorage(e)}}_cleanupOldStorage(e){const t=Date.now();for(let i=0;i<e.length;i++){const s=e.key(i);if(s?.startsWith("kupola:"))try{const i=JSON.parse(e.getItem(s));i.timestamp&&t-i.timestamp>2592e6&&e.removeItem(s)}catch(t){e.removeItem(s)}}}_encrypt(e,t){return window.CryptoJS?window.CryptoJS.AES.encrypt(e,t).toString():(console.warn("CryptoJS not available, encryption skipped"),e)}_decrypt(e,t){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),e;try{return window.CryptoJS.AES.decrypt(e,t).toString(window.CryptoJS.enc.Utf8)}catch(t){return console.warn("Decryption failed:",t),e}}unpersist(e){const t=this.persistedKeys.get(e);t&&(t.timeout&&clearTimeout(t.timeout),t.storage.removeItem(`kupola:${e}`),this.persistedKeys.delete(e))}loadPersisted(e={}){const t={},{encryptionKey:i=null}=e;for(let s=0;s<localStorage.length;s++){const n=localStorage.key(s);if(n?.startsWith("kupola:")){const s=n.replace("kupola:","");try{const a=localStorage.getItem(n);let r;if(i){const e=this._decrypt(a,i);r=JSON.parse(e)}else r=JSON.parse(a);if(void 0!==r.version&&r.version!==e.version){console.debug(`Skipping outdated data for ${s} (version ${r.version})`);continue}t[s]=void 0!==r.value?r.value:r}catch(e){console.warn(`Failed to load persisted key ${s}:`,e)}}}for(let s=0;s<sessionStorage.length;s++){const n=sessionStorage.key(s);if(n?.startsWith("kupola:")){const s=n.replace("kupola:","");try{const a=sessionStorage.getItem(n);let r;if(i){const e=this._decrypt(a,i);r=JSON.parse(e)}else r=JSON.parse(a);if(void 0!==r.version&&r.version!==e.version){console.debug(`Skipping outdated data for ${s} (version ${r.version})`);continue}t[s]=void 0!==r.value?r.value:r}catch(e){}}}return Object.keys(t).length>0&&this.load(t),t}_clone(e){if("function"==typeof structuredClone)try{return structuredClone(e)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(e))}snapshot(){const e=this._clone(this.rawData);return this.snapshots.push(e),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(e=-1){if(0===this.snapshots.length)return!1;const t=e>=0?e:this.snapshots.length-1,i=this.snapshots[t];return!!i&&(this.rawData=this._clone(i),this.createReactiveData(),Object.keys(this.rawData).forEach(e=>{this.queueUpdate(e,this.rawData[e])}),this.processComputed(),!0)}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(e=>{const i=e.getAttribute("data-bind");if(!i)return;const s=i.split(":"),n=s[1]?.trim();n&&("checkbox"===e.type?(t[n]||(t[n]=[]),e.checked&&t[n].push(e.value)):"radio"===e.type?e.checked&&(t[n]=e.value):t[n]=e.value)}),t}fillForm(e,t){Object.keys(t).forEach(i=>{e.querySelectorAll('[data-bind*=":'+i+'"]').forEach(e=>{"checkbox"===e.type?e.checked=Array.isArray(t[i])?t[i].includes(e.value):!!t[i]:"radio"===e.type?e.checked=e.value===t[i]:e.value=t[i]??""})})}createReactive(e,t=""){if(e[c])return e;if(this._proxyCache.has(e))return this._proxyCache.get(e);const i={get:(e,t,i)=>{if("__raw__"===t)return e;if(t===d||"__parent__"===t)return e[d];if(t===h||"__path__"===t)return e[h];if(t===c||"__isReactive__"===t)return!0;const s=Reflect.get(e,t,i);return s&&"object"==typeof s&&!Array.isArray(s)?this.wrapReactive(s,`${e[h]}${e[h]?".":""}${t}`):s},set:(e,t,i,s)=>{if(t===d||t===h||t===c||"__parent__"===t||"__path__"===t||"__isReactive__"===t)return!0;const n=Reflect.get(e,t,s),a=Reflect.set(e,t,i,s),r=`${e[h]}${e[h]?".":""}${t}`;return this.notify(r,i,n),this.queueUpdate(r,i),a},deleteProperty:(e,t)=>{if(t===d||t===h||t===c)return!1;const i=Reflect.get(e,t),s=Reflect.deleteProperty(e,t),n=`${e[h]}${e[h]?".":""}${t}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),s},has:(e,t)=>"__raw__"===t||t===d||t===h||t===c||"__parent__"===t||"__path__"===t||"__isReactive__"===t||t in e,ownKeys:e=>Reflect.ownKeys(e).filter(e=>e!==d&&e!==h&&e!==c),getOwnPropertyDescriptor:(e,t)=>t===d||t===h||t===c?{configurable:!1,enumerable:!1,writable:!1,value:e[t]}:Reflect.getOwnPropertyDescriptor(e,t)},s=new Proxy(e,i);return e[d]=e,e[h]=t,e[c]=!0,this._proxyCache.set(e,s),Object.keys(e).forEach(i=>{e[i]&&"object"==typeof e[i]&&!Array.isArray(e[i])&&(e[i]=this.wrapReactive(e[i],`${t}${t?".":""}${i}`))}),s}bind(){document.querySelectorAll("[data-bind]").forEach(e=>{this._bindElement(e)}),this._mutationObserver||(this._mutationObserver=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){e.querySelectorAll("[data-bind]").forEach(e=>this._bindElement(e)),e.hasAttribute&&e.hasAttribute("data-bind")&&this._bindElement(e)}})})}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(e){const t=e.getAttribute("data-bind").split(":");t[0].split("|")[0].trim();const i=t[1]?.trim();if(i){if(this.pathTrie.insert(i),this.elements[i]||(this.elements[i]=[]),this.elements[i].includes(e)||this.elements[i].push(e),"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName){const t=e.__kupolaBindHandler;t&&e.removeEventListener("input",t);const s=()=>{const t="checkbox"===e.type?e.checked:e.value;i.includes(".")?this.setNested(i,t):this.set(i,t)};e.__kupolaBindHandler=s,e.addEventListener("input",s)}void 0!==this.rawData[i]&&this.updateElement(e,this.rawData[i])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(e=>{e.forEach(e=>{const t=e.__kupolaBindHandler;t&&(e.removeEventListener("input",t),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((e,t)=>{e.timeout&&clearTimeout(e.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new l,this.updateQueue.clear(),this.snapshots=[]}}class p{constructor(e,t={}){this.name=e,this._stateKey=`__store_${e}__`;const i=t.state?t.state():{};this.getters=t.getters||{},this.actions=t.actions||{},this.mutations=t.mutations||{},this.observers={},window.kupolaData?(window.kupolaData.set(this._stateKey,i),this.state=window.kupolaData.data?.[this._stateKey]||window.kupolaData.createReactive(i,this._stateKey),window.kupolaData.observe(this._stateKey,e=>{this.notify(e)})):this.state=i,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(e=>{Object.defineProperty(this,e,{get:()=>this.getters[e](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(e=>{this[e]=(...t)=>this.actions[e]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...t)})}commit(e,t){const i=this.mutations[e];i?i(this.state,t):console.warn(`Mutation ${e} not found in store ${this.name}`)}dispatch(e,t){const i=this.actions[e];if(i)return i({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},t);console.warn(`Action ${e} not found in store ${this.name}`)}observe(e){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(e),e}unobserve(e){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(t=>t!==e))}notify(e){this.observers["*"]&&this.observers["*"].forEach(t=>{try{t(e)}catch(e){console.error(`Observer error for store ${this.name}:`,e)}}),window.kupolaData&&window.kupolaData.set(this.name,e)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((e,t)=>(e[t]=this[t],e),{})}}}class m{constructor(){this.stores=new Map}createStore(e,t){const i=new p(e,t);return this.stores.set(e,i),i}getStore(e){return this.stores.get(e)}registerStore(e){e instanceof p&&this.stores.set(e.name,e)}dispose(){this.stores.clear()}}class g{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),t}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(e=>e!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(i=>{try{i(t)}catch(t){console.error(`Error in event handler for ${e}:`,t)}}),this.events["*"]?.forEach(i=>{try{i(e,t)}catch(e){console.error("Error in wildcard event handler:",e)}})}once(e,t){const i=s=>{t(s),this.off(e,i)};return this.on(e,i),i}delegate(e,t,i){if(!this.delegatedEvents[t]){this.delegatedEvents[t]=[];const e=e=>{this.delegatedEvents[t].forEach(({selector:t,cb:i})=>{(e.target.matches(t)||e.target.closest(t))&&i(e)})};document.addEventListener(t,e),this.eventListeners[t]=e}return this.delegatedEvents[t].push({selector:e,cb:i}),i}undelegate(e,t){if(this.delegatedEvents[t]&&(this.delegatedEvents[t]=this.delegatedEvents[t].filter(t=>t.selector!==e),0===this.delegatedEvents[t].length)){const e=this.eventListeners[t];e&&(document.removeEventListener(t,e),delete this.eventListeners[t]),delete this.delegatedEvents[t]}}destroy(){Object.entries(this.eventListeners).forEach(([e,t])=>{document.removeEventListener(e,t)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function y(e=null){const t={_value:e,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get:()=>t._value,set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(t=>t(e)))}}),t}const _=new u,f=new g,v=new m;function w(e,t){return v.createStore(e,t)}function b(e){return v.getStore(e)}"undefined"!=typeof window&&(window.KupolaDataBind=u,window.KupolaEventBus=g,window.KupolaStore=p,window.KupolaStoreManager=m,window.kupolaData=_,window.kupolaEvents=f,window.kupolaStoreManager=v,window.createStore=w,window.getStore=b,window.kupolaRef=y);const k="kupola-theme",E="kupola-brand",x=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function C(){return localStorage.getItem(k)||"dark"}function S(e){if("dark"!==e&&"light"!==e)return;document.documentElement.setAttribute("data-theme",e),localStorage.setItem(k,e);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",e);const i=t.querySelector(".theme-icon");if(i){const t=i.src.substring(0,i.src.lastIndexOf("/")+1);i.src="dark"===e?t+"sun.svg":t+"moon.svg"}}}function L(){return localStorage.getItem(E)||"zengqing"}function D(e){const t=x.find(t=>t.id===e);if(!t)return;document.documentElement.setAttribute("data-brand",e),localStorage.setItem(E,e);const i=document.querySelector("[data-brand-toggle]");if(i){i.setAttribute("data-current-brand",e);const s=i.querySelector(".brand-icon");s&&(s.style.backgroundColor=t.color);const n=i.querySelector(".brand-name");n&&(n.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.getAttribute("data-brand-btn")===e?t.classList.add("is-active"):t.classList.remove("is-active")})}function M(){S(C());D(L());const e=document.querySelector("[data-theme-toggle]");e&&e.addEventListener("click",()=>{S("dark"===C()?"light":"dark")});let t=document.getElementById("brand-picker");t||(t=document.createElement("div"),t.id="brand-picker",t.style.position="fixed",t.style.top="64px",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",x.forEach(e=>{const i=document.createElement("button");i.setAttribute("data-brand-btn",e.id),i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.height="60px",i.style.backgroundColor=e.color,i.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(e.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=e.name,t.appendChild(i)}),document.body.appendChild(t));const i=document.querySelector("[data-brand-toggle]");function s(e){t&&i&&(t.contains(e.target)||i.contains(e.target)||(t.style.display="none",document.removeEventListener("click",s,!0)))}i&&t&&(i.onclick=function(e){e.stopPropagation(),e.preventDefault();const i="none"===t.style.display;t.style.display=i?"grid":"none",i?setTimeout(()=>{document.addEventListener("click",s,!0)},0):document.removeEventListener("click",s,!0)},t.onclick=function(e){e.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(e=>{e.addEventListener("click",i=>{i.stopPropagation();D(e.getAttribute("data-brand-btn")),t&&(t.style.display="none")})})}function I(){const e=document.createElement("button");e.setAttribute("data-theme-toggle",""),e.setAttribute("data-current-theme",C()),e.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",e.style.position="fixed",e.style.top="16px",e.style.right="16px",e.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const i=document.getElementsByTagName("script"),s=i[i.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src="dark"===C()?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",e.appendChild(t),document.body.appendChild(e),e.addEventListener("click",()=>{S("dark"===C()?"light":"dark")}),e}function H(){const e=document.createElement("div");e.id="brand-picker-auto",e.style.position="fixed",e.style.top="56px",e.style.right="16px",e.style.zIndex="9998",e.style.display="none",e.style.padding="12px",e.style.width="200px",e.style.gridTemplateColumns="repeat(3, 1fr)",e.style.gap="6px",e.style.backgroundColor="var(--bg-base-secondary)",e.style.border="1px solid var(--border-neutral-l1)",e.style.borderRadius="8px",e.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",e.style.overflow="hidden",x.forEach(t=>{const i=document.createElement("button");i.setAttribute("data-brand-btn",t.id),i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.height="60px",i.style.backgroundColor=t.color,i.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.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=t.name,e.appendChild(i)}),document.body.appendChild(e);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",L()),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 i=document.createElement("span");i.className="brand-icon",i.style.width="12px",i.style.height="12px",i.style.borderRadius="50%",i.style.backgroundColor=x.find(e=>e.id===L()).color;const s=document.createElement("span");function n(i){e.contains(i.target)||t.contains(i.target)||(e.style.display="none",document.removeEventListener("click",n,!0))}s.className="brand-name",s.style.fontSize="11px",s.textContent=x.find(e=>e.id===L()).name,t.appendChild(i),t.appendChild(s),document.body.appendChild(t),t.onclick=function(t){t.stopPropagation(),t.preventDefault();const i="none"===e.style.display;e.style.display=i?"grid":"none",i?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},e.onclick=function(e){e.stopPropagation()};return e.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",i=>{i.stopPropagation();D(t.getAttribute("data-brand-btn")),e.style.display="none"})}),{toggleBtn:t,container:e}}"undefined"!=typeof window&&(window.getTheme=C,window.setTheme=S,window.initTheme=M,window.createThemeToggle=I,window.getBrand=L,window.setBrand=D,window.BRAND_OPTIONS=x,window.createBrandPicker=H);class T{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(e,t,i=null,s={}){this.initializers.set(e,t),i&&this.cleanupFunctions.set(e,i),s.dataAttribute&&!this._dataAttrs.includes(s.dataAttribute)&&(this._dataAttrs.push(s.dataAttribute),this._cachedSelector=null),s.cssClass&&!this._cssClasses.includes(s.cssClass)&&(this._cssClasses.push(s.cssClass),this._cachedSelector=null)}unregister(e){this.initializers.delete(e),this.cleanupFunctions.delete(e)}has(e){return this.initializers.has(e)}get(e){return this.initializers.get(e)}_buildSelector(){if(null!==this._cachedSelector)return this._cachedSelector;const e=this._dataAttrs.map(e=>`[${e}]`);for(const t of this._cssClasses)e.push(`.${t}`);return this._cachedSelector=e.join(", "),this._cachedSelector}async initialize(e){if(this.processedElements.has(e))return;for(const t of this._dataAttrs){const i=e.getAttribute(t);if(null!==i){const s=i||t.replace("data-",""),n=this.initializers.get(s)||this.initializers.get(t.replace("data-",""));if(n){try{await n(e),this.processedElements.add(e)}catch(e){console.error(`[ComponentInitializerRegistry] Error initializing "${s}":`,e)}return}}}const t=e.className;if("string"==typeof t)for(const i of this._cssClasses)if(t.includes(i)){const t=i.replace("ds-",""),s=this.initializers.get(t)||this.initializers.get(i);if(s){try{await s(e),this.processedElements.add(e)}catch(e){console.error(`[ComponentInitializerRegistry] Error initializing "${t}":`,e)}return}}}cleanup(e){for(const t of this._dataAttrs){const i=e.getAttribute(t);if(null!==i){const s=i||t.replace("data-",""),n=this.cleanupFunctions.get(s)||this.cleanupFunctions.get(t.replace("data-",""));if(n){try{n(e)}catch(e){console.error(`[ComponentInitializerRegistry] Error cleaning up "${s}":`,e)}return void this.processedElements.delete(e)}}}const t=e.className;if("string"==typeof t)for(const i of this._cssClasses)if(t.includes(i)){const t=i.replace("ds-",""),s=this.cleanupFunctions.get(t)||this.cleanupFunctions.get(i);if(s){try{s(e)}catch(e){console.error(`[ComponentInitializerRegistry] Error cleaning up "${t}":`,e)}return void this.processedElements.delete(e)}}}async initializeAll(e=document){const t=this._buildSelector();if(!t)return;const i=e.querySelectorAll(t),s=[];i.forEach(e=>{this.processedElements.has(e)||s.push(this.initialize(e))}),await Promise.all(s)}}const A=new T,z=[{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 e of z)e.attr&&!A._dataAttrs.includes(e.attr)&&A._dataAttrs.push(e.attr),e.cls&&!A._cssClasses.includes(e.cls)&&A._cssClasses.push(e.cls);"undefined"!=typeof window&&(window.Kupola=window.Kupola||{},window.Kupola.refresh=async function(e){return A.initializeAll(e||document)},window.Kupola.init=async function(e){return A.initialize(e)},window.Kupola.cleanup=function(e){return A.cleanup(e)},window.Kupola.initializer=A,window.Kupola.ComponentInitializerRegistry=T),"undefined"!=typeof window&&(window.ComponentInitializerRegistry=T,window.kupolaInitializer=A);class ${constructor(e){this.element=e,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new t,this.setupContext=null}_parseProps(){const e={};for(const t of this.element.attributes)if(t.name.startsWith("data-prop-")){const i=t.name.replace("data-prop-","");let s=t.value;try{s=JSON.parse(s)}catch(e){}e[i]=s}return e}_parseSlots(){const e={};return this.element.querySelectorAll("[data-slot]").forEach(t=>{const i=t.getAttribute("data-slot")||"default";e[i]=t.innerHTML.trim(),t.remove()}),!e.default&&this.element.children.length>0&&(e.default=this.element.innerHTML.trim()),e}$slot(e="default"){return this.slots[e]||""}$emit(e,t){if((this._eventListeners[e]||[]).forEach(i=>{try{i(t)}catch(t){console.error(`Error in event handler for ${e}:`,t)}}),this.element){const i=new CustomEvent(`kupola:${e}`,{detail:t,bubbles:!0,cancelable:!0});this.element.dispatchEvent(i)}}$on(e,t){return this._eventListeners[e]||(this._eventListeners[e]=[]),this._eventListeners[e].push(t),t}$off(e,t){this._eventListeners[e]&&(this._eventListeners[e]=this._eventListeners[e].filter(e=>e!==t))}async setProps(e){try{this.props={...this.props,...e},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(t){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,t),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:t,args:[e]})}}async setState(e){try{this.state={...this.state,...e},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(t){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,t),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:t,args:[e]})}}async mount(){if(!this.isMounted&&!this.isDestroyed)try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),"undefined"!=typeof window&&window._setCurrentSetupContext&&window.SetupContext&&(this.setupContext=new window.SetupContext(this),window._setCurrentSetupContext(this.setupContext),"function"==typeof this.setup)){const e=this.setup();e instanceof Promise&&await e}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted(),"undefined"!=typeof window&&window._clearSetupContext&&window._clearSetupContext()}catch(e){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,e),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:e,args:[]}),"function"==typeof this.renderError)try{this.renderError(e)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`\n <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">\n <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>\n <div style="font-size: 12px; white-space: pre-wrap;">${e.message}</div>\n </div>\n `}}_bindLifecycleHooks(){if(this._hooksBound)return;const e={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let t=Object.getPrototypeOf(this);const i=new Set;for(;t&&t.constructor!==Object&&t.constructor!==$;){for(const[s,n]of Object.entries(e))i.has(s)||t.hasOwnProperty(s)&&(Array.isArray(n)?n.forEach(e=>{"render"===s&&this.lifecycle.on(e,()=>this.render?.())}):"renderError"===s?this.lifecycle.on(n,e=>(this.renderError(e.error),"handled")):this.lifecycle.on(n,()=>this[s]?.()),i.add(s));t=Object.getPrototypeOf(t)}this._hooksBound=!0}async unmount(){if(this.isMounted&&!this.isDestroyed)try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(e){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,e),this.lifecycle&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:e,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(e){}updated(){}setup(){}}function P(e,t){Object.keys(t).forEach(i=>{if("constructor"!==i)if("function"==typeof t[i]){const s=e.prototype[i];e.prototype[i]=s?function(...e){return t[i].apply(this,e),s.apply(this,e)}:t[i]}else e.prototype[i]=t[i]})}"undefined"!=typeof window&&(window.KupolaComponent=$,window.applyMixin=P);class q{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(e,t){if(!(t.prototype instanceof $))throw new Error(`Component ${e} must extend KupolaComponent`);this.components.set(e,t)}registerLazy(e,t){this.lazyComponents.set(e,t)}unregister(e){this.components.delete(e),this.lazyComponents.delete(e),this.loadedComponents.delete(e),this.loadingPromises.delete(e)}get(e){return this.components.get(e)||this.loadedComponents.get(e)}async getAsync(e){const t=this.components.get(e)||this.loadedComponents.get(e);if(t)return t;if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const i=this.lazyComponents.get(e);if(!i)throw new Error(`Component ${e} not found`);const s=(async()=>{try{const t=await i(),s=t.default||t;if(!(s.prototype instanceof $))throw new Error(`Component ${e} must extend KupolaComponent`);return this.loadedComponents.set(e,s),s}catch(t){throw this.loadingPromises.delete(e),t}})();return this.loadingPromises.set(e,s),s}defineMixin(e,t){this.mixins.set(e,t)}useMixin(e,...t){t.forEach(t=>{const i=this.mixins.get(t);i&&P(e,i)})}async bootstrap(e=document){await this._upgradeElements(e),this._startObserver(e)}async _upgradeElements(e){const t=e.querySelectorAll("[data-component]"),i=[];t.forEach(e=>{i.push(this._upgradeElement(e))}),await Promise.all(i)}async _upgradeElement(e){if(!e.__kupolaInstance&&!e.__kupolaUpgrading){e.__kupolaUpgrading=!0;try{const t=e.getAttribute("data-component");if(t){const i=A.get(t);if(i)try{return void await i(e)}catch(e){console.warn(`[KupolaComponentRegistry] Initializer for "${t}" failed, trying component class:`,e)}}let i=this.components.get(t);if(!i){try{i=await this.getAsync(t)}catch(e){return void console.error(`Failed to load component ${t}:`,e)}if(!e.isConnected)return}const s=e.getAttribute("data-mixins"),n=i;s&&s.split(",").forEach(e=>{const t=this.mixins.get(e.trim());t&&P(n,t)});const a=new n(e);e.__kupolaInstance=a,this.instances.set(e,a),a.mount()}finally{e.__kupolaUpgrading=!1}}}_startObserver(e){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){e.hasAttribute("data-component")&&this._upgradeElement(e).catch(e=>console.error(e)),this._upgradeElements(e).catch(e=>console.error(e)),A.initialize(e).catch(()=>{});const t=A._buildSelector();t&&e.querySelectorAll?.(t).forEach(e=>{A.initialize(e).catch(()=>{})})}}),e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=this.instances.get(e);t&&(t.unmount(),this.instances.delete(e)),e.querySelectorAll("[data-component]").forEach(e=>{const t=this.instances.get(e);t&&(t.unmount(),this.instances.delete(e))}),A.cleanup(e),e.querySelectorAll?.("*").forEach(e=>{A.cleanup(e)})}})})}),this.observer.observe(e,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(e=>{e.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}async function N(){"undefined"!=typeof window&&(_.loadPersisted(),_.bind(),M(),await A.initializeAll(),e.kupolaRegistry&&await e.kupolaRegistry.bootstrap())}function F(t,i){e.kupolaRegistry&&e.kupolaRegistry.register(t,i)}function O(t,i){e.kupolaRegistry&&e.kupolaRegistry.registerLazy(t,i)}function B(t){return e.kupolaRegistry?e.kupolaRegistry.bootstrap(t):Promise.resolve()}function R(t,i){e.kupolaRegistry&&e.kupolaRegistry.defineMixin(t,i)}function V(t,...i){e.kupolaRegistry&&e.kupolaRegistry.useMixin(t,...i)}function K(t,i){if(!i||"object"!=typeof i)throw new Error(`defineComponent("${t}"): options must be an object`);i.componentClass?e.kupolaRegistry&&e.kupolaRegistry.register(t,i.componentClass):i.lazy&&e.kupolaRegistry&&e.kupolaRegistry.registerLazy(t,i.lazy),i.init?A.register(t,i.init,i.cleanup||null,{dataAttribute:i.dataAttribute,cssClass:i.cssClass}):(i.dataAttribute||i.cssClass)&&A.register(t,()=>{},null,{dataAttribute:i.dataAttribute,cssClass:i.cssClass})}"undefined"!=typeof window&&(window.KupolaComponentRegistry=q),e.kupolaRegistry=null,"undefined"!=typeof window&&(e.kupolaRegistry=new q),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",N):"undefined"!=typeof window&&setTimeout(N,0),"undefined"!=typeof window&&(window.kupolaRegistry=e.kupolaRegistry,window.kupolaInitializer=A,window.kupolaBootstrap=N,window.registerComponent=F,window.registerLazyComponent=O,window.bootstrapComponents=B,window.defineMixin=R,window.useMixin=V,window.defineComponent=K);class j{constructor(e={}){this.locales=e.locales||{},this.currentLocale=e.defaultLocale||"zh-CN",this.fallbackLocale=e.fallbackLocale||"zh-CN",this.delimiter=e.delimiter||".",this.missingHandler=e.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(e=>{const t=e.dataset.kupolaI18n;if(t)try{const i=JSON.parse(e.textContent);this.addLocale(t,i)}catch(e){console.error("Failed to parse i18n data:",e)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(e,t){this.locales[e]||(this.locales[e]={}),this._mergeDeep(this.locales[e],t)}_mergeDeep(e,t){for(const i of Object.keys(t))t[i]instanceof Object&&i in e?this._mergeDeep(e[i],t[i]):e[i]=t[i]}setLocale(e){return!!this.locales[e]&&(this.currentLocale=e,document.documentElement.lang=e,this._emitChange(),!0)}getLocale(){return this.currentLocale}t(e,t={}){let i=this._getTranslation(e,this.currentLocale);return i||(i=this._getTranslation(e,this.fallbackLocale)),i?this._interpolate(i,t):this.missingHandler(e)}_getTranslation(e,t){if(!this.locales[t])return null;const i=e.split(this.delimiter);let s=this.locales[t];for(const e of i){if(!s||"object"!=typeof s||!(e in s))return null;s=s[e]}return"string"==typeof s?s:null}_interpolate(e,t){return e.replace(/\{(\w+)\}/g,(e,i)=>void 0!==t[i]?t[i]:e)}n(e,t,i={}){const s=this.t(e,{...i,count:t});if(!s)return s;const n=s.split("|");return 1===n.length?s.replace("{count}",t):2===n.length?1===t?n[0]:n[1]:n.length>=3?0===t?n[0]:1===t?n[1]:n[2]:s}_emitChange(){const e=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(e)}async loadLocale(e,t){try{const i=await fetch(t),s=await i.json();return this.addLocale(e,s),!0}catch(e){return console.error("Failed to load locale:",e),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(e){return!!this.locales[e]}formatDate(e,t={}){const i=t.locale||this.currentLocale,s="string"==typeof e?new Date(e):e;return new Intl.DateTimeFormat(i,t).format(s)}formatNumber(e,t={}){const i=t.locale||this.currentLocale;return new Intl.NumberFormat(i,t).format(e)}formatCurrency(e,t,i={}){const s=i.locale||this.currentLocale;return new Intl.NumberFormat(s,{style:"currency",currency:t,...i}).format(e)}formatRelativeTime(e,t,i={}){const s=i.locale||this.currentLocale;return new Intl.RelativeTimeFormat(s,i).format(e,t)}}const W=new j;function U(e){return new j(e)}function Y(e,t={}){return W.t(e,t)}function X(e,t,i={}){return W.n(e,t,i)}function J(e){return W.setLocale(e)}function G(){return W.getLocale()}function Z(e,t={}){return W.formatDate(e,t)}function Q(e,t={}){return W.formatNumber(e,t)}function ee(e,t,i={}){return W.formatCurrency(e,t,i)}"undefined"!=typeof window&&(window.KupolaI18n=j,window.kupolaI18n=W,window.createI18n=U,window.t=Y,window.n=X,window.setLocale=J,window.getLocale=G,window.formatDate=Z,window.formatNumber=Q,window.formatCurrency=ee);class te{constructor(e,t={}){this.element=e,this.trigger=e.querySelector(".ds-dropdown__trigger"),this.menu=e.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`,this.triggerMode=t.trigger||e.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=t.hoverDelay||parseInt(e.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=t.disabled||e.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==t.keyboardNav,this.autoPosition=!1!==t.autoPosition,this.onSelect=t.onSelect||null,this.onShow=t.onShow||null,this.onHide=t.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null}init(){this.trigger&&this.menu&&(this.element.__kupolaInitialized||(this._itemClickHandler=e=>{const t=e.currentTarget;t.classList.contains("is-disabled")||t.classList.contains("ds-dropdown__divider")||(this.triggerText&&!t.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=t.textContent.trim()),this.onSelect&&this.onSelect({item:t,value:t.getAttribute("data-value"),text:t.textContent.trim()}),this.hideMenu(),this.trigger.focus())},this._bindMenuItems(),this._triggerClickHandler=e=>{e.stopPropagation(),this.disabled||this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||"hover"!==this.triggerMode||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{"hover"===this.triggerMode&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||"hover"!==this.triggerMode||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{"hover"===this.triggerMode&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=e=>{if(!this.isOpen||this.disabled)return;const t=this._getNavigableItems();if(t.length)switch(e.key){case"ArrowDown":e.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,t.length-1),this._focusItem(t);break;case"ArrowUp":e.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(t);break;case"Enter":case" ":e.preventDefault(),this.focusIndex>=0&&t[this.focusIndex]&&t[this.focusIndex].click();break;case"Escape":e.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":e.preventDefault(),this.focusIndex=0,this._focusItem(t);break;case"End":e.preventDefault(),this.focusIndex=t.length-1,this._focusItem(t)}},"hover"===this.triggerMode?(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.trigger.addEventListener("keydown",e=>{this.disabled||"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),this.showMenu())}),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=e=>{this.element.contains(e.target)||this.hideMenu()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this.menu.style.display="none",this.element.__kupolaInitialized=!0))}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e.addEventListener("click",this._itemClickHandler),e._dropdownItemClickHandler=this._itemClickHandler})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(e=>!e.classList.contains("is-disabled")&&!e.classList.contains("ds-dropdown__divider"))}_focusItem(e){e.forEach(e=>e.classList.remove("is-focused")),e[this.focusIndex]&&(e[this.focusIndex].classList.add("is-focused"),e[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const e=this.element.getBoundingClientRect(),t=this.menu.getBoundingClientRect(),i=window.innerHeight,s=window.innerWidth;this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup");const n=i-e.bottom,a=e.top;n<t.height&&a>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"),e.left+t.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.menu.style.display="block",this.element.classList.add("is-open"),this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>e.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(e){this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",e.forEach(e=>{if("divider"===e.type){const e=document.createElement("div");e.className="ds-dropdown__divider",this.menu.appendChild(e)}else{const t=document.createElement("div");t.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),t.textContent=e.text||e.label||"",void 0!==e.value&&t.setAttribute("data-value",e.value),e.icon&&(t.innerHTML=e.icon+t.innerHTML),e.disabled&&t.classList.add("is-disabled"),this.menu.appendChild(t)}}),this._bindMenuItems()}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this.element.__kupolaInitialized=!1)}}function ie(e,t){const i=new te(e,t);i.init(),e._kupolaDropdown=i}function se(e=document){e.querySelectorAll(".ds-dropdown").forEach(e=>{ie(e)})}function ne(e){e._kupolaDropdown&&(e._kupolaDropdown.destroy(),e._kupolaDropdown=null)}function ae(){document.querySelectorAll(".ds-dropdown").forEach(e=>{ne(e)})}"undefined"!=typeof window&&(window.Dropdown=te,window.initDropdown=ie,window.initDropdowns=se,window.cleanupDropdown=ne,window.cleanupAllDropdowns=ae,window.kupolaInitializer&&window.kupolaInitializer.register("dropdown",ie,ne));class re{constructor(e,t={}){this.element=e,this.trigger=e.querySelector(".ds-select__trigger"),this.valueEl=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span"),this.optionsEl=e.querySelector(".ds-select__options")||e.querySelector(".ds-select__menu"),this.nativeSelect=e.querySelector("select"),this.icon=e.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=t.multiple||e.hasAttribute("data-select-multiple"),this.searchable=t.searchable||e.hasAttribute("data-select-search"),this.clearable=t.clearable||e.hasAttribute("data-select-clear"),this.placeholder=t.placeholder||e.getAttribute("data-select-placeholder")||"",this.disabled=t.disabled||e.hasAttribute("data-select-disabled"),this.maxSelection=t.maxSelection||parseInt(e.getAttribute("data-select-max"))||1/0,this.remoteMethod=t.remoteMethod||null,this.onChange=t.onChange||null,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){this.trigger&&this.optionsEl&&(this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=e=>{const t=e.currentTarget;if(t.classList.contains("is-disabled"))return;const i=t.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,t):this._selectSingleOption(i,t)},this._bindOptionClicks(),this._triggerClickHandler=e=>{e.stopPropagation(),this.disabled||this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=e=>{if(!this.isOpen||this.disabled)return;const t=this._getVisibleOptions();if(t.length)switch(e.key){case"ArrowDown":e.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,t.length-1),this._focusOption(t);break;case"ArrowUp":e.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(t);break;case"Enter":e.preventDefault(),this.focusIndex>=0&&t[this.focusIndex]&&t[this.focusIndex].click();break;case"Escape":e.preventDefault(),this.hideOptions(),this.trigger.focus()}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=e=>{this.element.contains(e.target)||this.hideOptions()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0))}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{this.allOptions.push({el:e,value:e.getAttribute("data-value"),text:e.textContent.trim(),group:e.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:e.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",e=>e.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 e=this.trigger.querySelector(".ds-select__value")||this.trigger;e.parentNode.insertBefore(this.clearBtn,e.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const e=this.valueEl||this.trigger;e.parentNode.insertBefore(this.tagsWrap,e.nextSibling)}_handleSearch(){const e=this.searchInput.value.toLowerCase().trim();this.remoteMethod?this.remoteMethod(e,e=>{this._renderRemoteOptions(e)}):(this.filteredOptions=this.allOptions.filter(t=>t.text.toLowerCase().includes(e)),this.allOptions.forEach(e=>{const t=this.filteredOptions.includes(e);e.el.style.display=t?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const t=e.getAttribute("data-group"),i=this.filteredOptions.some(e=>e.group===t);e.style.display=i?"":"none"}),this.focusIndex=-1)}_renderRemoteOptions(e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),e.forEach(e=>{const t=document.createElement("div");t.className="ds-select__option",t.setAttribute("data-value",e.value),t.textContent=e.text||e.label,e.disabled&&t.classList.add("is-disabled"),this.selectedValues.has(e.value)&&t.classList.add("is-selected"),t.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler,this.optionsEl.appendChild(t)}),this.allOptions=e.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(e,t){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>e.classList.remove("is-selected")),t.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(e),this.updateValue(t.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(e,t){if(this.selectedValues.has(e))this.selectedValues.delete(e),t.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(e),t.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(e=>{const t=this.allOptions.find(t=>t.value===e);if(!t)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=t.text;const s=document.createElement("button");s.className="ds-select__tag-close",s.type="button",s.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.addEventListener("click",t=>{t.stopPropagation(),this.selectedValues.delete(e);const i=this.optionsEl.querySelector(`[data-value="${e}"]`);i&&i.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(s),this.tagsWrap.appendChild(i)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const e=this.selectedValues.size;0===e?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${e}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=e>0?"none":"")}else 0===this.selectedValues.size&&(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(e=>{e.selected=this.selectedValues.has(e.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const e=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:e,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:e,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect)if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(e=>{this.selectedValues.add(e.value);const t=this.optionsEl.querySelector(`[data-value="${e.value}"]`);t&&t.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const e=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);e&&(e.classList.add("is-selected"),this.updateValue(e.textContent.trim()))}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.addEventListener("click",this._optionClickHandler),e._selectOptionClickHandler=this._optionClickHandler})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(e=>"none"!==e.style.display&&!e.classList.contains("is-disabled"))}_focusOption(e){e.forEach(e=>e.classList.remove("is-focused")),e[this.focusIndex]&&(e[this.focusIndex].classList.add("is-focused"),e[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(e){this.valueEl&&(this.valueEl.textContent=e||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.optionsEl.style.display="block",this.icon&&(this.icon.style.transform="rotate(180deg)"),this.element.classList.add("is-open"),this.focusIndex=-1,this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>e.classList.remove("is-focused")))}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>e.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(e=>{const t=this.allOptions.find(t=>t.value===e);return t?{value:t.value,text:t.text}:{value:e,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(e){this.multiple&&Array.isArray(e)?(this.selectedValues.clear(),e.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(e),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{const i=t.getAttribute("data-value")===e;t.classList.toggle("is-selected",i),i&&this.updateValue(t.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(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function oe(e,t){const i=new re(e,t);i.init(),e._kupolaSelect=i}function le(e=document){e.querySelectorAll(".ds-select").forEach(e=>{oe(e)})}function de(e){e._kupolaSelect&&(e._kupolaSelect.destroy(),e._kupolaSelect=null)}"undefined"!=typeof window&&(window.Select=re,window.initSelect=oe,window.initSelects=le,window.cleanupSelect=de,window.cleanupAllSelects=function(){document.querySelectorAll(".ds-select").forEach(e=>{de(e)})},window.kupolaInitializer&&window.kupolaInitializer.register("select",oe,de));class he{constructor(e,t={}){this.element=e,this.input=e.querySelector("input"),this.endInput=e.querySelector(".ds-datepicker__end-input"),this.icon=e.querySelector(".ds-datepicker__icon"),this.calendarEl=e.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`,this.format=t.format||e.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=t.range||e.hasAttribute("data-datepicker-range"),this.minDate=t.minDate||e.getAttribute("data-datepicker-min")||null,this.maxDate=t.maxDate||e.getAttribute("data-datepicker-max")||null,this.disabledDate=t.disabledDate||null,this.weekStart=t.weekStart||parseInt(e.getAttribute("data-datepicker-week-start"))||0,this.placeholder=t.placeholder||e.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==t.showToday,this.showWeekNumber=t.showWeekNumber||e.hasAttribute("data-datepicker-week-number"),this.onChange=t.onChange||null,this.months=t.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=t.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=t.todayText||"Today",this.clearText=t.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._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const e=this.input.value.split(" ~ ");2===e.length&&(this.rangeStart=this._parseDate(e[0].trim()),this.rangeEnd=this._parseDate(e[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=e=>this.toggleCalendar(e),this._inputClickHandler=e=>this.toggleCalendar(e),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&this.endInput.addEventListener("click",e=>{this.isSelectingEnd=!0,this.toggleCalendar(e)}),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",e=>this.hideCalendar(e),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",e=>this.hideCalendar(e)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=e=>this.hideCalendar(e),this._resizeHandler=()=>this.resizeHandler()),this._keydownHandler=e=>{"Escape"===e.key&&"block"===this.calendarEl.style.display&&this.hideCalendar(e)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(e){if(!e)return null;const t=e.split("-");return 3===t.length?new Date(parseInt(t[0]),parseInt(t[1])-1,parseInt(t[2])):null}_formatDate(e){if(!e)return"";const t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return this.format.replace("YYYY",t).replace("MM",i).replace("DD",s)}_isDateDisabled(e){if(this.minDate){if(e<("string"==typeof this.minDate?this._parseDate(this.minDate):this.minDate))return!0}if(this.maxDate){if(e>("string"==typeof this.maxDate?this._parseDate(this.maxDate):this.maxDate))return!0}return!!this.disabledDate&&this.disabledDate(e)}_isToday(e){const t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}_isSameDay(e,t){return!(!e||!t)&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())}_isInRange(e){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const t=e.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),s=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return t>=i&&t<=s}calculatePosition(){const e=this.element.getBoundingClientRect(),t=this.calendarEl.getBoundingClientRect(),i=window.innerHeight-e.bottom,s=e.top,n=t.height||320;i>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):s>=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(e){e.preventDefault(),e.stopPropagation();const t="block"===this.calendarEl.style.display;document.querySelectorAll(".ds-datepicker__calendar").forEach(e=>{e!==this.calendarEl&&(e.style.display="none",e.setAttribute("hidden",""))}),t||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(e){this.element.contains(e.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days")}resizeHandler(){"block"===this.calendarEl.style.display&&this.calculatePosition()}_renderCalendar(){const e=this.calendarEl;if(!e)return;if(e.querySelectorAll(".ds-datepicker__day").forEach(e=>{e._dayClickHandler&&e.removeEventListener("click",e._dayClickHandler)}),"years"===this.viewMode)return void this._renderYearsView();if("months"===this.viewMode)return void this._renderMonthsView();const t=this.currentDate.getFullYear(),i=this.currentDate.getMonth();e.innerHTML="";const 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",e=>{e.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${t} ${this.months[i]}`,a.addEventListener("click",e=>{e.stopPropagation(),this.viewMode="months",this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--next",r.type="button",r.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>',r.addEventListener("click",e=>{e.stopPropagation(),this._nextMonth()}),s.appendChild(n),s.appendChild(a),s.appendChild(r),e.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__weekdays";[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(e=>{const t=document.createElement("span");t.className="ds-datepicker__weekday",t.textContent=e,o.appendChild(t)}),e.appendChild(o);const l=document.createElement("div");l.className="ds-datepicker__days";const d=new Date(t,i,1).getDay(),h=new Date(t,i+1,0).getDate(),c=(d-this.weekStart+7)%7;for(let e=0;e<c;e++){const e=document.createElement("span");e.className="ds-datepicker__day ds-datepicker__day--empty",l.appendChild(e)}for(let e=1;e<=h;e++){const s=new Date(t,i,e),n=document.createElement("button");n.className="ds-datepicker__day",n.type="button",n.textContent=e,this._formatDate(s),this._isToday(s)&&n.classList.add("is-today"),this.range?((this._isSameDay(s,this.rangeStart)||this._isSameDay(s,this.rangeEnd))&&n.classList.add("is-selected"),this._isInRange(s)&&n.classList.add("is-in-range")):this._isSameDay(s,this.selectedDate)&&n.classList.add("is-selected"),this._isDateDisabled(s)&&(n.classList.add("is-disabled"),n.disabled=!0);const a=()=>this._selectDate(s);n.addEventListener("click",a),n._dayClickHandler=a,l.appendChild(n)}if(e.appendChild(l),this.showToday){const t=document.createElement("div");t.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",e=>{e.stopPropagation(),this._goToToday()});const s=document.createElement("button");s.className="ds-datepicker__clear-btn",s.type="button",s.textContent=this.clearText,s.addEventListener("click",e=>{e.stopPropagation(),this._clearDate()}),t.appendChild(i),t.appendChild(s),e.appendChild(t)}}_renderYearsView(){const e=this.calendarEl;e.innerHTML="";const t=this.currentDate.getFullYear(),i=t-6,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",e=>{e.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",e=>{e.stopPropagation()});const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--next",r.type="button",r.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>',r.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),s.appendChild(n),s.appendChild(a),s.appendChild(r),e.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__years-grid";for(let e=0;e<12;e++){const s=i+e,n=document.createElement("button");n.className="ds-datepicker__year-cell",n.type="button",n.textContent=s,s===t&&n.classList.add("is-selected"),n.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setFullYear(s),this.viewMode="months",this._renderCalendar()}),o.appendChild(n)}e.appendChild(o)}_renderMonthsView(){const e=this.calendarEl;e.innerHTML="";const t=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const s=document.createElement("button");s.className="ds-datepicker__nav ds-datepicker__nav--prev",s.type="button",s.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>',s.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const n=document.createElement("button");n.className="ds-datepicker__title",n.type="button",n.textContent=t,n.addEventListener("click",e=>{e.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",e=>{e.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),i.appendChild(s),i.appendChild(n),i.appendChild(a),e.appendChild(i);const r=document.createElement("div");r.className="ds-datepicker__months-grid",this.months.forEach((e,t)=>{const i=document.createElement("button");i.className="ds-datepicker__month-cell",i.type="button",i.textContent=e,t===this.currentDate.getMonth()&&i.classList.add("is-selected"),i.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setMonth(t),this.viewMode="days",this._renderCalendar()}),r.appendChild(i)}),e.appendChild(r)}_selectDate(e){if(!this._isDateDisabled(e)){if(!this.range)return this.selectedDate=e,this.input&&(this.input.value=this._formatDate(e)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this._fireChange();if(this.isSelectingEnd&&this.rangeStart)return this.rangeEnd=e,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",""),void this._fireChange();this.rangeStart=e,this.rangeEnd=null,this.isSelectingEnd=!0,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 e=new Date;this.currentDate=new Date(e),this._isDateDisabled(e)?this._renderCalendar():this._selectDate(e)}_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(e){const t="string"==typeof e?this._parseDate(e):e;t&&(this.selectedDate=t,this.currentDate=new Date(t),this.input&&(this.input.value=this._formatDate(t)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(e,t){this.rangeStart="string"==typeof e?this._parseDate(e):e,this.rangeEnd="string"==typeof t?this._parseDate(t):t,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._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(e=>{e._dayClickHandler&&e.removeEventListener("click",e._dayClickHandler)}),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function ce(e,t){const i=new he(e,t);i.init(),e._kupolaDatepicker=i}function ue(e=document){e.querySelectorAll(".ds-datepicker").forEach(e=>{ce(e)})}function pe(e){e._kupolaDatepicker&&(e._kupolaDatepicker.destroy(),e._kupolaDatepicker=null)}"undefined"!=typeof window&&(window.Datepicker=he,window.initDatepicker=ce,window.initDatepickers=ue,window.cleanupDatepicker=pe,window.cleanupAllDatepickers=function(){document.querySelectorAll(".ds-datepicker").forEach(e=>{pe(e)})},window.kupolaInitializer&&window.kupolaInitializer.register("datepicker",ce,pe));class me{constructor(e,t={}){this.element=e,this.input=e.querySelector("input"),this.inputWrap=e.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=t.showSeconds||e.hasAttribute("data-timepicker-seconds"),this.use12Hour=t.use12Hour||e.hasAttribute("data-timepicker-12h"),this.hourStep=t.hourStep||parseInt(e.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=t.minuteStep||parseInt(e.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=t.secondStep||parseInt(e.getAttribute("data-timepicker-second-step"))||5,this.minTime=t.minTime||e.getAttribute("data-timepicker-min")||null,this.maxTime=t.maxTime||e.getAttribute("data-timepicker-max")||null,this.disabledTime=t.disabledTime||null,this.placeholder=t.placeholder||e.getAttribute("data-timepicker-placeholder")||"",this.clearable=t.clearable||e.hasAttribute("data-timepicker-clear"),this.onChange=t.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=e=>{e.stopPropagation(),this.panelEl&&"block"===this.panelEl.style.display?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",e=>this.hideTimepicker(e),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",e=>this.hideTimepicker(e)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=e=>this.hideTimepicker(e),this._resizeHandler=()=>this.resizeHandler()),this._keydownHandler=e=>{"Escape"===e.key&&this.panelEl&&"block"===this.panelEl.style.display&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const e=this.input.value.trim();if(!e)return;const t=e.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(t)return this.selectedHour=parseInt(t[1])%12,"PM"===t[4].toUpperCase()&&(this.selectedHour+=12),this.selectedMinute=parseInt(t[2]),void(this.selectedSecond=t[3]?parseInt(t[3]):0);const i=e.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(e,t,i){if(this.disabledTime)return this.disabledTime(e,t,i);const s=3600*e+60*t+i;if(this.minTime){const e=this.minTime.split(":");if(s<3600*parseInt(e[0])+60*parseInt(e[1])+(parseInt(e[2])||0))return!0}if(this.maxTime){const e=this.maxTime.split(":");if(s>3600*parseInt(e[0])+60*parseInt(e[1])+(parseInt(e[2])||0))return!0}return!1}_formatTime(){let e=this.selectedHour,t=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const s=e>=12?"PM":"AM";return e=e%12||12,this.showSeconds?`${e}:${String(t).padStart(2,"0")}:${String(i).padStart(2,"0")} ${s}`:`${e}:${String(t).padStart(2,"0")} ${s}`}return this.showSeconds?`${String(e).padStart(2,"0")}:${String(t).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(e).padStart(2,"0")}:${String(t).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const e=this.element.getBoundingClientRect(),t=this.panelEl.getBoundingClientRect(),i=window.innerHeight-e.bottom,s=e.top,n=t.height||320;i>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):s>=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._syncPanelSelection(),void this.calculatePosition();this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let e="";if(e+='<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>',e+='<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&&(e+='<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&&(e+='<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">${e}</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._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",e=>{e.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 e=this.panelEl.querySelector('[data-type="hour"]');if(!e)return;this.use12Hour;for(let t=this.use12Hour?1:0;t<(this.use12Hour?13:24);t+=this.hourStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(t).padStart(2,"0"),i.dataset.value=t,i.addEventListener("click",()=>{let e=t;this.use12Hour&&(e=12===t?this.isPM?12:0:this.isPM?t+12:t),this.selectedHour=e,this._updateDisplay(),this._syncGridSelection("hour",t),this._confirmSelection()}),e.appendChild(i)}}_populateMinuteGrid(){const e=this.panelEl.querySelector('[data-type="minute"]');if(e)for(let t=0;t<60;t+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(t).padStart(2,"0"),i.dataset.value=t,i.addEventListener("click",()=>{this.selectedMinute=t,this._updateDisplay(),this._syncGridSelection("minute",t),this._confirmSelection()}),e.appendChild(i)}}_populateSecondGrid(){const e=this.panelEl.querySelector('[data-type="second"]');if(e)for(let t=0;t<60;t+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(t).padStart(2,"0"),i.dataset.value=t,i.addEventListener("click",()=>{this.selectedSecond=t,this._updateDisplay(),this._syncGridSelection("second",t),this._confirmSelection()}),e.appendChild(i)}}_populateAmPmGrid(){const e=this.panelEl.querySelector('[data-type="ampm"]');e&&["AM","PM"].forEach(t=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=t,i.dataset.value=t,i.addEventListener("click",()=>{this.isPM="PM"===t,this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this._updateDisplay(),e.querySelectorAll(".ds-timepicker__item").forEach(e=>e.classList.remove("is-selected")),i.classList.add("is-selected"),this._confirmSelection()}),e.appendChild(i)})}_updateDisplay(){if(!this.panelEl)return;const e=this.panelEl.querySelector(".ds-timepicker__display-hour"),t=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),s=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(e){const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;e.textContent=String(t).padStart(2,"0")}t&&(t.textContent=String(this.selectedMinute).padStart(2,"0")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),s&&(s.textContent=this.selectedHour>=12?"PM":"AM")}_syncPanelSelection(){if(!this.panelEl)return;const e=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this._syncGridSelection("hour",e),this._syncGridSelection("minute",this.selectedMinute),this._syncGridSelection("second",this.selectedSecond);const t=this.panelEl.querySelector('[data-type="ampm"]');t&&t.querySelectorAll(".ds-timepicker__item").forEach(e=>{e.classList.toggle("is-selected","PM"===e.dataset.value==this.selectedHour>=12)}),this._updateDisplay()}_syncGridSelection(e,t){const i=this.panelEl.querySelector(`[data-type="${e}"]`);i&&i.querySelectorAll(".ds-timepicker__item").forEach(e=>{e.classList.toggle("is-selected",parseInt(e.dataset.value)===t)})}_scrollToSelection(){["hour","minute","second"].forEach(e=>{const t=this.panelEl.querySelector(`[data-type="${e}"]`);if(!t)return;const i=t.querySelector(".is-selected");i&&i.scrollIntoView({block:"center"})})}_confirmSelection(){this.input.value=this._formatTime()}hideTimepicker(e){this.panelEl&&"block"===this.panelEl.style.display&&(this.element.contains(e.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&&"block"===this.panelEl.style.display&&this.calculatePosition()}setTime(e,t,i){this.selectedHour=Math.max(0,Math.min(23,e)),this.selectedMinute=Math.max(0,Math.min(59,t)),this.selectedSecond=Math.max(0,Math.min(59,i||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 ge(e,t){const i=new me(e,t);i.init(),e._kupolaTimepicker=i}function ye(e=document){e.querySelectorAll(".ds-timepicker").forEach(e=>{ge(e)})}function _e(e){e._kupolaTimepicker&&(e._kupolaTimepicker.destroy(),e._kupolaTimepicker=null)}"undefined"!=typeof window&&(window.Timepicker=me,window.initTimepicker=ge,window.initTimepickers=ye,window.cleanupTimepicker=_e,window.kupolaInitializer&&window.kupolaInitializer.register("timepicker",ge,_e));class fe{constructor(e,t={}){if(this.element=e,this.track=e.querySelector(".ds-slider__track"),this.fill=e.querySelector(".ds-slider__fill"),this.input=e.querySelector(".ds-slider__input"),this.valueEl=e.querySelector(".ds-slider__value"),this.range=t.range||e.hasAttribute("data-slider-range"),this.vertical=t.vertical||e.hasAttribute("data-slider-vertical"),this.disabled=t.disabled||e.hasAttribute("data-slider-disabled"),this.showTooltip=!1!==t.showTooltip,this.showMarks=t.marks||e.hasAttribute("data-slider-marks"),this.markStep=t.markStep||parseInt(e.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=t.tooltipFormat||(e=>e),this.onChange=t.onChange||null,this.onInput=t.onInput||null,this.inputEnd=e.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 e=parseFloat(this.input?.min||0),t=parseFloat(this.input?.max||100);for(let i=e;i<=t;i+=this.markStep){const s=document.createElement("div");s.className="ds-slider__mark";const n=(i-e)/(t-e)*100;this.vertical?s.style.bottom=n+"%":s.style.left=n+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=i,s.appendChild(a),this.marksEl.appendChild(s)}this.element.appendChild(this.marksEl)}_bindEvents(){if(this.input){const e=()=>this.updateSlider(),t=()=>this.updateSlider();this.input.addEventListener("input",e),this.input.addEventListener("change",t),this._listeners.push({el:this.input,event:"input",handler:e},{el:this.input,event:"change",handler:t})}if(this.inputEnd){const e=()=>this.updateSlider();this.inputEnd.addEventListener("input",e),this._listeners.push({el:this.inputEnd,event:"input",handler:e})}if(this.thumbStart&&this._bindThumbDrag(this.thumbStart,"start"),this.thumbEnd&&this._bindThumbDrag(this.thumbEnd,"end"),this.track){const e=e=>{this.disabled||this._handleTrackClick(e)};this.track.addEventListener("click",e),this._listeners.push({el:this.track,event:"click",handler:e})}if(this.thumbStart){const e=e=>this._handleKeyboard(e,"start");this.thumbStart.addEventListener("keydown",e),this._listeners.push({el:this.thumbStart,event:"keydown",handler:e})}if(this.thumbEnd){const e=e=>this._handleKeyboard(e,"end");this.thumbEnd.addEventListener("keydown",e),this._listeners.push({el:this.thumbEnd,event:"keydown",handler:e})}}_bindThumbDrag(e,t){const i=e=>{this.disabled||(e.preventDefault(),this._isDragging=!0,this._activeThumb=t,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",s),document.addEventListener("mouseup",n),document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",n))},s=e=>{if(!this._isDragging)return;e.preventDefault();const i=e.touches?e.touches[0].clientX:e.clientX,s=e.touches?e.touches[0].clientY:e.clientY,n=this.track.getBoundingClientRect();let a;a=this.vertical?1-(s-n.top)/n.height:(i-n.left)/n.width,a=Math.max(0,Math.min(1,a));const r=parseFloat(this.input?.min||0),o=parseFloat(this.input?.max||100),l=parseFloat(this.input?.step||1);let d=r+a*(o-r);if(d=Math.round(d/l)*l,d=Math.max(r,Math.min(o,d)),"start"===t&&this.range&&this.inputEnd){const e=parseFloat(this.inputEnd.value);d>e&&(d=e)}if("end"===t&&this.range&&this.input){const e=parseFloat(this.input.value);d<e&&(d=e)}"start"===t&&this.input?this.input.value=d:"end"===t&&this.inputEnd&&(this.inputEnd.value=d),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:a})},n=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",s),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}))};e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!1}),this._listeners.push({el:e,event:"mousedown",handler:i},{el:e,event:"touchstart",handler:i})}_handleTrackClick(e){if(e.target.classList.contains("ds-slider__thumb"))return;const t=this.track.getBoundingClientRect(),i=e.clientX,s=e.clientY;let n;n=this.vertical?1-(s-t.top)/t.height:(i-t.left)/t.width,n=Math.max(0,Math.min(1,n));const a=parseFloat(this.input?.min||0),r=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let l=a+n*(r-a);if(l=Math.round(l/o)*o,this.range){const e=parseFloat(this.input?.value||0),t=parseFloat(this.inputEnd?.value||0);Math.abs(l-e)<=Math.abs(l-t)?this.input&&(this.input.value=Math.min(l,t)):this.inputEnd&&(this.inputEnd.value=Math.max(l,e))}else this.input&&(this.input.value=l);this.updateSlider()}_handleKeyboard(e,t){if(this.disabled)return;const i="start"===t?this.input:this.inputEnd;if(!i)return;const s=parseFloat(i.step||1),n=parseFloat(i.min||0),a=parseFloat(i.max||100);let r=parseFloat(i.value);switch(e.key){case"ArrowRight":case"ArrowUp":e.preventDefault(),r=Math.min(a,r+s);break;case"ArrowLeft":case"ArrowDown":e.preventDefault(),r=Math.max(n,r-s);break;case"Home":e.preventDefault(),r=n;break;case"End":e.preventDefault(),r=a;break;default:return}i.value=r,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const e=parseFloat(this.input?.min||0),t=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const i=parseFloat(this.input?.value||0),s=parseFloat(this.inputEnd?.value||0),n=(i-e)/(t-e)*100,a=(s-e)/(t-e)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=a-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=a-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(s)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(s)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",s)}else{const i=this.input?.value||0,s=(i-e)/(t-e)*100;this.vertical?this.fill.style.height=`${s}%`:this.fill.style.width=`${s}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=s+"%":this.thumbStart.style.left=s+"%"),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._listeners?.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),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(e,t){this.input&&(this.input.value=e),void 0!==t&&this.inputEnd&&(this.inputEnd.value=t),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 ve(e,t){if(!e.__kupolaInitialized)try{const i=new fe(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function we(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function be(){document.querySelectorAll(".ds-slider").forEach(e=>{ve(e)})}"undefined"!=typeof window&&(window.Slider=fe,window.initSlider=ve,window.initSliders=be,window.cleanupSlider=we,window.kupolaInitializer&&window.kupolaInitializer.register("slider",ve,we));class ke{constructor(e,t={}){this.element=e,this.track=e.querySelector(".ds-carousel__track"),this.items=e.querySelectorAll(".ds-carousel__item"),this.prevBtn=e.querySelector(".ds-carousel__prev"),this.nextBtn=e.querySelector(".ds-carousel__next"),this.indicators=e.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=e.querySelector(".ds-carousel__auto"),this.mode=t.mode||e.getAttribute("data-carousel-mode")||"slide",this.vertical=t.vertical||e.hasAttribute("data-carousel-vertical"),this.autoPlay=!1!==t.autoPlay,this.interval=t.interval||parseInt(e.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=t.transitionDuration||parseInt(e.getAttribute("data-carousel-duration"))||500,this.loop=!1!==t.loop,this.pauseOnHover=!1!==t.pauseOnHover,this.swipe=!1!==t.swipe,this.swipeThreshold=t.swipeThreshold||50,this.keyboardNav=t.keyboardNav||e.hasAttribute("data-carousel-keyboard"),this.onChange=t.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((e,t)=>{const i=()=>this.goTo(t);this._indicatorClickHandlers.push(i),e.addEventListener("click",i)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.swipe&&(this._touchStartHandler=e=>this._handleTouchStart(e),this._touchMoveHandler=e=>this._handleTouchMove(e),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=e=>{this.element.contains(document.activeElement)&&("ArrowLeft"===e.key||"ArrowUp"===e.key?(e.preventDefault(),this.prev()):"ArrowRight"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),this.next()))},this.element.addEventListener("keydown",this._keydownHandler)),"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._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(e){if(this.isTransitioning)return;if(e<0||e>=this.totalItems)return;this.isTransitioning=!0;const t=this.currentIndex;if(this.currentIndex=e,"fade"===this.mode)this.items.forEach((t,i)=>{t.style.opacity=i===e?"1":"0",t.style.zIndex=i===e?"1":"0"});else if(this.vertical){const t=100*-e;this.track.style.transform=`translateY(${t}%)`}else{const t=100*-e;this.track.style.transform=`translateX(${t}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:e,prevIndex:t,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:e,prevIndex:t,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((e,t)=>{e.classList.toggle("is-active",t===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()}_handleTouchStart(e){this.touchStartX=e.touches[0].clientX,this.touchStartY=e.touches[0].clientY,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!0,this.isAutoPlaying&&(this.stopAutoPlay(),this._wasAutoPlaying=!0)}_handleTouchMove(e){if(!this.isSwiping)return;this.touchDeltaX=e.touches[0].clientX-this.touchStartX,this.touchDeltaY=e.touches[0].clientY-this.touchStartY;const t=Math.abs(this.touchDeltaX);t>Math.abs(this.touchDeltaY)&&t>10&&e.preventDefault()}_handleTouchEnd(){if(!this.isSwiping)return;this.isSwiping=!1;const e=Math.abs(this.touchDeltaX),t=Math.abs(this.touchDeltaY);e>this.swipeThreshold&&e>t&&(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((e,t)=>{const i=this._indicatorClickHandlers[t];i&&e.removeEventListener("click",i)}),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 Ee(e,t){if(e.__kupolaInitialized)return;const i=new ke(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}function xe(e=document){e.querySelectorAll(".ds-carousel").forEach(e=>{Ee(e)})}function Ce(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}"undefined"!=typeof window&&(window.Carousel=ke,window.initCarousel=Ee,window.initCarousels=xe,window.kupolaInitializer&&window.kupolaInitializer.register("carousel",Ee,Ce));class Se{constructor(e,t={}){this.element=e,this.mask=e.querySelector(".ds-drawer-mask"),this.drawerEl=e.querySelector(".ds-drawer"),this.placement=t.placement||e.getAttribute("data-drawer-placement")||"right",this.width=t.width||e.getAttribute("data-drawer-width")||"400px",this.height=t.height||e.getAttribute("data-drawer-height")||"400px",this.escClose=!1!==t.escClose,this.maskClosable=!1!==t.maskClosable,this.showMask=!1!==t.showMask,this.onOpen=t.onOpen||null,this.onClose=t.onClose||null,this.onBeforeClose=t.onBeforeClose||null,this._keydownHandler=null,this._bindEvents()}_bindEvents(){const e=this.mask?.querySelector(".ds-drawer__close"),t=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=e=>{this.maskClosable&&e.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),e&&e.addEventListener("click",this.closeDrawer),t&&t.addEventListener("click",this.closeDrawer),i&&i.addEventListener("click",this.closeDrawer),this.escClose&&(this._keydownHandler=e=>{"Escape"===e.key&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this._keydownHandler)),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:e,event:"click",handler:this.closeDrawer},{el:t,event:"click",handler:this.closeDrawer},{el:i,event:"click",handler:this.closeDrawer}].filter(e=>e.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}`),"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._listeners?.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),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 Le(e,t){if(e.__kupolaInitialized)return;const i=new Se(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}function De(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Me(){document.querySelectorAll("[data-drawer]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-drawer"),i=document.getElementById(t);i&&(Le(i,{placement:e.getAttribute("data-drawer-placement")||"right",width:e.getAttribute("data-drawer-width"),height:e.getAttribute("data-drawer-height")}),i.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(e=>{const t=e.parentElement;t&&Le(t)})}"undefined"!=typeof window&&(window.Drawer=Se,window.initDrawer=Le,window.initDrawers=Me,window.cleanupDrawer=De,window.createDrawer=function(e={}){const{title:t="",content:i="",html:s=!1,placement:n="right",width:a="400px",height:r="400px",closable:o=!0,showMask:l=!0,footer:d=null,onClose:h,onOpen:c}=e,u=document.createElement("div");u.className="ds-drawer-container";let p="";null!==d&&(p="string"==typeof d?`<div class="ds-drawer__footer">${d}</div>`:'<div class="ds-drawer__footer">\n <button class="ds-btn ds-btn--ghost" data-drawer-cancel>Cancel</button>\n <button class="ds-btn ds-btn--brand" data-drawer-confirm>OK</button>\n </div>'),u.innerHTML=`\n <div class="ds-drawer-mask">\n <div class="ds-drawer ds-drawer--${n}" style="${"left"===n||"right"===n?"width:"+a:"height:"+r}">\n <div class="ds-drawer__header">\n <span class="ds-drawer__title"></span>\n ${o?'<button class="ds-drawer__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-drawer__body"></div>\n ${p}\n </div>\n </div>\n `,document.body.appendChild(u);const m=new Se(u,{placement:n,width:a,height:r,showMask:l,onClose:h,onOpen:c}),g=u.querySelector(".ds-drawer__title");g&&(g.textContent=t);const y=u.querySelector(".ds-drawer__body");y&&(s?y.innerHTML=i:y.textContent=i);const _=u.querySelector("[data-drawer-confirm]"),f=u.querySelector("[data-drawer-cancel]");f&&f.addEventListener("click",()=>m.close()),_&&_.addEventListener("click",()=>{e.onConfirm&&e.onConfirm(),m.close()});const v=m.closeDrawer;return m.closeDrawer=()=>{v(),setTimeout(()=>{m.destroy(),u.remove()},300)},m.open(),m},window.kupolaInitializer&&window.kupolaInitializer.register("drawer",Le,De));class Ie{constructor(e,t={}){this.element=e,this.mask=e.querySelector(".ds-modal-mask"),this.modal=e.querySelector(".ds-modal"),this.closeBtn=e.querySelector(".ds-modal__close"),this.fullscreen=t.fullscreen||e.hasAttribute("data-modal-fullscreen"),this.closableOnMask=!1!==t.closableOnMask,this.escClose=!1!==t.escClose,this.width=t.width||e.getAttribute("data-modal-width")||"",this.center=!1!==t.center,this.onBeforeOpen=t.onBeforeOpen||null,this.onBeforeClose=t.onBeforeClose||null,this.onOpened=t.onOpened||null,this.onClosed=t.onClosed||null,this._keydownHandler=e=>{this.escClose&&"Escape"===e.key&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=e=>{this.closableOnMask&&e.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(){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")})),Ie._openCount=(Ie._openCount||0)+1,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),Ie._openCount=Math.max(0,(Ie._openCount||0)-1),0===Ie._openCount&&(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.isVisible()&&this.close()}}function He(e={}){const{title:t="",content:i="",html:s=!1,width:n="480px",fullscreen:a=!1,showCancel:r=!0,showConfirm:o=!0,confirmText:l="OK",cancelText:d="Cancel",confirmClass:h="ds-btn--brand",cancelClass:c="ds-btn--ghost",closable:u=!0,maskClosable:p=!0,onConfirm:m,onCancel:g,onOpen:y,onClose:_,footer:f=null}=e,v=document.createElement("div");v.className="ds-modal-container";let w="";null!==f&&("string"==typeof f?w=`<div class="ds-modal__footer">${f}</div>`:(o||r)&&(w=`<div class="ds-modal__footer">\n ${r?`<button class="ds-btn ${c}" data-modal-cancel>${d}</button>`:""}\n ${o?`<button class="ds-btn ${h}" data-modal-confirm>${l}</button>`:""}\n </div>`)),v.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${a?" ds-modal--fullscreen":""}" style="${a?"":"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(v);const b=new Ie(v,{fullscreen:a,closableOnMask:p}),k=v.querySelector(".ds-modal__title");k&&(k.textContent=t);const E=v.querySelector(".ds-modal__body");E&&(s?E.innerHTML=i:E.textContent=i);const x=v.querySelector("[data-modal-confirm]"),C=v.querySelector("[data-modal-cancel]");let S=!1;const L=async()=>{if(m){x.disabled=!0,x.classList.add("is-loading");try{if(!1===await m())return x.disabled=!1,void x.classList.remove("is-loading")}catch(e){return x.disabled=!1,void x.classList.remove("is-loading")}}S=!0,b.close()},D=()=>{g&&g(),b.close()};x&&x.addEventListener("click",L),C&&C.addEventListener("click",D);const M=b.close.bind(b);return b.close=()=>{M(),setTimeout(()=>{x&&x.removeEventListener("click",L),C&&C.removeEventListener("click",D),b.destroy(),v.remove(),_&&_(S)},300)},b.open(),y&&setTimeout(()=>y(),50),b}function Te(e){return"string"==typeof e&&(e={content:e}),He({...e,showCancel:!0,showConfirm:!0})}function Ae(e){return"string"==typeof e&&(e={content:e}),He({...e,showCancel:!1,showConfirm:!0})}function ze(e){if(e.__kupolaInitialized)return;const t=new Ie(e);e.__kupolaInstance=t,e.__kupolaInitialized=!0}function $e(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Pe(){document.querySelectorAll(".ds-modal-container").forEach(e=>{ze(e)})}Ie._openCount=0,"undefined"!=typeof window&&(window.Modal=Ie,window.initModal=ze,window.cleanupModal=$e,window.initModals=Pe,window.createModal=He,window.confirmModal=Te,window.alertModal=Ae,window.kupolaInitializer&&window.kupolaInitializer.register("modal",ze,$e));class qe{static normal(e={}){return this._create({type:"normal",...e})}static success(e={}){return this._create({type:"success",...e})}static warning(e={}){return this._create({type:"warning",...e})}static error(e={}){return this._create({type:"error",...e})}static info(e={}){return this._create({type:"info",...e})}static confirm(e={}){return this._create({type:"confirm",...e})}static _create(e){const{type:t="normal",title:i="",content:s="",onConfirm:n,onCancel:a}=e,r={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},o=document.createElement("div");o.className="ds-modal-container",o.innerHTML=`\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--${t}">${r[t]}</div>\n ${i?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===t||a?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}\n <button class="ds-btn ${"confirm"===t?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>\n ${"confirm"===t?"Confirm":"OK"}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,document.body.appendChild(o),i&&(o.querySelector(".ds-dialog__title").textContent=i),o.querySelector(".ds-dialog__content").textContent=s;const l=o.querySelector(".ds-modal-mask"),d=o.querySelector("[data-dialog-confirm]"),h=o.querySelector("[data-dialog-cancel]"),c=function(e){"Escape"===e.key&&(a&&a(),g())},u=function(e){e.target===l&&(a&&a(),g())},p=function(){n&&n(),g()},m=function(){a&&a(),g()},g=()=>{l.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",c),l.removeEventListener("click",u),d&&d.removeEventListener("click",p),h&&h.removeEventListener("click",m),setTimeout(()=>o.remove(),300)};return l.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",p),h&&h.addEventListener("click",m),l.addEventListener("click",u),document.addEventListener("keydown",c),{close:g}}}"undefined"!=typeof window&&(window.Dialog=qe);const Ne={normal:function(e){this.show({...e,type:"normal"})},success:function(e){this.show({...e,type:"success"})},error:function(e){this.show({...e,type:"error"})},warning:function(e){this.show({...e,type:"warning"})},info:function(e){this.show({...e,type:"info"})},show:function(e){const{title:t,message:i,type:s="normal",duration:n=4e3}=e,a=document.createElement("div");a.className=`ds-notification__item ds-notification__item--${s}`;a.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${s}">${{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>'}[s]}</div>\n <div class="ds-notification__content">\n ${t?'<div class="ds-notification__title"></div>':""}\n ${i?'<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 `,t&&(a.querySelector(".ds-notification__title").textContent=t),i&&(a.querySelector(".ds-notification__message").textContent=i);let r=document.querySelector(".ds-notification");r||(r=document.createElement("div"),r.className="ds-notification",document.body.appendChild(r)),r.appendChild(a),setTimeout(()=>{a.classList.add("is-visible")},10),a.querySelector(".ds-notification__close").addEventListener("click",()=>{a.classList.remove("is-visible"),a.classList.add("is-exiting"),setTimeout(()=>a.remove(),300)}),n>0&&setTimeout(()=>{a.classList.remove("is-visible"),a.classList.add("is-exiting"),setTimeout(()=>a.remove(),300)},n)}};function Fe(){}"undefined"!=typeof window&&(window.Notification=Ne,window.initNotifications=Fe);const Oe={normal:function(e,t={}){this.show(e,"normal",t)},success:function(e,t={}){this.show(e,"success",t)},error:function(e,t={}){this.show(e,"error",t)},warning:function(e,t={}){this.show(e,"warning",t)},info:function(e,t={}){this.show(e,"info",t)},show:function(e,t="normal",i={}){const{duration:s=3e3}=i,n=document.createElement("div");n.className=`ds-message__item ds-message__item--${t}`;n.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${t}">${{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>'}[t]}</div>\n <div class="ds-message__content"></div>\n `,n.querySelector(".ds-message__content").textContent=e;let a=document.querySelector(".ds-message");a||(a=document.createElement("div"),a.className="ds-message",document.body.appendChild(a)),a.appendChild(n),setTimeout(()=>{n.classList.add("is-visible")},10),s>0&&setTimeout(()=>{n.classList.remove("is-visible"),n.classList.add("is-exiting"),setTimeout(()=>n.remove(),300)},s)}};function Be(){}"undefined"!=typeof window&&(window.Message=Oe,window.initMessages=Be);class Re{constructor(e){this.element=e,this.dropzone=e.querySelector(".ds-fileupload__dropzone"),this.input=e.querySelector(".ds-fileupload__input"),this.list=e.querySelector(".ds-fileupload__list"),this.progress=e.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(e.getAttribute("data-max-size"))||0,this.maxCount=parseInt(e.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const e=e=>{e.target===this.input||this.input.contains(e.target)||this.input.click()},t=e=>{const t=Array.from(e.target.files);this.addFiles(t),e.target.value=""},i=e=>{e.preventDefault(),e.stopPropagation(),this.dropzone.classList.add("is-dragging")},s=e=>{e.preventDefault(),e.stopPropagation(),this.dropzone.classList.remove("is-dragging")},n=e=>{e.preventDefault(),e.stopPropagation(),this.dropzone.classList.remove("is-dragging");const t=Array.from(e.dataTransfer.files);this.addFiles(t)};this.dropzone.addEventListener("click",e),this.input.addEventListener("change",t),this.dropzone.addEventListener("dragover",i),this.dropzone.addEventListener("dragleave",s),this.dropzone.addEventListener("drop",n),this._listeners.push({el:this.dropzone,event:"click",handler:e},{el:this.input,event:"change",handler:t},{el:this.dropzone,event:"dragover",handler:i},{el:this.dropzone,event:"dragleave",handler:s},{el:this.dropzone,event:"drop",handler:n})}addFiles(e){e.forEach(e=>{this.maxCount>0&&this.files.length>=this.maxCount?this.showError(`Maximum ${this.maxCount} files allowed`):this.isValidFile(e)&&(this.files.push(e),this.renderFileItem(e),this.showPreview(e))}),this.dispatchChange()}isValidFile(e){const t=this.input.getAttribute("accept");if(t&&""!==t){const i=t.split(",").map(e=>e.trim()),s=e.type,n=e.name.toLowerCase();if(!i.some(e=>e.startsWith(".")?n.endsWith(e):!e.includes("/")||(e.endsWith("/*")?s.startsWith(e.replace("/*","")):s===e)))return this.showError(`File type not allowed: ${e.type}`),!1}return!(this.maxSize>0&&e.size>this.maxSize)||(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1)}renderFileItem(e){const t=document.createElement("div");t.className="ds-fileupload__item",t.dataset.filename=e.name;const i=this.getFileIcon(e.type);t.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(e.name)}</span>\n <span class="ds-fileupload__size">${this.formatSize(e.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 s=t.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(e,t)};s.addEventListener("click",n),this._listeners.push({el:s,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(t)}getFileIcon(e){return e.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>':e.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>':e.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>':e.includes("pdf")||e.includes("document")||e.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>':e.includes("zip")||e.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(e,t=20){if(e.length<=t)return e;const i=e.substring(e.lastIndexOf("."));return e.substring(0,e.lastIndexOf(".")).substring(0,t-i.length-3)+"..."+i}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(1))+" "+["B","KB","MB","GB"][t]}removeFile(e,t){this.files=this.files.filter(t=>t!==e),t&&t.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(e){this.clearError(),this.dropzone.classList.add("is-error");const t=document.createElement("div");t.className="ds-fileupload__error",t.textContent=e,t.setAttribute("role","alert"),t.setAttribute("aria-live","polite"),this.dropzone.appendChild(t),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const e=this.dropzone.querySelector(".ds-fileupload__error");e&&e.remove()}showPreview(e){if(!e.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 t=new FileReader;t.onload=t=>{const i=document.createElement("div");i.className="ds-fileupload__preview-item",i.innerHTML=`\n <img src="${t.target.result}" alt="${e.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 s=i.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(e,this.list?.querySelector(`[data-filename="${e.name}"]`)),i.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),this.preview.appendChild(i)},t.readAsDataURL(e)}updateProgress(e){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 t=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");t.className="ds-fileupload__progress-bar",t.style.width=`${e}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(t),e>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(e){this.updateProgress(0);const t=100;let i=0;Math.max(1,Math.floor(e.size/t));const s=setInterval(()=>{i++;const e=Math.min(100,Math.floor(i/t*100));this.updateProgress(e),i>=t&&(clearInterval(s),this.updateProgress(100))},Math.max(50,Math.floor(50)));return s}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:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function Ve(e){if(e.__kupolaInitialized)return;const t=new Re(e);e.__kupolaInstance=t,e.__kupolaInitialized=!0}function Ke(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function je(){document.querySelectorAll(".ds-fileupload").forEach(e=>{Ve(e)})}"undefined"!=typeof window&&(window.FileUpload=Re,window.initFileUpload=Ve,window.cleanupFileUpload=Ke,window.initFileUploads=je,window.kupolaInitializer&&window.kupolaInitializer.register("fileupload",Ve,Ke));class We{constructor(e,t={}){this.element=e,this.headers=[],this._listeners=[],this.accordion=t.accordion||e.hasAttribute("data-collapse-accordion"),this.animationDuration=t.animationDuration||parseInt(e.getAttribute("data-collapse-duration"))||300,this.disabledItems=t.disabledItems||[],this.defaultExpanded=t.defaultExpanded||[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach((e,t)=>{const i=e.closest(".ds-collapse__item"),s=e.nextElementSibling;if(!i||!s||!s.classList.contains("ds-collapse__content"))return;const n=i.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(t);n&&i.classList.add("is-disabled");let a=i.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(t))&&(a=!0),a?(i.classList.add("is-active"),s.style.height=s.scrollHeight+"px",s.style.overflow="hidden",setTimeout(()=>{i.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible")},this.animationDuration)):(i.classList.remove("is-active"),s.style.height="0",s.style.overflow="hidden");const r=()=>{if(n)return;const e=i.classList.contains("is-active");this.accordion&&!e&&this.headers.forEach((e,i)=>{i!==t&&e.item.classList.contains("is-active")&&this._collapseItem(e)}),e?this._collapseItem({item:i,content:s}):this._expandItem({item:i,content:s}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:t,expanded:!e,item:i},bubbles:!0}))};e.addEventListener("click",r),this.headers.push({header:e,item:i,content:s,clickHandler:r,isDisabled:n}),this._listeners.push({el:e,event:"click",handler:r})})}_expandItem(e){const{item:t,content:i}=e;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",t.classList.add("is-active");const s=()=>{i.removeEventListener("transitionend",s),t.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}_collapseItem(e){const{item:t,content:i}=e;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",t.classList.remove("is-active");const s=()=>{i.removeEventListener("transitionend",s),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}destroy(){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.headers=null,this.element=null}toggle(e){const t=this.headers[e];t&&!t.isDisabled&&t.clickHandler()}expand(e){const t=this.headers[e];!t||t.item.classList.contains("is-active")||t.isDisabled||(this.accordion&&this.headers.forEach((t,i)=>{i!==e&&t.item.classList.contains("is-active")&&this._collapseItem(t)}),this._expandItem(t))}collapse(e){const t=this.headers[e];t&&t.item.classList.contains("is-active")&&this._collapseItem(t)}expandAll(){this.accordion||this.headers.forEach((e,t)=>{e.item.classList.contains("is-active")||e.isDisabled||this._expandItem(e)})}collapseAll(){this.headers.forEach(e=>{e.item.classList.contains("is-active")&&this._collapseItem(e)})}getExpandedIndices(){return this.headers.map((e,t)=>e.item.classList.contains("is-active")?t:-1).filter(e=>e>=0)}disable(e){this.headers[e]&&(this.headers[e].isDisabled=!0,this.headers[e].item.classList.add("is-disabled"))}enable(e){this.headers[e]&&(this.headers[e].isDisabled=!1,this.headers[e].item.classList.remove("is-disabled"))}}function Ue(e,t){if(e.__kupolaInitialized)return;const i=new We(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}function Ye(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Xe(){document.querySelectorAll(".ds-collapse").forEach(e=>{Ue(e)})}"undefined"!=typeof window&&(window.Collapse=We,window.initCollapse=Ue,window.cleanupCollapse=Ye,window.initCollapses=Xe,window.kupolaInitializer&&window.kupolaInitializer.register("collapse",Ue,Ye));class Je{constructor(e,t={}){this.element=e,this.trigger=e.querySelector(".ds-color-picker__trigger"),this.panel=e.querySelector(".ds-color-picker__panel"),this.valueSpan=e.querySelector(".ds-color-picker__value"),this.customInput=e.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=t,this.value=t.value||"#007bff",this.showAlpha=!1!==t.showAlpha,this.mode=t.mode||"hex",this.previousColors=t.previousColors||this._getStoredColors(),this.previousColorsLimit=t.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 e=localStorage.getItem("kupola-color-picker-previous");return e?JSON.parse(e):[]}catch{return[]}}_storeColors(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}_addPreviousColor(e){const t=this.previousColors.indexOf(e);-1!==t&&this.previousColors.splice(t,1),this.previousColors.unshift(e),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this._storeColors(),this._renderPreviousColors()}_colorStringToHSB(e){const t=e.replace(/^#/,""),i=parseInt(t.substring(0,2),16)/255,s=parseInt(t.substring(2,4),16)/255,n=parseInt(t.substring(4,6),16)/255,a=8===t.length?parseInt(t.substring(6,8),16)/255:1,r=Math.max(i,s,n),o=Math.min(i,s,n);let l=0,d=0,h=r;const c=r-o;if(d=0===r?0:c/r,r!==o)switch(r){case i:l=((s-n)/c+(s<n?6:0))/6;break;case s:l=((n-i)/c+2)/6;break;case n:l=((i-s)/c+4)/6}this.hue=Math.round(360*l),this.saturation=Math.round(100*d),this.brightness=Math.round(100*h),this.alpha=Math.round(100*a)}_HSBToColorString(e,t,i,s=1){t/=100,i/=100,s/=100;const n=t=>(t+e/60)%6,a=e=>i*(1-t*Math.max(0,Math.min(n(e),4-n(e),1))),r=Math.round(255*a(5)),o=Math.round(255*a(3)),l=Math.round(255*a(1));if("rgb"===this.mode)return s<1?`rgba(${r}, ${o}, ${l}, ${s.toFixed(2)})`:`rgb(${r}, ${o}, ${l})`;if("hsl"===this.mode)return s<1?`hsla(${e}, ${Math.round(100*t)}%, ${Math.round(100*i)}%, ${s.toFixed(2)})`:`hsl(${e}, ${Math.round(100*t)}%, ${Math.round(100*i)}%)`;const d=`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`;return s<1?d+Math.round(255*s).toString(16).padStart(2,"0"):d}_renderPreviousColors(){const e=this.panel.querySelector(".ds-color-picker__previous");e&&(e.innerHTML="",this.previousColors.forEach(t=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=t,i.setAttribute("data-color",t),i.addEventListener("click",this._colorClickHandler),e.appendChild(i)}))}_renderColorPanel(){const e=this.panel.querySelector(".ds-color-picker__hue"),t=this.panel.querySelector(".ds-color-picker__sv"),i=this.panel.querySelector(".ds-color-picker__alpha");e&&(e.value=this.hue,e.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%))"),t&&(t.style.background=`hsl(${this.hue}, 100%, 50%)`),i&&this.showAlpha&&(i.value=this.alpha,i.style.background=`linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel)return;if(this.element.__kupolaInitialized)return;this._triggerClickHandler=e=>{e.stopPropagation(),this.togglePanel()},this._colorClickHandler=e=>{const t=e.currentTarget.getAttribute("data-color");this.updateColor(t),this.hidePanel()},this._inputInputHandler=e=>{const t=e.target.value;this._isValidColor(t)&&this.updateColor(t)},this._alphaChangeHandler=e=>{this.alpha=parseInt(e.target.value),this._updateFromHSB()},this._modeChangeHandler=e=>{const t=e.currentTarget;this.mode=t.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(e=>e.classList.remove("is-active")),t.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=e=>{this.hue=parseInt(e.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=e=>{const t=e.currentTarget.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top;this.saturation=Math.round(i/t.width*100),this.brightness=Math.round(100*(1-s/t.height)),this._updateFromHSB()},this._documentClickHandler=e=>{this.element.contains(e.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(e=>{e.addEventListener("click",this._colorClickHandler),e._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler);const e=this.panel.querySelector(".ds-color-picker__hue");e&&e.addEventListener("input",this._hueChangeHandler);const t=this.panel.querySelector(".ds-color-picker__sv");t&&(t.addEventListener("click",this._saturationChangeHandler),t.addEventListener("mousemove",e=>{1===e.buttons&&this._saturationChangeHandler(e)}));const i=this.panel.querySelector(".ds-color-picker__alpha");i&&this.showAlpha&&i.addEventListener("input",this._alphaChangeHandler),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(e=>{e.addEventListener("click",this._modeChangeHandler),e.getAttribute("data-mode")===this.mode&&e.classList.add("is-active")}),window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this._renderPreviousColors(),this._renderColorPanel(),this._updateDisplay(),this.element.__kupolaInitialized=!0}_isValidColor(e){const t=(new Option).style;return t.color=e,""!==t.color}_updateFromHSB(){const e=this._HSBToColorString(this.hue,this.saturation,this.brightness,this.alpha);this.value=e,this._updateDisplay(),this._addPreviousColor(e),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(e){this._isValidColor(e)&&(this.value=e,this._colorStringToHSB(e),this._updateDisplay(),this._addPreviousColor(e),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(e){this.updateColor(e)}getValue(){return this.value}setMode(e){"hex"!==e&&"rgb"!==e&&"hsl"!==e||(this.mode=e,this._updateDisplay())}getMode(){return this.mode}setAlpha(e){this.alpha=Math.max(0,Math.min(100,e)),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(e=>{e._colorPickerColorHandler&&e.removeEventListener("click",e._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler);const e=this.panel?.querySelector(".ds-color-picker__hue");e&&this._hueChangeHandler&&e.removeEventListener("input",this._hueChangeHandler);const t=this.panel?.querySelector(".ds-color-picker__sv");t&&this._saturationChangeHandler&&(t.removeEventListener("click",this._saturationChangeHandler),t.removeEventListener("mousemove",this._saturationChangeHandler));const i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this._alphaChangeHandler&&i.removeEventListener("input",this._alphaChangeHandler),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(e=>{e.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 Ge(e,t){const i=new Je(e,t);i.init(),e._kupolaColorPicker=i}function Ze(e=document){e.querySelectorAll(".ds-color-picker").forEach(e=>{Ge(e)})}function Qe(e){e._kupolaColorPicker&&(e._kupolaColorPicker.destroy(),e._kupolaColorPicker=null)}"undefined"!=typeof window&&(window.ColorPicker=Je,window.initColorPicker=Ge,window.initColorPickers=Ze,window.cleanupColorPicker=Qe,window.cleanupAllColorPickers=function(){document.querySelectorAll(".ds-color-picker").forEach(e=>{Qe(e)})},window.kupolaInitializer&&window.kupolaInitializer.register("color-picker",Ge,Qe));class et{constructor(e,t={}){if(this.element=e,this.titleEl=e.querySelector(".ds-calendar__title"),this.daysEl=e.querySelector(".ds-calendar__days"),this.prevBtn=e.querySelector(".ds-calendar__nav--prev"),this.nextBtn=e.querySelector(".ds-calendar__nav--next"),this.todayBtn=e.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=t.selectedDate?new Date(t.selectedDate):null,this.rangeStart=t.rangeStart?new Date(t.rangeStart):null,this.rangeEnd=t.rangeEnd?new Date(t.rangeEnd):null,this.isRangeMode=t.rangeMode||e.hasAttribute("data-calendar-range"),this.viewMode=t.viewMode||e.getAttribute("data-calendar-view")||"month",this.events=t.events||[],this.i18n=t.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=t.onSelect||null,this.onRangeSelect=t.onRangeSelect||null,this.onChange=t.onChange||null,this.onEventClick=t.onEventClick||null,this._init()}_init(){this.render();const e=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()},t=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()},i=()=>{this.currentDate=new Date,this.render(),this._emitChange()};this.prevBtn&&(this.prevBtn.addEventListener("click",e),this._listeners.push({el:this.prevBtn,event:"click",handler:e})),this.nextBtn&&(this.nextBtn.addEventListener("click",t),this._listeners.push({el:this.nextBtn,event:"click",handler:t})),this.todayBtn&&(this.todayBtn.addEventListener("click",i),this._listeners.push({el:this.todayBtn,event:"click",handler:i}))}_emitChange(){const e={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(e),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:e,bubbles:!0}))}_formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}_isSameDay(e,t){return!(!e||!t)&&this._formatDate(e)===this._formatDate(t)}_isDateInRange(e){if(!this.rangeStart||!this.rangeEnd)return!1;const t=this._formatDate(e),i=this._formatDate(this.rangeStart),s=this._formatDate(this.rangeEnd);return t>=i&&t<=s}_isRangeStart(e){return this._isSameDay(e,this.rangeStart)}_isRangeEnd(e){return this._isSameDay(e,this.rangeEnd)}_getEventsForDate(e){const t=this._formatDate(e);return this.events.filter(e=>{const i=e.date||e.start,s=e.end;if(!i)return!1;const n="string"==typeof i?i:this._formatDate(i);if(!s)return n===t;const a="string"==typeof s?s:this._formatDate(s);return t>=n&&t<=a})}render(){const e=this.currentDate.getFullYear(),t=this.currentDate.getMonth();"week"===this.viewMode?this._renderWeekView(e,t):this._renderMonthView(e,t)}_renderMonthView(e,t){this.titleEl.textContent=`${e} ${this.i18n.months[t]}`;const i=new Date(e,t,1).getDay(),s=new Date(e,t+1,0).getDate();this.daysEl.innerHTML="";for(let e=0;e<i;e++){const e=document.createElement("span");e.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(e)}const n=new Date,a=this._formatDate(n);for(let i=1;i<=s;i++){const s=new Date(e,t,i),n=document.createElement("button");n.className="ds-calendar__day",n.textContent=i;const r=this._formatDate(s);r===a&&n.classList.add("is-today"),this._isSameDay(s,this.selectedDate)&&n.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(s)&&n.classList.add("is-range-start"),this._isRangeEnd(s)&&n.classList.add("is-range-end"),this._isDateInRange(s)&&n.classList.add("is-in-range"));const o=this._getEventsForDate(s);if(o.length>0){n.classList.add("has-events");const e=document.createElement("span");e.className="ds-calendar__day-event",e.style.backgroundColor=o[0].color||"#007bff",n.appendChild(e)}const l=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(e=>e.classList.remove("is-selected")),n.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(s,this.rangeEnd)?(this.rangeStart=s,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(s<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=s):this.rangeEnd=s,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=s,this.onSelect&&this.onSelect({date:s,dateStr:r}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:s,dateStr:r},bubbles:!0}))),o.forEach(e=>{this.onEventClick&&this.onEventClick(e,s)}),this.render()};n.addEventListener("click",l),this._listeners.push({el:n,event:"click",handler:l}),this.daysEl.appendChild(n)}}_renderWeekView(e,t){const i=this.currentDate.getDay(),s=new Date(e,t,this.currentDate.getDate()-i+(0===i?-6:1)),n=s,a=new Date(s);a.setDate(s.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${e}`,this.daysEl.innerHTML="";const r=new Date,o=this._formatDate(r);for(let e=0;e<7;e++){const t=new Date(s);t.setDate(s.getDate()+e);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[t.getDay()],i.appendChild(n);const a=document.createElement("span");a.className="ds-calendar__day-number",a.textContent=t.getDate(),i.appendChild(a);const r=this._formatDate(t);r===o&&i.classList.add("is-today"),this._isSameDay(t,this.selectedDate)&&i.classList.add("is-selected");const l=this._getEventsForDate(t);if(l.length>0){const e=document.createElement("span");e.className="ds-calendar__day-events",l.slice(0,3).forEach(t=>{const i=document.createElement("span");i.className="ds-calendar__day-event",i.style.backgroundColor=t.color||"#007bff",e.appendChild(i)}),i.appendChild(e)}const d=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(e=>e.classList.remove("is-selected")),i.classList.add("is-selected"),this.selectedDate=t,this.onSelect&&this.onSelect({date:t,dateStr:r}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:t,dateStr:r},bubbles:!0})),this.render()};i.addEventListener("click",d),this._listeners.push({el:i,event:"click",handler:d}),this.daysEl.appendChild(i)}}destroy(){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(e){this.currentDate=new Date(e),this.render(),this._emitChange()}getDate(){return this.currentDate}setSelectedDate(e){this.selectedDate=e?new Date(e):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(e,t){this.rangeStart=e?new Date(e):null,this.rangeEnd=t?new Date(t):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(e){this.events=e||[],this.render()}addEvent(e){this.events.push(e),this.render()}removeEvent(e){this.events=this.events.filter(t=>t.id!==e),this.render()}setViewMode(e){"month"!==e&&"week"!==e||(this.viewMode=e,this.render(),this._emitChange())}getViewMode(){return this.viewMode}setI18n(e){this.i18n={...this.i18n,...e},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(e){this.currentDate=new Date(e),this.render(),this._emitChange()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this._emitChange()}}function tt(e,t){if(!e.__kupolaInitialized)try{const i=new et(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function it(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function st(){document.querySelectorAll(".ds-calendar").forEach(e=>{tt(e)})}"undefined"!=typeof window&&(window.Calendar=et,window.initCalendar=tt,window.cleanupCalendar=it,window.initCalendars=st,window.kupolaInitializer&&window.kupolaInitializer.register("calendar",tt,it));class nt{constructor(e,t={}){this.element=e,this.input=e.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.maxCount=t.maxCount||parseInt(e.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=!1!==t.allowDuplicates,this.color=t.color||e.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{const t=e.querySelector(".ds-dynamic-tags__remove");if(t){const i=t=>{t.stopPropagation(),e.remove(),this.dispatchChange()};t.addEventListener("click",i),this._listeners.push({el:t,event:"click",handler:i})}}),this.input){const e=()=>{const e=this.input.value.trim();if(!e)return;if(!this.allowDuplicates&&this.hasTag(e))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 t=this.createTag(e);this.element.insertBefore(t,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},t=t=>{"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),e())};this.input.addEventListener("keydown",t),this._listeners.push({el:this.input,event:"keydown",handler:t});const i=()=>{this.input.focus()};this.element.addEventListener("click",i),this._listeners.push({el:this.element,event:"click",handler:i})}}createTag(e){const t=document.createElement("span");t.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(e);t.appendChild(i);const s=document.createElement("button");s.className="ds-dynamic-tags__remove",s.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>',t.appendChild(s);const n=e=>{e.stopPropagation(),t.remove(),this.dispatchChange()};return s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),t}hasTag(e){const t=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of t)if(i.textContent.trim()===e)return!0;return!1}addTag(e,t){if(!e||!this.input)return;if(!this.allowDuplicates&&this.hasTag(e))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(e);if(t){const e=["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"];e.forEach(e=>i.classList.remove(e)),e.includes(`ds-dynamic-tags__tag--${t}`)&&i.classList.add(`ds-dynamic-tags__tag--${t}`)}this.element.insertBefore(i,this.input),this.dispatchChange()}removeTag(e){const t=this.element.querySelectorAll(".ds-dynamic-tags__tag")[e];t&&(t.remove(),this.dispatchChange())}removeTagByValue(e){const t=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of t)if(i.textContent.trim()===e)return i.remove(),void this.dispatchChange()}getTags(){const e=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{e.push(t.textContent.trim())}),e}getTagsWithColor(){const e=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const i=Array.from(t.classList).find(e=>e.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";e.push({value:t.textContent.trim(),color:i})}),e}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{e.remove()}),this.dispatchChange()}setTags(e){this.clearTags(),e.forEach(e=>{"string"==typeof e?this.addTag(e):e&&"object"==typeof e&&e.value&&this.addTag(e.value,e.color)})}setMaxCount(e){this.maxCount=e,this.element.setAttribute("data-dynamic-tags-max",e)}getMaxCount(){return this.maxCount}setAllowDuplicates(e){this.allowDuplicates=e}isAllowDuplicates(){return this.allowDuplicates}setColor(e){["default","primary","success","warning","danger","info"].includes(e)&&(this.color=e,this.element.setAttribute("data-dynamic-tags-color",e))}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:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.input=null,this.element=null}}function at(e,t){if(e.__kupolaInitialized)return;const i=new nt(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}function rt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function ot(){document.querySelectorAll(".ds-dynamic-tags").forEach(e=>{at(e)})}"undefined"!=typeof window&&(window.DynamicTags=nt,window.initDynamicTags=at,window.cleanupDynamicTags=rt,window.initDynamicTagsAll=ot,window.kupolaInitializer&&window.kupolaInitializer.register("dynamic-tags",at,rt));class lt{constructor(e={}){this.images=e.images||[],this.currentIndex=e.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=e.zoomStep||.2,this.minZoom=e.minZoom||.5,this.maxZoom=e.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 e=this.overlay.querySelector(".ds-image-preview__close"),t=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),i=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this._prevHandler=()=>this.prev(),this._nextHandler=()=>this.next(),e.addEventListener("click",this.closeHandler),t.addEventListener("click",this._prevHandler),i.addEventListener("click",this._nextHandler);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(e=>{e.addEventListener("click",t=>{const i=e.getAttribute("data-action");this.handleToolbarAction(i)})});this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",e=>{e.preventDefault(),e.deltaY<0?this.zoomIn():this.zoomOut()},{passive:!1})}handleToolbarAction(e){switch(e){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(e){this.rotation+=e,this.updateTransform()}setRotation(e){this.rotation=e,this.updateTransform()}setZoom(e){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,e)),this.updateTransform()}updateTransform(){const e=this.overlay.querySelector(".ds-image-preview__content img");e&&(e.style.transform=`scale(${this.zoom}) rotate(${this.rotation}deg)`)}handleKeydown(e){if(this.overlay.classList.contains("is-visible"))switch(e.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"+":case"=":e.preventDefault(),this.zoomIn();break;case"-":case"_":e.preventDefault(),this.zoomOut();break;case"0":e.preventDefault(),this.resetZoom();break;case"[":e.preventDefault(),this.rotate(-90);break;case"]":e.preventDefault(),this.rotate(90)}}handleOverlayClick(e){e.target===this.overlay&&this.close()}show(e,t=0){this.images=e,this.currentIndex=Math.min(Math.max(t,0),e.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(e){e>=0&&e<this.images.length&&(this.currentIndex=e,this.resetZoom(),this.render())}render(){const e=this.overlay.querySelector(".ds-image-preview__content img"),t=this.overlay.querySelector(".ds-image-preview__title"),i=this.overlay.querySelector(".ds-image-preview__meta"),s=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),r=this.images[this.currentIndex];e.src=r.src,e.alt=r.alt||"",t.textContent=r.title||"",i.textContent=r.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,a.disabled=this.currentIndex===this.images.length-1,s.innerHTML=this.images.map((e,t)=>`\n <button class="ds-image-preview__indicator${t===this.currentIndex?" is-active":""}" type="button" data-index="${t}" aria-label="Go to image ${t+1}"></button>\n `).join(""),s.querySelectorAll(".ds-image-preview__indicator").forEach(e=>{const t=()=>{this.goTo(parseInt(e.dataset.index))};e.addEventListener("click",t),e._clickHandler=t})}destroy(){this.close();const e=this.overlay?.querySelector(".ds-image-preview__indicators");e&&e.querySelectorAll(".ds-image-preview__indicator").forEach(e=>{e._clickHandler&&e.removeEventListener("click",e._clickHandler)});const t=this.overlay?.querySelector(".ds-image-preview__close"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");t&&t.removeEventListener("click",this.closeHandler),i&&this._prevHandler&&i.removeEventListener("click",this._prevHandler),s&&this._nextHandler&&s.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let dt=null;function ht(){dt||(dt=new lt),document.querySelectorAll("[data-image-preview]").forEach(e=>{e.addEventListener("click",()=>{const t=JSON.parse(e.getAttribute("data-image-preview")),i=parseInt(e.getAttribute("data-image-index"))||0;dt.show(t,i)})})}function ct(e,t=0){dt||(dt=new lt),dt.show(e,t)}"undefined"!=typeof window&&(window.ImagePreview=lt,window.initImagePreview=ht,window.showImagePreview=ct);class ut{constructor(e,t={}){this.element=e,this.closeBtn=e.querySelector(".ds-tag__close"),this.checkbox=e.querySelector(".ds-tag__checkbox"),this.editInput=e.querySelector(".ds-tag__input"),this._listeners=[],this.color=t.color||e.getAttribute("data-tag-color")||"default",this.size=t.size||e.getAttribute("data-tag-size")||"default",this.checkable=t.checkable||e.hasAttribute("data-tag-checkable"),this.checked=t.checked||e.hasAttribute("data-tag-checked"),this.editable=t.editable||e.hasAttribute("data-tag-editable"),this.maxLength=t.maxLength||parseInt(e.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this._applyStyles(),this.closeBtn){const e=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",e),this._listeners.push({el:this.closeBtn,event:"click",handler:e})}if(this.checkable){const e=e=>{e.target!==this.checkbox&&e.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",e),this._listeners.push({el:this.element,event:"click",handler:e}),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 e=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",e),this._listeners.push({el:this.element,event:"dblclick",handler:e}),this.editInput){const e=()=>{this.endEdit()},t=e=>{"Enter"===e.key?this.endEdit():"Escape"===e.key&&this.cancelEdit()};this.editInput.addEventListener("blur",e),this.editInput.addEventListener("keydown",t),this._listeners.push({el:this.editInput,event:"blur",handler:e}),this._listeners.push({el:this.editInput,event:"keydown",handler:t})}}}_applyStyles(){const e=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],t=["ds-tag--default","ds-tag--small","ds-tag--large"];e.forEach(e=>this.element.classList.remove(e)),t.forEach(e=>this.element.classList.remove(e)),e.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),t.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(e){this.editable&&this.editInput&&(this.editInput.value=e);const t=[];this.element.childNodes.forEach(e=>{e.nodeType===Node.TEXT_NODE&&t.push(e)}),t.forEach(e=>e.remove());const i=this.element.querySelector(".ds-tag__close"),s=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),a=i||s||n||null;this.element.insertBefore(document.createTextNode(e),a),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:e},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(e){["default","primary","success","warning","danger","info"].includes(e)&&(this.color=e,this.element.setAttribute("data-tag-color",e),this._applyStyles())}getColor(){return this.color}setSize(e){["default","small","large"].includes(e)&&(this.size=e,this.element.setAttribute("data-tag-size",e),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(e){this.checked=e,this.element.setAttribute("data-tag-checked",e?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=e)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const e=this.getContent();if(this.editInput)this.editInput.value=e;else{const t=document.createElement("input");t.type="text",t.className="ds-tag__input",t.value=e,t.maxLength=this.maxLength,this.editInput=t;const i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(t,i);const s=()=>this.endEdit(),n=e=>{"Enter"===e.key?this.endEdit():"Escape"===e.key&&this.cancelEdit()};t.addEventListener("blur",s),t.addEventListener("keydown",n),this._listeners.push({el:t,event:"blur",handler:s}),this._listeners.push({el:t,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 e=this.editInput.value.trim();this.element.classList.remove("is-editing"),e&&e!==this.getContent()&&(this.setContent(e),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:e},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(e){this.editable=e,e?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this._applyStyles()}isEditable(){return this.editable}setCheckable(e){this.checkable!==e&&(this.destroy(),this.checkable=e,e?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function pt(e,t){if(e.__kupolaInitialized)return;const i=new ut(e,t);e.__kupolaInstance=i,e.__kupolaInitialized=!0}function mt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function gt(){document.querySelectorAll(".ds-tag").forEach(e=>{pt(e)})}"undefined"!=typeof window&&(window.Tag=ut,window.initTag=pt,window.cleanupTag=mt,window.initTags=gt,window.kupolaInitializer&&window.kupolaInitializer.register("tag",pt,mt));class yt{constructor(e){this.element=e,this.valueElement=e.querySelector(".ds-statcard__value"),this.progressFill=e.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(e=>{e.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 e=this.valueElement.textContent,t=e.match(/[\d.,]+/);if(!t)return;const i=parseFloat(t[0].replace(",","")),s=e.substring(0,t.index),n=e.substring(t.index+t[0].length),a=performance.now(),r=e=>{const t=e-a,o=Math.min(t/1500,1),l=1-Math.pow(1-o,3),d=0+(i-0)*l;let h;h=i>=1e6?(d/1e6).toFixed(1)+"M":i>=1e3?(d/1e3).toFixed(1)+"K":Number.isInteger(i)?Math.floor(d).toLocaleString():d.toFixed(2),this.valueElement.textContent=s+h+n,o<1&&requestAnimationFrame(r)};requestAnimationFrame(r)}animateProgress(){if(!this.progressFill)return;const e=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=e}updateValue(e,t={}){if(!this.valueElement)return;const i=t.duration||800,s=this.valueElement.textContent,n=s.match(/[\d.,]+/);if(!n)return void(this.valueElement.textContent=e);const a=s.substring(0,n.index),r=s.substring(n.index+n[0].length),o=parseFloat(n[0].replace(",","")),l=parseFloat(e),d=performance.now(),h=e=>{const t=e-d,s=Math.min(t/i,1),n=1-Math.pow(1-s,3),c=o+(l-o)*n;let u;u=l>=1e6?(c/1e6).toFixed(1)+"M":l>=1e3?(c/1e3).toFixed(1)+"K":Number.isInteger(l)?Math.floor(c).toLocaleString():c.toFixed(2),this.valueElement.textContent=a+u+r,s<1&&requestAnimationFrame(h)};requestAnimationFrame(h)}updateProgress(e,t={}){if(!this.progressFill)return;const i=t.duration||600,s=parseFloat(this.progressFill.style.width||"0"),n=Math.min(Math.max(e,0),100),a=performance.now(),r=e=>{const t=e-a,o=Math.min(t/i,1),l=1-Math.pow(1-o,3),d=s+(n-s)*l;this.progressFill.style.width=d+"%",o<1&&requestAnimationFrame(r)};requestAnimationFrame(r)}setTrend(e,t){const i=this.element.querySelector(".ds-statcard__trend");if(!i)return;i.className=`ds-statcard__trend ds-statcard__trend--${e}`;const s="up"===e?'<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"===e?'<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=s+t}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function _t(e){if(e.__kupolaInitialized)return;const t=new yt(e);e.__kupolaInstance=t,e.__kupolaInitialized=!0}function ft(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function vt(){document.querySelectorAll(".ds-statcard").forEach(e=>{_t(e)})}"undefined"!=typeof window&&(window.StatCard=yt,window.initStatCard=_t,window.cleanupStatCard=ft,window.initStatCards=vt,window.updateStatCard=function(e,t){const i=document.querySelector(e);i&&i.__kupolaInstance&&i.__kupolaInstance.updateValue(t)},window.kupolaInitializer&&window.kupolaInitializer.register("statcard",_t,ft));class wt{constructor(e,t={}){this.element=e,this.data=t.data||[],this.startDate=t.startDate||this.getOneYearAgo(),this.endDate=t.endDate||new Date,this.cellSize=t.cellSize||14,this.onCellClick=t.onCellClick||null,this.tooltip=null,this.baseColor=t.color||e.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const e=new Date;return e.setFullYear(e.getFullYear()-1),e}init(){this.render(),this.createTooltip()}getDataByDate(e){const t=this.formatDate(e),i=this.data.find(e=>e.date===t);return i?i.value:0}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}getLevel(e,t){if(0===e)return 0;t&&0!==t||(t=Math.max(...this.data.map(e=>e.value),1));const i=e/t;return i<.2?1:i<.4?2:i<.6?3:i<.8?4:5}hexToRgb(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:34,g:197,b:94}}getCellColor(e){const t=this.hexToRgb(this.baseColor);if(0===e)return"rgba(0, 0, 0, 0.1)";const i=[.2,.4,.6,.8,1][e-1];return`rgba(${t.r}, ${t.g}, ${t.b}, ${i})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const e=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],t=[];let i=-1;for(let s=new Date(this.startDate);s<=this.endDate;s.setDate(s.getDate()+1)){const n=s.getMonth(),a=s.getDate();n!==i&&1===a&&(t.push({month:n,label:e[n],offset:Math.floor((s-this.startDate)/864e5)}),i=n)}return t}getWeekCount(){let e=0;const t=new Date(this.startDate).getDay();for(let t=new Date(this.startDate);t<=this.endDate;t.setDate(t.getDate()+1))0===t.getDay()&&e++;return 0!==t&&e++,e}render(){const e=this.element.querySelector(".ds-heatmap__body");if(!e)return;e.innerHTML="";const t=[];let i=[];const s=new Date(this.startDate).getDay();for(let e=1;e<s;e++)i.push(null);for(let e=new Date(this.startDate);e<=this.endDate;e.setDate(e.getDate()+1))i.push(new Date(e)),6!==e.getDay()&&e.getTime()!==this.endDate.getTime()||(t.push(i),i=[]);const n=t.length,a=this.element.classList.contains("ds-heatmap--compact")?12:16,r=n*a,o=document.createElement("div");o.className="ds-heatmap__container";const l=document.createElement("div");l.className="ds-heatmap__labels-and-grid";const d=document.createElement("div");d.className="ds-heatmap__weekday-labels";const h=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(e=>{const t=document.createElement("div");t.className="ds-heatmap__weekday-label",t.textContent=e,t.style.height=h+"px",t.style.lineHeight=h+"px",d.appendChild(t)}),l.appendChild(d);const c=document.createElement("div");c.className="ds-heatmap__grid-container";const u=document.createElement("div");u.className="ds-heatmap__month-labels",u.style.width=r+"px";const p=this.getMonthLabels();p.forEach((e,t)=>{const i=document.createElement("div");i.className="ds-heatmap__month-label",i.textContent=e.label;const s=p[t+1];let r;r=s?Math.ceil((s.offset-e.offset)/7):n-Math.floor(e.offset/7),i.style.width=r*a+"px",u.appendChild(i)}),c.appendChild(u);const m=document.createElement("div");m.className="ds-heatmap__grid",t.forEach(e=>{const t=document.createElement("div");t.className="ds-heatmap__week-column",e.forEach(e=>{if(null===e){const e=document.createElement("div");e.className="ds-heatmap__cell",e.style.visibility="hidden",t.appendChild(e)}else{const i=this.getDataByDate(e),s=Math.max(...this.data.map(e=>e.value),1),n=this.getLevel(i,s),a=document.createElement("div");a.className="ds-heatmap__cell",a.dataset.date=this.formatDate(e),a.dataset.value=i,a.style.backgroundColor=this.getCellColor(n);const r=t=>this.showTooltip(t,e,i),o=()=>this.hideTooltip(),l=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(e),value:i})};a.addEventListener("mouseenter",r),a.addEventListener("mouseleave",o),a.addEventListener("click",l),this._listeners.push({el:a,event:"mouseenter",handler:r},{el:a,event:"mouseleave",handler:o},{el:a,event:"click",handler:l}),t.appendChild(a)}}),m.appendChild(t)}),c.appendChild(m),l.appendChild(c),o.appendChild(l),e.appendChild(o),this.renderLegend(e)}renderLegend(e){const t=document.createElement("div");t.className="ds-heatmap__legend";const i=document.createElement("span");i.className="ds-heatmap__legend-label",i.textContent="少";const s=document.createElement("div");s.className="ds-heatmap__legend-cells";for(let e=0;e<=5;e++){const t=document.createElement("div");t.className="ds-heatmap__legend-cell",t.style.backgroundColor=this.getCellColor(e),s.appendChild(t)}const n=document.createElement("span");n.className="ds-heatmap__legend-label",n.textContent="多",t.appendChild(i),t.appendChild(s),t.appendChild(n),e.appendChild(t)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(e,t,i){const s=e.target.getBoundingClientRect();this.tooltip.innerHTML=`\n <div class="ds-heatmap__tooltip-date">${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日</div>\n <div class="ds-heatmap__tooltip-value">${i} contributions</div>\n `,this.tooltip.style.left=Math.min(s.left+s.width/2-75,window.innerWidth-150-16)+"px",this.tooltip.style.top=s.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(e){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=[],this.data=e,this.render()}setDateRange(e,t){this.startDate=e,this.endDate=t,this.render()}destroy(){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function bt(e){if(e.__kupolaInitialized)return;const t=e.getAttribute("data-heatmap-data");let i=[];if(t)try{i=JSON.parse(t)}catch(e){i=xt()}else i=xt();const s=new wt(e,{data:i,onCellClick:e=>{}});e.__kupolaInstance=s,e.__kupolaInitialized=!0}function kt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Et(){document.querySelectorAll(".ds-heatmap").forEach(e=>{bt(e)})}function xt(){const e=[],t=new Date,i=new Date;i.setFullYear(i.getFullYear()-1);for(let s=new Date(i);s<=t;s.setDate(s.getDate()+1)){const t=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),a=0===s.getDay()||6===s.getDay()?20*Math.random():50*Math.random(),r=Math.floor(a);e.push({date:`${t}-${i}-${n}`,value:r>0?r:Math.floor(30*Math.random())+1})}return e}"undefined"!=typeof window&&(window.Heatmap=wt,window.initHeatmap=bt,window.cleanupHeatmap=kt,window.initHeatmaps=Et,window.createHeatmap=function(e,t={}){const i=document.querySelector(e);if(i){const e=t.data||xt();return new wt(i,{data:e,...t})}return null},window.generateMockHeatmapData=xt,window.kupolaInitializer&&window.kupolaInitializer.register("heatmap",bt,kt));class Ct{constructor(e,t={}){this.element=e,this.tooltipEl=null,this.options=t,this.delay=t.delay||parseInt(e.getAttribute("data-tooltip-delay"))||0,this.hideDelay=t.hideDelay||parseInt(e.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=t.trigger||e.getAttribute("data-tooltip-trigger")||"hover",this.html=t.html||e.hasAttribute("data-tooltip-html"),this.theme=t.theme||e.getAttribute("data-tooltip-theme")||"default",this.position=t.position||e.getAttribute("data-tooltip-position")||"top",this.animation=!1!==t.animation,this.mouseFollow=t.mouseFollow||e.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=e=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const t=this.tooltipEl.getBoundingClientRect();let i=e.clientX+10,s=e.clientY+10;const n=window.innerWidth,a=window.innerHeight;i+t.width>n&&(i=e.clientX-t.width-10),s+t.height>a&&(s=e.clientY-t.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${s}px`},"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.mouseFollow&&this.element.addEventListener("mousemove",this._mouseMoveHandler)),"click"===this.trigger&&(this.element.addEventListener("click",this._clickHandler),document.addEventListener("click",e=>{!this.isVisible||this.element.contains(e.target)||this.tooltipEl?.contains(e.target)||this.hide()})),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip)),this.element.__kupolaInitialized=!0)}show(){if(this.isVisible)return;const e=this.element.getAttribute("data-tooltip");e&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.html?this.tooltipEl.innerHTML=e:this.tooltipEl.textContent=e,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 e=this.tooltipEl;setTimeout(()=>{e===this.tooltipEl&&(e.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:e},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}_positionTooltip(){if(!this.tooltipEl)return;const e=this.element.getBoundingClientRect(),t=this.tooltipEl.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight;let n,a;switch(this.position){case"bottom":n=e.left+e.width/2-t.width/2,a=e.bottom+8;break;case"right":n=e.right+8,a=e.top+e.height/2-t.height/2;break;case"left":n=e.left-t.width-8,a=e.top+e.height/2-t.height/2;break;default:n=e.left+e.width/2-t.width/2,a=e.top-t.height-8}n<8&&(n=8),n+t.width>i&&(n=i-t.width-8),a<8&&(a=8),a+t.height>s&&(a=s-t.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${a}px`,this.tooltipEl.style.position="fixed"}updateContent(e,t=!1){this.element.setAttribute("data-tooltip",e),t?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=t,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=e:this.tooltipEl.textContent=e,this._positionTooltip())}setPosition(e){["top","bottom","left","right"].includes(e)&&(this.position=e,this.element.setAttribute("data-tooltip-position",e),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this._positionTooltip()))}setTheme(e){this.theme=e,this.element.setAttribute("data-tooltip-theme",e),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(e){this.delay=e,this.element.setAttribute("data-tooltip-delay",e)}setHideDelay(e){this.hideDelay=e,this.element.setAttribute("data-tooltip-hide-delay",e)}setTrigger(e){["hover","click","focus","manual"].includes(e)&&(this.destroy(),this.trigger=e,this.element.setAttribute("data-tooltip-trigger",e),this.init())}enableMouseFollow(e){this.mouseFollow=e,e?(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),"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("mouseleave",this._hideTooltip)),"click"===this.trigger&&this.element.removeEventListener("click",this._clickHandler),"focus"!==this.trigger&&"hover"!==this.trigger||(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 St(e,t){const i=new Ct(e,t);i.init(),e._kupolaTooltip=i}function Lt(e=document){e.querySelectorAll("[data-tooltip]").forEach(e=>{St(e)})}function Dt(e){e._kupolaTooltip&&(e._kupolaTooltip.destroy(),e._kupolaTooltip=null)}"undefined"!=typeof window&&(window.Tooltip=Ct,window.initTooltip=St,window.initTooltips=Lt,window.cleanupTooltip=Dt,window.kupolaInitializer&&window.kupolaInitializer.register("tooltip",St,Dt));class Mt{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(e,t){this.customValidators[e]=t}addAsyncValidator(e,t){this.customAsyncValidators[e]=t}validate(e){const t=e.id||`form-${Math.random().toString(36).substr(2,9)}`,i={},s=e.querySelectorAll("[data-validate]");let n=!1;return s.forEach(e=>{const t=e.name||e.id,s=this.parseRules(e.getAttribute("data-validate")),a=this.getValue(e);for(const[r,o]of Object.entries(s)){const s=this.customValidators[r]||this.validators[r],l=s?.(a,o);if(!l){i[t]=this.getErrorMessage(r,o,e),this.showError(e,i[t]),n=!0;break}this.clearError(e)}}),this.formStates[t]={valid:!n,errors:i,errorCount:Object.keys(i).length},this.updateFormState(e),!n}getValue(e){if(e.classList.contains("ds-datepicker__input")||e.classList.contains("ds-timepicker__input"))return e.value.trim();if(e.closest(".ds-select")){const t=e.closest(".ds-select"),i=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span");return i?i.textContent.trim():""}if(e.closest(".ds-fileupload")){const t=e.closest(".ds-fileupload").__fileUploadInstance;return t&&t.getFiles().length>0?"has-files":""}return e.value.trim()}validateInput(e){const t=this.parseRules(e.getAttribute("data-validate")),i=this.getValue(e);for(const[s,n]of Object.entries(t)){const t=this.customValidators[s]||this.validators[s],a=t?.(i,n);if(!a)return this.showError(e,this.getErrorMessage(s,n,e)),!1}return this.clearError(e),!0}validateAll(){const e=document.querySelectorAll("form[data-validation]");let t=!0;return e.forEach(e=>{this.validate(e)||(t=!1)}),t}async validateAsync(e,t={}){const i=e.id||`form-${Math.random().toString(36).substr(2,9)}`,s=t.group,n=s?e.querySelectorAll(`[data-validate][data-validate-group="${s}"]`):e.querySelectorAll("[data-validate]");let a=!1;for(const e of n){await this.validateInputAsync(e)||(a=!0)}const r={};return n.forEach(e=>{const t=e.name||e.id,i=e.parentElement.querySelector(".ds-input__error");i&&(r[t]=i.textContent)}),this.formStates[i]={valid:!a,errors:r,errorCount:Object.keys(r).length},this.updateFormState(e),!a}async validateInputAsync(e){const t=this.parseRules(e.getAttribute("data-validate")),i=this.parseRules(e.getAttribute("data-validate-async")||""),s=this.getValue(e);for(const[i,n]of Object.entries(t)){const t=this.customValidators[i]||this.validators[i],a=t?.(s,n);if(!a)return this.showError(e,this.getErrorMessage(i,n,e)),!1}for(const[t,n]of Object.entries(i)){const i=this.customAsyncValidators[t]||this.asyncValidators[t];if(i)try{if(!await i(s,n,e))return this.showError(e,this.getErrorMessage(t,n,e)),!1}catch(t){return this.showError(e,t.message||"Validation error"),!1}}return this.clearError(e),!0}async validateGroup(e,t){const i=e.querySelectorAll(`[data-validate][data-validate-group="${t}"]`);let s=!1;for(const e of i){await this.validateInputAsync(e)||(s=!0)}return!s}getGroups(e){const t=new Set;return e.querySelectorAll("[data-validate-group]").forEach(e=>{t.add(e.getAttribute("data-validate-group"))}),Array.from(t)}getFormState(e){const t=e.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[t]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(e){const t=this.getFormState(e);t.valid?(e.classList.remove("ds-form--invalid"),e.classList.add("ds-form--valid")):(e.classList.remove("ds-form--valid"),e.classList.add("ds-form--invalid")),t.loading?e.classList.add("ds-form--loading"):e.classList.remove("ds-form--loading"),t.submitting?e.classList.add("ds-form--submitting"):e.classList.remove("ds-form--submitting"),t.disabled?(e.classList.add("ds-form--disabled"),e.querySelectorAll("input, select, textarea, button").forEach(e=>e.disabled=!0)):(e.classList.remove("ds-form--disabled"),e.querySelectorAll("input, select, textarea, button").forEach(e=>{e.hasAttribute("data-permanent-disabled")||(e.disabled=!1)}));const i=e.querySelector(".ds-form__status");i&&(t.errorCount>0?(i.textContent=`${t.errorCount} ${1===t.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(e,t){const i=e.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=t,this.updateFormState(e)}setFormSubmitting(e,t){const i=e.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=t,this.updateFormState(e)}setFormDisabled(e,t){const i=e.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=t,this.updateFormState(e)}resetForm(e){const t=e.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[t]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},e.reset(),e.querySelectorAll(".ds-input--error").forEach(e=>{e.classList.remove("ds-input--error");const t=e.parentElement?.querySelector(".ds-input__error");t&&(t.textContent="")}),this.updateFormState(e)}parseRules(e){const t={};return e.split("|").forEach(e=>{const[i,s]=e.split(":");t[i]=s?s.split(","):[]}),t}validateRequired(e){return""!==e}validateEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}validateUrl(e){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(e)}validateMinLength(e,[t]){return e.length>=parseInt(t)}validateMaxLength(e,[t]){return e.length<=parseInt(t)}validatePattern(e,[t]){return new RegExp(t).test(e)}validateMin(e,[t]){return parseFloat(e)>=parseFloat(t)}validateMax(e,[t]){return parseFloat(e)<=parseFloat(t)}validateEqualTo(e,[t]){const i=document.getElementById(t);return i&&e===i.value}validatePhone(e){return/^[\d\s\-\+\(\)]{7,20}$/.test(e)}validateDate(e){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(e)&&!isNaN(Date.parse(e))}validateNumber(e){return!isNaN(parseFloat(e))&&isFinite(e)}showError(e,t){e.classList.add("ds-input--error"),e.classList.remove("ds-input--success"),e.setAttribute("aria-invalid","true");let i=e.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),e.parentElement.appendChild(i)),i.textContent=t,this.removeStatusIcon(e),e.dispatchEvent(new CustomEvent("validation-error",{detail:{message:t}}))}clearError(e){e.classList.remove("ds-input--error"),e.setAttribute("aria-invalid","false");const t=e.parentElement.querySelector(".ds-input__error");t&&t.remove(),e.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(e){e.classList.add("ds-input--success"),e.classList.remove("ds-input--error"),e.setAttribute("aria-invalid","false"),this.removeStatusIcon(e);const t=document.createElement("span");t.className="ds-input__status-icon ds-input__status-icon--success",t.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>',e.parentElement.appendChild(t)}removeStatusIcon(e){const t=e.parentElement.querySelector(".ds-input__status-icon");t&&t.remove()}getErrorMessage(e,t,i){const s=i.getAttribute(`data-message-${e}`);if(s)return s;return{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${t[0]} characters`,maxLength:`Maximum length is ${t[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${t[0]}`,max:`Maximum value is ${t[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"}[e]||"Invalid input"}}const It=new Mt;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(e=>{e.addEventListener("submit",async t=>{const i=e.id||`form-${Math.random().toString(36).substr(2,9)}`;if(It.submitting.has(i))return void t.preventDefault();t.preventDefault();let s;if(s=null!==e.querySelector("[data-validate-async]")?await It.validateAsync(e):It.validate(e),s){It.submitting.add(i);const t=e.querySelector('button[type="submit"]');if(t){const e=t.textContent;t.setAttribute("data-original-text",e),t.textContent="Submitting...",t.disabled=!0}try{const t=e.getAttribute("data-on-submit");t&&window[t]?await window[t](e):e.submit()}finally{It.submitting.delete(i),t&&(t.textContent=t.getAttribute("data-original-text")||"Submit",t.disabled=!1)}}else{const t=e.querySelector(".ds-input--error");t&&t.focus()}}),e.querySelectorAll("[data-validate]").forEach(e=>{e.addEventListener("blur",()=>{setTimeout(()=>{const t=document.activeElement;if(t&&t.closest(".ds-select"))return;It.validateInput(e)&&e.value.trim()&&It.showSuccess(e)},50)});const t=((e,t)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>e.apply(void 0,s),t)}})(()=>{const t=It.getValue(e);if(t.length>0||e.classList.contains("ds-input--error")){It.validateInput(e)&&t&&It.showSuccess(e)}else It.removeStatusIcon(e)},300);e.addEventListener("input",t),e.addEventListener("keyup",t=>{if("Enter"===t.key){It.validateInput(e)&&e.value.trim()&&It.showSuccess(e)}})})})})),"undefined"!=typeof window&&(window.KupolaValidator=Mt,window.kupolaValidator=It);class Ht{constructor(e,t={}){this.element=e,this.data=t.data||[],this.itemHeight=t.itemHeight||48,this.itemWidth=t.itemWidth||200,this.bufferSize=t.bufferSize||5,this.renderItem=t.renderItem||this.defaultRenderItem,this.onItemClick=t.onItemClick||null,this.onItemSelect=t.onItemSelect||null,this.onScroll=t.onScroll||null,this.onScrollEnd=t.onScrollEnd||null,this.selectedKey=t.selectedKey||null,this.keyField=t.keyField||"id",this.useDynamicHeight=t.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=t.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(e,t){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">${e.title||e.name||`Item ${t+1}`}</div>\n <div class="ds-virtual-list__item-subtitle">${e.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._scrollHandler=e=>this.handleScroll(e),this._thumbDragStartHandler=e=>this.handleThumbDragStart(e),this._thumbDragMoveHandler=e=>this.handleThumbDragMove(e),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=e=>{e.preventDefault();this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=e.deltaX+e.deltaY:this.element.scrollTop+=e.deltaY+e.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(e){const t=this.element.classList.contains("ds-virtual-list--horizontal"),i=t?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:i,isHorizontal:t,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 e=this.element.classList.contains("ds-virtual-list--horizontal"),t=e?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:t,isHorizontal:e,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(e){const t=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const t=this.data[e][this.keyField]||e;if(this.dynamicHeightCache.has(t))return this.dynamicHeightCache.get(t)}return t?this.itemWidth:this.itemHeight}getItemPositions(){const e=[];let t=0;return this.data.forEach((i,s)=>{const n=this.getItemSize(s);e.push({start:t,end:t+n,size:n}),t+=n}),e}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((e,t,i)=>e+this.getItemSize(i),0);const e=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*e}getIndexAtOffset(e){if(this.useDynamicHeight){const t=this.getItemPositions();for(let i=0;i<t.length;i++)if(e>=t[i].start&&e<t[i].end)return i;return this.data.length-1}const t=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(e/t)}renderVisibleItems(){const e=this.element.classList.contains("ds-virtual-list--horizontal"),t=e?this.element.scrollLeft:this.element.scrollTop,i=e?this.element.clientWidth:this.element.clientHeight,s=Math.max(0,this.getIndexAtOffset(t)-this.bufferSize);let n=Math.min(this.data.length-1,this.getIndexAtOffset(t+i)+this.bufferSize);n<s&&(n=s),this.startIndex=s,this.endIndex=n;const a=this.data.slice(s,n+1);let r="",o=0;if(this.useDynamicHeight){const e=this.getItemPositions();o=e[s]?.start||0}else{const t=e?this.itemWidth:this.itemHeight;o=s*t}a.forEach((t,i)=>{const n=s+i,a=t[this.keyField]||n,l=this.selectedKey===a,d=this.getItemSize(n),h=o;r+=e?`\n <div \n class="ds-virtual-list__item${l?" is-selected":""}" \n style="position: absolute; top: 0; left: ${h}px; width: ${d}px; height: 100%;"\n data-index="${n}"\n data-key="${a}"\n >\n ${this.renderItem(t,n)}\n </div>\n `:`\n <div \n class="ds-virtual-list__item${l?" is-selected":""}" \n style="position: absolute; top: ${h}px; left: 0; right: 0; height: ${d}px;"\n data-index="${n}"\n data-key="${a}"\n >\n ${this.renderItem(t,n)}\n </div>\n `,o+=d}),this.container.innerHTML=r,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{e.addEventListener("click",()=>this.handleItemClick(e))})}updateDynamicHeights(){if(this.isUpdating)return;let e=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(t=>{const i=parseInt(t.dataset.index),s=this.data[i][this.keyField]||i,n=t.offsetHeight;n!==this.getItemSize(i)&&(this.dynamicHeightCache.set(s,n),e=!0)}),e&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(e){const t=parseInt(e.dataset.index),i=e.dataset.key,s=this.data[t];this.onItemClick&&this.onItemClick({item:s,index:t,key:i}),this.onItemSelect&&this.select(i)}select(e){if(this.selectedKey=e,this.onItemSelect){const t=this.data.findIndex(t=>t[this.keyField]===e);-1!==t&&this.onItemSelect({item:this.data[t],index:t,key:e})}this.renderVisibleItems()}updateScrollbar(){const e=this.element.classList.contains("ds-virtual-list--horizontal"),t=this.getTotalSize(),i=e?this.element.clientWidth:this.element.clientHeight,s=e?this.element.scrollLeft:this.element.scrollTop;if(e)return void(this.scrollbarThumb.style.display="none");const n=Math.max(20,i/t*i),a=s/(t-i||1)*(i-n);this.scrollbarThumb.style.height=n+"px",this.scrollbarThumb.style.top=a+"px"}handleThumbDragStart(e){e.preventDefault(),this.isDragging=!0,this.dragStartY=e.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(e){if(!this.isDragging)return;const t=this.element.clientHeight,i=this.getTotalSize(),s=t-(parseFloat(this.scrollbarThumb.style.height)||t),n=e.clientY-this.dragStartY;let a=this.dragStartTop+n;a=Math.max(0,Math.min(a,s)),this.scrollbarThumb.style.top=a+"px";const r=a/s*(i-t||0);this.element.scrollTop=r}handleThumbDragEnd(){this.isDragging=!1}update(){const e=this.element.classList.contains("ds-virtual-list--horizontal"),t=this.getTotalSize();e?(this.container.style.width=t+"px",this.container.style.height="100%"):(this.container.style.height=t+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(e){this.data=e,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(e){this.data.push(e),this.update()}removeItem(e){this.data.splice(e,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(e,t){this.data.splice(e,0,t),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(e,t="smooth"){const i=this.element.classList.contains("ds-virtual-list--horizontal");let s=0;if(this.useDynamicHeight){const t=this.getItemPositions();s=t[e]?.start||0}else{s=e*(i?this.itemWidth:this.itemHeight)}i?this.element.scrollTo({left:s,behavior:t}):this.element.scrollTo({top:s,behavior:t})}scrollToKey(e,t="smooth"){const i=this.data.findIndex(t=>t[this.keyField]===e);-1!==i&&this.scrollTo(i,t)}scrollToTop(e="smooth"){const t=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[t?"left":"top"]:0,behavior:e})}scrollToBottom(e="smooth"){const t=this.element.classList.contains("ds-virtual-list--horizontal"),i=this.getTotalSize(),s=t?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[t?"left":"top"]:i-s,behavior:e})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((e,t)=>({item:e,index:this.startIndex+t,key:e[this.keyField]||this.startIndex+t}))}getItemIndex(e){return this.data.findIndex(t=>t[this.keyField]===e)}getItem(e){const t=this.getItemIndex(e);return-1!==t?this.data[t]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),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 Tt(e=1e3){const t=[],i=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let s=1;s<=e;s++){const e=Math.floor(Math.random()*i.length),n=Math.floor(1e4*Math.random());t.push({id:s,title:`${i[e]} ${n}`,subtitle:`Last modified ${Math.floor(30*Math.random())} days ago`,type:i[e].toLowerCase()})}return t}function At(e){if(e.__kupolaInitialized)return;const t=e.getAttribute("data-virtual-list");let i=[];if(t)try{i=JSON.parse(t)}catch(e){i=Tt(1e3)}else i=Tt(1e3);const s=new Ht(e,{data:i,onItemClick:e=>{},onItemSelect:e=>{}});e.__kupolaInstance=s,e.__kupolaInitialized=!0}function zt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}"undefined"!=typeof window&&(window.VirtualList=Ht,window.initVirtualList=At,window.cleanupVirtualList=zt,window.initVirtualLists=function(){document.querySelectorAll(".ds-virtual-list").forEach(e=>{At(e)})},window.createVirtualList=function(e,t={}){const i=document.querySelector(e);if(i){const e=t.data||Tt(t.count||1e3);return new Ht(i,{data:e,...t})}return null},window.generateMockVirtualListData=Tt,window.kupolaInitializer&&window.kupolaInitializer.register("virtual-list",At,zt));const $t={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 Pt(e,t=16,i="0 0 24 24"){const s=$t[e];if(!s)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="${t}"`).replace('height="16"',`height="${t}"`).replace('viewBox="0 0 24 24"',`viewBox="${i}"`)}>${s}</svg>`}function qt(e=document){e.querySelectorAll("[data-icon]").forEach(e=>{const t=e.getAttribute("data-icon"),i=+e.getAttribute("data-size")||16,s=e.getAttribute("data-viewbox")||"0 0 24 24";e.innerHTML=Pt(t,i,s),e.classList.add("icon")})}const Nt={svg:Pt,render:qt,PATHS:$t};"undefined"!=typeof window&&(window.Icons=Nt,"loading"!==document.readyState?qt():document.addEventListener("DOMContentLoaded",()=>qt()));class Ft{constructor(e){this.element=e,this.hoursEl=e.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=e.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=e.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const e=this.element.getAttribute("data-end-time");if(e)return new Date(e).getTime();const t=parseInt(this.element.getAttribute("data-hours"))||0,i=parseInt(this.element.getAttribute("data-minutes"))||0,s=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*t+60*i+s)}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 e=(new Date).getTime(),t=this.endTime-e;if(t<=0)return this.stop(),this.displayTime(0,0,0),void this.dispatchComplete();const i=Math.floor(t%864e5/36e5),s=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);this.displayTime(i,s,n)}displayTime(e,t,i){this.hoursEl&&(this.hoursEl.textContent=String(e).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(t).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(i).padStart(2,"0"))}setEndTime(e){this.endTime=e.getTime(),this.update()}addTime(e){this.endTime+=1e3*e,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 Ot(e){if(e.__kupolaInitialized)return;const t=new Ft(e);e.__kupolaInstance=t,e.__kupolaInitialized=!0}function Bt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Rt(){document.querySelectorAll(".ds-countdown").forEach(e=>{Ot(e)})}"undefined"!=typeof window&&(window.Countdown=Ft,window.initCountdown=Ot,window.cleanupCountdown=Bt,window.initCountdowns=Rt,window.kupolaInitializer&&window.kupolaInitializer.register("countdown",Ot,Bt));class Vt{constructor(e){if(this.element=e,this.minusBtn=e.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=e.querySelector(".ds-number-input__btn--increase"),this.inputEl=e.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 e=()=>this.updateValue(-this.step),t=()=>this.updateValue(this.step),i=()=>this.handleInput();this.minusBtn.addEventListener("click",e),this.plusBtn.addEventListener("click",t),this.inputEl.addEventListener("input",i),this._listeners.push({el:this.minusBtn,event:"click",handler:e},{el:this.plusBtn,event:"click",handler:t},{el:this.inputEl,event:"input",handler:i})}updateValue(e){let t=parseInt(this.inputEl.value)||0;t+=e,t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let e=parseInt(this.inputEl.value);isNaN(e)&&(e=0),e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.updateState(),this.dispatchChange()}updateState(){const e=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=e<=this.min,this.plusBtn.disabled=e>=this.max}setValue(e){e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(e,t){this.min=e,this.max=t,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:e,event:t,handler:i})=>{e.removeEventListener(t,i)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Kt(e){if(!e.__kupolaInitialized)try{const t=new Vt(e);e.__kupolaInstance=t,e.__kupolaInitialized=!0}catch(e){console.error("[NumberInput] Error initializing:",e)}}function jt(e){if(!e.__kupolaInitialized||!e.__kupolaInstance)return;e.__kupolaInstance.destroy(),e.__kupolaInstance=null,e.__kupolaInitialized=!1}function Wt(){document.querySelectorAll(".ds-number-input").forEach(e=>{Kt(e)})}"undefined"!=typeof window&&(window.NumberInput=Vt,window.initNumberInput=Kt,window.cleanupNumberInput=jt,window.initNumberInputs=Wt,window.kupolaInitializer&&window.kupolaInitializer.register("number-input",Kt,jt));class Ut{constructor(e){this.container=e,this.track=e.querySelector(".ds-slider-captcha__track"),this.btn=e.querySelector(".ds-slider-captcha__btn"),this.text=e.querySelector(".ds-slider-captcha__text"),this.progress=e.querySelector(".ds-slider-captcha__progress"),this.statusEl=e.querySelector(".ds-slider-captcha__status"),this.refreshBtn=e.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=e.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(e.getAttribute("data-angle"))||30,this.shape=e.getAttribute("data-shape")||"circle",this.hasDistractor="circle"!==this.shape,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=e=>{this.isVerified||this.isProcessing||(e.preventDefault(),this.isDragging=!0,this.startX=e.clientX,this.startY=e.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=e=>{if(!this.isDragging)return;e.preventDefault();const t=this.track.offsetWidth-this.btn.offsetWidth-8;let i=e.clientX-this.startX;i<0&&(i=0),i>t&&(i=t),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/t*100+"%"),this.collectTrack(e.clientX,e.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=e=>{this.isVerified||this.isProcessing||(e.preventDefault(),this.isDragging=!0,this.startX=e.touches[0].clientX,this.startY=e.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=e=>{if(!this.isDragging)return;e.preventDefault();const t=this.track.offsetWidth-this.btn.offsetWidth-8;let i=e.touches[0].clientX-this.startX;i<0&&(i=0),i>t&&(i=t),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/t*100+"%"),this.collectTrack(e.touches[0].clientX,e.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),window.globalEvents?(this._mouseMoveListener=window.globalEvents.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=window.globalEvents.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=window.globalEvents.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=window.globalEvents.on(document,"touchend",this._touchEndHandler,{scope:this.scope})):(document.addEventListener("mousemove",this._mouseMoveHandler),document.addEventListener("mouseup",this._mouseUpHandler),document.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),document.addEventListener("touchend",this._touchEndHandler)),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 e=this.track.offsetWidth,t=this.btn.offsetWidth,i=.35*e,s=.85*e-t,n=.6*e;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-t)),this.distractorX=Math.floor(n+Math.random()*(s-n))):(this.targetX=Math.floor(n+Math.random()*(s-n)),this.distractorX=Math.floor(i+Math.random()*(n-i-t)))}else this.targetX=Math.floor(i+Math.random()*(s-i));const a=this.container.querySelector(".ds-slider-captcha__target");if(a&&(a.style.left=this.targetX+14+t/2+"px",a.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",a.style.display="block"),this.hasDistractor){const e=this.container.querySelector(".ds-slider-captcha__target--distractor");e&&(e.style.left=this.distractorX+14+t/2+"px",e.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",e.style.display="block")}else{const e=this.container.querySelector(".ds-slider-captcha__target--distractor");e&&(e.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(e,t){const i=Date.now()-this.startTime;let s=0,n=0;if(this.trackData.length>0){const e=this.trackData[this.trackData.length-1],t=this.currentX-e.x,a=i-e.t;if(a>0&&(s=t/a,this.trackData.length>1)){const t=this.trackData[this.trackData.length-2],i=e.t-t.t;if(i>0){n=s-(e.x-t.x)/i}}}this.trackData.push({x:this.currentX,y:t-this.startY,t:i,v:s,a:n});const a=this.container.querySelector(".ds-slider-captcha__point-count");a&&(a.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const e=this.trackData[this.trackData.length-1].x,t=this.hasDistractor?Math.abs(e-this.distractorX):1/0,i=Math.abs(e-this.targetX);if(this.hasDistractor&&t<i&&t<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(i>this.config.tolerance)return{passed:!1,msg:"验证失败"};const s=[];for(let e=1;e<this.trackData.length;e++){const t=this.trackData[e].x-this.trackData[e-1].x,i=this.trackData[e].t-this.trackData[e-1].t;i>0&&i<500&&s.push(t/i)}if(s.length<3)return{passed:!1,msg:"验证失败"};if(Math.max(...s)-Math.min(...s)<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let n=!1;for(const e of this.trackData)if(Math.abs(e.y)>2){n=!0;break}if(!n&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const a=this.trackData[this.trackData.length-1].t;if(a<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(a>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const r=[];for(let e=1;e<s.length;e++)r.push(Math.abs(s[e]-s[e-1]));if(r.length>2){if(r.reduce((e,t)=>e+t,0)/r.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 e=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",e.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 t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.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=e.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=e.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 e=this.container.querySelector(".ds-slider-captcha__target");e&&(e.style.display="none");const t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.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 Yt(){document.querySelectorAll(".ds-slider-captcha").forEach(e=>{const t=new Ut(e);t.init(),e._kupolaSlideCaptcha=t})}function Xt(e){e._kupolaSlideCaptcha&&(e._kupolaSlideCaptcha.destroy(),e._kupolaSlideCaptcha=null)}function Jt(){document.querySelectorAll(".ds-slider-captcha").forEach(e=>{Xt(e)})}"undefined"!=typeof window&&(window.SlideCaptcha=Ut,window.initSlideCaptchas=Yt,window.cleanupSlideCaptcha=Xt,window.cleanupAllSlideCaptchas=Jt,window.kupolaInitializer&&window.kupolaInitializer.register("slide-captcha",Yt,Jt));class Gt{constructor(e){this.form=e,this.fields=[],this.validators={},this.errorMessages={},this._init()}_init(){this._setupValidators(),this._collectFields(),this._bindEvents()}_setupValidators(){this.validators={required:e=>"string"==typeof e?""!==e.trim():Array.isArray(e)?e.length>0:null!=e,email:e=>{if(!e)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)},phone:e=>{if(!e)return!0;return/^1[3-9]\d{9}$/.test(e)},url:e=>{if(!e)return!0;try{return new URL(e),!0}catch{return!1}},number:e=>!e||!isNaN(parseFloat(e))&&isFinite(e),minlength:(e,t)=>!e||e.length>=parseInt(t),maxlength:(e,t)=>!e||e.length<=parseInt(t),min:(e,t)=>!e||parseFloat(e)>=parseFloat(t),max:(e,t)=>!e||parseFloat(e)<=parseFloat(t),pattern:(e,t)=>{if(!e)return!0;return new RegExp(t).test(e)},equalTo:(e,t)=>{const i=document.getElementById(t);return!i||e===i.value}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:e=>`至少需要${e}个字符`,maxlength:e=>`最多允许${e}个字符`,min:e=>`最小值为${e}`,max:e=>`最大值为${e}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}_collectFields(){this.form.querySelectorAll("input, select, textarea").forEach(e=>{e.hasAttribute("data-kupola-ignore")||this.fields.push(e)})}_bindEvents(){this.form.addEventListener("submit",e=>{this.validate()||e.preventDefault()}),this.fields.forEach(e=>{e.addEventListener("blur",()=>this.validateField(e)),e.addEventListener("input",()=>this.clearError(e))})}validate(){let e=!0;return this.fields.forEach(t=>{this.validateField(t)||(e=!1)}),e}validateField(e){const t=this._getFieldErrors(e);return t.length>0?(this.showError(e,t[0]),!1):(this.clearError(e),!0)}_getFieldErrors(e){const t=[],i=this._getFieldValue(e);for(const[s,n]of Object.entries(this.validators)){const a=e.getAttribute(`data-${s}`);if(null!==a){if(!n(i,a)){let e=this.errorMessages[s];"function"==typeof e&&(e=e(a)),t.push(e)}}}return t}_getFieldValue(e){const t=e.type;if("checkbox"===t)return e.checked;if("radio"===t){const t=e.name,i=this.form.querySelector(`input[name="${t}"]:checked`);return i?i.value:null}return"select-multiple"===t?Array.from(e.selectedOptions).map(e=>e.value):e.value}showError(e,t){this.clearError(e);const i=document.createElement("span");i.className="ds-form-error",i.textContent=t,e.classList.add("ds-form-field--error");const s=e.parentElement;s.classList.contains("ds-form-field")?s.appendChild(i):e.parentNode.insertBefore(i,e.nextSibling)}clearError(e){e.classList.remove("ds-form-field--error");const t=e.parentElement.querySelector(".ds-form-error");t&&t.remove()}addValidator(e,t,i){this.validators[e]=t,this.errorMessages[e]=i}getData(){const e={};return this.fields.forEach(t=>{const i=t.name;if(!i)return;const s=this._getFieldValue(t);"checkbox"===t.type?(e[i]||(e[i]=[]),t.checked&&e[i].push(t.value)):"radio"===t.type?!e[i]&&t.checked&&(e[i]=t.value):e[i]=s}),e}setData(e){Object.keys(e).forEach(t=>{this.form.querySelectorAll(`[name="${t}"]`).forEach(i=>{const s=i.type;if("checkbox"===s){const s=Array.isArray(e[t])?e[t]:[e[t]];i.checked=s.includes(i.value)}else if("radio"===s)i.checked=i.value===e[t];else if("select-multiple"===s){const s=Array.isArray(e[t])?e[t]:[e[t]];Array.from(i.options).forEach(e=>{e.selected=s.includes(e.value)})}else i.value=e[t]||""})})}reset(){this.form.reset(),this.fields.forEach(e=>this.clearError(e))}destroy(){this.fields.forEach(e=>{e.removeEventListener("blur",()=>this.validateField(e)),e.removeEventListener("input",()=>this.clearError(e))}),this.form.removeEventListener("submit",()=>{}),this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function Zt(e){const t=document.querySelectorAll(e||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const t=new Gt(e);e._kupolaForm=t}),t.length}function Qt(e){return e._kupolaForm}function ei(e){const t=e._kupolaForm;return!!t&&t.validate()}"undefined"!=typeof window&&(window.KupolaForm=Gt,window.initFormValidation=Zt,window.getFormInstance=Qt,window.validateForm=ei,window.kupolaInitializer&&window.kupolaInitializer.register("form-validation",Zt));class ti{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(e,t,i,s={}){const{scope:n=null,once:a=!1,passive:r=!1,capture:o=!1}=s,l=this._generateId(),d={id:l,target:e,eventName:t,handler:i,scope:n,once:a,wrappedHandler:null};d.wrappedHandler=t=>{a&&this.offById(l),i.call(e,t)};const h=this._getEventKey(e,t);return this._listeners.has(h)||this._listeners.set(h,[]),this._listeners.get(h).push(d),n&&(this._scopeListeners.has(n)||this._scopeListeners.set(n,[]),this._scopeListeners.get(n).push(l)),e.addEventListener(t,d.wrappedHandler,{passive:r,capture:o}),{unsubscribe:()=>this.offById(l)}}once(e,t,i,s={}){return this.on(e,t,i,{...s,once:!0})}off(e,t,i){const s=this._getEventKey(e,t);if(!this._listeners.has(s))return;const n=this._listeners.get(s),a=n.filter(e=>e.handler!==i);n.forEach(s=>{s.handler===i&&(e.removeEventListener(t,s.wrappedHandler),this._removeFromScope(s))}),0===a.length?this._listeners.delete(s):this._listeners.set(s,a)}offById(e){for(const[t,i]of this._listeners){const s=i.findIndex(t=>t.id===e);if(-1!==s){const e=i[s];return e.target.removeEventListener(e.eventName,e.wrappedHandler),i.splice(s,1),0===i.length&&this._listeners.delete(t),this._removeFromScope(e),!0}}return!1}offByScope(e){if(!this._scopeListeners.has(e))return;this._scopeListeners.get(e).forEach(e=>{this.offById(e)}),this._scopeListeners.delete(e)}offAll(e,t=null){if(t){const i=this._getEventKey(e,t);if(!this._listeners.has(i))return;this._listeners.get(i).forEach(i=>{e.removeEventListener(t,i.wrappedHandler),this._removeFromScope(i)}),this._listeners.delete(i)}else for(const[t,i]of this._listeners){const[s]=t.split(":");this._getTargetId(e)===s&&(i.forEach(t=>{e.removeEventListener(t.eventName,t.wrappedHandler),this._removeFromScope(t)}),this._listeners.delete(t))}}emit(e,t,i={}){const s=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});return e.dispatchEvent(s),s}emitGlobal(e,t={}){return this.emit(document,e,t)}emitToScope(e,t,i={}){if(!this._scopeListeners.has(e))return;const s=this._scopeListeners.get(e),n=new Set;for(const[e,t]of this._listeners)t.forEach(e=>{s.includes(e.id)&&n.add(e.target)});n.forEach(e=>{this.emit(e,t,i)})}getListenerCount(e,t=null){if(t){const i=this._getEventKey(e,t);return this._listeners.has(i)?this._listeners.get(i).length:0}let i=0;const s=this._getTargetId(e);for(const[e,t]of this._listeners){const[n]=e.split(":");n===s&&(i+=t.length)}return i}getScopeListenerCount(e){return this._scopeListeners.has(e)?this._scopeListeners.get(e).length:0}hasListeners(e,t=null){return this.getListenerCount(e,t)>0}_getEventKey(e,t){return`${this._getTargetId(e)}:${t}`}_getTargetId(e){return e===document?"document":e===window?"window":e===document.body?"body":(e._kupolaId||(e._kupolaId=this._generateId()),e._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(e){if(!e.scope||!this._scopeListeners.has(e.scope))return;const t=this._scopeListeners.get(e.scope),i=t.indexOf(e.id);-1!==i&&(t.splice(i,1),0===t.length&&this._scopeListeners.delete(e.scope))}destroy(){for(const[e,t]of this._listeners)t.forEach(e=>{e.target.removeEventListener(e.eventName,e.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const ii=new ti;function si(e,t,i,s){return ii.on(e,t,i,s)}function ni(e,t,i,s){return ii.once(e,t,i,s)}function ai(e,t,i){ii.off(e,t,i)}function ri(e,t,i){return ii.emit(e,t,i)}function oi(e,t){return ii.emitGlobal(e,t)}function li(e){ii.offByScope(e)}function di(e,t){ii.offAll(e,t)}function hi(e,t){return ii.getListenerCount(e,t)}"undefined"!=typeof window&&(window.GlobalEvents=ti,window.globalEvents=ii,window.kupolaOn=si,window.kupolaOnce=ni,window.kupolaOff=ai,window.kupolaEmit=ri,window.kupolaEmitGlobal=oi,window.kupolaOffByScope=li,window.kupolaOffAll=di,window.kupolaGetListenerCount=hi);class ci{constructor(){this._queue=new Set,this._scheduled=!1}schedule(e){this._queue.add(e),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){const e=Array.from(this._queue);this._queue.clear(),this._scheduled=!1;const t=new Set;for(const i of e)if(!t.has(i)){t.add(i);try{i()}catch(e){console.error("[DependsScheduler]",e)}}}}const ui=new ci;class pi{constructor(e,t){this.data=e,this.createdAt=Date.now(),this.ttl=t}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class mi{constructor(){this._store=new Map}get(e){const t=this._store.get(e);return t||null}set(e,t,i=6e4){this._store.set(e,new pi(t,i))}has(e){return this._store.has(e)}delete(e){this._store.delete(e)}clear(){this._store.clear()}getStale(e){const t=this._store.get(e);return t?t.data:null}}class gi extends Error{constructor(e,t,i){super(e),this.name="DependsError",this.code=t,this.cause=i,this.timestamp=Date.now()}}let yi="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;function _i(e){if(!e||"function"!=typeof e.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");yi=e.fetch.bind(e)}function fi(){return yi}function vi(){yi="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null}class wi{constructor(e,t){this.config=e,this.cacheKey=e.cacheKey||String(e.source),this.staleTime=e.staleTime??6e4,this.cache=t,this.subscribers=[],this.pending=null,this.retryCount=e.retry??0,this.retryDelay=e.retryDelay??1e3,this.onError=e.onError||null}subscribe(e){return this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);t>-1&&this.subscribers.splice(t,1)}}notify(){ui.schedule(()=>{this.subscribers.forEach(e=>{try{e()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(e){throw new gi("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(e){const t=this.cache.get(this.cacheKey);return t&&t.isFresh?t.data:t&&t.isStale?(this._revalidate(e),t.data):this._fetchWithRetry(e)}async _fetchWithRetry(e,t=0){try{const t=await this.fetch(e);return this.cache.set(this.cacheKey,t,this.staleTime),this.notify(),t}catch(i){if(t<this.retryCount){const i=this.retryDelay*Math.pow(2,t);return await new Promise(e=>setTimeout(e,i)),this._fetchWithRetry(e,t+1)}const s=i instanceof gi?i:new gi(i.message||"Fetch failed","FETCH_ERROR",i);if(this.onError)try{this.onError(s)}catch(e){}throw s}}async _revalidate(e){try{await this._fetchWithRetry(e)}catch(e){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class bi extends wi{constructor(e,t){super(e,t),this.method=e.method||"GET",this.headers=e.headers||{},this.queryParams=e.query||{}}async fetch(e){let t=this.config.source;for(const i in e)t=t.replace(`:${i}`,encodeURIComponent(e[i]));const i=[];for(const[e,t]of Object.entries(this.queryParams||{}))i.push(`${encodeURIComponent(e)}=${encodeURIComponent(t)}`);for(const t in e)this.config.source.includes(`:${t}`)||i.push(`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`);i.length>0&&(t+=(t.includes("?")?"&":"?")+i.join("&"));const s={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...this.headers}};["POST","PUT","PATCH"].includes(s.method)&&(s.body=JSON.stringify(e));const n=yi;if(!n)throw new gi("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const a=await n(t,s),r="boolean"==typeof a.ok?a.ok:a.status>=200&&a.status<300,o="number"==typeof a.status?a.status:0;if(!r)throw new gi(`HTTP ${o}`,"HTTP_ERROR");return"function"==typeof a.json?await a.json():void 0!==a.data?a.data:a}}class ki extends wi{constructor(e,t){super(e,t),this.storageKey=e.source.replace("localStorage:",""),this.defaultValue=e.default,this.sync=!1!==e.sync,this.sync&&"undefined"!=typeof window&&(this._storageHandler=e=>{e.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const e=localStorage.getItem(this.storageKey);if(null===e)return this.defaultValue;try{return JSON.parse(e)}catch(t){return e}}catch(e){return this.defaultValue}}setValue(e){const t="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(this.storageKey,t),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class Ei extends wi{constructor(e,t){super(e,t),this.paramName=e.source.replace("route:","")}async fetch(){if("undefined"==typeof window)return"";const e=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));if(e)return decodeURIComponent(e[1]);return new URLSearchParams(location.search).get(this.paramName)||""}}class xi extends wi{async fetch(e){return await this.config.source(e)}}class Ci extends wi{async fetch(){return this.config.source}}class Si extends wi{constructor(e,t){super(e,t),this.ws=null,this.reconnect=!1!==e.reconnect,this.reconnectDelay=e.reconnectDelay||3e3,this.messageHandler=null,this._connected=!1}async fetch(){return new Promise((e,t)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,e(this.cache.getStale(this.cacheKey))},this.messageHandler=e=>{let t;try{t=JSON.parse(e.data)}catch(i){t=e.data}this.cache.set(this.cacheKey,t,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=e=>{this._connected||t(new gi("WebSocket connection failed","WS_ERROR",e))},this.ws.onclose=()=>{this._connected=!1,this.reconnect&&setTimeout(()=>{this.fetch().catch(()=>{})},this.reconnectDelay)}}catch(e){t(new gi("WebSocket creation failed","WS_ERROR",e))}})}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("string"==typeof e?e:JSON.stringify(e))}destroy(){super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Li(e,t){const i=e.source;return"function"==typeof i?new xi(e,t):"string"==typeof i&&(i.startsWith("ws://")||i.startsWith("wss://"))?new Si(e,t):"string"==typeof i&&(i.startsWith("/")||i.startsWith("http"))?new bi(e,t):"string"==typeof i&&i.startsWith("localStorage:")?new ki(e,t):"string"==typeof i&&i.startsWith("route:")?new Ei(e,t):new Ci(e,t)}function Di(e,t){const i={},s=new mi,n=[];for(const a in t){let r=t[a];"string"==typeof r&&(r={source:r});const o=Li({...r,cacheKey:r.cacheKey||`${a}-${JSON.stringify(Ii(e))}`},s),l=y(null),d=y(!0),h=y(null),c=y(null);let u=0;async function p(){const t=++u;d.value=!0,h.value=null;try{const i=await o.getValue(Ii(e));if(t!==u)return;l.value=i,c.value=Date.now()}catch(e){if(t!==u)return;h.value=e.message||"Unknown error"}finally{t===u&&(d.value=!1)}}p();const m=o.subscribe(()=>{const e=s.getStale(o.cacheKey);null!=e&&(l.value=e,c.value=Date.now())});n.push(m);const g=Object.keys(e);g.length>0&&g.forEach(t=>{const i=e[t];if(i&&"object"==typeof i&&"value"in i&&i._subscribers){const e=()=>{o.invalidate(),p()};i._subscribers.add(e),n.push(()=>i._subscribers.delete(e))}}),i[a]={data:l,loading:d,error:h,lastUpdated:c,refresh:()=>(o.invalidate(),p()),setValue(e){o instanceof ki&&(o.setValue(e),l.value=e)},send(e){o instanceof Si&&o.send(e)},_source:o}}return i._dispose=()=>{if(n.forEach(e=>e()),window.__kupolaDepInstances){const e=window.__kupolaDepInstances.indexOf(i);-1!==e&&window.__kupolaDepInstances.splice(e,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(i),i}function Mi(e){const t=new mi,i=Li(e,t),s=y(null),n=y(!0),a=y(null);let r=0;async function o(){const t=++r;n.value=!0,a.value=null;try{const n=await i.getValue(e.params||{});if(t!==r)return;s.value=n}catch(e){if(t!==r)return;a.value=e.message||"Unknown error"}finally{t===r&&(n.value=!1)}}return o(),i.subscribe(()=>{const e=t.getStale(i.cacheKey);null!=e&&(s.value=e)}),{data:s,loading:n,error:a,refresh:()=>(i.invalidate(),o())}}function Ii(e){const t={};for(const i in e){const s=e[i];t[i]=s&&"object"==typeof s&&"value"in s?s.value:s}return t}function Hi(){}"undefined"!=typeof window&&(window.useDeps=Di,window.useQuery=Mi,window.clearCache=Hi,window.DependsError=gi,window.CacheManager=mi,window.Scheduler=ci,window.configureHttpClient=_i,window.getHttpClient=fi,window.resetHttpClient=vi);class Ti{constructor(e,t={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=t,this.columns=(t.columns||[]).map((e,t)=>({...e,_index:t})),this.rowKey=t.rowKey||"id",this._data=[],this._loading=!1,this.striped=!1!==t.striped,this.bordered=t.bordered||!1,this.hoverable=!1!==t.hoverable,this.compact=t.compact||!1,this.emptyText=t.emptyText||"暂无数据",this.loadingText=t.loadingText||"加载中...",this.multiSort=t.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=!1!==t.pagination,this._pageSizes=t.pageSizes||[10,20,50,100],this._pageSize=t.pageSize||10,this._currentPage=1,this._total=0,this.selection=t.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=t.selectionColumnTitle||"",this.expandable=t.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=t.expandColumnTitle||"",this.editable=t.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=t.resizable||!1,this.draggable=t.draggable||!1,this._dragState=null,this.tree=t.tree||null,this._treeExpandedKeys=new Set,t.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=t.virtualScroll||null,this._scrollContainer=null,this.mergeCells=t.mergeCells||null,this.onSort=t.onSort||null,this.onPageChange=t.onPageChange||null,this.onRowClick=t.onRowClick||null,this.onFilter=t.onFilter||null,this.onSelect=t.onSelect||null,this.onExpand=t.onExpand||null,this.onEditSave=t.onEditSave||null,this.onEditCancel=t.onEditCancel||null,this.onRowDragEnd=t.onRowDragEnd||null,this.onColumnResize=t.onColumnResize||null,this.sortKey=y(null),this.sortOrder=y(null),this.currentPage=y(1),this.filterText=y(""),this.selectedKeys=y([]),this._init()}_init(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(e){e&&"object"==typeof e&&"value"in e?(this._data=Array.isArray(e.value)?e.value:[],e._subscribers?.add(e=>{this._data=Array.isArray(e)?e:[],this._total=this._data.length,this.render()})):Array.isArray(e)?this._data=e:this._data=[],this.tree&&this._treeExpandAll&&this._flattenForExpand(this._data),this._total=this._getFlatData(this._data).length,this.render()}setLoading(e){e&&"object"==typeof e&&"value"in e?(this._loading=e.value,e._subscribers?.add(e=>{this._loading=e,this.render()})):this._loading=!!e,this.render()}_flattenForExpand(e,t=0,i=null){const s=this.tree?.childrenKey||"children",n=[];for(const a of e){const e=a[this.rowKey];n.push({...a,_level:t,_parentKey:i,_hasChildren:!(!a[s]||!a[s].length)}),a[s]&&a[s].length&&n.push(...this._flattenForExpand(a[s],t+1,e))}return n}_getFlatData(e){return this.tree?this._flattenVisible(e,0):e}_flattenVisible(e,t){const i=this.tree?.childrenKey||"children",s=[];for(const n of e){const e=n[this.rowKey];s.push({...n,_level:t,_hasChildren:!(!n[i]||!n[i].length)}),n[i]&&n[i].length&&this._treeExpandedKeys.has(e)&&s.push(...this._flattenVisible(n[i],t+1))}return s}getProcessedData(){let e=(this.tree,[...this._data]);if(this._filterText){const t=this._filterText.toLowerCase();e=this.tree?this._filterTree(e,t):e.filter(e=>this.columns.some(i=>{const s=e[i.key];return null!=s&&String(s).toLowerCase().includes(t)}))}this._sorts.length>0&&(e=this.tree?this._sortTree(e):this._sortFlat(e));const t=this.tree?this._flattenVisible(e):e;this._total=t.length;let i=t;if(this._showPagination&&this._pageSize>0){const e=(this._currentPage-1)*this._pageSize;i=t.slice(e,e+this._pageSize)}return i}_filterTree(e,t){const i=this.tree?.childrenKey||"children";return e.reduce((e,s)=>{const n=s[i]?this._filterTree(s[i],t):[];return(this.columns.some(e=>{const i=s[e.key];return null!=i&&String(i).toLowerCase().includes(t)})||n.length>0)&&(e.push({...s,[i]:n}),n.length>0&&this._treeExpandedKeys.add(s[this.rowKey])),e},[])}_sortFlat(e){return[...e].sort((e,t)=>{for(const i of this._sorts){const s=this.columns.find(e=>e.key===i.key);let n=e[i.key],a=t[i.key],r=0;if(r=s?.sorter?s.sorter(n,a,i.order):null==n?1:null==a?-1:"number"==typeof n&&"number"==typeof a?"asc"===i.order?n-a:a-n:"asc"===i.order?String(n).localeCompare(String(a)):String(a).localeCompare(String(n)),0!==r)return r}return 0})}_sortTree(e){const t=this._sortFlat(e),i=this.tree?.childrenKey||"children";return t.map(e=>e[i]?.length?{...e,[i]:this._sortTree(e[i])}:e)}render(){const e=this.getProcessedData(),t=this.element;t.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&t.appendChild(this._renderToolbar());const i=document.createElement("div");i.className="kupola-table-container";const s=document.createElement("table");s.className=this._getTableClass(),s.appendChild(this._renderThead()),this.virtualScroll?s.appendChild(this._renderVirtualTbody(e)):s.appendChild(this._renderTbody(e)),i.appendChild(s),t.appendChild(i),this._showPagination&&this._total>0&&t.appendChild(this._renderPagination()),this.resizable&&this._initColumnResize(),this.draggable&&this._initRowDrag(),this._applyStickyColumns()}_renderThead(){const e=document.createElement("thead"),t=document.createElement("tr");if(this.selection){const e=document.createElement("th");if(e.className="kupola-table-col-selection","checkbox"===this.selection){const t=document.createElement("input");t.type="checkbox";const i=this.getProcessedData().map(e=>e[this.rowKey]);t.checked=i.length>0&&i.every(e=>this._selectedKeys.has(e)),t.addEventListener("change",()=>t.checked?this.selectAll():this.deselectAll()),e.appendChild(t)}t.appendChild(e)}if(this.expandable){const e=document.createElement("th");e.className="kupola-table-col-expand",t.appendChild(e)}return this.columns.forEach(e=>{const i=document.createElement("th");if(i.textContent=e.title||e.key,e.width&&(i.style.width="number"==typeof e.width?e.width+"px":e.width),e.minWidth&&(i.style.minWidth="number"==typeof e.minWidth?e.minWidth+"px":e.minWidth),e.align&&(i.style.textAlign=e.align),e.fixed&&i.setAttribute("data-fixed",e.fixed),e.sortable){i.classList.add("kupola-table-sortable");const t=this._sorts.find(t=>t.key===e.key);t&&i.classList.add(`kupola-table-sort-${t.order}`),i.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const s=document.createElement("span");s.className="kupola-table-sort-icon",s.textContent=t?this.multiSort?` ${this._sorts.indexOf(t)+1}${"asc"===t.order?"▲":"▼"}`:"asc"===t.order?" ▲":" ▼":" ⇅",i.appendChild(s)}if(this.resizable&&e.key!==this.columns[this.columns.length-1]?.key){const t=document.createElement("span");t.className="kupola-table-resize-handle",t.setAttribute("data-col-key",e.key),i.appendChild(t)}t.appendChild(i)}),e.appendChild(t),e}_renderTbody(e){const t=document.createElement("tbody");if(this._loading)t.appendChild(this._renderStatusRow(this.loadingText,"kupola-table-loading"));else if(0===e.length)t.appendChild(this._renderStatusRow(this.emptyText,"kupola-table-empty"));else{const i=this.mergeCells?this.mergeCells(e):[],s=new Map;i.forEach(e=>s.set(`${e.row}-${e.col}`,e));const n=new Set;e.forEach((e,i)=>{const a=e[this.rowKey]??i,r=this._selectedKeys.has(a),o=this._expandedKeys.has(a),l=this._renderDataRow(e,i,a,r,n,s);if(t.appendChild(l),this.expandable&&o){const i=document.createElement("tr");i.className="kupola-table-expand-row";const s=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;s.colSpan=n,s.className="kupola-table-expand-content";const a=this.expandable(e);"string"==typeof a?s.innerHTML=a:a instanceof HTMLElement&&s.appendChild(a),i.appendChild(s),t.appendChild(i)}})}return t}_renderDataRow(e,t,i,s,n,a){const r=document.createElement("tr");if(r.setAttribute("data-row-key",i),s&&r.classList.add("kupola-table-row-selected"),this.draggable&&(r.draggable=!0,r.classList.add("kupola-table-draggable")),this.selection){const e=document.createElement("td");e.className="kupola-table-col-selection";const t=document.createElement("input");t.type=this.selection,t.checked=s,t.addEventListener("change",()=>{"radio"===this.selection?(this._selectedKeys.clear(),this._selectedKeys.add(i)):s?this._selectedKeys.delete(i):this._selectedKeys.add(i),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),e.appendChild(t),r.appendChild(e)}if(this.expandable){const e=document.createElement("td");e.className="kupola-table-col-expand";const t=document.createElement("button");t.className="kupola-table-expand-btn";const s=this._expandedKeys.has(i);t.textContent=s?"▼":"▶",t.type="button",t.addEventListener("click",()=>this._toggleExpand(i)),e.appendChild(t),r.appendChild(e)}return this.columns.forEach((s,o)=>{if(n.has(`${t}-${o}`))return;const l=document.createElement("td");s.align&&(l.style.textAlign=s.align),s.fixed&&(l.setAttribute("data-fixed",s.fixed),l.classList.add(`kupola-table-fixed-${s.fixed}`));const d=a.get(`${t}-${o}`);if(d){d.rowSpan>1&&(l.rowSpan=d.rowSpan),d.colSpan>1&&(l.colSpan=d.colSpan);for(let e=0;e<(d.rowSpan||1);e++)for(let i=0;i<(d.colSpan||1);i++)0===e&&0===i||n.add(`${t+e}-${o+i}`)}if(this.tree&&0===o&&e._level>0){const t=document.createElement("span");if(t.className="kupola-table-tree-indent",t.style.paddingLeft=20*e._level+"px",l.appendChild(t),e._hasChildren){const t=document.createElement("button");t.className="kupola-table-tree-toggle",t.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",t.type="button",t.addEventListener("click",t=>{t.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),l.appendChild(t)}else{const e=document.createElement("span");e.className="kupola-table-tree-toggle-placeholder",l.appendChild(e)}}const h=this._editingCell&&this._editingCell.rowKey===i&&this._editingCell.colKey===s.key;if(h)l.appendChild(this._renderEditCell(s,e));else if(s.render){const i=s.render(e[s.key],e,t);"string"==typeof i?l.innerHTML=i:i instanceof HTMLElement&&l.appendChild(i)}else l.textContent=e[s.key]??"";this.editable&&!h&&!1!==s.editable&&(l.classList.add("kupola-table-editable-cell"),l.addEventListener("dblclick",()=>this._startEdit(i,s.key,e[s.key]))),r.appendChild(l)}),this.onRowClick&&(r.style.cursor="pointer",r.addEventListener("click",i=>{i.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(e,t,i)})),r}_renderStatusRow(e,t){const i=document.createElement("tr"),s=document.createElement("td");return s.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),s.className=t,s.textContent=e,i.appendChild(s),i}_renderVirtualTbody(e){const t=document.createElement("tbody"),{rowHeight:i=40,overscan:s=5}=this.virtualScroll,n=e.length*i;if(this._loading)return this._renderTbody(e);if(0===e.length)return this._renderTbody(e);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",t.appendChild(a),this._virtualData={data:e,rowHeight:i,overscan:s,totalHeight:n,tbody:t,topSpacer:a},this._updateVirtualScroll();const r=document.createElement("tr");r.className="kupola-table-virtual-spacer-bottom",r.style.height="0px",t.appendChild(r);const o=this.element.querySelector(".kupola-table-container");return o&&(o.style.maxHeight=this.virtualScroll.maxHeight||"400px",o.style.overflowY="auto",o.addEventListener("scroll",()=>this._updateVirtualScroll())),t}_updateVirtualScroll(){if(!this._virtualData)return;const{data:e,rowHeight:t,overscan:i,tbody:s,topSpacer:n}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const r=a.scrollTop,o=a.clientHeight,l=Math.max(0,Math.floor(r/t)-i),d=Math.min(e.length,Math.ceil((r+o)/t)+i);s.querySelectorAll(".kupola-table-virtual-row").forEach(e=>e.remove());const h=document.createDocumentFragment();for(let i=l;i<d;i++){const s=e[i],n=s[this.rowKey]??i,a=this._renderDataRow(s,i,n,this._selectedKeys.has(n),new Set,new Map);a.classList.add("kupola-table-virtual-row"),a.style.height=t+"px",h.appendChild(a)}n.style.height=l*t+"px";const c=s.querySelector(".kupola-table-virtual-spacer-bottom");c&&(c.style.height=(e.length-d)*t+"px"),n.after(h)}_renderEditCell(e,t){const i=document.createElement("div");i.className="kupola-table-edit-cell";const s=document.createElement("input");if(s.type=e.editType||"text",s.className="ds-input kupola-table-edit-input",s.value=this._editBuffer[e.key]??t[e.key]??"",e.editOptions){const t=document.createElement("select");t.className="ds-input kupola-table-edit-input",e.editOptions.forEach(e=>{const i=document.createElement("option");i.value="object"==typeof e?e.value:e,i.textContent="object"==typeof e?e.label:e,String(i.value)===String(s.value)&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>{this._editBuffer[e.key]=t.value}),i.appendChild(t)}else s.addEventListener("input",()=>{this._editBuffer[e.key]=s.value}),i.appendChild(s);const n=document.createElement("div");n.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(t,e));const r=document.createElement("button");return r.className="kupola-table-edit-cancel",r.textContent="✗",r.type="button",r.addEventListener("click",()=>this._cancelEdit()),n.appendChild(a),n.appendChild(r),i.appendChild(n),s.addEventListener("keydown",i=>{"Enter"===i.key&&this._saveEdit(t,e),"Escape"===i.key&&this._cancelEdit()}),setTimeout(()=>s.focus?.(),0),i}_startEdit(e,t,i){this._editingCell={rowKey:e,colKey:t},this._editBuffer={[t]:i},this.render()}_saveEdit(e,t){const i=this._editBuffer[t.key];this.onEditSave?this.onEditSave(e,t.key,i,this._data):e[t.key]=i,this._editingCell=null,this._editBuffer={},this.render()}_cancelEdit(){this.onEditCancel&&this.onEditCancel(this._editingCell),this._editingCell=null,this._editBuffer={},this.render()}_handleSort(e){if(this.multiSort){const t=this._sorts.findIndex(t=>t.key===e);if(t>=0){const e=this._sorts[t];"asc"===e.order?e.order="desc":this._sorts.splice(t,1)}else this._sorts.push({key:e,order:"asc"})}else{const t=this._sorts.find(t=>t.key===e);t?"asc"===t.order?t.order="desc":this._sorts=[]:this._sorts=[{key:e,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(e){this._expandedKeys.has(e)?this._expandedKeys.delete(e):this._expandedKeys.add(e),this.onExpand&&this.onExpand(e,this._expandedKeys.has(e)),this.render()}_toggleTreeExpand(e){this._treeExpandedKeys.has(e)?this._treeExpandedKeys.delete(e):this._treeExpandedKeys.add(e),this.render()}selectRow(e){this._selectedKeys.add(e),this._syncSelected(),this.render()}deselectRow(e){this._selectedKeys.delete(e),this._syncSelected(),this.render()}selectAll(){this.getProcessedData().forEach(e=>this._selectedKeys.add(e[this.rowKey])),this._syncSelected(),this.render()}deselectAll(){this._selectedKeys.clear(),this._syncSelected(),this.render()}invertSelection(){this.getProcessedData().forEach(e=>{const t=e[this.rowKey];this._selectedKeys.has(t)?this._selectedKeys.delete(t):this._selectedKeys.add(t)}),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",t=>{t.preventDefault();const i=e.getAttribute("data-col-key"),s=e.parentElement,n=t.clientX,a=s.offsetWidth,r=e=>{const t=Math.max(50,a+(e.clientX-n));s.style.width=t+"px";const r=this.columns.find(e=>e.key===i);r&&(r.width=t),this.onColumnResize&&this.onColumnResize(i,t)},o=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})})}_initRowDrag(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(e=>{e.addEventListener("dragstart",t=>{this._dragState={fromKey:e.getAttribute("data-row-key")},e.classList.add("kupola-table-dragging"),t.dataTransfer.effectAllowed="move"}),e.addEventListener("dragover",t=>{t.preventDefault(),t.dataTransfer.dropEffect="move",e.classList.add("kupola-table-drag-over")}),e.addEventListener("dragleave",()=>e.classList.remove("kupola-table-drag-over")),e.addEventListener("drop",t=>{if(t.preventDefault(),e.classList.remove("kupola-table-drag-over"),!this._dragState)return;const i=e.getAttribute("data-row-key");if(this._dragState.fromKey===i)return;const s=this._data.findIndex(e=>String(e[this.rowKey])===this._dragState.fromKey),n=this._data.findIndex(e=>String(e[this.rowKey])===i);if(s>=0&&n>=0){const[e]=this._data.splice(s,1);this._data.splice(n,0,e),this.onRowDragEnd&&this.onRowDragEnd(e,s,n,this._data),this.render()}}),e.addEventListener("dragend",()=>{e.classList.remove("kupola-table-dragging"),this._dragState=null})})}_applyStickyColumns(){const e=this.columns.filter(e=>"left"===e.fixed);this.selection,this.expandable,e.forEach(e=>{const t=this.element.querySelectorAll('th[data-fixed="left"]'),i=this.element.querySelectorAll('td[data-fixed="left"]'),s=this.columns.indexOf(e);let n=(this.selection?40:0)+(this.expandable?40:0);for(let e=0;e<s;e++)"left"===this.columns[e].fixed&&(n+=this.columns[e]._resolvedWidth||120);t.forEach(t=>{t.textContent.startsWith(e.title||e.key)&&(t.style.position="sticky",t.style.left=n+"px",t.style.zIndex="2",e._resolvedWidth=t.offsetWidth)}),i.forEach(e=>{e.style.position="sticky",e.style.left=n+"px",e.style.zIndex="1",e.style.background="inherit"})});let t=0;[...this.columns].filter(e=>"right"===e.fixed).reverse().forEach(e=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(e=>{e.style.position="sticky",e.style.right=t+"px",e.style.zIndex="1"}),t+=e._resolvedWidth||e.width||120})}_renderToolbar(){const e=document.createElement("div");if(e.className="kupola-table-toolbar",this.options.showFilter){const t=document.createElement("input");let i;t.type="text",t.className="ds-input kupola-table-filter-input",t.placeholder=this.options.filterPlaceholder||"搜索...",t.value=this._filterText,t.addEventListener("input",()=>{clearTimeout(i),i=setTimeout(()=>{this._filterText=t.value,this._currentPage=1,this.filterText.value=this._filterText,this.onFilter&&this.onFilter(this._filterText),this.render()},300)}),e.appendChild(t)}const t=document.createElement("div");if(t.className="kupola-table-toolbar-right",this.selection&&this._selectedKeys.size>0){const e=document.createElement("span");e.className="kupola-table-selection-info",e.textContent=`已选 ${this._selectedKeys.size} 项`,t.appendChild(e);const i=document.createElement("button");i.className="ds-btn ds-btn--sm",i.textContent="反选",i.type="button",i.addEventListener("click",()=>this.invertSelection()),t.appendChild(i)}if(this.options.showExport){const e=document.createElement("button");e.className="ds-btn ds-btn--sm ds-btn--secondary",e.textContent="导出 CSV",e.type="button",e.addEventListener("click",()=>this.exportCSV()),t.appendChild(e)}const i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this._total} 条`,t.appendChild(i),e.appendChild(t),e}_renderPagination(){const e=Math.ceil(this._total/this._pageSize);if(e<=1)return document.createElement("div");const t=document.createElement("div");if(t.className="kupola-table-pagination",this.options.showPageSize){const e=document.createElement("select");e.className="kupola-table-page-size",this._pageSizes.forEach(t=>{const i=document.createElement("option");i.value=t,i.textContent=`${t} 条/页`,t===this._pageSize&&(i.selected=!0),e.appendChild(i)}),e.addEventListener("change",()=>{this._pageSize=parseInt(e.value),this._currentPage=1,this.currentPage.value=1,this.render()}),t.appendChild(e)}const i=document.createElement("div");i.className="kupola-table-pages";const s=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));s.disabled=this._currentPage<=1,i.appendChild(s),this._getPageRange(this._currentPage,e).forEach(e=>{if("..."===e){const e=document.createElement("span");e.className="kupola-table-page-ellipsis",e.textContent="...",i.appendChild(e)}else{const t=this._createPageBtn(e,()=>this._goToPage(e));e===this._currentPage&&t.classList.add("active"),i.appendChild(t)}});const n=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));n.disabled=this._currentPage>=e,i.appendChild(n),t.appendChild(i);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${e}`,t.appendChild(a),t}_createPageBtn(e,t){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=e,i.type="button",i.addEventListener("click",t),i}_goToPage(e){const t=Math.ceil(this._total/this._pageSize);e<1||e>t||(this._currentPage=e,this.currentPage.value=e,this.onPageChange&&this.onPageChange(e,this._pageSize),this.render())}_getPageRange(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);const i=[];if(e<=3){for(let e=1;e<=5;e++)i.push(e);i.push("...",t)}else if(e>=t-2){i.push(1,"...");for(let e=t-4;e<=t;e++)i.push(e)}else{i.push(1,"...");for(let t=e-1;t<=e+1;t++)i.push(t);i.push("...",t)}return i}exportCSV(e="export.csv"){const t=this.getProcessedData(),i=this.columns.map(e=>e.title||e.key),s=t.map(e=>this.columns.map(t=>{let i=e[t.key];return null==i&&(i=""),i=String(i).replace(/"/g,'""'),`"${i}"`}).join(",")),n="\ufeff"+[i.join(","),...s].join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(a),o=document.createElement("a");o.href=r,o.download=e,o.click(),URL.revokeObjectURL(r)}_getTableClass(){const e=["kupola-table"];return this.striped&&e.push("kupola-table-striped"),this.bordered&&e.push("kupola-table-bordered"),this.hoverable&&e.push("kupola-table-hover"),this.compact&&e.push("kupola-table-compact"),e.join(" ")}refresh(){this.render()}getPage(){return{current:this._currentPage,pageSize:this._pageSize,total:this._total}}setColumns(e){this.columns=e.map((e,t)=>({...e,_index:t})),this.render()}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper")}}let Ai=!1;function zi(e,t){return function(){if(Ai||"undefined"==typeof document)return;const e=document.createElement("style");e.textContent="\n .kupola-table-wrapper { width: 100%; }\n .kupola-table-container { overflow-x: auto; }\n .kupola-table { width: 100%; border-collapse: collapse; font-size: 14px; }\n .kupola-table th, .kupola-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #e8e8e8; }\n .kupola-table th { background: #fafafa; font-weight: 600; color: #333; white-space: nowrap; }\n .kupola-table-striped tbody tr:nth-child(even) { background: #fafafa; }\n .kupola-table-hover tbody tr:hover { background: #f0f7ff; }\n .kupola-table-bordered { border: 1px solid #e8e8e8; }\n .kupola-table-bordered th, .kupola-table-bordered td { border: 1px solid #e8e8e8; }\n .kupola-table-compact th, .kupola-table-compact td { padding: 8px 12px; }\n .kupola-table-sortable { cursor: pointer; user-select: none; position: relative; }\n .kupola-table-sortable:hover { background: #f0f0f0; }\n .kupola-table-sort-icon { font-size: 12px; opacity: 0.5; margin-left: 4px; }\n .kupola-table-sort-asc .kupola-table-sort-icon,\n .kupola-table-sort-desc .kupola-table-sort-icon { opacity: 1; color: #1890ff; }\n .kupola-table-empty, .kupola-table-loading { text-align: center; padding: 40px 16px !important; color: #999; }\n .kupola-table-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }\n .kupola-table-toolbar-right { display: flex; align-items: center; gap: 8px; }\n .kupola-table-filter-input { padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; width: 240px; }\n .kupola-table-filter-input:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.1); }\n .kupola-table-info { color: #999; font-size: 13px; }\n .kupola-table-selection-info { color: #1890ff; font-size: 13px; font-weight: 500; }\n .kupola-table-col-selection { width: 40px; text-align: center; }\n .kupola-table-col-expand { width: 40px; text-align: center; }\n .kupola-table-expand-btn { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 6px; color: #666; }\n .kupola-table-expand-btn:hover { color: #1890ff; }\n .kupola-table-expand-row td { background: #fafafa; padding: 16px; }\n .kupola-table-row-selected { background: #e6f7ff !important; }\n .kupola-table-row-selected:hover { background: #bae7ff !important; }\n /* Resize */\n .kupola-table-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; background: transparent; }\n .kupola-table-resize-handle:hover { background: #1890ff; opacity: 0.3; }\n /* Drag */\n .kupola-table-draggable { transition: opacity 0.2s; }\n .kupola-table-dragging { opacity: 0.4; }\n .kupola-table-drag-over { border-top: 2px solid #1890ff !important; }\n /* Edit */\n .kupola-table-editable-cell { cursor: text; }\n .kupola-table-editable-cell:hover { background: #e6f7ff; }\n .kupola-table-edit-cell { display: flex; gap: 4px; align-items: center; }\n .kupola-table-edit-input { flex: 1; padding: 2px 6px; font-size: 13px; }\n .kupola-table-edit-actions { display: flex; gap: 2px; }\n .kupola-table-edit-save, .kupola-table-edit-cancel { background: none; border: 1px solid #d9d9d9; border-radius: 3px; cursor: pointer; padding: 2px 6px; font-size: 12px; }\n .kupola-table-edit-save { color: #52c41a; border-color: #52c41a; }\n .kupola-table-edit-cancel { color: #ff4d4f; border-color: #ff4d4f; }\n .kupola-table-edit-save:hover { background: #f6ffed; }\n .kupola-table-edit-cancel:hover { background: #fff2f0; }\n /* Tree */\n .kupola-table-tree-indent { display: inline-block; }\n .kupola-table-tree-toggle { background: none; border: none; cursor: pointer; font-size: 10px; padding: 0 4px; color: #666; }\n .kupola-table-tree-toggle:hover { color: #1890ff; }\n .kupola-table-tree-toggle-placeholder { display: inline-block; width: 18px; }\n /* Virtual */\n .kupola-table-virtual-wrapper .kupola-table-container { overflow-y: auto; }\n /* Pagination */\n .kupola-table-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; padding: 8px 0; }\n .kupola-table-pages { display: flex; gap: 4px; align-items: center; }\n .kupola-table-page-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; }\n .kupola-table-page-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }\n .kupola-table-page-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }\n .kupola-table-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }\n .kupola-table-page-ellipsis { padding: 0 4px; color: #999; }\n .kupola-table-page-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }\n .kupola-table-page-info { color: #999; font-size: 13px; }\n ",document.head.appendChild(e),Ai=!0}(),new Ti(e,t)}"undefined"!=typeof window&&(window.KupolaTable=Ti,window.initTable=zi);class $i{constructor(e,t={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=t,this._current=t.current||1,this._total=t.total||0,this._pageSize=t.pageSize||10,this._maxPages=t.maxPages||7,this._showTotal=!1!==t.showTotal,this._showSizeChanger=t.showSizeChanger||!1,this._pageSizes=t.pageSizes||[10,20,50,100],this._simple=t.simple||!1,this.current=y(this._current),this.total=y(this._total),this.onChange=t.onChange||null,this.onPageSizeChange=t.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(e){(e=Math.max(1,Math.min(e,this.totalPages)))!==this._current&&(this._current=e,this.current.value=e,this.onChange&&this.onChange(e,this._pageSize),this.render())}setTotal(e){e&&"object"==typeof e&&"value"in e?(this._total=e.value||0,e._subscribers?.add(e=>{this._total=e||0,this._current>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this._total=e,this.total.value=this._total,this.render()}setPageSize(e){this._pageSize=e,this._current=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(e,this._current),this.render()}render(){const e=this.element;e.innerHTML="",this._total<=0||(this._simple?this._renderSimple(e):this._renderFull(e))}_renderSimple(e){const t=this.totalPages,i=this._btn("‹",()=>this.setCurrent(this._current-1));i.disabled=this._current<=1,e.appendChild(i);const s=document.createElement("span");s.className="kupola-pagination-simple-info",s.textContent=`${this._current} / ${t}`,e.appendChild(s);const n=this._btn("›",()=>this.setCurrent(this._current+1));n.disabled=this._current>=t,e.appendChild(n)}_renderFull(e){const t=this.totalPages;if(this._showTotal){const t=document.createElement("span");t.className="kupola-pagination-total",t.textContent=`共 ${this._total} 条`,e.appendChild(t)}if(this._showSizeChanger){const t=document.createElement("select");t.className="kupola-pagination-size",this._pageSizes.forEach(e=>{const i=document.createElement("option");i.value=e,i.textContent=`${e} 条/页`,e===this._pageSize&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>this.setPageSize(parseInt(t.value))),e.appendChild(t)}const i=document.createElement("div");i.className="kupola-pagination-pages";const s=this._btn("‹",()=>this.setCurrent(this._current-1));s.disabled=this._current<=1,i.appendChild(s),this._getPageRange().forEach(e=>{if("..."===e){const e=document.createElement("span");e.className="kupola-pagination-ellipsis",e.textContent="···",i.appendChild(e)}else{const t=this._btn(e,()=>this.setCurrent(e));e===this._current&&t.classList.add("active"),i.appendChild(t)}});const n=this._btn("›",()=>this.setCurrent(this._current+1));if(n.disabled=this._current>=t,i.appendChild(n),e.appendChild(i),t>10){const i=document.createElement("span");i.className="kupola-pagination-jumper",i.innerHTML='跳至 <input type="number" min="1" max="'+t+'" value="'+this._current+'"> 页';const s=i.querySelector("input");s.addEventListener("change",()=>{const e=parseInt(s.value);e>=1&&e<=t&&this.setCurrent(e)}),s.addEventListener("keydown",e=>{if("Enter"===e.key){const e=parseInt(s.value);e>=1&&e<=t&&this.setCurrent(e)}}),e.appendChild(i)}}_btn(e,t){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=e,i.type="button",i.addEventListener("click",t),i}_getPageRange(){const e=this.totalPages,t=this._maxPages;if(e<=t)return Array.from({length:e},(e,t)=>t+1);const i=[],s=Math.floor(t/2);if(this._current<=s+1){for(let e=1;e<=t-2;e++)i.push(e);i.push("...",e)}else if(this._current>=e-s){i.push(1,"...");for(let s=e-t+3;s<=e;s++)i.push(s)}else{i.push(1,"...");for(let e=this._current-s+2;e<=this._current+s-2;e++)i.push(e);i.push("...",e)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let Pi=!1;function qi(e,t){return function(){if(Pi||"undefined"==typeof document)return;const e=document.createElement("style");e.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(e),Pi=!0}(),new $i(e,t)}"undefined"!=typeof window&&(window.KupolaPagination=$i,window.initPagination=qi);let Ni=!1;class Fi extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const e=this.querySelector('[slot="trigger"]'),t=this.querySelectorAll('[slot="item"]'),i=document.createElement("div");i.className="ds-dropdown",i.setAttribute("data-dropdown",""),e&&(e.setAttribute("class",(e.getAttribute("class")||"")+" ds-dropdown__trigger"),i.appendChild(e));const s=document.createElement("div");s.className="ds-dropdown__menu",t.forEach(e=>{e.className="ds-dropdown__item",s.appendChild(e)}),i.appendChild(s),this.innerHTML="",this.appendChild(i)}attributeChangedCallback(e,t,i){if("open"===e){const e=this.querySelector(".ds-dropdown__menu");e&&(e.style.display=null!==i?"block":"")}}}class Oi extends HTMLElement{static get observedAttributes(){return["title","position"]}connectedCallback(){const e=this.firstElementChild;e&&(e.setAttribute("data-title",this.getAttribute("title")||""),this.getAttribute("position")&&e.setAttribute("data-tooltip-position",this.getAttribute("position")))}attributeChangedCallback(e,t,i){if("title"===e){const e=this.firstElementChild;e&&e.setAttribute("data-title",i||"")}}}class Bi extends HTMLElement{connectedCallback(){this._render()}_render(){const e=document.createElement("div");e.className="ds-collapse",e.setAttribute("data-collapse","");this.querySelectorAll("k-collapse-item").forEach(t=>{const i=t.getAttribute("title")||"",s=t.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">${s}</div></div>\n `,e.appendChild(n)}),this.innerHTML="",this.appendChild(e)}}class Ri extends HTMLElement{static get observedAttributes(){return["title"]}}class Vi extends HTMLElement{static get observedAttributes(){return["position","open"]}connectedCallback(){this._render()}_render(){const e=this.getAttribute("position")||"left",t=document.createElement("div");t.className=`ds-drawer ds-drawer--${e}`,t.setAttribute("data-drawer",""),t.innerHTML=this.innerHTML,this.innerHTML="",this.appendChild(t)}attributeChangedCallback(e,t,i){if("open"===e){const e=this.querySelector(".ds-drawer");e&&e.classList.toggle("is-open",null!==i)}}}class Ki extends HTMLElement{static get observedAttributes(){return["title","open"]}connectedCallback(){this._render()}_render(){const e=this.getAttribute("title")||"",t=document.createElement("div");t.className="ds-backdrop",t.style.display="none",t.innerHTML=`\n <div class="ds-dialog">\n <div class="ds-dialog__head">\n <span class="ds-dialog__title">${e}</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=t.querySelector(".ds-dialog__body"),s=this.querySelector('[slot="body"]');s&&i.appendChild(s);const n=t.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&n.appendChild(a);const r=t.querySelector(".ds-dialog__close");r&&r.addEventListener("click",()=>this.close()),t.addEventListener("click",e=>{e.target===t&&this.close()}),this.innerHTML="",this.appendChild(t)}attributeChangedCallback(e,t,i){if("open"===e){const e=this.querySelector(".ds-backdrop");e&&(e.style.display=null!==i?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}function ji(){if(Ni||"undefined"==typeof customElements)return;Ni=!0;const e=[["k-dropdown",Fi],["k-tooltip",Oi],["k-collapse",Bi],["k-collapse-item",Ri],["k-drawer",Vi],["k-modal",Ki]];for(const[t,i]of e)customElements.get(t)||customElements.define(t,i)}"undefined"!=typeof window&&(window.registerWebComponents=ji,window.KupolaDropdownElement=Fi,window.KupolaTooltipElement=Oi,window.KupolaCollapseElement=Bi,window.KupolaDrawerElement=Vi,window.KupolaModalElement=Ki),e.BRAND_OPTIONS=x,e.CacheEntry=pi,e.CacheManager=mi,e.Calendar=et,e.Carousel=ke,e.Collapse=We,e.ColorPicker=Je,e.ComponentInitializerRegistry=T,e.Countdown=Ft,e.Datepicker=he,e.DependsError=gi,e.DependsSource=wi,e.Dialog=qe,e.Drawer=Se,e.Dropdown=te,e.DynamicTags=nt,e.FetchedSource=bi,e.FileUpload=Re,e.FunctionSource=xi,e.GlobalEvents=ti,e.Heatmap=wt,e.Icons=Nt,e.ImagePreview=lt,e.KupolaComponent=$,e.KupolaComponentRegistry=q,e.KupolaDataBind=u,e.KupolaEventBus=g,e.KupolaForm=Gt,e.KupolaI18n=j,e.KupolaLifecycle=t,e.KupolaPagination=$i,e.KupolaStore=p,e.KupolaStoreManager=m,e.KupolaTable=Ti,e.KupolaUtils=r,e.KupolaValidator=Mt,e.Message=Oe,e.Modal=Ie,e.Notification=Ne,e.NumberInput=Vt,e.PATHS=$t,e.RouteSource=Ei,e.Scheduler=ci,e.Select=re,e.SlideCaptcha=Ut,e.Slider=fe,e.StatCard=yt,e.StaticSource=Ci,e.StorageSource=ki,e.Tag=ut,e.Timepicker=me,e.Tooltip=Ct,e.VirtualList=Ht,e.WebSocketSource=Si,e.alertModal=Ae,e.applyMixin=P,e.bootstrapComponents=B,e.cleanupAllDropdowns=ae,e.cleanupAllSlideCaptchas=Jt,e.cleanupCalendar=it,e.cleanupCarousel=Ce,e.cleanupCollapse=Ye,e.cleanupColorPicker=Qe,e.cleanupCountdown=Bt,e.cleanupDatepicker=pe,e.cleanupDrawer=De,e.cleanupDropdown=ne,e.cleanupDynamicTags=rt,e.cleanupFileUpload=Ke,e.cleanupHeatmap=kt,e.cleanupModal=$e,e.cleanupNumberInput=jt,e.cleanupSelect=de,e.cleanupSlideCaptcha=Xt,e.cleanupSlider=we,e.cleanupStatCard=ft,e.cleanupTag=mt,e.cleanupTimepicker=_e,e.cleanupTooltip=Dt,e.cleanupVirtualList=zt,e.clearCache=Hi,e.configureHttpClient=_i,e.confirmModal=Te,e.createBrandPicker=H,e.createI18n=U,e.createLifecycle=a,e.createModal=He,e.createSource=Li,e.createStore=w,e.createThemeToggle=I,e.defineComponent=K,e.defineMixin=R,e.emit=ri,e.emitGlobal=oi,e.formatCurrency=ee,e.formatDate=Z,e.formatNumber=Q,e.getBrand=L,e.getFormInstance=Qt,e.getHttpClient=fi,e.getListenerCount=hi,e.getLocale=G,e.getStore=b,e.getTheme=C,e.globalEvents=ii,e.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(e=>{const t=e.getAttribute("data-kupola-table");let i={};if(t)try{i=JSON.parse(t)}catch(e){}zi(e,i)})},e.initCalendar=tt,e.initCalendars=st,e.initCarousel=Ee,e.initCarousels=xe,e.initCollapse=Ue,e.initCollapses=Xe,e.initColorPicker=Ge,e.initColorPickers=Ze,e.initCountdown=Ot,e.initCountdowns=Rt,e.initDatepicker=ce,e.initDatepickers=ue,e.initDrawer=Le,e.initDrawers=Me,e.initDropdown=ie,e.initDropdowns=se,e.initDynamicTags=at,e.initDynamicTagsAll=ot,e.initFileUpload=Ve,e.initFileUploads=je,e.initFormValidation=Zt,e.initHeatmap=bt,e.initHeatmaps=Et,e.initImagePreview=ht,e.initMessages=Be,e.initModal=ze,e.initModals=Pe,e.initNotifications=Fe,e.initNumberInput=Kt,e.initNumberInputs=Wt,e.initPagination=qi,e.initSelect=oe,e.initSelects=le,e.initSlideCaptchas=Yt,e.initSlider=ve,e.initSliders=be,e.initStatCard=_t,e.initStatCards=vt,e.initTable=zi,e.initTag=pt,e.initTags=gt,e.initTheme=M,e.initTimepicker=ge,e.initTimepickers=ye,e.initTooltip=St,e.initTooltips=Lt,e.initVirtualList=At,e.kupolaBootstrap=N,e.kupolaData=_,e.kupolaEvents=f,e.kupolaI18n=W,e.kupolaInitializer=A,e.kupolaLifecycle=s,e.kupolaStoreManager=v,e.n=X,e.off=ai,e.offAll=di,e.offByScope=li,e.on=si,e.once=ni,e.ref=y,e.registerComponent=F,e.registerLazyComponent=O,e.registerWebComponents=ji,e.renderIcon=qt,e.resetHttpClient=vi,e.setBrand=D,e.setLocale=J,e.setTheme=S,e.showImagePreview=ct,e.svg=Pt,e.t=Y,e.useDeps=Di,e.useMixin=V,e.useQuery=Mi,e.validateForm=ei,e.validator=It});
2
+ //# sourceMappingURL=kupola.min.js.map