@kupola/kupola 1.7.8 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";class t{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(t=>{this.allPhases.push(`before${t.charAt(0).toUpperCase()+t.slice(1)}`),this.allPhases.push(t),this.allPhases.push(`after${t.charAt(0).toUpperCase()+t.slice(1)}`)}),this.allPhases.forEach(t=>{this.hooks.set(t,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this.t=null}i(t){const s=this.transitions.get(this.state);if(!s||!s.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}o(t){this.i(t),this.state=t,this.stateHistory.push(t)}l(t){const s=this.hooks.get(t);s&&s.forEach(t=>{t.resolved=!1})}on(t,s,i={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const e=this.hooks.get(t);return e.push({handler:s,priority:i.priority||0,depends:i.depends||[],name:i.name||s.name||`anonymous_${e.length}`}),e.sort((t,s)=>s.priority-t.priority),()=>{const t=e.findIndex(t=>t.handler===s);t>-1&&e.splice(t,1)}}async u(t,s){if(t&&0!==t.length)for(const i of t){const t=this.hooks.get(s).find(t=>t.name===i);t&&!t.resolved&&(await t.handler(),t.resolved=!0)}}async emit(t,...s){if("destroyed"===this.state&&"error"!==t)return;const i=this.hooks.get(t);if(!i||0===i.length)return;const e=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(e);const n=performance.now();try{for(const n of i){await this.u(n.depends,t);const i=performance.now();let h,o;try{h=n.handler(...s),h instanceof Promise&&await h,n.resolved=!0}catch(i){o=i,"error"!==t&&await this.p({phase:t,hook:n.name,error:i,args:s})}const r=performance.now()-i;this.trace.push({emitId:e,phase:t,hookName:n.name,duration:r,status:o?"error":"success",error:o?o.message:null,timestamp:Date.now()})}performance.now()}finally{this.pendingHooks.delete(e)}}async runPhase(t,...s){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const i=this.phaseStateMap[t];if(i)if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${i.from}`);const e=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,n=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this.l(e),this.l(t),this.l(n),this.allPhases.includes(e)&&await this.emit(e,...s),await this.emit(t,...s),i&&this.o(i.to),this.allPhases.includes(n)&&await this.emit(n,...s)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async m(){return new Promise(t=>{if("complete"===document.readyState||"interactive"===document.readyState)return void t();const s=()=>{document.removeEventListener("DOMContentLoaded",s),window.removeEventListener("load",s),t()};document.addEventListener("DOMContentLoaded",s),window.addEventListener("load",s)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this.m(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(t=>{t.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const s=this.hooks.get(t);return s&&s.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this.t=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",s=>"function"==typeof t?t(s):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async p(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors)return;if(await this.emit("error",t),"function"==typeof this.t)try{await this.t(t)}catch(t){}const s=this.hooks.get("errorBoundary");if(s&&s.length>0)for(const i of s)try{const s=i.handler(t);if(s instanceof Promise&&await s,"handled"===s)return}catch(t){}}}const s=new t("app");const i=new Set(["__proto__","prototype","constructor"]);function e(t){return i.has(t)}const n={trim:function(t){return t?t.trim():""},trimLeft:function(t){return t?t.replace(/^\s+/,""):""},trimRight:function(t){return t?t.replace(/\s+$/,""):""},toUpperCase:function(t){return t?t.toUpperCase():""},toLowerCase:function(t){return t?t.toLowerCase():""},capitalize:function(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""},camelize:function(t){return t?t.replace(/-(\w)/g,(t,s)=>s?s.toUpperCase():""):""},hyphenate:function(t){return t?t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart:function(t,s,i=" "){return(String(t)||"").padStart(s,i)},padEnd:function(t,s,i=" "){return(String(t)||"").padEnd(s,i)},truncate:function(t,s,i="..."){return!t||t.length<=s?t||"":t.slice(0,s)+i},replaceAll:function(t,s,i){return t?t.split(s).join(i):""},format:function(t,s){return t?t.replace(/\{\{(\w+)\}\}/g,(t,i)=>void 0!==s[i]?s[i]:`{{${i}}}`):""},startsWith:function(t,s){return(t||"").startsWith(s)},endsWith:function(t,s){return(t||"").endsWith(s)},includes:function(t,s){return(t||"").includes(s)},repeat:function(t,s){return(t||"").repeat(s)},reverse:function(t){return(t||"").split("").reverse().join("")},countOccurrences:function(t,s){return t&&s?t.split(s).length-1:0},escapeHtml:function(t){if(!t)return"";const s=document.createElement("div");return s.textContent=t,s.innerHTML},unescapeHtml:function(t){if(!t)return"";const s=document.createElement("div");return s.innerHTML=t,s.textContent},generateRandom:function(t=8){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let e=0;e<t;e++)i+=s.charAt(Math.floor(62*Math.random()));return i},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=16*Math.random()|0;return("x"===t?s:3&s|8).toString(16)})}};function h(t){return t?t.reduce((t,s)=>t+(Number(s)||0),0):0}const o={isArray:function(t){return Array.isArray(t)},isEmpty:function(t){return!t||0===t.length},size:function(t){return t?t.length:0},first:function(t,s){return t&&t.length>0?t[0]:s},last:function(t,s){return t&&t.length>0?t[t.length-1]:s},get:function(t,s,i){return t&&void 0!==t[s]?t[s]:i},slice:function(t,s,i){return t?t.slice(s,i):[]},concat:function(...t){return t.reduce((t,s)=>t.concat(s||[]),[])},join:function(t,s=","){return t?t.join(s):""},indexOf:function(t,s,i=0){if(!t)return-1;if(Number.isNaN(s)){for(let s=i;s<t.length;s++)if(Number.isNaN(t[s]))return s;return-1}return t.indexOf(s,i)},lastIndexOf:function(t,s,i){if(!t)return-1;if(Number.isNaN(s)){for(let s=void 0!==i?i:t.length-1;s>=0;s--)if(Number.isNaN(t[s]))return s;return-1}return t.lastIndexOf(s,i)},includes:function(t,s){return!!t&&t.includes(s)},push:function(t,...s){return t&&t.push(...s),t},pop:function(t){return t?t.pop():void 0},shift:function(t){return t?t.shift():void 0},unshift:function(t,...s){return t&&t.unshift(...s),t},remove:function(t,s){if(!t)return t;const i=Number.isNaN(s)?t.findIndex(t=>Number.isNaN(t)):t.indexOf(s);return i>-1&&t.splice(i,1),t},removeAt:function(t,s){return!t||s<0||s>=t.length||t.splice(s,1),t},insert:function(t,s,i){return t?(t.splice(s,0,i),t):t},reverse:function(t){return t?t.slice().reverse():[]},sort:function(t,s){return t?t.slice().sort(s):[]},sortBy:function(t,s,i="asc"){return t?t.slice().sort((t,e)=>{const n="object"==typeof t?t[s]:t,h="object"==typeof e?e[s]:e;return n<h?"asc"===i?-1:1:n>h?"asc"===i?1:-1:0}):[]},filter:function(t,s){return t?t.filter(s):[]},map:function(t,s){return t?t.map(s):[]},reduce:function(t,s,i){return t?t.reduce(s,i):i},forEach:function(t,s){t&&t.forEach(s)},every:function(t,s){return!t||t.every(s)},some:function(t,s){return!!t&&t.some(s)},find:function(t,s){return t?t.find(s):void 0},findIndex:function(t,s){return t?t.findIndex(s):-1},flat:function(t,s=1){return t?t.flat(s):[]},flattenDeep:function t(s){return s?s.reduce((s,i)=>Array.isArray(i)?s.concat(t(i)):s.concat(i),[]):[]},unique:function(t){return t?[...new Set(t)]:[]},uniqueBy:function(t,s){if(!t)return[];const i=new Set;return t.filter(t=>{const e="object"==typeof t?t[s]:t;return!i.has(e)&&(i.add(e),!0)})},chunk:function(t,s){if(!t||s<=0)return[];const i=[];for(let e=0;e<t.length;e+=s)i.push(t.slice(e,e+s));return i},shuffle:function(t){if(!t)return[];const s=t.slice();for(let t=s.length-1;t>0;t--){const i=Math.floor(Math.random()*(t+1));[s[t],s[i]]=[s[i],s[t]]}return s},sum:h,average:function(t){return t&&0!==t.length?h(t)/t.length:0},max:function(t){return t&&t.length>0?Math.max(...t):-1/0},min:function(t){return t&&t.length>0?Math.min(...t):1/0},intersection:function(...t){return 0===t.length?[]:t.reduce((t,s)=>t.filter(t=>s&&s.includes(t)))},union:function(...t){return[...new Set(t.flat().filter(Boolean))]},difference:function(t,s){return t?t.filter(t=>!s||!s.includes(t)):[]},zip:function(...t){if(0===t.length)return[];const s=Math.max(...t.map(t=>t?t.length:0));return Array.from({length:s},(s,i)=>t.map(t=>t&&t[i]))}};function r(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}const a={isObject:r,isEmpty:function(t){return!t||"object"!=typeof t||0===Object.keys(t).length},keys:function(t){return t?Object.keys(t):[]},values:function(t){return t?Object.values(t):[]},entries:function(t){return t?Object.entries(t):[]},has:function(t,s){return!!t&&Object.prototype.hasOwnProperty.call(t,s)},get:function(t,s,i){if(!t)return i;const n=s.split(".");return n.some(e)?i:n.reduce((t,s)=>t&&t[s],t)??i},set:function(t,s,i){if(!t||"object"!=typeof t)return t;const n=s.split(".");if(n.some(e))return t;const h=n.pop();let o=t;return n.forEach(t=>{o[t]&&"object"==typeof o[t]||(o[t]={}),o=o[t]}),o[h]=i,t},pick:function(t,s){return t?s.reduce((s,i)=>(void 0!==t[i]&&(s[i]=t[i]),s),{}):{}},omit:function(t,s){return t?Object.keys(t).reduce((i,e)=>(s.includes(e)||(i[e]=t[e]),i),{}):{}},merge:function t(...s){return s.reduce((s,i)=>(i&&"object"==typeof i&&Object.keys(i).forEach(n=>{e(n)||(r(i[n])&&r(s[n])?s[n]=t(s[n],i[n]):s[n]=i[n])}),s),{})},clone:function(t){return t?JSON.parse(JSON.stringify(t)):t},deepClone:function t(s,i=new WeakMap){if(!s||"object"!=typeof s)return s;if(i.has(s))return i.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const e=new Map;return i.set(s,e),s.forEach((s,n)=>e.set(n,t(s,i))),e}if(s instanceof Set){const e=new Set;return i.set(s,e),s.forEach(s=>e.add(t(s,i))),e}if(Array.isArray(s)){const e=[];return i.set(s,e),s.forEach(s=>e.push(t(s,i))),e}const n={};return i.set(s,n),Object.keys(s).forEach(h=>{e(h)||(n[h]=t(s[h],i))}),n},forEach:function(t,s){t&&Object.keys(t).forEach(i=>s(t[i],i,t))},map:function(t,s){if(!t)return{};const i={};return Object.keys(t).forEach(e=>{i[e]=s(t[e],e,t)}),i},filter:function(t,s){if(!t)return{};const i={};return Object.keys(t).forEach(e=>{s(t[e],e,t)&&(i[e]=t[e])}),i},reduce:function(t,s,i){return t?Object.keys(t).reduce((i,e)=>s(i,t[e],e,t),i):i},toArray:function(t){return t?Object.keys(t).map(s=>({key:s,value:t[s]})):[]},fromArray:function(t,s,i){return t?t.reduce((t,e)=>{const n="object"==typeof e?e[s]:e,h=i?e[i]:e;return void 0!==n&&(t[n]=h),t},{}):{}},size:function(t){return t?Object.keys(t).length:0},invert:function(t){if(!t)return{};const s={};return Object.keys(t).forEach(i=>{s[t[i]]=i}),s},isEqual:function t(s,i){if(s===i)return!0;if(!s||!i||"object"!=typeof s||"object"!=typeof i)return!1;const e=Object.keys(s),n=Object.keys(i);return e.length===n.length&&e.every(e=>t(s[e],i[e]))},freeze:function t(s){return s?(Object.freeze(s),Object.keys(s).forEach(i=>{"object"==typeof s[i]&&t(s[i])}),s):s},seal:function(t){return t?Object.seal(t):t}};function c(t){return"number"==typeof t&&!isNaN(t)}function l(...t){return t.flat().filter(c).reduce((t,s)=>t+s,0)}function d(t=0,s=1){return Math.random()*(s-t)+t}const u={isNumber:c,isInteger:function(t){return Number.isInteger(t)},isFloat:function(t){return c(t)&&!Number.isInteger(t)},isPositive:function(t){return c(t)&&t>0},isNegative:function(t){return c(t)&&t<0},isZero:function(t){return c(t)&&0===t},clamp:function(t,s,i){return c(t)?Math.min(Math.max(t,s),i):t},round:function(t,s=0){if(!c(t))return t;const i=Math.pow(10,s);return Math.round(t*i)/i},floor:function(t){return c(t)?Math.floor(t):t},ceil:function(t){return c(t)?Math.ceil(t):t},abs:function(t){return c(t)?Math.abs(t):t},min:function(...t){const s=t.filter(c);return s.length>0?Math.min(...s):void 0},max:function(...t){const s=t.filter(c);return s.length>0?Math.max(...s):void 0},sum:l,average:function(...t){const s=t.flat().filter(c);return s.length>0?l(s)/s.length:0},random:d,randomInt:function(t,s){return Math.floor(d(t,s+1))},format:function(t,s=2){return c(t)?t.toFixed(s):String(t)},formatCurrency:function(t,s="CNY",i=2){return c(t)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:s,minimumFractionDigits:i,maximumFractionDigits:i}).format(t):String(t)},formatPercent:function(t,s=0){return c(t)?`${(100*t).toFixed(s)}%`:String(t)},toFixed:function(t,s=0){return c(t)?t.toFixed(s):String(t)},toPrecision:function(t,s=6){return c(t)?t.toPrecision(s):String(t)},isNaN:function(t){return Number.isNaN(t)},isFinite:function(t){return Number.isFinite(t)},parseInt:function(t,s=10){return Number.parseInt(t,s)},parseFloat:function(t){return Number.parseFloat(t)},toNumber:function(t,s=0){const i=Number(t);return isNaN(i)?s:i},safeDivide:function(t,s,i=0){return c(t)&&c(s)&&0!==s?t/s:i},safeMultiply:function(...t){return t.reduce((t,s)=>c(t)&&c(s)?t*s:0,1)}};function p(){return Date.now()}function f(){const t=new Date;return t.setHours(0,0,0,0),t}function m(t){return t instanceof Date&&!isNaN(t.getTime())}function g(t){return m(t)}function _(t,s){if(!m(t)||!m(s))return 0;const i=new Date(t);i.setHours(0,0,0,0);const e=new Date(s);return e.setHours(0,0,0,0),Math.floor((i.getTime()-e.getTime())/864e5)}function b(t,s=1){if(!m(t))return t;const i=new Date(t),e=i.getDay(),n=e>=s?e-s:e+(7-s);return i.setDate(i.getDate()-n),i.setHours(0,0,0,0),i}const v={now:p,today:f,tomorrow:function(){const t=f();return t.setDate(t.getDate()+1),t},yesterday:function(){const t=f();return t.setDate(t.getDate()-1),t},isDate:m,isValid:g,parse:function(t){const s=new Date(t);return g(s)?s:null},format:function(t,s="YYYY-MM-DD HH:mm:ss"){if(!m(t))return"";const i=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),h=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0"),a=String(t.getMilliseconds()).padStart(3,"0"),c=["日","一","二","三","四","五","六"][t.getDay()];return s.replace("YYYY",i).replace("MM",e).replace("DD",n).replace("HH",h).replace("mm",o).replace("ss",r).replace("SSS",a).replace("D",t.getDate()).replace("M",t.getMonth()+1).replace("H",t.getHours()).replace("m",t.getMinutes()).replace("s",t.getSeconds()).replace("W",c)},toISO:function(t){return m(t)?t.toISOString():""},toUTC:function(t){return m(t)?new Date(t.toUTCString()):null},addDays:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setDate(i.getDate()+s),i},addHours:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setHours(i.getHours()+s),i},addMinutes:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setMinutes(i.getMinutes()+s),i},addSeconds:function(t,s){if(!m(t))return t;const i=new Date(t);return i.setSeconds(i.getSeconds()+s),i},diffDays:_,diffHours:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/36e5):0},diffMinutes:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/6e4):0},diffSeconds:function(t,s){return m(t)&&m(s)?Math.floor((t.getTime()-s.getTime())/1e3):0},isToday:function(t){return!!m(t)&&0===_(t,f())},isYesterday:function(t){return!!m(t)&&-1===_(t,f())},isTomorrow:function(t){return!!m(t)&&1===_(t,f())},isFuture:function(t){return!!m(t)&&t.getTime()>p()},isPast:function(t){return!!m(t)&&t.getTime()<p()},isLeapYear:function(t){if(!m(t))return!1;const s=t.getFullYear();return s%4==0&&(s%100!=0||s%400==0)},getDaysInMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():0},getWeekOfYear:function(t){if(!m(t))return 0;const s=new Date(t.getFullYear(),0,1),i=t.getTime()-s.getTime();return Math.ceil(i/6048e5)},getQuarter:function(t){return m(t)?Math.ceil((t.getMonth()+1)/3):0},startOfDay:function(t){if(!m(t))return t;const s=new Date(t);return s.setHours(0,0,0,0),s},endOfDay:function(t){if(!m(t))return t;const s=new Date(t);return s.setHours(23,59,59,999),s},startOfMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth(),1):t},endOfMonth:function(t){return m(t)?new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59,999):t},startOfWeek:b,endOfWeek:function(t,s=1){if(!m(t))return t;const i=b(t,s),e=new Date(i);return e.setDate(e.getDate()+6),e.setHours(23,59,59,999),e},getAge:function(t){if(!m(t))return 0;const s=new Date;let i=s.getFullYear()-t.getFullYear();return(s.getMonth()<t.getMonth()||s.getMonth()===t.getMonth()&&s.getDate()<t.getDate())&&i--,Math.max(0,i)},fromNow:function(t){if(!m(t))return"";const s=p()-t.getTime(),i=6e4,e=36e5,n=24*e,h=7*n,o=30*n,r=365*n;return s<i?"刚刚":s<e?`${Math.floor(s/i)}分钟前`:s<n?`${Math.floor(s/e)}小时前`:s<h?`${Math.floor(s/n)}天前`:s<o?`${Math.floor(s/h)}周前`:s<r?`${Math.floor(s/o)}个月前`:`${Math.floor(s/r)}年前`}};function w(t,s,i={}){let e=null,n=null,h=null,o=0;const r=i.leading||!1,a=!1!==i.trailing;function c(){t.apply(h,n)}function l(){e=null,a&&n&&c(),n=null,h=null}return function(...t){n=t,h=this,o=Date.now(),e?(clearTimeout(e),e=setTimeout(l,Math.max(0,s-(Date.now()-o)))):(o=Date.now(),r?(e=setTimeout(l,s),c()):e=setTimeout(l,s))}}function y(t,s,i={}){let e=!1;const n=i.trailing||!1;let h=null,o=null;function r(){t.apply(o,h),h=null,o=null}return function(...t){e?n&&(h=t,o=this):(e=!0,h=t,o=this,r(),setTimeout(()=>{e=!1,n&&h&&r()},s))}}function k(t){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t||"")}function x(t){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t||"")}function $(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t||"")}function M(t){const s=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(t||"");return!!s&&s.slice(1).every(t=>parseInt(t)>=0&&parseInt(t)<=255)}function S(t){const s=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(t||"");if(!s)return!1;const[,i,e,n,h]=s;return parseInt(i)>=0&&parseInt(i)<=255&&parseInt(e)>=0&&parseInt(e)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(h)>=0&&parseFloat(h)<=1}function C(t,s){return(t||"").includes(s)}const E={isEmail:function(t){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t||"")},isPhone:function(t){return/^1[3-9]\d{9}$/.test(t||"")},isURL:function(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(t||"")},isIPv4:k,isIPv6:x,isIP:function(t){return k(t)||x(t)},isIDCard:function(t){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(t||"")},isPassport:function(t){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(t||"")},isCreditCard:function(t){const s=t.replace(/\s/g,"");if(!/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/.test(s))return!1;let i=0,e=!1;for(let t=s.length-1;t>=0;t--){let n=parseInt(s[t],10);e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0},isHexColor:$,isRGB:M,isRGBA:S,isColor:function(t){return $(t)||M(t)||S(t)},isDate:function(t){return!isNaN(new Date(t).getTime())},isJSON:function(t){try{return JSON.parse(t),!0}catch{return!1}},isEmpty:function(t){return!t||""===t.trim()},isWhitespace:function(t){return/^\s+$/.test(t||"")},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},isInteger:function(t){return/^-?\d+$/.test(t||"")},isFloat:function(t){return/^-?\d+\.\d+$/.test(t||"")},isPositive:function(t){const s=parseFloat(t);return!isNaN(s)&&s>0},isNegative:function(t){const s=parseFloat(t);return!isNaN(s)&&s<0},isAlpha:function(t){return/^[a-zA-Z]+$/.test(t||"")},isAlphaNumeric:function(t){return/^[a-zA-Z0-9]+$/.test(t||"")},isChinese:function(t){return/^[\u4e00-\u9fa5]+$/.test(t||"")},isLength:function(t,s,i){const e=(t||"").length;return e>=s&&(void 0===i||e<=i)},minLength:function(t,s){return(t||"").length>=s},maxLength:function(t,s){return(t||"").length<=s},matches:function(t,s){return s instanceof RegExp&&s.test(t||"")},equals:function(t,s){return String(t)===String(s)},contains:C,notContains:function(t,s){return!C(t,s)},isArray:function(t){return Array.isArray(t)},arrayLength:function(t,s,i){const e=t?t.length:0;return e>=s&&(void 0===i||e<=i)},arrayMinLength:function(t,s){return!!t&&t.length>=s},arrayMaxLength:function(t,s){return!!t&&t.length<=s},isObject:function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},hasKeys:function(t,s){return!!(t&&s&&Array.isArray(s))&&s.every(s=>Object.prototype.hasOwnProperty.call(t,s))},validate:function(t,s){const i={};return Object.keys(s).forEach(e=>{const n=t[e],h=s[e],o=[];h.forEach(s=>{if("string"==typeof s){const[t,...i]=s.split(":");E[t](n,...i)||o.push(t)}else if("function"==typeof s){const i=s(n,t);!0!==i&&o.push(i||"validation_failed")}}),o.length>0&&(i[e]=o)}),{valid:0===Object.keys(i).length,errors:i}}};const T={md5:function(t){const s=t?String(t):"",i=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(t,s){return t<<s|t>>>32-s}function h(t,s){const[h,o,r,a]=s,c=[];for(let s=0;s<16;s++)c[s]=255&t.charCodeAt(4*s)|(255&t.charCodeAt(4*s+1))<<8|(255&t.charCodeAt(4*s+2))<<16|(255&t.charCodeAt(4*s+3))<<24;let l=h,d=o,u=r,p=a;for(let t=0;t<64;t++){let s,h;const o=Math.floor(t/16),r=t%16;0===o?(s=d&u|~d&p,h=r):1===o?(s=p&d|~p&u,h=(5*r+1)%16):2===o?(s=d^u^p,h=(3*r+5)%16):(s=u^(d|~p),h=7*r%16);const a=p;p=u,u=d,d+=n(l+s+i[t]+c[h]&4294967295,e[o][t%4]),l=a}return[h+l&4294967295,o+d&4294967295,r+u&4294967295,a+p&4294967295]}const o=function(t){const s=8*t.length;for(t+="€";t.length%64!=56;)t+="\0";const i=4294967295&s,e=s>>>32&4294967295;for(let s=0;s<4;s++)t+=String.fromCharCode(i>>>8*s&255);for(let s=0;s<4;s++)t+=String.fromCharCode(e>>>8*s&255);return t}(s);let r=[1732584193,4023233417,2562383102,271733878];for(let t=0;t<o.length;t+=64)r=h(o.substring(t,t+64),r);let a="";return r.forEach(t=>{for(let s=0;s<4;s++)a+=(t>>>8*s&255).toString(16).padStart(2,"0")}),a},sha256:function(t){const s=t?String(t):"",i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function e(t,s){return t>>>s|t<<32-s}function n(t,s){const n=[];for(let s=0;s<16;s++)n[s]=255&t.charCodeAt(4*s)|(255&t.charCodeAt(4*s+1))<<8|(255&t.charCodeAt(4*s+2))<<16|(255&t.charCodeAt(4*s+3))<<24;for(let t=16;t<64;t++){const s=e(n[t-15],7)^e(n[t-15],18)^n[t-15]>>>3,i=e(n[t-2],17)^e(n[t-2],19)^n[t-2]>>>10;n[t]=n[t-16]+s+n[t-7]+i&4294967295}let[h,o,r,a,c,l,d,u]=s;for(let t=0;t<64;t++){const s=u+(e(c,6)^e(c,11)^e(c,25))+(c&l^~c&d)+i[t]+n[t]&4294967295,p=h&o^h&r^o&r;u=d,d=l,l=c,c=a+s&4294967295,a=r,r=o,o=h,h=s+((e(h,2)^e(h,13)^e(h,22))+p&4294967295)&4294967295}return[s[0]+h&4294967295,s[1]+o&4294967295,s[2]+r&4294967295,s[3]+a&4294967295,s[4]+c&4294967295,s[5]+l&4294967295,s[6]+d&4294967295,s[7]+u&4294967295]}const h=function(t){const s=8*t.length;for(t+="€";t.length%64!=56;)t+="\0";const i=4294967295&s,e=s>>>32&4294967295;for(let s=0;s<4;s++)t+=String.fromCharCode(e>>>8*s&255);for(let s=0;s<4;s++)t+=String.fromCharCode(i>>>8*s&255);return t}(s);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let t=0;t<h.length;t+=64)o=n(h.substring(t,t+64),o);let r="";return o.forEach(t=>{for(let s=3;s>=0;s--)r+=(t>>>8*s&255).toString(16).padStart(2,"0")}),r},base64Encode:function(t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",e=0;const n=t?t.split("").map(t=>t.charCodeAt(0)):[];for(;e<n.length;){const t=n[e++],h=n[e++]||0,o=n[e++]||0,r=(15&h)<<2|o>>6,a=63&o;i+=s[t>>2]+s[(3&t)<<4|h>>4]+(e>n.length+1?"=":s[r])+(e>n.length?"=":s[a])}return i},base64Decode:function(t){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i="",e=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");e<t.length;){const n=s.indexOf(t.charAt(e++)),h=s.indexOf(t.charAt(e++)),o=s.indexOf(t.charAt(e++)),r=s.indexOf(t.charAt(e++)),a=n<<2|h>>4,c=(15&h)<<4|o>>2,l=(3&o)<<6|r;i+=String.fromCharCode(a),64!==o&&(i+=String.fromCharCode(c)),64!==r&&(i+=String.fromCharCode(l))}return i},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=16*Math.random()|0;return("x"===t?s:3&s|8).toString(16)})}},D=new Map;async function O(t,s={}){const{crossOrigin:i="anonymous"}=s;return D.has(t)?D.get(t):new Promise((s,e)=>{const n=new Image;n.crossOrigin=i,n.onload=()=>{D.set(t,n),s(n)},n.onerror=()=>{e(new Error(`Failed to load image: ${t}`))},n.src=t})}async function F(t,s={}){const{type:i="text/javascript",async:e=!0,defer:n=!1}=s;return D.has(t)?D.get(t):new Promise((s,h)=>{const o=document.createElement("script");o.type=i,o.async=e,o.defer=n,o.onload=()=>{D.set(t,o),s(o)},o.onerror=()=>{o.remove(),h(new Error(`Failed to load script: ${t}`))},o.src=t,document.head.appendChild(o)})}async function I(t,s={}){const{media:i="all"}=s;return D.has(t)?D.get(t):new Promise((s,e)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=t,n.media=i,n.onload=()=>{D.set(t,n),s(n)},n.onerror=()=>{n.remove(),e(new Error(`Failed to load stylesheet: ${t}`))},document.head.appendChild(n)})}const A={loadImage:O,loadImages:async function(t,s={}){const{parallel:i=!0}=s;if(i)return Promise.all(t.map(t=>O(t,s)));const e=[];for(const i of t)e.push(await O(i,s));return e},loadScript:F,loadStylesheet:I,loadFont:async function(t,s,i={}){const{weight:e="normal",style:n="normal"}=i,h=new FontFace(t,`url(${s})`,{weight:e,style:n});try{return await h.load(),document.fonts.add(h),h}catch(s){throw new Error(`Failed to load font: ${t}`)}},preload:async function(t,s="image"){switch(s){case"image":return O(t);case"script":return F(t);case"stylesheet":case"style":return I(t);default:throw new Error(`Unsupported preload type: ${s}`)}},isLoaded:function(t){return D.has(t)},clearCache:function(){D.clear()},clearCacheByUrl:function(t){D.delete(t)}},R={string:n,array:o,object:a,number:u,date:v,debounce:w,throttle:y,validator:E,crypto:T,preload:A};class j{constructor(){this.children={},this.keys=[]}}class P{constructor(){this.root=new j}insert(t){let s=this.root;const i=t.split(".");i.forEach((e,n)=>{s.children[e]||(s.children[e]=new j),s=s.children[e],n===i.length-1&&s.keys.push(t)})}getSubKeys(t){let s=this.root;const i=t.split("."),e=[];for(let t=0;t<i.length;t++){const n=i[t];if(!s.children[n])break;s=s.children[n];const h=t=>{t.keys.length>0&&e.push(...t.keys),Object.values(t.children).forEach(t=>h(t))};h(s)}return[...new Set(e)]}getParentKeys(t){const s=t.split("."),i=[];for(let t=1;t<=s.length;t++){const e=s.slice(0,t).join(".");i.push(e)}return i}}const N=Symbol("reactive_parent"),B=Symbol("reactive_path"),z=Symbol("reactive_is_reactive");class L{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new P,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(t,s,i)=>{if("__raw__"===s)return t;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,s):e},set:(t,s,i,e)=>{const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=this.resolvePath(t,s);return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{const i=Reflect.get(t,s,receiver),e=Reflect.deleteProperty(t,s),n=this.resolvePath(t,s);return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e}};this.data=new Proxy(this.rawData,t),this.data.v=null,this.data.k=""}wrapReactive(t,s){if(t[z])return t;if(this._.has(t))return this._.get(t);const i=new Proxy(t,{get:(t,s,i)=>{if("__raw__"===s)return t;if(s===N||"__parent__"===s)return t[N];if(s===B||"__path__"===s)return t[B];if(s===z||"__isReactive__"===s)return!0;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[B]}${t[B]?".":""}${s}`):e},set:(t,s,i,e)=>{if(s===N||s===B||s===z||"__parent__"===s||"__path__"===s||"__isReactive__"===s)return!0;const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=`${t[B]}${t[B]?".":""}${s}`;return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{if(s===N||s===B||s===z)return!1;const i=Reflect.get(t,s),e=Reflect.deleteProperty(t,s),n=`${t[B]}${t[B]?".":""}${s}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e},has:(t,s)=>"__raw__"===s||s===N||s===B||s===z||"__parent__"===s||"__path__"===s||"__isReactive__"===s||s in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==N&&t!==B&&t!==z),getOwnPropertyDescriptor:(t,s)=>s===N||s===B||s===z?{configurable:!1,enumerable:!1,writable:!1,value:t[s]}:Reflect.getOwnPropertyDescriptor(t,s)});return t[N]=t,t[B]=s,t[z]=!0,this._.set(t,i),Object.keys(t).forEach(i=>{t[i]&&"object"==typeof t[i]&&!Array.isArray(t[i])&&(t[i]=this.wrapReactive(t[i],`${s}${s?".":""}${i}`))}),i}resolvePath(t,s){return t[B]?`${t[B]}.${s}`:s}queueUpdate(t,s){this.updateQueue.set(t,s),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((s,i)=>{t.add(i),this.updateElementsDirect(i,s);this.pathTrie.getSubKeys(i).forEach(s=>{if(!t.has(s)){const i=this.get(s);this.updateElementsDirect(s,i),t.add(s)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,s){this.elements[t]&&this.elements[t].forEach(t=>{this.updateElement(t,s)})}processComputed(){Object.keys(this.computedProperties).forEach(t=>{this.computedProperties[t].deps.some(t=>this.updateQueue.has(t)||this.pathTrie.getSubKeys(t).some(t=>this.updateQueue.has(t)))&&this.updateComputedProperty(t)})}set(t,s,i=!1){const e=this.get(t);"object"==typeof t?(Object.assign(this.rawData,t),Object.keys(t).forEach(s=>{i||(this.notify(s,t[s],e?.[s]),this.queueUpdate(s,t[s]))})):(t.includes(".")?this.setNested(t,s):this.rawData[t]=s,i||(this.notify(t,s,e),this.queueUpdate(t,s))),i||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((t,s)=>t?.[s],this.rawData)}setNested(t,s){const i=t.split("."),e=i.pop(),n=i.reduce((t,s)=>(t[s]||(t[s]={}),t[s]),this.rawData),h=n[e];n[e]=s,this.notify(t,s,h),this.queueUpdate(t,s)}observe(t,s){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(s)}unobserve(t,s){this.observers[t]&&(this.observers[t]=this.observers[t].filter(t=>t!==s))}notify(t,s,i){this.observers[t]&&this.observers[t].forEach(t=>{try{t(s,i)}catch(t){}}),this.observers["*"]?.forEach(e=>{try{e(t,s,i)}catch(t){}})}updateElement(t,s){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(i=>{const e=i.split(":"),n=e[0].trim(),h=e[1]?.trim();switch(n){case"text":t.textContent!==String(s??"")&&(t.textContent=s??"");break;case"html":const i=function(t){if(!t)return"";let s=String(t);const i=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let e;do{e=s,s=s.replace(i,"")}while(s!==e);return s=s.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),s=s.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),s=s.replace(/expression\s*\([^)]*\)/gi,""),s}(s);t.innerHTML!==i&&(t.innerHTML=i);break;case"value":"checkbox"===t.type?t.checked!==!!s&&(t.checked=!!s):t.value!==String(s??"")&&(t.value=s??"");break;case"checked":t.checked!==!!s&&(t.checked=!!s);break;case"disabled":t.disabled!==!!s&&(t.disabled=!!s);break;case"hidden":const e=s?"none":"";t.style.display!==e&&(t.style.display=e);break;case"class":h&&(s?t.classList.add(h):t.classList.remove(h));break;case"style":h&&t.style[h]!==String(s??"")&&(t.style[h]=s??"");break;case"attr":if(h){t.getAttribute(h)!==String(s??"")&&t.setAttribute(h,s??"")}break;case"src":t.src!==String(s??"")&&(t.src=s??"");break;case"href":t.href!==String(s??"")&&(t.href=s??"");break;case"placeholder":t.placeholder!==String(s??"")&&(t.placeholder=s??"")}})}computed(t,s,i){this.computedProperties[t]={deps:s,callback:i},s.forEach(t=>{this.pathTrie.insert(t)}),this.updateComputedProperty(t)}updateComputedProperty(t){const s=this.computedProperties[t];if(s)try{const i=s.deps.map(t=>this.get(t)),e=s.callback(...i);this.set(t,e,!0)}catch(t){}}load(t){Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])?this.rawData[s]=this.wrapReactive(t[s],s):this.rawData[s]=t[s],this.queueUpdate(s,this.rawData[s])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new P,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,s={}){const{storage:i="local",debounce:e=0,version:n=1,encrypt:h=!1,encryptionKey:o=null}=s,r="session"===i?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:r,debounce:e,timeout:null,version:n,encrypt:h,encryptionKey:o});const a=this.get(t);void 0!==a&&this.$(t,a,r,{version:n,encrypt:h,encryptionKey:o}),this.observe(t,s=>{const i=this.persistedKeys.get(t);i&&(i.debounce>0?(i.timeout&&clearTimeout(i.timeout),i.timeout=setTimeout(()=>{this.$(t,s,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey})},i.debounce)):this.$(t,s,i.storage,{version:i.version,encrypt:i.encrypt,encryptionKey:i.encryptionKey}))})}$(t,s,i,e={}){try{const{version:n=1,encrypt:h=!1,encryptionKey:o=null}=e,r={value:s,version:n,timestamp:Date.now()};let a=JSON.stringify(r);h&&o&&(a=this.M(a,o)),this.S(i),i.setItem(`kupola:${t}`,a)}catch(e){if("QuotaExceededError"===e.name&&i===localStorage)try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:s,version:1}))}catch(t){}}}S(t){try{const s="kupola:__storage_test__";t.setItem(s,"test"),t.removeItem(s)}catch(s){"QuotaExceededError"===s.name&&this.C(t)}}C(t){const s=Date.now();for(let i=0;i<t.length;i++){const e=t.key(i);if(e?.startsWith("kupola:"))try{const i=JSON.parse(t.getItem(e));i.timestamp&&s-i.timestamp>2592e6&&t.removeItem(e)}catch(s){t.removeItem(e)}}}M(t,s){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,s).toString():t}T(t,s){if(!window.CryptoJS)return t;try{return window.CryptoJS.AES.decrypt(t,s).toString(window.CryptoJS.enc.Utf8)}catch(s){return t}}unpersist(t){const s=this.persistedKeys.get(t);s&&(s.timeout&&clearTimeout(s.timeout),s.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const s={},{encryptionKey:i=null}=t;for(let e=0;e<localStorage.length;e++){const n=localStorage.key(e);if(n?.startsWith("kupola:")){const e=n.replace("kupola:","");try{const h=localStorage.getItem(n);let o;if(i){const t=this.T(h,i);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;s[e]=void 0!==o.value?o.value:o}catch(t){}}}for(let e=0;e<sessionStorage.length;e++){const n=sessionStorage.key(e);if(n?.startsWith("kupola:")){const e=n.replace("kupola:","");try{const h=sessionStorage.getItem(n);let o;if(i){const t=this.T(h,i);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;s[e]=void 0!==o.value?o.value:o}catch(t){}}}return Object.keys(s).length>0&&this.load(s),s}D(t){if("function"==typeof structuredClone)try{return structuredClone(t)}catch(t){}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this.D(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(0===this.snapshots.length)return!1;const s=t>=0?t:this.snapshots.length-1,i=this.snapshots[s];return!!i&&(this.rawData=this.D(i),this.createReactiveData(),Object.keys(this.rawData).forEach(t=>{this.queueUpdate(t,this.rawData[t])}),this.processComputed(),!0)}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const s={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const i=t.getAttribute("data-bind");if(!i)return;const e=i.split(":"),n=e[1]?.trim();n&&("checkbox"===t.type?(s[n]||(s[n]=[]),t.checked&&s[n].push(t.value)):"radio"===t.type?t.checked&&(s[n]=t.value):s[n]=t.value)}),s}fillForm(t,s){Object.keys(s).forEach(i=>{t.querySelectorAll('[data-bind*=":'+i+'"]').forEach(t=>{"checkbox"===t.type?t.checked=Array.isArray(s[i])?s[i].includes(t.value):!!s[i]:"radio"===t.type?t.checked=t.value===s[i]:t.value=s[i]??""})})}createReactive(t,s=""){if(t[z])return t;if(this._.has(t))return this._.get(t);const i={get:(t,s,i)=>{if("__raw__"===s)return t;if(s===N||"__parent__"===s)return t[N];if(s===B||"__path__"===s)return t[B];if(s===z||"__isReactive__"===s)return!0;const e=Reflect.get(t,s,i);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[B]}${t[B]?".":""}${s}`):e},set:(t,s,i,e)=>{if(s===N||s===B||s===z||"__parent__"===s||"__path__"===s||"__isReactive__"===s)return!0;const n=Reflect.get(t,s,e),h=Reflect.set(t,s,i,e),o=`${t[B]}${t[B]?".":""}${s}`;return this.notify(o,i,n),this.queueUpdate(o,i),h},deleteProperty:(t,s)=>{if(s===N||s===B||s===z)return!1;const i=Reflect.get(t,s),e=Reflect.deleteProperty(t,s),n=`${t[B]}${t[B]?".":""}${s}`;return this.notify(n,void 0,i),this.queueUpdate(n,void 0),e},has:(t,s)=>"__raw__"===s||s===N||s===B||s===z||"__parent__"===s||"__path__"===s||"__isReactive__"===s||s in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==N&&t!==B&&t!==z),getOwnPropertyDescriptor:(t,s)=>s===N||s===B||s===z?{configurable:!1,enumerable:!1,writable:!1,value:t[s]}:Reflect.getOwnPropertyDescriptor(t,s)},e=new Proxy(t,i);return t[N]=t,t[B]=s,t[z]=!0,this._.set(t,e),Object.keys(t).forEach(i=>{t[i]&&"object"==typeof t[i]&&!Array.isArray(t[i])&&(t[i]=this.wrapReactive(t[i],`${s}${s?".":""}${i}`))}),e}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this.O(t)}),this.F||(this.I=!1,this.F=new MutationObserver(t=>{if(!this.I){this.I=!0;try{t.forEach(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.querySelectorAll("[data-bind]").forEach(t=>this.O(t)),t.hasAttribute&&t.hasAttribute("data-bind")&&this.O(t)}})})}finally{this.I=!1}}}),this.F.observe(document.body,{childList:!0,subtree:!0}))}O(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const i=s[1]?.trim();if(i){if(this.pathTrie.insert(i),this.elements[i]||(this.elements[i]=[]),this.elements[i].includes(t)||this.elements[i].push(t),"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const s=t.A;s&&t.removeEventListener("input",s);const e=()=>{const s="checkbox"===t.type?t.checked:t.value;i.includes(".")?this.setNested(i,s):this.set(i,s)};t.A=e,t.addEventListener("input",e)}void 0!==this.rawData[i]&&this.updateElement(t,this.rawData[i])}}destroy(){this.F&&(this.F.disconnect(),this.F=null),Object.values(this.elements).forEach(t=>{t.forEach(t=>{const s=t.A;s&&(t.removeEventListener("input",s),delete t.A)})}),this.persistedKeys.forEach((t,s)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new P,this.updateQueue.clear(),this.snapshots=[]}}class H{constructor(t,s={}){this.name=t,this.R=`__store_${t}__`;const i=s.state?s.state():{};this.getters=s.getters||{},this.actions=s.actions||{},this.mutations=s.mutations||{},this.observers={},q?(q.set(this.R,i),this.state=q.data?.[this.R]||q.createReactive(i,this.R),q.observe(this.R,t=>{this.notify(t)})):this.state=i,this.j(),this.P()}j(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}P(){Object.keys(this.actions).forEach(t=>{this[t]=(...s)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...s)})}commit(t,s){const i=this.mutations[t];i&&i(this.state,s)}dispatch(t,s){const i=this.actions[t];if(i)return i({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},s)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(s=>s!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(s=>{try{s(t)}catch(t){}}),q&&q.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,s)=>(t[s]=this[s],t),{})}}}class U{constructor(){this.stores=new Map}createStore(t,s){const i=new H(t,s);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof H&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class V{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,s){return this.events[t]||(this.events[t]=[]),this.events[t].push(s),s}off(t,s){this.events[t]&&(this.events[t]=this.events[t].filter(t=>t!==s))}emit(t,s){this.events[t]&&this.events[t].forEach(t=>{try{t(s)}catch(t){}}),this.events["*"]?.forEach(i=>{try{i(t,s)}catch(t){}})}once(t,s){const i=e=>{s(e),this.off(t,i)};return this.on(t,i),i}delegate(t,s,i){if(!this.delegatedEvents[s]){this.delegatedEvents[s]=[];const t=t=>{this.delegatedEvents[s].forEach(({selector:s,cb:i})=>{(t.target.matches(s)||t.target.closest(s))&&i(t)})};document.addEventListener(s,t),this.eventListeners[s]=t}return this.delegatedEvents[s].push({selector:t,cb:i}),i}undelegate(t,s){if(this.delegatedEvents[s]&&(this.delegatedEvents[s]=this.delegatedEvents[s].filter(s=>s.selector!==t),0===this.delegatedEvents[s].length)){const t=this.eventListeners[s];t&&(document.removeEventListener(s,t),delete this.eventListeners[s]),delete this.delegatedEvents[s]}}destroy(){Object.entries(this.eventListeners).forEach(([t,s])=>{document.removeEventListener(t,s)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function J(t=null){const s={N:t,B:new Set};return Object.defineProperty(s,"value",{configurable:!0,enumerable:!0,get:()=>s.N,set(t){t!==s.N&&(s.N=t,s.B.forEach(s=>s(t)))}}),s.subscribe=t=>(s.B.add(t),{unsubscribe(){s.B.delete(t)}}),s}const q=new L,W=new V,K=new U;const Y={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}},Z=[];function G(){if("undefined"!=typeof window&&window.kupolaConfig)try{dt(Y,window.kupolaConfig),X()}catch(t){}}function X(){Z.forEach(t=>{try{t(Y)}catch(t){}})}function Q(t){"function"==typeof t&&Z.push(t)}function tt(t){return t?function(t,s){return s.split(".").reduce((t,s)=>void 0!==(t&&t[s])?t[s]:void 0,t)}(Y,t):Y}function st(){return Y.paths.base+Y.paths.icons.replace(/^\//,"")}function it(){return Y.theme.default}function et(){return Y.theme.brand}function nt(){return Y.ui}function ht(){return Y.zIndex}function ot(){return Y.security}function rt(){return Y.performance}function at(){return Y.message}function ct(){return Y.notification}function lt(){return Y.validation}function dt(t,s){for(const i in s)s[i]instanceof Object&&i in t&&t[i]instanceof Object?dt(t[i],s[i]):t[i]=s[i];return t}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",G):G());const ut="kupola-theme",pt="kupola-brand";Q(t=>{const s=document.querySelector("[data-theme-toggle]");if(s){const t=mt();vt(s),gt(t)}});const ft=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function mt(){return localStorage.getItem(ut)||it()}function gt(t){if("dark"!==t&&"light"!==t)return;var s=document.documentElement;s.hasAttribute("data-kupola-theme-preloaded")&&(s.style.removeProperty("--bg-base-default"),s.style.removeProperty("--text-default"),s.removeAttribute("data-kupola-theme-preloaded")),s.setAttribute("data-theme",t),localStorage.setItem(ut,t);const i=document.querySelector("[data-theme-toggle]");i&&(i.setAttribute("data-current-theme",t),vt(i))}function _t(){return localStorage.getItem(pt)||et()}function bt(t){const s=ft.find(s=>s.id===t);if(!s)return;document.documentElement.setAttribute("data-brand",t),localStorage.setItem(pt,t);const i=document.querySelector("[data-brand-toggle]");if(i){i.setAttribute("data-current-brand",t);const e=i.querySelector(".brand-icon");e&&(e.style.backgroundColor=s.color);const n=i.querySelector(".brand-name");n&&(n.textContent=s.name)}document.querySelectorAll("[data-brand-btn]").forEach(s=>{s.getAttribute("data-brand-btn")===t?s.classList.add("is-active"):s.classList.remove("is-active")})}function vt(t){const s=t.querySelector(".theme-icon");if(s){const t=mt(),i=st();s.src="dark"===t?i+"sun.svg":i+"moon.svg"}}function wt(t){t.preventDefault();gt("dark"===mt()?"light":"dark")}function yt(){var t=document.documentElement;t.hasAttribute("data-kupola-theme-preloaded")&&(t.style.removeProperty("--bg-base-default"),t.style.removeProperty("--text-default"),t.removeAttribute("data-kupola-theme-preloaded"));const s=document.querySelector("[data-theme-toggle]");gt(mt());bt(_t()),s&&(vt(s),s.removeEventListener("click",wt),s.addEventListener("click",wt));let i=document.getElementById("brand-picker");i||(i=document.createElement("div"),i.id="brand-picker",i.style.position="fixed",i.style.top="64px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",ft.forEach(t=>{const s=document.createElement("button");s.setAttribute("data-brand-btn",t.id),s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="60px",s.style.backgroundColor=t.color,s.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.color)?"#0C0C0D":"#FFFFFF",s.style.fontWeight="500",s.style.borderRadius="4px",s.style.border="none",s.style.cursor="pointer",s.style.margin="0",s.style.padding="0",s.textContent=t.name,i.appendChild(s)}),document.body.appendChild(i));const e=document.querySelector("[data-brand-toggle]");function n(t){i&&e&&(i.contains(t.target)||e.contains(t.target)||(i.style.display="none",document.removeEventListener("click",n,!0)))}e&&i&&(e.onclick=function(t){t.stopPropagation(),t.preventDefault();const s="none"===i.style.display;i.style.display=s?"grid":"none",s?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(t){t.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",s=>{s.stopPropagation();bt(t.getAttribute("data-brand-btn")),i&&(i.style.display="none")})})}class kt{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this.L=["data-component"],this.H=[],this.U=null}register(t,s,i=null,e={}){this.initializers.set(t,s),i&&this.cleanupFunctions.set(t,i),e.dataAttribute&&!this.L.includes(e.dataAttribute)&&(this.L.push(e.dataAttribute),this.U=null),e.cssClass&&!this.H.includes(e.cssClass)&&(this.H.push(e.cssClass),this.U=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}V(){if(null!==this.U)return this.U;const t=this.L.map(t=>`[${t}]`);for(const s of this.H)t.push(`.${s}`);return this.U=t.join(", "),this.U}async initialize(t){if(this.processedElements.has(t))return;for(const s of this.L){const i=t.getAttribute(s);if(null!==i){const e=i||s.replace("data-",""),n=this.initializers.get(e)||this.initializers.get(s.replace("data-",""));if(n){try{await n(t),this.processedElements.add(t)}catch(t){}return}}}const s=t.className;if("string"==typeof s)for(const i of this.H){if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(s)){const s=i.replace("ds-",""),e=this.initializers.get(s)||this.initializers.get(i);if(e){try{await e(t),this.processedElements.add(t)}catch(t){}return}}}}cleanup(t){for(const s of this.L){const i=t.getAttribute(s);if(null!==i){const e=i||s.replace("data-",""),n=this.cleanupFunctions.get(e)||this.cleanupFunctions.get(s.replace("data-",""));if(n){try{n(t)}catch(t){}return void this.processedElements.delete(t)}}}const s=t.className;if("string"==typeof s)for(const i of this.H){if(new RegExp(`(^|\\s)${i}(\\s|$)`).test(s)){const s=i.replace("ds-",""),e=this.cleanupFunctions.get(s)||this.cleanupFunctions.get(i);if(e){try{e(t)}catch(t){}return void this.processedElements.delete(t)}}}}async initializeAll(t=document){const s=this.V();if(!s)return;const i=t.querySelectorAll(s),e=[];i.forEach(t=>{this.processedElements.has(t)||e.push(this.initialize(t))}),await Promise.all(e)}}const xt=new kt,$t=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const t of $t)t.attr&&!xt.L.includes(t.attr)&&xt.L.push(t.attr),t.cls&&!xt.H.includes(t.cls)&&xt.H.push(t.cls);class Mt{constructor(s){this.element=s,this.isMounted=!1,this.isDestroyed=!1,this.props=this.J(),this.state={},this.slots=this.q(),this.W={},this.K=[],this.lifecycle=new t,this.setupContext=null}J(){const t={};for(const s of this.element.attributes)if(s.name.startsWith("data-prop-")){const i=s.name.replace("data-prop-","");let e=s.value;try{e=JSON.parse(e)}catch(t){}t[i]=e}return t}q(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const i=s.getAttribute("data-slot")||"default";t[i]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,s){if((this.W[t]||[]).forEach(t=>{try{t(s)}catch(t){}}),this.element){const i=new CustomEvent(`kupola:${t}`,{detail:s,bubbles:!0,cancelable:!0});this.element.dispatchEvent(i)}}$on(t,s){return this.W[t]||(this.W[t]=[]),this.W[t].push(s),s}$off(t,s){this.W[t]&&(this.W[t]=this.W[t].filter(t=>t!==s))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?.Y()}catch(s){this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"update",hook:"setProps",error:s,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?.Y()}catch(s){this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"update",hook:"setState",error:s,args:[t]})}}async mount(){if(!this.isMounted&&!this.isDestroyed)try{if(this.Z(),await this.lifecycle.bootstrap(),"function"==typeof this.setup){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?.G()}catch(t){if(this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"mount",hook:"component",error:t,args:[]}),"function"==typeof this.renderError)try{this.renderError(t)}catch(t){}else this.element.innerHTML=`\n <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">\n <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>\n <div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>\n </div>\n `}}Z(){if(this.X)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let s=Object.getPrototypeOf(this);const i=new Set;for(;s&&s.constructor!==Object&&s.constructor!==Mt;){for(const[e,n]of Object.entries(t))i.has(e)||s.hasOwnProperty(e)&&(Array.isArray(n)?n.forEach(t=>{"render"===e&&this.lifecycle.on(t,()=>this.render?.())}):"renderError"===e?this.lifecycle.on(n,t=>(this.renderError(t.error),"handled")):this.lifecycle.on(n,()=>this[e]?.()),i.add(e));s=Object.getPrototypeOf(s)}this.X=!0}async unmount(){if(this.isMounted&&!this.isDestroyed)try{this.setupContext?.tt(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(t){this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function St(t,s){Object.keys(s).forEach(i=>{if("constructor"!==i)if("function"==typeof s[i]){const e=t.prototype[i];t.prototype[i]=e?function(...t){return s[i].apply(this,t),e.apply(this,t)}:s[i]}else t.prototype[i]=s[i]})}class Ct{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(t,s){if(!(s.prototype instanceof Mt))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,s)}registerLazy(t,s){this.lazyComponents.set(t,s)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const s=this.components.get(t)||this.loadedComponents.get(t);if(s)return s;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const i=this.lazyComponents.get(t);if(!i)throw new Error(`Component ${t} not found`);const e=(async()=>{try{const s=await i(),e=s.default||s;if(!(e.prototype instanceof Mt))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,e),e}catch(s){throw this.loadingPromises.delete(t),s}})();return this.loadingPromises.set(t,e),e}defineMixin(t,s){this.mixins.set(t,s)}useMixin(t,...s){s.forEach(s=>{const i=this.mixins.get(s);i&&St(t,i)})}async bootstrap(t=document){await this.st(t),this.it(t)}async st(t){const s=t.querySelectorAll("[data-component]"),i=[];s.forEach(t=>{i.push(this.et(t))}),await Promise.all(i)}async et(t){if(!t.nt&&!t.ht){t.ht=!0;try{const s=t.getAttribute("data-component");if(s){const i=xt.get(s);if(i)try{return void await i(t)}catch(t){}}let i=this.components.get(s);if(!i){try{i=await this.getAsync(s)}catch(t){return}if(!t.isConnected)return}const e=t.getAttribute("data-mixins"),n=i;e&&e.split(",").forEach(t=>{const s=this.mixins.get(t.trim());s&&St(n,s)});const h=new n(t);t.nt=h,this.instances.set(t,h),h.mount()}finally{t.ht=!1}}}it(t){this.observer||(this.observer=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.hasAttribute("data-component")&&this.et(t).catch(t=>{}),this.st(t).catch(t=>{}),xt.initialize(t).catch(()=>{});const s=xt.V();s&&t.querySelectorAll?.(s).forEach(t=>{xt.initialize(t).catch(()=>{})})}}),t.removedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const s=this.instances.get(t);s&&(s.unmount(),this.instances.delete(t)),t.querySelectorAll("[data-component]").forEach(t=>{const s=this.instances.get(t);s&&(s.unmount(),this.instances.delete(t))}),xt.cleanup(t),t.querySelectorAll?.("*").forEach(t=>{xt.cleanup(t)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}async function Et(){if("undefined"!=typeof window){!function(){if(ot().xssProtection&&"undefined"!=typeof document){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild))}}();const t=tt();q.loadPersisted(),q.bind(),yt(),!1!==t.components?.autoInit&&(await xt.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}exports.kupolaRegistry=null,"undefined"!=typeof window&&(exports.kupolaRegistry=new Ct),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Et):"undefined"!=typeof window&&setTimeout(Et,0);class Tt{constructor(){this.ot=new Map,this.rt=new Map}on(t,s,i,e={}){const{scope:n=null,once:h=!1,passive:o=!1,capture:r=!1}=e,a=this.ct(),c={id:a,target:t,eventName:s,handler:i,scope:n,once:h,wrappedHandler:null};c.wrappedHandler=s=>{h&&this.offById(a),i.call(t,s)};const l=this.lt(t,s);return this.ot.has(l)||this.ot.set(l,[]),this.ot.get(l).push(c),n&&(this.rt.has(n)||this.rt.set(n,[]),this.rt.get(n).push(a)),t.addEventListener(s,c.wrappedHandler,{passive:o,capture:r}),{unsubscribe:()=>this.offById(a)}}once(t,s,i,e={}){return this.on(t,s,i,{...e,once:!0})}off(t,s,i){const e=this.lt(t,s);if(!this.ot.has(e))return;const n=this.ot.get(e),h=n.filter(t=>t.handler!==i);n.forEach(e=>{e.handler===i&&(t.removeEventListener(s,e.wrappedHandler),this.dt(e))}),0===h.length?this.ot.delete(e):this.ot.set(e,h)}offById(t){for(const[s,i]of this.ot){const e=i.findIndex(s=>s.id===t);if(-1!==e){const t=i[e];return t.target.removeEventListener(t.eventName,t.wrappedHandler),i.splice(e,1),0===i.length&&this.ot.delete(s),this.dt(t),!0}}return!1}offByScope(t){if(!this.rt.has(t))return;this.rt.get(t).forEach(t=>{this.offById(t)}),this.rt.delete(t)}offAll(t,s=null){if(s){const i=this.lt(t,s);if(!this.ot.has(i))return;this.ot.get(i).forEach(i=>{t.removeEventListener(s,i.wrappedHandler),this.dt(i)}),this.ot.delete(i)}else for(const[s,i]of this.ot){const[e]=s.split(":");this.ut(t)===e&&(i.forEach(s=>{t.removeEventListener(s.eventName,s.wrappedHandler),this.dt(s)}),this.ot.delete(s))}}emit(t,s,i={}){const e=new CustomEvent(s,{detail:i,bubbles:!0,cancelable:!0});return t.dispatchEvent(e),e}emitGlobal(t,s={}){return this.emit(document,t,s)}emitToScope(t,s,i={}){if(!this.rt.has(t))return;const e=this.rt.get(t),n=new Set;for(const[t,s]of this.ot)s.forEach(t=>{e.includes(t.id)&&n.add(t.target)});n.forEach(t=>{this.emit(t,s,i)})}getListenerCount(t,s=null){if(s){const i=this.lt(t,s);return this.ot.has(i)?this.ot.get(i).length:0}let i=0;const e=this.ut(t);for(const[t,s]of this.ot){const[n]=t.split(":");n===e&&(i+=s.length)}return i}getScopeListenerCount(t){return this.rt.has(t)?this.rt.get(t).length:0}hasListeners(t,s=null){return this.getListenerCount(t,s)>0}lt(t,s){return`${this.ut(t)}:${s}`}ut(t){return t===document?"document":t===window?"window":t===document.body?"body":(t.ft||(t.ft=this.ct()),t.ft)}ct(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}dt(t){if(!t.scope||!this.rt.has(t.scope))return;const s=this.rt.get(t.scope),i=s.indexOf(t.id);-1!==i&&(s.splice(i,1),0===s.length&&this.rt.delete(t.scope))}destroy(){for(const[t,s]of this.ot)s.forEach(t=>{t.target.removeEventListener(t.eventName,t.wrappedHandler)});this.ot.clear(),this.rt.clear()}}const Dt=new Tt;class Ot{constructor(t,s={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const i=nt();this.triggerMode=s.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=s.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=s.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==s.keyboardNav,this.autoPosition=!1!==s.autoPosition,this.closeOnClick=void 0!==s.closeOnClick?s.closeOnClick:void 0===i.dropdown?.closeOnClick||i.dropdown.closeOnClick,this.appendToBody=!1!==s.appendToBody,this.onSelect=s.onSelect||null,this.onShow=s.onShow||null,this.onHide=s.onHide||null,this.isOpen=!1,this.focusIndex=-1,this.gt=null,this._t=null,this.bt=null,this.vt=null,this.wt=null,this.yt=null,this.kt=null,this.xt=null,this.$t=null,this.Mt=null,this.St=null,this.Ct=null,this.Et=null,this.Tt=null}init(){this.trigger&&this.menu&&(this.element.Dt||(this.xt=t=>{t.stopPropagation();const s=t.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))},this.Ot(),this.wt=t=>{t.stopPropagation(),this.disabled||this.toggleMenu()},this.Ct=()=>{this.disabled||"hover"!==this.triggerMode||(clearTimeout(this._t),this.gt=setTimeout(()=>this.showMenu(),this.hoverDelay))},this.Et=()=>{"hover"===this.triggerMode&&(clearTimeout(this.gt),this._t=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this.Mt=()=>{this.disabled||"hover"!==this.triggerMode||clearTimeout(this._t)},this.St=()=>{"hover"===this.triggerMode&&(this._t=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this.$t=t=>{if(!this.isOpen||this.disabled)return;const s=this.Ft();if(s.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,s.length-1),this.It(s);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.It(s);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&s[this.focusIndex]&&s[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this.It(s);break;case"End":t.preventDefault(),this.focusIndex=s.length-1,this.It(s)}},"hover"===this.triggerMode?(this.trigger.addEventListener("mouseenter",this.Ct),this.trigger.addEventListener("mouseleave",this.Et),this.menu.addEventListener("mouseenter",this.Mt),this.menu.addEventListener("mouseleave",this.St)):this.trigger.addEventListener("click",this.wt),this.Tt=t=>{this.disabled||"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this.Tt),document.addEventListener("keydown",this.$t),this.yt=t=>{if(!this.isOpen)return;const s=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);s||i||this.hideMenu()},this.kt=Dt.on(document,"click",this.yt,{scope:this.scope}),this.menu.style.display="none",this.element.Dt=!0))}Ot(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.At=t=>this.xt(t),t.addEventListener("click",t.At)})}Ft(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}It(t){t.forEach(t=>t.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}Rt(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),s=window.innerHeight,i=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const e=this.menu.getBoundingClientRect(),n=s-t.bottom,h=t.top;n<e.height&&h>n?(this.menu.style.top=t.top-e.height-4+"px",this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+e.width>i?(this.menu.style.left=t.right-e.width+"px",this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const e=s-t.bottom,n=t.top;e<menuRect.height&&n>e?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>i?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this.jt(),this.Pt()),this.menu.style.display="block",this.Rt(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this.Nt(),this.Bt()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}jt(){if(!this.menu)return;this.bt=this.menu.parentNode,this.vt=this.menu.style.position,this.zt=this.menu.style.top,this.Lt=this.menu.style.left,this.Ht=this.menu.style.right,this.Ut=this.menu.style.bottom,this.Vt=this.menu.style.marginBottom,this.Jt=this.menu.style.width,this.qt=this.menu.style.transform,this.Wt=this.menu.style.zIndex,this.Kt=this.menu.style.display;const t=this.element.getBoundingClientRect(),s=ht().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=s,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}Nt(){this.menu&&this.bt&&(this.bt.appendChild(this.menu),this.menu.style.position=this.vt||"",this.menu.style.top=this.zt||"",this.menu.style.left=this.Lt||"",this.menu.style.right=this.Ht||"",this.menu.style.bottom=this.Ut||"",this.menu.style.marginBottom=this.Vt||"",this.menu.style.width=this.Jt||"",this.menu.style.zIndex=this.Wt||"",this.menu.style.transform=this.qt||"",this.menu.style.display=this.Kt||"",this.bt=null)}Pt(){this.Yt=()=>{this.hideMenu()},window.addEventListener("scroll",this.Yt,!0)}Bt(){this.Yt&&(window.removeEventListener("scroll",this.Yt,!0),this.Yt=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this.xt||(this.xt=t=>{t.stopPropagation();const s=t.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.At&&t.removeEventListener("click",t.At)}),this.menu.innerHTML="",t.forEach((t,s)=>{if("divider"===t.type){const t=document.createElement("div");t.className="ds-dropdown__divider",this.menu.appendChild(t)}else{const s=document.createElement("div");s.className="ds-dropdown__item"+(t.disabled?" is-disabled":"")+(t.active?" is-selected":""),s.textContent=t.text||t.label||"",void 0!==t.value&&s.setAttribute("data-value",t.value),t.icon&&(s.innerHTML=t.icon+s.innerHTML),t.disabled&&s.classList.add("is-disabled"),s.At=t=>this.xt(t),s.addEventListener("click",s.At),this.menu.appendChild(s)}})}destroy(){this.element.Dt&&(clearTimeout(this.gt),clearTimeout(this._t),this.trigger&&(this.wt&&this.trigger.removeEventListener("click",this.wt),this.Ct&&this.trigger.removeEventListener("mouseenter",this.Ct),this.Et&&this.trigger.removeEventListener("mouseleave",this.Et),this.Tt&&this.trigger.removeEventListener("keydown",this.Tt)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.At&&t.removeEventListener("click",t.At)}),this.Mt&&this.menu.removeEventListener("mouseenter",this.Mt),this.St&&this.menu.removeEventListener("mouseleave",this.St)),this.$t&&document.removeEventListener("keydown",this.$t),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.appendToBody&&this.bt&&this.Nt(),this.yt=null,this.kt=null,this.wt=null,this.xt=null,this.$t=null,this.Mt=null,this.St=null,this.Ct=null,this.Et=null,this.Tt=null,this.element.Dt=!1)}}function Ft(t,s){t.Zt&&t.Zt.destroy();const i=new Ot(t,s);i.init(),t.Zt=i}function It(t){t.Zt&&(t.Zt.destroy(),t.Zt=null)}xt.register("dropdown",Ft,It);class At{constructor(t,s={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=s.multiple||t.hasAttribute("data-select-multiple"),this.searchable=s.searchable||t.hasAttribute("data-select-search"),this.clearable=s.clearable||t.hasAttribute("data-select-clear"),this.placeholder=s.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=s.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=s.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=s.remoteMethod||null,this.onChange=s.onChange||null,this.appendToBody=!1!==s.appendToBody,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this.bt=null,this.vt=null,this.wt=null,this.yt=null,this.kt=null,this.Gt=null,this.$t=null}init(){this.trigger&&this.optionsEl&&(this.element.Dt||(this.Xt(),this.searchable&&this.Qt(),this.clearable&&this.ts(),this.multiple&&this.ss(),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.Gt=t=>{t.stopPropagation();const s=t.currentTarget;if(s.classList.contains("is-disabled"))return;const i=s.getAttribute("data-value");this.multiple?this.es(i,s):this.ns(i,s)},this.hs(),this.wt=t=>{t.stopPropagation(),this.disabled||this.toggleOptions()},this.trigger.addEventListener("click",this.wt),this.$t=t=>{if(!this.isOpen||this.disabled)return;const s=this.rs();if(s.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,s.length-1),this.cs(s);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.cs(s);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&s[this.focusIndex]&&s[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus()}},document.addEventListener("keydown",this.$t),this.yt=t=>{if(!this.isOpen)return;const s=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);s||i||this.hideOptions()},this.kt=Dt.on(document,"click",this.yt,{scope:this.scope}),this.ls(),this.optionsEl.style.display="none",this.element.Dt=!0))}Xt(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}Qt(){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.ds()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}ts(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",t=>{t.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}ss(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}ds(){const t=this.searchInput.value.toLowerCase().trim();this.remoteMethod?this.remoteMethod(t,t=>{this.us(t)}):(this.filteredOptions=this.allOptions.filter(s=>s.text.toLowerCase().includes(t)),this.allOptions.forEach(t=>{const s=this.filteredOptions.includes(t);t.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(t=>{const s=t.getAttribute("data-group"),i=this.filteredOptions.some(t=>t.group===s);t.style.display=i?"":"none"}),this.focusIndex=-1)}us(t){this.Gt||(this.Gt=t=>{t.stopPropagation();const s=t.currentTarget;if(s.classList.contains("is-disabled"))return;const i=s.getAttribute("data-value");this.multiple?this.es(i,s):this.ns(i,s)}),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.ps&&t.removeEventListener("click",t.ps),t.remove()}),t.forEach(t=>{const s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",t.value),s.textContent=t.text||t.label,t.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(t.value)&&s.classList.add("is-selected"),s.ps=t=>this.Gt(t),s.addEventListener("click",s.ps),this.optionsEl.appendChild(s)}),this.allOptions=t.map(t=>({el:this.optionsEl.querySelector(`[data-value="${t.value}"]`),value:t.value,text:t.text||t.label,group:"",disabled:!!t.disabled})),this.filteredOptions=[...this.allOptions]}ns(t,s){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(s.textContent.trim()),this.fs(),this.hideOptions(),this.gs(),this._s()}es(t,s){if(this.selectedValues.has(t))this.selectedValues.delete(t),s.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),s.classList.add("is-selected")}this.bs(),this.vs(),this.fs(),this.gs(),this._s()}bs(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const s=this.allOptions.find(s=>s.value===t);if(!s)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=s.text;const e=document.createElement("button");e.className="ds-select__tag-close",e.type="button",e.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',e.addEventListener("click",s=>{s.stopPropagation(),this.selectedValues.delete(t);const i=this.optionsEl.querySelector(`[data-value="${t}"]`);i&&i.classList.remove("is-selected"),this.bs(),this.vs(),this.fs(),this.gs(),this._s()}),i.appendChild(e),this.tagsWrap.appendChild(i)}))}vs(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;0===t?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else 0===this.selectedValues.size&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}gs(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}fs(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_s(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}ls(){if(this.nativeSelect)if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const s=this.optionsEl.querySelector(`[data-value="${t.value}"]`);s&&s.classList.add("is-selected")}),this.bs(),this.vs();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}this.gs()}hs(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.ps=t=>this.Gt(t),t.addEventListener("click",t.ps)})}rs(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>"none"!==t.style.display&&!t.classList.contains("is-disabled"))}cs(t){t.forEach(t=>t.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this.ys(),this.Pt()),this.optionsEl.style.display="block",this.ks(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this.xs(),this.Bt()),this.searchInput&&(this.searchInput.value="",this.ds()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}Pt(){this.Yt=()=>{this.hideOptions()},window.addEventListener("scroll",this.Yt,!0)}Bt(){this.Yt&&(window.removeEventListener("scroll",this.Yt,!0),this.Yt=null)}ys(){if(!this.optionsEl)return;this.bt=this.optionsEl.parentNode,this.vt=this.optionsEl.style.position,this.zt=this.optionsEl.style.top,this.Lt=this.optionsEl.style.left,this.Ht=this.optionsEl.style.right,this.Jt=this.optionsEl.style.width,this.qt=this.optionsEl.style.transform,this.Wt=this.optionsEl.style.zIndex;const t=this.element.getBoundingClientRect(),s=ht().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=s,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}xs(){this.optionsEl&&this.bt&&(this.bt.appendChild(this.optionsEl),this.optionsEl.style.position=this.vt||"",this.optionsEl.style.top=this.zt||"",this.optionsEl.style.left=this.Lt||"",this.optionsEl.style.right=this.Ht||"",this.optionsEl.style.width=this.Jt||"",this.optionsEl.style.zIndex=this.Wt||"",this.optionsEl.style.transform=this.qt||"",this.bt=null)}ks(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),s=window.innerHeight,i=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const e=this.optionsEl.getBoundingClientRect(),n=s-t.bottom,h=t.top;n<e.height&&h>n?this.optionsEl.style.top=t.top-e.height-4+"px":this.optionsEl.style.top=`${t.bottom+4}px`,t.left+e.width>i?this.optionsEl.style.left=t.right-e.width+"px":this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this.bs(),this.vs(),this.fs(),this.gs(),this._s()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const s=this.allOptions.find(s=>s.value===t);return s?{value:s.value,text:s.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(t=>this.selectedValues.add(t)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.classList.toggle("is-selected",this.selectedValues.has(t.getAttribute("data-value")))}),this.bs(),this.vs()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(s=>{const i=s.getAttribute("data-value")===t;s.classList.toggle("is-selected",i),i&&this.updateValue(s.textContent.trim())})),this.fs(),this.gs()}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.Dt&&(this.trigger&&this.wt&&this.trigger.removeEventListener("click",this.wt),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.ps&&t.removeEventListener("click",t.ps)}),this.$t&&document.removeEventListener("keydown",this.$t),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this.bt&&this.xs(),this.yt=null,this.kt=null,this.wt=null,this.Gt=null,this.$t=null,this.element.Dt=!1)}}function Rt(t,s){const i=new At(t,s);i.init(),t.$s=i}function jt(t){t.$s&&(t.$s.destroy(),t.$s=null)}xt.register("select",Rt,jt);class Pt{constructor(t,s={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const i=nt(),e=void 0!==i.datepicker?.weekStart?i.datepicker.weekStart:1;this.format=s.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=s.range||t.hasAttribute("data-datepicker-range"),this.minDate=s.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=s.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=s.disabledDate||null,this.weekStart=void 0!==s.weekStart?s.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||e,this.appendToBody=!1!==s.appendToBody,this.placeholder=s.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==s.showToday,this.showWeekNumber=s.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=s.onChange||null,this.months=s.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=s.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=s.todayText||"Today",this.clearText=s.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.Ms=null,this.Ss=null,this.Cs=null,this.yt=null,this.bt=null,this.kt=null,this.Es=null,this.Ts=null,this.$t=null}init(){if(this.calendarEl&&!this.element.Dt){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");2===t.length&&(this.rangeStart=this.Ds(t[0].trim()),this.rangeEnd=this.Ds(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this.Ds(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.Ms=t=>this.toggleCalendar(t),this.Ss=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this.Ms),this.input&&this.input.addEventListener("click",this.Ss),this.endInput&&(this.Cs=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this.Cs)),this.kt=Dt.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this.Ts=Dt.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this.$t=t=>{"Escape"===t.key&&"block"===this.calendarEl.style.display&&this.hideCalendar(t)},document.addEventListener("keydown",this.$t),this.element.Dt=!0,this.Os()}}Ds(t){if(!t)return null;const s=t.split("-");return 3===s.length?new Date(parseInt(s[0]),parseInt(s[1])-1,parseInt(s[2])):null}Fs(t){if(!t)return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",s).replace("MM",i).replace("DD",e)}Is(t){if(this.minDate){if(t<("string"==typeof this.minDate?this.Ds(this.minDate):this.minDate))return!0}if(this.maxDate){if(t>("string"==typeof this.maxDate?this.Ds(this.maxDate):this.maxDate))return!0}return!!this.disabledDate&&this.disabledDate(t)}As(t){const s=new Date;return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}Rs(t,s){return!(!t||!s)&&(t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate())}js(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const s=t.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),e=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return s>=i&&s<=e}calculatePosition(){const t=this.element.getBoundingClientRect(),s=this.calendarEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,e=t.top,n=s.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,i>=n?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):e>=n?(this.calendarEl.style.top=t.top-n-4+"px",this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):i>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):e>=n?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const s="block"===this.calendarEl.style.display;document.querySelectorAll(".ds-datepicker__calendar").forEach(t=>{t!==this.calendarEl&&(t.style.display="none",t.setAttribute("hidden",""))}),s||(this.appendToBody&&(this.Ps(),this.Pt()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||this.calendarEl.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this.Ns(),this.Bt()))}Pt(){this.Yt=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this.Yt,!0)}Bt(){this.Yt&&(window.removeEventListener("scroll",this.Yt,!0),this.Yt=null)}Ps(){if(!this.calendarEl)return;this.bt=this.calendarEl.parentNode,this.vt=this.calendarEl.style.position,this.zt=this.calendarEl.style.top,this.Lt=this.calendarEl.style.left,this.Jt=this.calendarEl.style.width,this.qt=this.calendarEl.style.transform,this.Wt=this.calendarEl.style.zIndex;const t=ht().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}Ns(){this.calendarEl&&this.bt&&(this.bt.appendChild(this.calendarEl),this.calendarEl.style.position=this.vt||"",this.calendarEl.style.top=this.zt||"",this.calendarEl.style.left=this.Lt||"",this.calendarEl.style.width=this.Jt||"",this.calendarEl.style.zIndex=this.Wt||"",this.calendarEl.style.transform=this.qt||"",this.bt=null)}resizeHandler(){"block"===this.calendarEl.style.display&&this.calculatePosition()}Os(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.Bs&&t.removeEventListener("click",t.Bs)}),"years"===this.viewMode)return void this.zs();if("months"===this.viewMode)return void this.Ls();const s=this.currentDate.getFullYear(),i=this.currentDate.getMonth();t.innerHTML="";const e=document.createElement("div");e.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this.Hs()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${s} ${this.months[i]}`,h.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",this.Os()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",t=>{t.stopPropagation(),this.Us()}),e.appendChild(n),e.appendChild(h),e.appendChild(o),t.appendChild(e);const r=document.createElement("div");r.className="ds-datepicker__weekdays";[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(t=>{const s=document.createElement("span");s.className="ds-datepicker__weekday",s.textContent=t,r.appendChild(s)}),t.appendChild(r);const a=document.createElement("div");a.className="ds-datepicker__days";const c=new Date(s,i,1).getDay(),l=new Date(s,i+1,0).getDate(),d=(c-this.weekStart+7)%7;for(let t=0;t<d;t++){const t=document.createElement("span");t.className="ds-datepicker__day ds-datepicker__day--empty",a.appendChild(t)}for(let t=1;t<=l;t++){const e=new Date(s,i,t),n=document.createElement("button");n.className="ds-datepicker__day",n.type="button",n.textContent=t,this.Fs(e),this.As(e)&&n.classList.add("is-today"),this.range?((this.Rs(e,this.rangeStart)||this.Rs(e,this.rangeEnd))&&n.classList.add("is-selected"),this.js(e)&&n.classList.add("is-in-range")):this.Rs(e,this.selectedDate)&&n.classList.add("is-selected"),this.Is(e)&&(n.classList.add("is-disabled"),n.disabled=!0);const h=()=>this.Vs(e);n.addEventListener("click",h),n.Bs=h,a.appendChild(n)}if(t.appendChild(a),this.showToday){const s=document.createElement("div");s.className="ds-datepicker__footer";const i=document.createElement("button");i.className="ds-datepicker__today-btn",i.type="button",i.textContent=this.todayText,i.addEventListener("click",t=>{t.stopPropagation(),this.Js()});const e=document.createElement("button");e.className="ds-datepicker__clear-btn",e.type="button",e.textContent=this.clearText,e.addEventListener("click",t=>{t.stopPropagation(),this.qs()}),s.appendChild(i),s.appendChild(e),t.appendChild(s)}}zs(){const t=this.calendarEl;t.innerHTML="";const s=this.currentDate.getFullYear(),i=s-6,e=document.createElement("div");e.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this.Os()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${i} - ${i+11}`,h.addEventListener("click",t=>{t.stopPropagation()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this.Os()}),e.appendChild(n),e.appendChild(h),e.appendChild(o),t.appendChild(e);const r=document.createElement("div");r.className="ds-datepicker__years-grid";for(let t=0;t<12;t++){const e=i+t,n=document.createElement("button");n.className="ds-datepicker__year-cell",n.type="button",n.textContent=e,e===s&&n.classList.add("is-selected"),n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(e),this.viewMode="months",this.Os()}),r.appendChild(n)}t.appendChild(r)}Ls(){const t=this.calendarEl;t.innerHTML="";const s=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const e=document.createElement("button");e.className="ds-datepicker__nav ds-datepicker__nav--prev",e.type="button",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',e.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this.Os()});const n=document.createElement("button");n.className="ds-datepicker__title",n.type="button",n.textContent=s,n.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="years",this.Os()});const h=document.createElement("button");h.className="ds-datepicker__nav ds-datepicker__nav--next",h.type="button",h.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',h.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this.Os()}),i.appendChild(e),i.appendChild(n),i.appendChild(h),t.appendChild(i);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((t,s)=>{const i=document.createElement("button");i.className="ds-datepicker__month-cell",i.type="button",i.textContent=t,s===this.currentDate.getMonth()&&i.classList.add("is-selected"),i.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(s),this.viewMode="days",this.Os()}),o.appendChild(i)}),t.appendChild(o)}Vs(t){if(!this.Is(t)){if(!this.range)return this.selectedDate=t,this.input&&(this.input.value=this.Fs(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this._s();if(this.isSelectingEnd&&this.rangeStart)return this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this.Fs(this.rangeStart)),this.endInput&&(this.endInput.value=this.Fs(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this._s();this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0,this.Os()}}_s(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this.Fs(this.rangeStart),endStr:this.Fs(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this.Fs(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this.Fs(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}Hs(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.Os()}Us(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.Os()}Js(){const t=new Date;this.currentDate=new Date(t),this.Is(t)?this.Os():this.Vs(t)}qs(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._s()}setDate(t){const s="string"==typeof t?this.Ds(t):t;s&&(this.selectedDate=s,this.currentDate=new Date(s),this.input&&(this.input.value=this.Fs(s)),this.Os())}getDate(){return this.selectedDate}setRange(t,s){this.rangeStart="string"==typeof t?this.Ds(t):t,this.rangeEnd="string"==typeof s?this.Ds(s):s,this.input&&(this.input.value=this.Fs(this.rangeStart)),this.endInput&&(this.endInput.value=this.Fs(this.rangeEnd)),this.Os()}destroy(){this.element.Dt&&(this.icon&&this.Ms&&this.icon.removeEventListener("click",this.Ms),this.input&&this.Ss&&this.input.removeEventListener("click",this.Ss),this.endInput&&this.Cs&&this.endInput.removeEventListener("click",this.Cs),this.$t&&document.removeEventListener("keydown",this.$t),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.Ts&&this.Ts.unsubscribe?this.Ts.unsubscribe():this.Es&&window.removeEventListener("resize",this.Es),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.Bs&&t.removeEventListener("click",t.Bs)}),this.appendToBody&&this.bt&&this.Ns(),this.yt=null,this.Es=null,this.kt=null,this.Ts=null,this.Ms=null,this.Ss=null,this.Cs=null,this.$t=null,this.element.Dt=!1)}}function Nt(t,s){const i=new Pt(t,s);i.init(),t.Ws=i}function Bt(t){t.Ws&&(t.Ws.destroy(),t.Ws=null)}xt.register("datepicker",Nt,Bt);class zt{constructor(t,s={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=s.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=s.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=s.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=s.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=s.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=s.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=s.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=s.disabledTime||null,this.placeholder=s.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=s.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=s.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this.Ks=null,this.yt=null,this.kt=null,this.Es=null,this.Ts=null,this.$t=null}init(){this.element.Dt||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this.Ys(),this.Ks=t=>{t.stopPropagation(),this.panelEl&&"block"===this.panelEl.style.display?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this.Ks),this.kt=Dt.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this.Ts=Dt.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this.$t=t=>{"Escape"===t.key&&this.panelEl&&"block"===this.panelEl.style.display&&this.hideTimepicker()},document.addEventListener("keydown",this.$t),this.element.Dt=!0)}Ys(){const t=this.input.value.trim();if(!t)return;const s=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(s)return this.selectedHour=parseInt(s[1])%12,"PM"===s[4].toUpperCase()&&(this.selectedHour+=12),this.selectedMinute=parseInt(s[2]),void(this.selectedSecond=s[3]?parseInt(s[3]):0);const i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}Zs(t,s,i){if(this.disabledTime)return this.disabledTime(t,s,i);const e=3600*t+60*s+i;if(this.minTime){const t=this.minTime.split(":");if(e<3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}if(this.maxTime){const t=this.maxTime.split(":");if(e>3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}return!1}Gs(){let t=this.selectedHour,s=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const e=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")} ${e}`:`${t}:${String(s).padStart(2,"0")} ${e}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(s).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),s=this.panelEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,e=t.top,n=s.height||320;i>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):e>=n?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl)return this.panelEl.style.display="block",this.Xs(),void this.calculatePosition();this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Hour</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>\n </div>',t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Min</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>\n </div>',this.showSeconds&&(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Sec</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--second" data-type="second"></div>\n </div>'),this.use12Hour&&(t+='<div class="ds-timepicker__section ds-timepicker__section--ampm">\n <div class="ds-timepicker__grid ds-timepicker__grid--ampm" data-type="ampm"></div>\n </div>'),this.panelEl.innerHTML=`\n <div class="ds-timepicker__header">\n <div class="ds-timepicker__display">\n <span class="ds-timepicker__display-hour">${String(this.selectedHour).padStart(2,"0")}</span>\n <span class="ds-timepicker__separator">:</span>\n <span class="ds-timepicker__display-minute">${String(this.selectedMinute).padStart(2,"0")}</span>\n ${this.showSeconds?'<span class="ds-timepicker__separator">:</span><span class="ds-timepicker__display-second">'+String(this.selectedSecond).padStart(2,"0")+"</span>":""}\n ${this.use12Hour?'<span class="ds-timepicker__display-ampm">'+(this.selectedHour>=12?"PM":"AM")+"</span>":""}\n </div>\n </div>\n <div class="ds-timepicker__body">${t}</div>\n ${this.clearable?'<div class="ds-timepicker__footer"><button class="ds-timepicker__clear-btn" type="button">Clear</button></div>':""}\n `,this.element.appendChild(this.panelEl),this.Qs(),this.ti(),this.showSeconds&&this.si(),this.use12Hour&&this.ii(),this.clearable){const t=this.panelEl.querySelector(".ds-timepicker__clear-btn");t&&t.addEventListener("click",t=>{t.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",t=>t.stopPropagation()),this.Xs(),setTimeout(()=>{this.calculatePosition(),this.ei()},0)}Qs(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;for(let s=this.use12Hour?1:0;s<(this.use12Hour?13:24);s+=this.hourStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{let t=s;this.use12Hour&&(t=12===s?this.isPM?12:0:this.isPM?s+12:s),this.selectedHour=t,this.ni(),this.hi("hour",s),this.oi()}),t.appendChild(i)}}ti(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let s=0;s<60;s+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{this.selectedMinute=s,this.ni(),this.hi("minute",s),this.oi()}),t.appendChild(i)}}si(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let s=0;s<60;s+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(s).padStart(2,"0"),i.dataset.value=s,i.addEventListener("click",()=>{this.selectedSecond=s,this.ni(),this.hi("second",s),this.oi()}),t.appendChild(i)}}ii(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(s=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=s,i.dataset.value=s,i.addEventListener("click",()=>{this.isPM="PM"===s,this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this.ni(),t.querySelectorAll(".ds-timepicker__item").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.oi()}),t.appendChild(i)})}ni(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),s=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),e=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const s=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(s).padStart(2,"0")}s&&(s.textContent=String(this.selectedMinute).padStart(2,"0")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),e&&(e.textContent=this.selectedHour>=12?"PM":"AM")}Xs(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this.hi("hour",t),this.hi("minute",this.selectedMinute),this.hi("second",this.selectedSecond);const s=this.panelEl.querySelector('[data-type="ampm"]');s&&s.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected","PM"===t.dataset.value==this.selectedHour>=12)}),this.ni()}hi(t,s){const i=this.panelEl.querySelector(`[data-type="${t}"]`);i&&i.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected",parseInt(t.dataset.value)===s)})}ei(){["hour","minute","second"].forEach(t=>{const s=this.panelEl.querySelector(`[data-type="${t}"]`);if(!s)return;const i=s.querySelector(".is-selected");i&&i.scrollIntoView({block:"center"})})}oi(){this.input.value=this.Gs()}hideTimepicker(t){this.panelEl&&"block"===this.panelEl.style.display&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this.Gs(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this.Gs()})))}resizeHandler(){this.panelEl&&"block"===this.panelEl.style.display&&this.calculatePosition()}setTime(t,s,i){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,s)),this.selectedSecond=Math.max(0,Math.min(59,i||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this.Gs()),this.panelEl&&this.Xs()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.Dt&&(this.inputWrap&&this.Ks&&this.inputWrap.removeEventListener("click",this.Ks),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.Ts&&this.Ts.unsubscribe?this.Ts.unsubscribe():this.Es&&window.removeEventListener("resize",this.Es),this.$t&&document.removeEventListener("keydown",this.$t),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this.Ks=null,this.yt=null,this.kt=null,this.Es=null,this.Ts=null,this.$t=null,this.element.Dt=!1)}}function Lt(t,s){const i=new zt(t,s);i.init(),t.ri=i}function Ht(t){t.ri&&(t.ri.destroy(),t.ri=null)}xt.register("timepicker",Lt,Ht);class Ut{constructor(t,s={}){if(this.element=t,this.track=t.querySelector(".ds-slider__track"),this.fill=t.querySelector(".ds-slider__fill"),this.input=t.querySelector(".ds-slider__input"),this.valueEl=t.querySelector(".ds-slider__value"),this.range=s.range||t.hasAttribute("data-slider-range"),this.vertical=s.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=s.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=!1!==s.showTooltip,this.showMarks=s.marks||t.hasAttribute("data-slider-marks"),this.markStep=s.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=s.tooltipFormat||(t=>t),this.onChange=s.onChange||null,this.onInput=s.onInput||null,this.inputEnd=t.querySelector(".ds-slider__input--end"),this.fillEnd=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.ot=[],this.ai=!1,this.ci=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this.li(),this.di(),this.updateSlider()}li(){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.pi()}pi(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),s=parseFloat(this.input?.max||100);for(let i=t;i<=s;i+=this.markStep){const e=document.createElement("div");e.className="ds-slider__mark";const n=(i-t)/(s-t)*100;this.vertical?e.style.bottom=n+"%":e.style.left=n+"%";const h=document.createElement("span");h.className="ds-slider__mark-label",h.textContent=i,e.appendChild(h),this.marksEl.appendChild(e)}this.element.appendChild(this.marksEl)}di(){if(this.input){const t=()=>this.updateSlider(),s=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",s),this.ot.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:s})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this.ot.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this.fi(this.thumbStart,"start"),this.thumbEnd&&this.fi(this.thumbEnd,"end"),this.track){const t=t=>{this.disabled||this.mi(t)};this.track.addEventListener("click",t),this.ot.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=t=>this.gi(t,"start");this.thumbStart.addEventListener("keydown",t),this.ot.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=t=>this.gi(t,"end");this.thumbEnd.addEventListener("keydown",t),this.ot.push({el:this.thumbEnd,event:"keydown",handler:t})}}fi(t,s){const i=t=>{this.disabled||(t.preventDefault(),this.ai=!0,this.ci=s,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("touchend",n))},e=t=>{if(!this.ai)return;t.preventDefault();const i=t.touches?t.touches[0].clientX:t.clientX,e=t.touches?t.touches[0].clientY:t.clientY,n=this.track.getBoundingClientRect();let h;h=this.vertical?1-(e-n.top)/n.height:(i-n.left)/n.width,h=Math.max(0,Math.min(1,h));const o=parseFloat(this.input?.min||0),r=parseFloat(this.input?.max||100),a=parseFloat(this.input?.step||1);let c=o+h*(r-o);if(c=Math.round(c/a)*a,c=Math.max(o,Math.min(r,c)),"start"===s&&this.range&&this.inputEnd){const t=parseFloat(this.inputEnd.value);c>t&&(c=t)}if("end"===s&&this.range&&this.input){const t=parseFloat(this.input.value);c<t&&(c=t)}"start"===s&&this.input?this.input.value=c:"end"===s&&this.inputEnd&&(this.inputEnd.value=c),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:h})},n=()=>{this.ai=!1,this.ci=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",e),document.removeEventListener("touchend",n),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!1}),this.ot.push({el:t,event:"mousedown",handler:i},{el:t,event:"touchstart",handler:i})}mi(t){if(t.target.classList.contains("ds-slider__thumb"))return;const s=this.track.getBoundingClientRect(),i=t.clientX,e=t.clientY;let n;n=this.vertical?1-(e-s.top)/s.height:(i-s.left)/s.width,n=Math.max(0,Math.min(1,n));const h=parseFloat(this.input?.min||0),o=parseFloat(this.input?.max||100),r=parseFloat(this.input?.step||1);let a=h+n*(o-h);if(a=Math.round(a/r)*r,this.range){const t=parseFloat(this.input?.value||0),s=parseFloat(this.inputEnd?.value||0);Math.abs(a-t)<=Math.abs(a-s)?this.input&&(this.input.value=Math.min(a,s)):this.inputEnd&&(this.inputEnd.value=Math.max(a,t))}else this.input&&(this.input.value=a);this.updateSlider()}gi(t,s){if(this.disabled)return;const i="start"===s?this.input:this.inputEnd;if(!i)return;const e=parseFloat(i.step||1),n=parseFloat(i.min||0),h=parseFloat(i.max||100);let o=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),o=Math.min(h,o+e);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),o=Math.max(n,o-e);break;case"Home":t.preventDefault(),o=n;break;case"End":t.preventDefault(),o=h;break;default:return}i.value=o,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),s=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const i=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0),n=(i-t)/(s-t)*100,h=(e-t)/(s-t)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=h-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=h-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=h+"%":this.thumbEnd.style.left=h+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(e)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(e)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",e)}else{const i=this.input?.value||0,e=(i-t)/(s-t)*100;this.vertical?this.fill.style.height=`${e}%`:this.fill.style.width=`${e}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=e+"%":this.thumbStart.style.left=e+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(i))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(i))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.element.setAttribute("aria-valuenow",i)}}destroy(){this.ot?.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.marksEl&&this.marksEl.remove(),this.track=null,this.fill=null,this.input=null,this.inputEnd=null,this.valueEl=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.element=null}setValue(t,s){this.input&&(this.input.value=t),void 0!==s&&this.inputEnd&&(this.inputEnd.value=s),this.updateSlider()}getValue(){return this.range&&this.inputEnd?[parseFloat(this.input?.value||0),parseFloat(this.inputEnd?.value||0)]:parseFloat(this.input?.value||0)}enable(){this.disabled=!1,this.element.classList.remove("is-disabled")}disable(){this.disabled=!0,this.element.classList.add("is-disabled")}}function Vt(t,s){if(!t.Dt)try{const i=new Ut(t,s);t.nt=i,t.Dt=!0}catch(t){}}function Jt(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("slider",Vt,Jt);class qt{constructor(t,s={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=s.placement||t.getAttribute("data-drawer-placement")||"right",this.width=s.width||t.getAttribute("data-drawer-width")||"400px",this.height=s.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=!1!==s.escClose,this.maskClosable=!1!==s.maskClosable,this.showMask=!1!==s.showMask,this.onOpen=s.onOpen||null,this.onClose=s.onClose||null,this.onBeforeClose=s.onBeforeClose||null,this.$t=null,this.di()}di(){const t=this.mask?.querySelector(".ds-drawer__close"),s=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),i=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{if(this.onBeforeClose){if(!1===this.onBeforeClose())return}this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible"),document.body.style.overflow="",this.onClose&&this.onClose(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-close",{bubbles:!0}))},this.handleMaskClick=t=>{this.maskClosable&&t.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),s&&s.addEventListener("click",this.closeDrawer),i&&i.addEventListener("click",this.closeDrawer),this.escClose&&(this.$t=t=>{"Escape"===t.key&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this.$t)),this.ot=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer},{el:i,event:"click",handler:this.closeDrawer}].filter(t=>t.el)}_i(){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.ot?.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.$t&&document.removeEventListener("keydown",this.$t),this.ot=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._i(),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 Wt(t,s){if(t.Dt)return;const i=new qt(t,s);t.nt=i,t.Dt=!0}function Kt(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("drawer",Wt,Kt);class Yt{constructor(t,s={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close");const i=nt(),e=void 0===i.modal?.backdropClick||i.modal.backdropClick;this.fullscreen=s.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=void 0!==s.closableOnMask?s.closableOnMask:e,this.escClose=!1!==s.escClose,this.width=s.width||t.getAttribute("data-modal-width")||"",this.center=!1!==s.center,this.onBeforeOpen=s.onBeforeOpen||null,this.onBeforeClose=s.onBeforeClose||null,this.onOpened=s.onOpened||null,this.onClosed=s.onClosed||null,this.bi=!1,this.$t=t=>{this.escClose&&"Escape"===t.key&&this.isVisible()&&this.close()},this.wi=()=>this.close(),this.yi=t=>{this.closableOnMask&&t.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this.wi),this.mask&&this.mask.addEventListener("click",this.yi),document.addEventListener("keydown",this.$t),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){if(this.onBeforeOpen){if(!1===this.onBeforeOpen())return}this.mask&&(this.mask.classList.add("is-visible"),this.mask.classList.add("ds-modal-fade-enter"),requestAnimationFrame(()=>{this.mask.classList.add("ds-modal-fade-enter-active")})),this.modal&&(this.modal.classList.add("ds-modal-zoom-enter"),requestAnimationFrame(()=>{this.modal.classList.add("ds-modal-zoom-enter-active")})),this.bi||(Yt.ki=(Yt.ki||0)+1,this.bi=!0),document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0}))}close(){if(this.onBeforeClose){if(!1===this.onBeforeClose())return}this.mask&&(this.mask.classList.remove("ds-modal-fade-enter-active"),this.mask.classList.add("ds-modal-fade-leave-active")),this.modal&&(this.modal.classList.remove("ds-modal-zoom-enter-active"),this.modal.classList.add("ds-modal-zoom-leave-active")),setTimeout(()=>{this.mask&&this.mask.classList.remove("is-visible","ds-modal-fade-enter","ds-modal-fade-leave-active"),this.modal&&this.modal.classList.remove("ds-modal-zoom-enter","ds-modal-zoom-leave-active")},300),this.bi&&(Yt.ki=Math.max(0,(Yt.ki||0)-1),this.bi=!1,0===Yt.ki&&(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.$t),this.closeBtn&&this.closeBtn.removeEventListener("click",this.wi),this.mask&&this.mask.removeEventListener("click",this.yi),this.bi&&(Yt.ki=Math.max(0,(Yt.ki||0)-1),this.bi=!1,0===Yt.ki&&(document.body.style.overflow=""))}}function Zt(t={}){const{title:s="",content:i="",html:e=!1,width:n="480px",fullscreen:h=!1,showCancel:o=!0,showConfirm:r=!0,confirmText:a="OK",cancelText:c="Cancel",confirmClass:l="ds-btn--brand",cancelClass:d="ds-btn--ghost",closable:u=!0,maskClosable:p=!0,onConfirm:f,onCancel:m,onOpen:g,onClose:_,footer:b=null,size:v=nt().defaultSize}=t,w="sm"===v?"ds-btn--sm":"lg"===v?"ds-btn--lg":"",y=document.createElement("div");y.className="ds-modal-container";let k="";null!==b&&("string"==typeof b?k=`<div class="ds-modal__footer">${b}</div>`:(r||o)&&(k=`<div class="ds-modal__footer">\n ${o?`<button class="ds-btn ${w} ${d}" data-modal-cancel>${c}</button>`:""}\n ${r?`<button class="ds-btn ${w} ${l}" data-modal-confirm>${a}</button>`:""}\n </div>`)),y.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${h?" ds-modal--fullscreen":""}" style="${h?"":"max-width: "+n}">\n <div class="ds-modal__header">\n <span class="ds-modal__title"></span>\n ${u?'<button class="ds-modal__close" aria-label="Close">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>':""}\n </div>\n <div class="ds-modal__body"></div>\n ${k}\n </div>\n </div>\n `,document.body.appendChild(y);const x=new Yt(y,{fullscreen:h,closableOnMask:p}),$=y.querySelector(".ds-modal__title");$&&($.textContent=s);const M=y.querySelector(".ds-modal__body");M&&(e?M.innerHTML=i:M.textContent=i);const S=y.querySelector("[data-modal-confirm]"),C=y.querySelector("[data-modal-cancel]");let E=!1;const T=async()=>{if(f){S.disabled=!0,S.classList.add("is-loading");try{if(!1===await f())return S.disabled=!1,void S.classList.remove("is-loading")}catch(t){return S.disabled=!1,void S.classList.remove("is-loading")}}E=!0,x.close()},D=()=>{m&&m(),x.close()};S&&S.addEventListener("click",T),C&&C.addEventListener("click",D);const O=x.close.bind(x);return x.close=()=>{O(),setTimeout(()=>{S&&S.removeEventListener("click",T),C&&C.removeEventListener("click",D),x.destroy(),y.remove(),_&&_(E)},300)},x.open(),g&&setTimeout(()=>g(),50),x}function Gt(t){if(t.Dt)return;const s=new Yt(t);t.nt=s,t.Dt=!0}function Xt(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}Yt.ki=0,xt.register("modal",Gt,Xt);const Qt={normal:function(t){this.show({...t,type:"normal"})},success:function(t){this.show({...t,type:"success"})},error:function(t){this.show({...t,type:"error"})},warning:function(t){this.show({...t,type:"warning"})},info:function(t){this.show({...t,type:"info"})},show:function(t){const s=ct(),{title:i,message:e,type:n="normal",duration:h=s.duration,position:o=s.position}=t,r=document.createElement("div");r.className=`ds-notification__item ds-notification__item--${n}`;r.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${n}">${{normal:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'}[n]}</div>\n <div class="ds-notification__content">\n ${i?'<div class="ds-notification__title"></div>':""}\n ${e?'<div class="ds-notification__message"></div>':""}\n </div>\n <button class="ds-notification__close">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>\n </button>\n `,i&&(r.querySelector(".ds-notification__title").textContent=i),e&&(r.querySelector(".ds-notification__message").textContent=e);let a=document.querySelector(".ds-notification");if(!a){a=document.createElement("div"),a.className=`ds-notification ds-notification--${o}`;const t=ht().notification;a.style.zIndex=t,a.style.transform="translateZ(0)",document.body.appendChild(a)}a.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),r.querySelector(".ds-notification__close").addEventListener("click",()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)}),h>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},h)}};const ts={normal:function(t,s={}){this.show(t,"normal",s)},success:function(t,s={}){this.show(t,"success",s)},error:function(t,s={}){this.show(t,"error",s)},warning:function(t,s={}){this.show(t,"warning",s)},info:function(t,s={}){this.show(t,"info",s)},show:function(t,s="normal",i={}){const e=at(),{duration:n=e.duration,position:h=e.position}=i,o=e.maxCount||5,r=document.createElement("div");r.className=`ds-message__item ds-message__item--${s}`;r.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${s}">${{normal:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'}[s]}</div>\n <div class="ds-message__content"></div>\n `,r.querySelector(".ds-message__content").textContent=t;let a=document.querySelector(".ds-message");if(!a){a=document.createElement("div"),a.className=`ds-message ds-message--${h}`;const t=ht().message;a.style.zIndex=t,a.style.transform="translateZ(0)",document.body.appendChild(a)}const c=a.querySelectorAll(".ds-message__item");if(c.length>=o){const t=c[0];t.classList.remove("is-visible"),t.classList.add("is-exiting"),setTimeout(()=>t.remove(),300)}a.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};function ss(t){return t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}class is{constructor(t){this.element=t,this.dropzone=t.querySelector(".ds-fileupload__dropzone"),this.input=t.querySelector(".ds-fileupload__input"),this.list=t.querySelector(".ds-fileupload__list"),this.progress=t.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(t.getAttribute("data-max-size"))||0,this.maxCount=parseInt(t.getAttribute("data-max-count"))||0,this.ot=[],this.init()}init(){this.bindEvents()}bindEvents(){const t=t=>{t.target===this.input||this.input.contains(t.target)||this.input.click()},s=t=>{const s=Array.from(t.target.files);this.addFiles(s),t.target.value=""},i=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.add("is-dragging")},e=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging")},n=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging");const s=Array.from(t.dataTransfer.files);this.addFiles(s)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",s),this.dropzone.addEventListener("dragover",i),this.dropzone.addEventListener("dragleave",e),this.dropzone.addEventListener("drop",n),this.ot.push({el:this.dropzone,event:"click",handler:t},{el:this.input,event:"change",handler:s},{el:this.dropzone,event:"dragover",handler:i},{el:this.dropzone,event:"dragleave",handler:e},{el:this.dropzone,event:"drop",handler:n})}addFiles(t){t.forEach(t=>{this.maxCount>0&&this.files.length>=this.maxCount?this.showError(`Maximum ${this.maxCount} files allowed`):this.isValidFile(t)&&(this.files.push(t),this.renderFileItem(t),this.showPreview(t))}),this.dispatchChange()}isValidFile(t){const s=this.input.getAttribute("accept");if(s&&""!==s){const i=s.split(",").map(t=>t.trim()),e=t.type,n=t.name.toLowerCase();if(!i.some(t=>t.startsWith(".")?n.endsWith(t):!t.includes("/")||(t.endsWith("/*")?e.startsWith(t.replace("/*","")):e===t)))return this.showError(`File type not allowed: ${t.type}`),!1}return!(this.maxSize>0&&t.size>this.maxSize)||(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1)}renderFileItem(t){const s=document.createElement("div");s.className="ds-fileupload__item",s.dataset.filename=t.name;const i=this.getFileIcon(t.type);s.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${i}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(ss(t.name))}</span>\n <span class="ds-fileupload__size">${this.formatSize(t.size)}</span>\n <button class="ds-fileupload__remove" type="button" aria-label="Remove file">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const e=s.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,s)};e.addEventListener("click",n),this.ot.push({el:e,event:"click",handler:n}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(s)}getFileIcon(t){return t.startsWith("image/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>':t.startsWith("video/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>':t.startsWith("audio/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>':t.includes("pdf")||t.includes("document")||t.includes("text")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>':t.includes("zip")||t.includes("archive")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M16 11V7a4 4 0 0 0-8 0v4"/><polyline points="10 14 8 16 6 14"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>'}truncateFilename(t,s=20){if(t.length<=s)return t;const i=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,s-i.length-3)+"..."+i}formatSize(t){if(0===t)return"0 B";const s=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,s)).toFixed(1))+" "+["B","KB","MB","GB"][s]}removeFile(t,s){this.files=this.files.filter(s=>s!==t),s&&s.remove(),0===this.files.length&&this.list&&(this.list.remove(),this.list=null),this.dispatchChange()}clearFiles(){this.files=[],this.list&&(this.list.remove(),this.list=null),this.preview&&(this.preview.innerHTML=""),this.clearError(),this.dispatchChange()}showError(t){this.clearError(),this.dropzone.classList.add("is-error");const s=document.createElement("div");s.className="ds-fileupload__error",s.textContent=t,s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),this.dropzone.appendChild(s),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const t=this.dropzone.querySelector(".ds-fileupload__error");t&&t.remove()}showPreview(t){if(!t.type.startsWith("image/"))return;this.preview||(this.preview=document.createElement("div"),this.preview.className="ds-fileupload__preview",this.element.insertBefore(this.preview,this.list||null));const s=new FileReader;s.onload=s=>{const i=document.createElement("div");i.className="ds-fileupload__preview-item",i.innerHTML=`\n <img src="${s.target.result}" alt="${ss(t.name)}">\n <button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const e=i.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),i.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};e.addEventListener("click",n),this.ot.push({el:e,event:"click",handler:n}),this.preview.appendChild(i)},s.readAsDataURL(t)}updateProgress(t){this.progress||(this.progress=document.createElement("div"),this.progress.className="ds-fileupload__progress",this.element.insertBefore(this.progress,this.list||null)),this.progress.style.display="block";const s=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");s.className="ds-fileupload__progress-bar",s.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(s),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const s=100;let i=0;Math.max(1,Math.floor(t.size/s));const e=setInterval(()=>{i++;const t=Math.min(100,Math.floor(i/s*100));this.updateProgress(t),i>=s&&(clearInterval(e),this.updateProgress(100))},Math.max(50,Math.floor(50)));return e}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function es(t){if(t.Dt)return;const s=new is(t);t.nt=s,t.Dt=!0}function ns(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("fileupload",es,ns);class hs{constructor(t,s={}){this.element=t,this.headers=[],this.ot=[],this.accordion=s.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=s.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=s.disabledItems||[],this.defaultExpanded=s.defaultExpanded||[],this.xi()}xi(){this.element.querySelectorAll(".ds-collapse__header").forEach((t,s)=>{const i=t.closest(".ds-collapse__item"),e=t.nextElementSibling;if(!i||!e||!e.classList.contains("ds-collapse__content"))return;const n=i.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(s);n&&i.classList.add("is-disabled");let h=i.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(s))&&(h=!0),h?(i.classList.add("is-active"),e.style.height=e.scrollHeight+"px",e.style.overflow="hidden",setTimeout(()=>{i.classList.contains("is-active")&&(e.style.height="auto",e.style.overflow="visible")},this.animationDuration)):(i.classList.remove("is-active"),e.style.height="0",e.style.overflow="hidden");const o=()=>{if(n)return;const t=i.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,i)=>{i!==s&&t.item.classList.contains("is-active")&&this.$i(t)}),t?this.$i({item:i,content:e}):this.Mi({item:i,content:e}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:s,expanded:!t,item:i},bubbles:!0}))};t.addEventListener("click",o),this.headers.push({header:t,item:i,content:e,clickHandler:o,isDisabled:n}),this.ot.push({el:t,event:"click",handler:o})})}Mi(t){const{item:s,content:i}=t;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",s.classList.add("is-active");const e=()=>{i.removeEventListener("transitionend",e),s.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",e),this.ot.push({el:i,event:"transitionend",handler:e})}$i(t){const{item:s,content:i}=t;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",s.classList.remove("is-active");const e=()=>{i.removeEventListener("transitionend",e),i.style.transition=""};i.addEventListener("transitionend",e),this.ot.push({el:i,event:"transitionend",handler:e})}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.headers=null,this.element=null}toggle(t){const s=this.headers[t];s&&!s.isDisabled&&s.clickHandler()}expand(t){const s=this.headers[t];!s||s.item.classList.contains("is-active")||s.isDisabled||(this.accordion&&this.headers.forEach((s,i)=>{i!==t&&s.item.classList.contains("is-active")&&this.$i(s)}),this.Mi(s))}collapse(t){const s=this.headers[t];s&&s.item.classList.contains("is-active")&&this.$i(s)}expandAll(){this.accordion||this.headers.forEach((t,s)=>{t.item.classList.contains("is-active")||t.isDisabled||this.Mi(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this.$i(t)})}getExpandedIndices(){return this.headers.map((t,s)=>t.item.classList.contains("is-active")?s:-1).filter(t=>t>=0)}disable(t){this.headers[t]&&(this.headers[t].isDisabled=!0,this.headers[t].item.classList.add("is-disabled"))}enable(t){this.headers[t]&&(this.headers[t].isDisabled=!1,this.headers[t].item.classList.remove("is-disabled"))}}function os(t,s){if(t.Dt)return;const i=new hs(t,s);t.nt=i,t.Dt=!0}function rs(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("collapse",os,rs);class as{constructor(t,s={}){this.element=t,this.trigger=t.querySelector(".ds-color-picker__trigger"),this.panel=t.querySelector(".ds-color-picker__panel"),this.valueSpan=t.querySelector(".ds-color-picker__value"),this.customInput=t.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=s,this.value=s.value||"#007bff",this.showAlpha=!1!==s.showAlpha,this.mode=s.mode||"hex",this.previousColors=s.previousColors||this.Si(),this.previousColorsLimit=s.previousColorsLimit||12,this.wt=null,this.yt=null,this.kt=null,this.Ci=null,this.Ei=null,this.Ti=null,this.Di=null,this.Oi=null,this.Fi=null,this.Ii=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this.Ai(this.value)}Si(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}Ri(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}ji(t){const s=this.previousColors.indexOf(t);-1!==s&&this.previousColors.splice(s,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this.Ri(),this.Pi()}Ai(t){const s=t.replace(/^#/,""),i=parseInt(s.substring(0,2),16)/255,e=parseInt(s.substring(2,4),16)/255,n=parseInt(s.substring(4,6),16)/255,h=8===s.length?parseInt(s.substring(6,8),16)/255:1,o=Math.max(i,e,n),r=Math.min(i,e,n);let a=0,c=0,l=o;const d=o-r;if(c=0===o?0:d/o,o!==r)switch(o){case i:a=((e-n)/d+(e<n?6:0))/6;break;case e:a=((n-i)/d+2)/6;break;case n:a=((i-e)/d+4)/6}this.hue=Math.round(360*a),this.saturation=Math.round(100*c),this.brightness=Math.round(100*l),this.alpha=Math.round(100*h)}Ni(t,s,i,e=1){s/=100,i/=100,e/=100;const n=s=>(s+t/60)%6,h=t=>i*(1-s*Math.max(0,Math.min(n(t),4-n(t),1))),o=Math.round(255*h(5)),r=Math.round(255*h(3)),a=Math.round(255*h(1));if("rgb"===this.mode)return e<1?`rgba(${o}, ${r}, ${a}, ${e.toFixed(2)})`:`rgb(${o}, ${r}, ${a})`;if("hsl"===this.mode)return e<1?`hsla(${t}, ${Math.round(100*s)}%, ${Math.round(100*i)}%, ${e.toFixed(2)})`:`hsl(${t}, ${Math.round(100*s)}%, ${Math.round(100*i)}%)`;const c=`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;return e<1?c+Math.round(255*e).toString(16).padStart(2,"0"):c}Pi(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(s=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=s,i.setAttribute("data-color",s),i.addEventListener("click",this.Ci),t.appendChild(i)}))}Bi(){const t=this.panel.querySelector(".ds-color-picker__hue"),s=this.panel.querySelector(".ds-color-picker__sv"),i=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),s&&(s.style.background=`hsl(${this.hue}, 100%, 50%)`),i&&this.showAlpha&&(i.value=this.alpha,i.style.background=`linear-gradient(to right, transparent, ${this.Ni(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel)return;if(this.element.Dt)return;this.wt=t=>{t.stopPropagation(),this.togglePanel()},this.Ci=t=>{const s=t.currentTarget.getAttribute("data-color");this.updateColor(s),this.hidePanel()},this.Ei=t=>{const s=t.target.value;this.zi(s)&&this.updateColor(s)},this.Ti=t=>{this.alpha=parseInt(t.target.value),this.Li()},this.Di=t=>{const s=t.currentTarget;this.mode=s.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>t.classList.remove("is-active")),s.classList.add("is-active"),this.ni()},this.Oi=t=>{this.hue=parseInt(t.target.value),this.Bi(),this.Li()},this.Fi=t=>{const s=t.currentTarget.getBoundingClientRect(),i=t.clientX-s.left,e=t.clientY-s.top;this.saturation=Math.round(i/s.width*100),this.brightness=Math.round(100*(1-e/s.height)),this.Li()},this.yt=t=>{this.element.contains(t.target)||this.hidePanel()},this.trigger.addEventListener("click",this.wt),this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.addEventListener("click",this.Ci),t.Hi=this.Ci}),this.customInput&&(this.customInput.addEventListener("input",this.Ei),this.customInput.Ui=this.Ei);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this.Oi);const s=this.panel.querySelector(".ds-color-picker__sv");s&&(s.addEventListener("click",this.Fi),s.addEventListener("mousemove",t=>{1===t.buttons&&this.Fi(t)}));const i=this.panel.querySelector(".ds-color-picker__alpha");i&&this.showAlpha&&i.addEventListener("input",this.Ti),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.addEventListener("click",this.Di),t.getAttribute("data-mode")===this.mode&&t.classList.add("is-active")}),this.kt=Dt.on(document,"click",this.yt,{scope:this.scope}),this.Pi(),this.Bi(),this.ni(),this.element.Dt=!0}zi(t){const s=(new Option).style;return s.color=t,""!==s.color}Li(){const t=this.Ni(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this.ni(),this.ji(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}}))}ni(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this.Bi()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this.zi(t)&&(this.value=t,this.Ai(t),this.ni(),this.ji(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}})))}setValue(t){this.updateColor(t)}getValue(){return this.value}setMode(t){"hex"!==t&&"rgb"!==t&&"hsl"!==t||(this.mode=t,this.ni())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this.Li()}getAlpha(){return this.alpha}destroy(){if(!this.element.Dt)return;this.trigger&&this.wt&&this.trigger.removeEventListener("click",this.wt),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.Hi&&t.removeEventListener("click",t.Hi)}),this.customInput&&this.Ei&&this.customInput.removeEventListener("input",this.Ei);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this.Oi&&t.removeEventListener("input",this.Oi);const s=this.panel?.querySelector(".ds-color-picker__sv");s&&this.Fi&&(s.removeEventListener("click",this.Fi),s.removeEventListener("mousemove",this.Fi));const i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this.Ti&&i.removeEventListener("input",this.Ti),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.removeEventListener("click",this.Di)}),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.yt=null,this.kt=null,this.wt=null,this.Ci=null,this.Ei=null,this.Ti=null,this.Di=null,this.Oi=null,this.Fi=null,this.Ii=null,this.element.Dt=!1}}function cs(t,s){const i=new as(t,s);i.init(),t.Vi=i}function ls(t){t.Vi&&(t.Vi.destroy(),t.Vi=null)}xt.register("color-picker",cs,ls);class ds{constructor(t,s={}){if(this.element=t,this.titleEl=t.querySelector(".ds-calendar__title"),this.daysEl=t.querySelector(".ds-calendar__days"),this.prevBtn=t.querySelector(".ds-calendar__nav--prev"),this.nextBtn=t.querySelector(".ds-calendar__nav--next"),this.todayBtn=t.querySelector(".ds-calendar__nav--today"),this.ot=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=s.selectedDate?new Date(s.selectedDate):null,this.rangeStart=s.rangeStart?new Date(s.rangeStart):null,this.rangeEnd=s.rangeEnd?new Date(s.rangeEnd):null,this.isRangeMode=s.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=s.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=s.events||[],this.i18n=s.i18n||{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortWeekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",selectRangeStart:"Select start date",selectRangeEnd:"Select end date"},this.onSelect=s.onSelect||null,this.onRangeSelect=s.onRangeSelect||null,this.onChange=s.onChange||null,this.onEventClick=s.onEventClick||null,this.xi()}xi(){this.render();const t=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.Ji()},s=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.Ji()},i=()=>{this.currentDate=new Date,this.render(),this.Ji()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this.ot.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",s),this.ot.push({el:this.nextBtn,event:"click",handler:s})),this.todayBtn&&(this.todayBtn.addEventListener("click",i),this.ot.push({el:this.todayBtn,event:"click",handler:i}))}Ji(){const t={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(t),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:t,bubbles:!0}))}Fs(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}Rs(t,s){return!(!t||!s)&&this.Fs(t)===this.Fs(s)}qi(t){if(!this.rangeStart||!this.rangeEnd)return!1;const s=this.Fs(t),i=this.Fs(this.rangeStart),e=this.Fs(this.rangeEnd);return s>=i&&s<=e}Wi(t){return this.Rs(t,this.rangeStart)}Ki(t){return this.Rs(t,this.rangeEnd)}Yi(t){const s=this.Fs(t);return this.events.filter(t=>{const i=t.date||t.start,e=t.end;if(!i)return!1;const n="string"==typeof i?i:this.Fs(i);if(!e)return n===s;const h="string"==typeof e?e:this.Fs(e);return s>=n&&s<=h})}render(){const t=this.currentDate.getFullYear(),s=this.currentDate.getMonth();"week"===this.viewMode?this.Zi(t,s):this.Gi(t,s)}Gi(t,s){this.titleEl.textContent=`${t} ${this.i18n.months[s]}`;const i=new Date(t,s,1).getDay(),e=new Date(t,s+1,0).getDate();this.daysEl.innerHTML="";for(let t=0;t<i;t++){const t=document.createElement("span");t.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(t)}const n=new Date,h=this.Fs(n);for(let i=1;i<=e;i++){const e=new Date(t,s,i),n=document.createElement("button");n.className="ds-calendar__day",n.textContent=i;const o=this.Fs(e);o===h&&n.classList.add("is-today"),this.Rs(e,this.selectedDate)&&n.classList.add("is-selected"),this.isRangeMode&&(this.Wi(e)&&n.classList.add("is-range-start"),this.Ki(e)&&n.classList.add("is-range-end"),this.qi(e)&&n.classList.add("is-in-range"));const r=this.Yi(e);if(r.length>0){n.classList.add("has-events");const t=document.createElement("span");t.className="ds-calendar__day-event",t.style.backgroundColor=r[0].color||"#007bff",n.appendChild(t)}const a=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),n.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this.Rs(e,this.rangeEnd)?(this.rangeStart=e,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(e<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=e):this.rangeEnd=e,this.onRangeSelect&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-range-select",{detail:{start:this.rangeStart,end:this.rangeEnd},bubbles:!0}))):(this.selectedDate=e,this.onSelect&&this.onSelect({date:e,dateStr:o}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:e,dateStr:o},bubbles:!0}))),r.forEach(t=>{this.onEventClick&&this.onEventClick(t,e)}),this.render()};n.addEventListener("click",a),this.ot.push({el:n,event:"click",handler:a}),this.daysEl.appendChild(n)}}Zi(t,s){const i=this.currentDate.getDay(),e=new Date(t,s,this.currentDate.getDate()-i+(0===i?-6:1)),n=e,h=new Date(e);h.setDate(e.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[h.getMonth()]} ${h.getDate()} ${t}`,this.daysEl.innerHTML="";const o=new Date,r=this.Fs(o);for(let t=0;t<7;t++){const s=new Date(e);s.setDate(e.getDate()+t);const i=document.createElement("button");i.className="ds-calendar__day ds-calendar__day--week";const n=document.createElement("span");n.className="ds-calendar__day-header",n.textContent=this.i18n.shortWeekdays[s.getDay()],i.appendChild(n);const h=document.createElement("span");h.className="ds-calendar__day-number",h.textContent=s.getDate(),i.appendChild(h);const o=this.Fs(s);o===r&&i.classList.add("is-today"),this.Rs(s,this.selectedDate)&&i.classList.add("is-selected");const a=this.Yi(s);if(a.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",a.slice(0,3).forEach(s=>{const i=document.createElement("span");i.className="ds-calendar__day-event",i.style.backgroundColor=s.color||"#007bff",t.appendChild(i)}),i.appendChild(t)}const c=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.selectedDate=s,this.onSelect&&this.onSelect({date:s,dateStr:o}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:s,dateStr:o},bubbles:!0})),this.render()};i.addEventListener("click",c),this.ot.push({el:i,event:"click",handler:c}),this.daysEl.appendChild(i)}}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(t){this.currentDate=new Date(t),this.render(),this.Ji()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,s){this.rangeStart=t?new Date(t):null,this.rangeEnd=s?new Date(s):null,this.render(),this.onRangeSelect&&this.rangeStart&&this.rangeEnd&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd})}getRange(){return{start:this.rangeStart,end:this.rangeEnd}}setEvents(t){this.events=t||[],this.render()}addEvent(t){this.events.push(t),this.render()}removeEvent(t){this.events=this.events.filter(s=>s.id!==t),this.render()}setViewMode(t){"month"!==t&&"week"!==t||(this.viewMode=t,this.render(),this.Ji())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.Ji()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.Ji()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this.Ji()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this.Ji()}goToToday(){this.currentDate=new Date,this.render(),this.Ji()}goToDate(t){this.currentDate=new Date(t),this.render(),this.Ji()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this.Ji()}}function us(t,s){if(!t.Dt)try{const i=new ds(t,s);t.nt=i,t.Dt=!0}catch(t){}}function ps(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("calendar",us,ps);class fs{constructor(t,s={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this.ot=[],this.maxCount=s.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=!1!==s.allowDuplicates,this.color=s.color||t.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const s=t.querySelector(".ds-dynamic-tags__remove");if(s){const i=s=>{s.stopPropagation(),t.remove(),this.dispatchChange()};s.addEventListener("click",i),this.ot.push({el:s,event:"click",handler:i})}}),this.input){const t=()=>{const t=this.input.value.trim();if(!t)return;if(!this.allowDuplicates&&this.hasTag(t))return void(this.input.value="");if(this.getTags().length>=this.maxCount)return this.input.value="",void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const s=this.createTag(t);this.element.insertBefore(s,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},s=s=>{"Enter"===s.key&&(s.preventDefault(),s.stopPropagation(),t())};this.input.addEventListener("keydown",s),this.ot.push({el:this.input,event:"keydown",handler:s});const i=()=>{this.input.focus()};this.element.addEventListener("click",i),this.ot.push({el:this.element,event:"click",handler:i})}}createTag(t){const s=document.createElement("span");s.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(t);s.appendChild(i);const e=document.createElement("button");e.className="ds-dynamic-tags__remove",e.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',s.appendChild(e);const n=t=>{t.stopPropagation(),s.remove(),this.dispatchChange()};return e.addEventListener("click",n),this.ot.push({el:e,event:"click",handler:n}),s}hasTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of s)if(i.textContent.trim()===t)return!0;return!1}addTag(t,s){if(!t||!this.input)return;if(!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount)return void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const i=this.createTag(t);if(s){const t=["ds-dynamic-tags__tag--default","ds-dynamic-tags__tag--primary","ds-dynamic-tags__tag--success","ds-dynamic-tags__tag--warning","ds-dynamic-tags__tag--danger","ds-dynamic-tags__tag--info"];t.forEach(t=>i.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${s}`)&&i.classList.add(`ds-dynamic-tags__tag--${s}`)}this.element.insertBefore(i,this.input),this.dispatchChange()}removeTag(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];s&&(s.remove(),this.dispatchChange())}removeTagByValue(t){const s=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of s)if(i.textContent.trim()===t)return i.remove(),void this.dispatchChange()}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(s=>{t.push(s.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(s=>{const i=Array.from(s.classList).find(t=>t.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:s.textContent.trim(),color:i})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(t=>{"string"==typeof t?this.addTag(t):t&&"object"==typeof t&&t.value&&this.addTag(t.value,t.color)})}setMaxCount(t){this.maxCount=t,this.element.setAttribute("data-dynamic-tags-max",t)}getMaxCount(){return this.maxCount}setAllowDuplicates(t){this.allowDuplicates=t}isAllowDuplicates(){return this.allowDuplicates}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-dynamic-tags-color",t))}getColor(){return this.color}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-change",{detail:{tags:this.getTags(),tagsWithColor:this.getTagsWithColor(),count:this.getTags().length,maxCount:this.maxCount}}))}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.input=null,this.element=null}}function ms(t,s){if(t.Dt)return;const i=new fs(t,s);t.nt=i,t.Dt=!0}function gs(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("dynamic-tags",ms,gs);class _s{constructor(t={}){this.images=t.images||[],this.currentIndex=t.currentIndex||0,this.overlay=null,this.closeHandler=this.close.bind(this),this.keyHandler=this.handleKeydown.bind(this),this.clickHandler=this.handleOverlayClick.bind(this),this.zoom=1,this.rotation=0,this.zoomStep=t.zoomStep||.2,this.minZoom=t.minZoom||.5,this.maxZoom=t.maxZoom||3,this.init()}init(){this.createOverlay()}createOverlay(){this.overlay=document.createElement("div"),this.overlay.className="ds-image-preview-overlay",this.overlay.innerHTML='\n <button class="ds-image-preview__close" type="button" aria-label="Close preview">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n <div class="ds-image-preview__nav">\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--prev" type="button" aria-label="Previous image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="15 18 9 12 15 6"/>\n </svg>\n </button>\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--next" type="button" aria-label="Next image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="9 18 15 12 9 6"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__toolbar">\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom in" data-action="zoom-in">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom out" data-action="zoom-out">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Reset zoom" data-action="zoom-reset">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/>\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate left" data-action="rotate-left">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="1 4 1 10 7 10"/>\n <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate right" data-action="rotate-right">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="23 4 23 10 17 10"/>\n <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__content">\n <img src="" alt="" />\n </div>\n <div class="ds-image-preview__info">\n <div class="ds-image-preview__title"></div>\n <div class="ds-image-preview__meta"></div>\n </div>\n <div class="ds-image-preview__indicators"></div>\n ',document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const t=this.overlay.querySelector(".ds-image-preview__close"),s=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),i=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this.Xi=()=>this.prev(),this.Qi=()=>this.next(),t.addEventListener("click",this.closeHandler),s.addEventListener("click",this.Xi),i.addEventListener("click",this.Qi);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",s=>{const i=t.getAttribute("data-action");this.handleToolbarAction(i)})});this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this.zoomIn():this.zoomOut()},{passive:!1})}handleToolbarAction(t){switch(t){case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"zoom-reset":this.resetZoom();break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90)}}zoomIn(){this.zoom=Math.min(this.maxZoom,this.zoom+this.zoomStep),this.updateTransform()}zoomOut(){this.zoom=Math.max(this.minZoom,this.zoom-this.zoomStep),this.updateTransform()}resetZoom(){this.zoom=1,this.rotation=0,this.updateTransform()}rotate(t){this.rotation+=t,this.updateTransform()}setRotation(t){this.rotation=t,this.updateTransform()}setZoom(t){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t)),this.updateTransform()}updateTransform(){const t=this.overlay.querySelector(".ds-image-preview__content img");t&&(t.style.transform=`scale(${this.zoom}) rotate(${this.rotation}deg)`)}handleKeydown(t){if(this.overlay.classList.contains("is-visible"))switch(t.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"+":case"=":t.preventDefault(),this.zoomIn();break;case"-":case"_":t.preventDefault(),this.zoomOut();break;case"0":t.preventDefault(),this.resetZoom();break;case"[":t.preventDefault(),this.rotate(-90);break;case"]":t.preventDefault(),this.rotate(90)}}handleOverlayClick(t){t.target===this.overlay&&this.close()}show(t,s=0){this.images=t,this.currentIndex=Math.min(Math.max(s,0),t.length-1),this.resetZoom(),this.render(),this.overlay.classList.add("is-visible"),document.addEventListener("keydown",this.keyHandler),this.overlay.addEventListener("click",this.clickHandler),document.body.style.overflow="hidden"}close(){this.overlay.classList.remove("is-visible"),document.removeEventListener("keydown",this.keyHandler),this.overlay.removeEventListener("click",this.clickHandler),document.body.style.overflow=""}prev(){this.currentIndex>0&&(this.currentIndex--,this.resetZoom(),this.render())}next(){this.currentIndex<this.images.length-1&&(this.currentIndex++,this.resetZoom(),this.render())}goTo(t){t>=0&&t<this.images.length&&(this.currentIndex=t,this.resetZoom(),this.render())}render(){const t=this.overlay.querySelector(".ds-image-preview__content img"),s=this.overlay.querySelector(".ds-image-preview__title"),i=this.overlay.querySelector(".ds-image-preview__meta"),e=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),h=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),o=this.images[this.currentIndex];t.src=o.src,t.alt=o.alt||"",s.textContent=o.title||"",i.textContent=o.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,h.disabled=this.currentIndex===this.images.length-1,e.innerHTML=this.images.map((t,s)=>`\n <button class="ds-image-preview__indicator${s===this.currentIndex?" is-active":""}" type="button" data-index="${s}" aria-label="Go to image ${s+1}"></button>\n `).join(""),e.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{const s=()=>{this.goTo(parseInt(t.dataset.index))};t.addEventListener("click",s),t.te=s})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{t.te&&t.removeEventListener("click",t.te)});const s=this.overlay?.querySelector(".ds-image-preview__close"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),e=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");s&&s.removeEventListener("click",this.closeHandler),i&&this.Xi&&i.removeEventListener("click",this.Xi),e&&this.Qi&&e.removeEventListener("click",this.Qi),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let bs=null;class vs{constructor(t,s={}){this.element=t,this.closeBtn=t.querySelector(".ds-tag__close"),this.checkbox=t.querySelector(".ds-tag__checkbox"),this.editInput=t.querySelector(".ds-tag__input"),this.ot=[],this.color=s.color||t.getAttribute("data-tag-color")||"default",this.size=s.size||t.getAttribute("data-tag-size")||"default",this.checkable=s.checkable||t.hasAttribute("data-tag-checkable"),this.checked=s.checked||t.hasAttribute("data-tag-checked"),this.editable=s.editable||t.hasAttribute("data-tag-editable"),this.maxLength=s.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this.se(),this.closeBtn){const t=t=>{t.stopPropagation(),this.element.dispatchEvent(new CustomEvent("kupola:tag-remove",{detail:{tag:this.element,content:this.getContent()},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",t),this.ot.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=t=>{t.target!==this.checkbox&&t.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this.ot.push({el:this.element,event:"click",handler:t}),this.checkbox){const t=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",t),this.ot.push({el:this.checkbox,event:"change",handler:t})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this.ot.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const t=()=>{this.endEdit()},s=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};this.editInput.addEventListener("blur",t),this.editInput.addEventListener("keydown",s),this.ot.push({el:this.editInput,event:"blur",handler:t}),this.ot.push({el:this.editInput,event:"keydown",handler:s})}}}se(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],s=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(t=>this.element.classList.remove(t)),s.forEach(t=>this.element.classList.remove(t)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),s.includes(`ds-tag--${this.size}`)&&this.element.classList.add(`ds-tag--${this.size}`),this.checkable&&this.element.classList.add("ds-tag--checkable"),this.checked&&this.element.classList.add("is-checked"),this.editable&&this.element.classList.add("ds-tag--editable")}setContent(t){this.editable&&this.editInput&&(this.editInput.value=t);const s=[];this.element.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE&&s.push(t)}),s.forEach(t=>t.remove());const i=this.element.querySelector(".ds-tag__close"),e=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),h=i||e||n||null;this.element.insertBefore(document.createTextNode(t),h),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:t},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-tag-color",t),this.se())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this.se())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this.se(),this.checkbox&&(this.checkbox.checked=this.checked),this.element.dispatchEvent(new CustomEvent("kupola:tag-check",{detail:{tag:this.element,checked:this.checked,content:this.getContent()},bubbles:!0}))}setChecked(t){this.checked=t,this.element.setAttribute("data-tag-checked",t?"true":"false"),this.se(),this.checkbox&&(this.checkbox.checked=t)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const t=this.getContent();if(this.editInput)this.editInput.value=t;else{const s=document.createElement("input");s.type="text",s.className="ds-tag__input",s.value=t,s.maxLength=this.maxLength,this.editInput=s;const i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(s,i);const e=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};s.addEventListener("blur",e),s.addEventListener("keydown",n),this.ot.push({el:s,event:"blur",handler:e}),this.ot.push({el:s,event:"keydown",handler:n})}this.element.classList.add("is-editing"),setTimeout(()=>{this.editInput&&(this.editInput.focus(),this.editInput.select())},0)}endEdit(){if(!this.editable||!this.element.classList.contains("is-editing"))return;const t=this.editInput.value.trim();this.element.classList.remove("is-editing"),t&&t!==this.getContent()&&(this.setContent(t),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:t},bubbles:!0})))}cancelEdit(){this.editable&&this.element.classList.contains("is-editing")&&(this.element.classList.remove("is-editing"),this.editInput&&(this.editInput.value=this.getContent()))}setEditable(t){this.editable=t,t?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this.se()}isEditable(){return this.editable}setCheckable(t){this.checkable!==t&&(this.destroy(),this.checkable=t,t?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function ws(t,s){if(t.Dt)return;const i=new vs(t,s);t.nt=i,t.Dt=!0}function ys(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("tag",ws,ys);class ks{constructor(t,s={}){this.element=t,this.tooltipEl=null,this.options=s;const i=nt(),e=void 0!==i.tooltip?.delay?i.tooltip.delay:300;this.delay=void 0!==s.delay?s.delay:parseInt(t.getAttribute("data-tooltip-delay"))||e,this.hideDelay=s.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=s.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=s.html||t.hasAttribute("data-tooltip-html"),this.theme=s.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=s.position||t.getAttribute("data-tooltip-position")||"top",this.animation=!1!==s.animation,this.mouseFollow=s.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this.ie=null,this.ee=null,this.ne=null,this.he=null,this.te=null,this.oe=null,this.re=null,this.ae=null,this.isVisible=!1}init(){this.element.Dt||(this.ie=()=>{this.delay>0?this.ne=setTimeout(()=>this.show(),this.delay):this.show()},this.ee=()=>{this.ne&&(clearTimeout(this.ne),this.ne=null),this.hideDelay>0?this.he=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this.te=()=>{this.isVisible?this.hide():this.show()},this.ae=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const s=this.tooltipEl.getBoundingClientRect();let i=t.clientX+10,e=t.clientY+10;const n=window.innerWidth,h=window.innerHeight;i+s.width>n&&(i=t.clientX-s.width-10),e+s.height>h&&(e=t.clientY-s.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${e}px`},"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.addEventListener("mouseenter",this.ie),this.element.addEventListener("mouseleave",this.ee),this.mouseFollow&&this.element.addEventListener("mousemove",this.ae)),"click"===this.trigger&&(this.element.addEventListener("click",this.te),document.addEventListener("click",t=>{!this.isVisible||this.element.contains(t.target)||this.tooltipEl?.contains(t.target)||this.hide()})),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.addEventListener("focus",this.ie),this.element.addEventListener("blur",this.ee)),this.element.Dt=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");if(!t)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;const s=ht().tooltip;this.tooltipEl.style.zIndex=s,this.tooltipEl.style.transform="translateZ(0)",this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{this.tooltipEl.classList.add("is-visible"),this.mouseFollow||this.ce(),this.isVisible=!0,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-show",{detail:{tooltip:this.tooltipEl},bubbles:!0}))})}hide(){if(!this.isVisible||!this.tooltipEl)return;this.tooltipEl.classList.remove("is-visible");const t=this.tooltipEl;setTimeout(()=>{t===this.tooltipEl&&(t.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:t},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}ce(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),s=this.tooltipEl.getBoundingClientRect(),i=window.innerWidth,e=window.innerHeight;let n,h;switch(this.position){case"bottom":n=t.left+t.width/2-s.width/2,h=t.bottom+8;break;case"right":n=t.right+8,h=t.top+t.height/2-s.height/2;break;case"left":n=t.left-s.width-8,h=t.top+t.height/2-s.height/2;break;default:n=t.left+t.width/2-s.width/2,h=t.top-s.height-8}n<8&&(n=8),n+s.width>i&&(n=i-s.width-8),h<8&&(h=8),h+s.height>e&&(h=e-s.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${h}px`,this.tooltipEl.style.position="fixed"}updateContent(t,s=!1){this.element.setAttribute("data-tooltip",t),s?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=s,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this.ce())}setPosition(t){["top","bottom","left","right"].includes(t)&&(this.position=t,this.element.setAttribute("data-tooltip-position",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this.ce()))}setTheme(t){this.theme=t,this.element.setAttribute("data-tooltip-theme",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(t){this.delay=t,this.element.setAttribute("data-tooltip-delay",t)}setHideDelay(t){this.hideDelay=t,this.element.setAttribute("data-tooltip-hide-delay",t)}setTrigger(t){["hover","click","focus","manual"].includes(t)&&(this.destroy(),this.trigger=t,this.element.setAttribute("data-tooltip-trigger",t),this.init())}enableMouseFollow(t){this.mouseFollow=t,t?(this.element.setAttribute("data-tooltip-mouse-follow",""),this.element.addEventListener("mousemove",this.ae)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this.ae))}destroy(){this.element.Dt&&(this.ne&&(clearTimeout(this.ne),this.ne=null),this.he&&(clearTimeout(this.he),this.he=null),"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.removeEventListener("mouseenter",this.ie),this.element.removeEventListener("mouseleave",this.ee)),"click"===this.trigger&&this.element.removeEventListener("click",this.te),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.removeEventListener("focus",this.ie),this.element.removeEventListener("blur",this.ee)),this.mouseFollow&&this.element.removeEventListener("mousemove",this.ae),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this.ie=null,this.ee=null,this.te=null,this.ae=null,this.element.Dt=!1)}}function xs(t,s){const i=new ks(t,s);i.init(),t.le=i}function $s(t){t.le&&(t.le.destroy(),t.le=null)}xt.register("tooltip",xs,$s);class Ms{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,s){this.customValidators[t]=s}addAsyncValidator(t,s){this.customAsyncValidators[t]=s}validate(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,i={},e=t.querySelectorAll("[data-validate]");let n=!1;return e.forEach(t=>{const s=t.name||t.id,e=this.parseRules(t.getAttribute("data-validate")),h=this.getValue(t);for(const[o,r]of Object.entries(e)){const e=this.customValidators[o]||this.validators[o],a=e?.(h,r);if(!a){i[s]=this.getErrorMessage(o,r,t),this.showError(t,i[s]),n=!0;break}this.clearError(t)}}),this.formStates[s]={valid:!n,errors:i,errorCount:Object.keys(i).length},this.updateFormState(t),!n}getValue(t){if(t.classList.contains("ds-datepicker__input")||t.classList.contains("ds-timepicker__input"))return t.value.trim();if(t.closest(".ds-select")){const s=t.closest(".ds-select"),i=s.querySelector(".ds-select__value")||s.querySelector(".ds-select__trigger span");return i?i.textContent.trim():""}if(t.closest(".ds-fileupload")){const s=t.closest(".ds-fileupload").de;return s&&s.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const s=this.parseRules(t.getAttribute("data-validate")),i=this.getValue(t);for(const[e,n]of Object.entries(s)){const s=this.customValidators[e]||this.validators[e],h=s?.(i,n);if(!h)return this.showError(t,this.getErrorMessage(e,n,t)),!1}return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let s=!0;return t.forEach(t=>{this.validate(t)||(s=!1)}),s}async validateAsync(t,s={}){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,e=s.group,n=e?t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`):t.querySelectorAll("[data-validate]");let h=!1;for(const t of n){await this.validateInputAsync(t)||(h=!0)}const o={};return n.forEach(t=>{const s=t.name||t.id,i=t.parentElement.querySelector(".ds-input__error");i&&(o[s]=i.textContent)}),this.formStates[i]={valid:!h,errors:o,errorCount:Object.keys(o).length},this.updateFormState(t),!h}async validateInputAsync(t){const s=this.parseRules(t.getAttribute("data-validate")),i=this.parseRules(t.getAttribute("data-validate-async")||""),e=this.getValue(t);for(const[i,n]of Object.entries(s)){const s=this.customValidators[i]||this.validators[i],h=s?.(e,n);if(!h)return this.showError(t,this.getErrorMessage(i,n,t)),!1}for(const[s,n]of Object.entries(i)){const i=this.customAsyncValidators[s]||this.asyncValidators[s];if(i)try{if(!await i(e,n,t))return this.showError(t,this.getErrorMessage(s,n,t)),!1}catch(s){return this.showError(t,s.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,s){const i=t.querySelectorAll(`[data-validate][data-validate-group="${s}"]`);let e=!1;for(const t of i){await this.validateInputAsync(t)||(e=!0)}return!e}getGroups(t){const s=new Set;return t.querySelectorAll("[data-validate-group]").forEach(t=>{s.add(t.getAttribute("data-validate-group"))}),Array.from(s)}getFormState(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[s]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const s=this.getFormState(t);s.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),s.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),s.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),s.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>t.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>{t.hasAttribute("data-permanent-disabled")||(t.disabled=!1)}));const i=t.querySelector(".ds-form__status");i&&(s.errorCount>0?(i.textContent=`${s.errorCount} ${1===s.errorCount?"error":"errors"} found`,i.classList.add("ds-form__status--error")):(i.textContent="All fields are valid",i.classList.remove("ds-form__status--error")))}setFormLoading(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].loading=s,this.updateFormState(t)}setFormSubmitting(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].submitting=s,this.updateFormState(t)}setFormDisabled(t,s){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].disabled=s,this.updateFormState(t)}resetForm(t){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(t=>{t.classList.remove("ds-input--error");const s=t.parentElement?.querySelector(".ds-input__error");s&&(s.textContent="")}),this.updateFormState(t)}parseRules(t){const s={};return t.split("|").forEach(t=>{const[i,e]=t.split(":");s[i]=e?e.split(","):[]}),s}validateRequired(t){return""!==t}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[s]){return t.length>=parseInt(s)}validateMaxLength(t,[s]){return t.length<=parseInt(s)}validatePattern(t,[s]){return new RegExp(s).test(t)}validateMin(t,[s]){return parseFloat(t)>=parseFloat(s)}validateMax(t,[s]){return parseFloat(t)<=parseFloat(s)}validateEqualTo(t,[s]){const i=document.getElementById(s);return i&&t===i.value}validatePhone(t){return/^[\d\s\-+()]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,s){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let i=t.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),t.parentElement.appendChild(i)),i.textContent=s,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:s}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const s=t.parentElement.querySelector(".ds-input__error");s&&s.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const s=document.createElement("span");s.className="ds-input__status-icon ds-input__status-icon--success",s.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(s)}removeStatusIcon(t){const s=t.parentElement.querySelector(".ds-input__status-icon");s&&s.remove()}getErrorMessage(t,s,i){const e=i.getAttribute(`data-message-${t}`);if(e)return e;return{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${s[0]} characters`,maxLength:`Maximum length is ${s[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${s[0]}`,max:`Maximum value is ${s[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const Ss=new Ms;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(t=>{t.addEventListener("submit",async s=>{const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;if(Ss.submitting.has(i))return void s.preventDefault();s.preventDefault();let e;if(e=null!==t.querySelector("[data-validate-async]")?await Ss.validateAsync(t):Ss.validate(t),e){Ss.submitting.add(i);const s=t.querySelector('button[type="submit"]');if(s){const t=s.textContent;s.setAttribute("data-original-text",t),s.textContent="Submitting...",s.disabled=!0}try{const s=t.getAttribute("data-on-submit");s&&window[s]?await window[s](t):t.submit()}finally{Ss.submitting.delete(i),s&&(s.textContent=s.getAttribute("data-original-text")||"Submit",s.disabled=!1)}}else{const s=t.querySelector(".ds-input--error");s&&s.focus()}}),t.querySelectorAll("[data-validate]").forEach(t=>{const s=lt(),i=s.trigger||"blur",e=()=>{s.showErrors&&setTimeout(()=>{const s=document.activeElement;if(s&&s.closest(".ds-select"))return;Ss.validateInput(t)&&t.value.trim()&&Ss.showSuccess(t)},50)};"blur"!==i&&"both"!==i||t.addEventListener("blur",e);const n=((t,s)=>{let i;return(...e)=>{clearTimeout(i),i=setTimeout(()=>t(...e),s)}})(()=>{if(!s.showErrors)return;const i=Ss.getValue(t);if(i.length>0||t.classList.contains("ds-input--error")){Ss.validateInput(t)&&i&&Ss.showSuccess(t)}else Ss.removeStatusIcon(t)},rt().debounceDelay);"input"!==i&&"both"!==i||t.addEventListener("input",n),t.addEventListener("keyup",s=>{if("Enter"===s.key){Ss.validateInput(t)&&t.value.trim()&&Ss.showSuccess(t)}})})})}));class Cs{constructor(t){this.element=t,this.hoursEl=t.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=t.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=t.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const t=this.element.getAttribute("data-end-time");if(t)return new Date(t).getTime();const s=parseInt(this.element.getAttribute("data-hours"))||0,i=parseInt(this.element.getAttribute("data-minutes"))||0,e=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*s+60*i+e)}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const t=(new Date).getTime(),s=this.endTime-t;if(s<=0)return this.stop(),this.displayTime(0,0,0),void this.dispatchComplete();const i=Math.floor(s%864e5/36e5),e=Math.floor(s%36e5/6e4),n=Math.floor(s%6e4/1e3);this.displayTime(i,e,n)}displayTime(t,s,i){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(s).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(i).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=1e3*t,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("kupola:countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function Es(t){if(t.Dt)return;const s=new Cs(t);t.nt=s,t.Dt=!0}function Ts(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("countdown",Es,Ts);class Ds{constructor(t){if(this.element=t,this.minusBtn=t.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=t.querySelector(".ds-number-input__btn--increase"),this.inputEl=t.querySelector(".ds-number-input__input"),this.ot=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const t=()=>this.updateValue(-this.step),s=()=>this.updateValue(this.step),i=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",s),this.inputEl.addEventListener("input",i),this.ot.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:s},{el:this.inputEl,event:"input",handler:i})}updateValue(t){let s=parseInt(this.inputEl.value)||0;s+=t,s<this.min&&(s=this.min),s>this.max&&(s=this.max),this.inputEl.value=s,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let t=parseInt(this.inputEl.value);isNaN(t)&&(t=0),t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}updateState(){const t=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=t<=this.min,this.plusBtn.disabled=t>=this.max}setValue(t){t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(t,s){this.min=t,this.max=s,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this.ot.forEach(({el:t,event:s,handler:i})=>{t.removeEventListener(s,i)}),this.ot=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Os(t){if(!t.Dt)try{const s=new Ds(t);t.nt=s,t.Dt=!0}catch(t){}}function Fs(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}xt.register("number-input",Os,Fs);class Is{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this.ue=null,this.pe=new Map,this.xi()}xi(){this.fe(),this.me(),this.di()}fe(){this.validators={required:t=>"string"==typeof t?""!==t.trim():Array.isArray(t)?t.length>0:null!=t,email:t=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},phone:t=>{if(!t)return!0;return/^1[3-9]\d{9}$/.test(t)},url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>!t||!isNaN(parseFloat(t))&&isFinite(t),minlength:(t,s)=>!t||t.length>=parseInt(s),maxlength:(t,s)=>!t||t.length<=parseInt(s),min:(t,s)=>!t||parseFloat(t)>=parseFloat(s),max:(t,s)=>!t||parseFloat(t)<=parseFloat(s),pattern:(t,s)=>{if(!t)return!0;return new RegExp(s).test(t)},equalTo:(t,s)=>{const i=document.getElementById(s);return!i||t===i.value}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}me(){this.form.querySelectorAll("input, select, textarea").forEach(t=>{t.hasAttribute("data-kupola-ignore")||this.fields.push(t)})}di(){this.ue=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this.ue),this.fields.forEach(t=>{const s=()=>this.validateField(t),i=()=>this.clearError(t);this.pe.set(t,{blur:s,input:i}),t.addEventListener("blur",s),t.addEventListener("input",i)})}validate(){let t=!0;return this.fields.forEach(s=>{this.validateField(s)||(t=!1)}),t}validateField(t){const s=this.ge(t);return s.length>0?(this.showError(t,s[0]),!1):(this.clearError(t),!0)}ge(t){const s=[],i=this._e(t);for(const[e,n]of Object.entries(this.validators)){const h=t.getAttribute(`data-${e}`);if(null!==h){if(!n(i,h)){let t=this.errorMessages[e];"function"==typeof t&&(t=t(h)),s.push(t)}}}return s}_e(t){const s=t.type;if("checkbox"===s)return t.checked;if("radio"===s){const s=t.name,i=this.form.querySelector(`input[name="${s}"]:checked`);return i?i.value:null}return"select-multiple"===s?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,s){this.clearError(t);const i=document.createElement("span");i.className="ds-form-error",i.textContent=s,t.classList.add("ds-form-field--error");const e=t.parentElement;e.classList.contains("ds-form-field")?e.appendChild(i):t.parentNode.insertBefore(i,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const s=t.parentElement.querySelector(".ds-form-error");s&&s.remove()}addValidator(t,s,i){this.validators[t]=s,this.errorMessages[t]=i}getData(){const t={};return this.fields.forEach(s=>{const i=s.name;if(!i)return;const e=this._e(s);"checkbox"===s.type?(t[i]||(t[i]=[]),s.checked&&t[i].push(s.value)):"radio"===s.type?!t[i]&&s.checked&&(t[i]=s.value):t[i]=e}),t}setData(t){Object.keys(t).forEach(s=>{this.form.querySelectorAll(`[name="${s}"]`).forEach(i=>{const e=i.type;if("checkbox"===e){const e=Array.isArray(t[s])?t[s]:[t[s]];i.checked=e.includes(i.value)}else if("radio"===e)i.checked=i.value===t[s];else if("select-multiple"===e){const e=Array.isArray(t[s])?t[s]:[t[s]];Array.from(i.options).forEach(t=>{t.selected=e.includes(t.value)})}else i.value=t[s]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this.ue&&this.form&&this.form.removeEventListener("submit",this.ue),this.pe.forEach((t,s)=>{s.removeEventListener("blur",t.blur),s.removeEventListener("input",t.input)}),this.ue=null,this.pe.clear(),this.pe=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function As(t){const s=document.querySelectorAll(t||".ds-form");return s.forEach(t=>{if(t.be)return;const s=new Is(t);t.be=s}),s.length}xt.register("form-validation",As);class Rs{constructor(){this.ve=new Set,this.we=!1,this.ye=0,this.ke=10}schedule(t){this.ve.add(t),this.we||(this.we=!0,queueMicrotask(()=>this.xe()))}xe(){if(this.ye>=this.ke)return this.ve.clear(),void(this.we=!1);const t=Array.from(this.ve);this.ve.clear(),this.we=!1,this.ye++;const s=new Set;for(const i of t)if(!s.has(i)){s.add(i);try{i()}catch(t){}}this.ye--}}const js=new Rs;class Ps{constructor(t,s){this.data=t,this.createdAt=Date.now(),this.ttl=s}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class Ns{constructor(){this.$e=new Map}get(t){const s=this.$e.get(t);return s||null}set(t,s,i=6e4){this.$e.set(t,new Ps(s,i))}has(t){return this.$e.has(t)}delete(t){this.$e.delete(t)}clear(){this.$e.clear()}getStale(t){const s=this.$e.get(t);return s?s.data:null}}class Bs extends Error{constructor(t,s,i){super(t),this.name="DependsError",this.code=s,this.cause=i,this.timestamp=Date.now()}}let zs="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;class Ls{constructor(t,s){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=s,this.subscribers=[],this.pending=null,this.retryCount=t.retry??0,this.retryDelay=t.retryDelay??1e3,this.onError=t.onError||null}subscribe(t){return this.subscribers.push(t),()=>{const s=this.subscribers.indexOf(t);s>-1&&this.subscribers.splice(s,1)}}notify(){js.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(t){}})})}async fetch(t){throw new Bs("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const s=this.cache.get(this.cacheKey);return s&&s.isFresh?s.data:s&&s.isStale?(this.Me(t),s.data):this.Se(t)}async Se(t,s=0){try{const s=await this.fetch(t);return this.cache.set(this.cacheKey,s,this.staleTime),this.notify(),s}catch(i){if(s<this.retryCount){const i=this.retryDelay*Math.pow(2,s),e=i+Math.random()*i*.5;return await new Promise(t=>setTimeout(t,e)),this.Se(t,s+1)}const e=i instanceof Bs?i:new Bs(i.message||"Fetch failed","FETCH_ERROR",i);if(this.onError)try{this.onError(e)}catch(t){}throw e}}async Me(t){try{await this.Se(t)}catch(t){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class Hs extends Ls{constructor(t,s){super(t,s),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let s=this.config.source;const i=tt("http");!i?.baseURL||s.startsWith("http://")||s.startsWith("https://")||(s=i.baseURL+s.replace(/^\//,""));for(const i in t)s=s.replace(`:${i}`,encodeURIComponent(t[i]));const e=[];for(const[t,s]of Object.entries(this.queryParams||{}))e.push(`${encodeURIComponent(t)}=${encodeURIComponent(s)}`);for(const s in t)this.config.source.includes(`:${s}`)||e.push(`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`);e.length>0&&(s+=(s.includes("?")?"&":"?")+e.join("&"));const n=i?.headers||{},h={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...n,...this.headers}};i?.withCredentials&&(h.credentials="include"),["POST","PUT","PATCH"].includes(h.method)&&(h.body=JSON.stringify(t));const o=zs;if(!o)throw new Bs("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const r=await o(s,h),a="boolean"==typeof r.ok?r.ok:r.status>=200&&r.status<300,c="number"==typeof r.status?r.status:0;if(!a)throw new Bs(`HTTP ${c}`,"HTTP_ERROR");return"function"==typeof r.json?await r.json():void 0!==r.data?r.data:r}}class Us extends Ls{constructor(t,s){super(t,s),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=!1!==t.sync,this.sync&&"undefined"!=typeof window&&(this.Ce=t=>{t.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this.Ce))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(null===t)return this.defaultValue;try{return JSON.parse(t)}catch(s){return t}}catch(t){return this.defaultValue}}setValue(t){const s="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(this.storageKey,s),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this.Ce&&window.removeEventListener("storage",this.Ce)}}class Vs extends Ls{constructor(t,s){super(t,s),this.paramName=t.source.replace("route:","")}async fetch(){if("undefined"==typeof window)return"";const t=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));if(t)return decodeURIComponent(t[1]);return new URLSearchParams(location.search).get(this.paramName)||""}}class Js extends Ls{async fetch(t){return await this.config.source(t)}}class qs extends Ls{async fetch(){return this.config.source}}class Ws extends Ls{constructor(t,s){super(t,s),this.ws=null,this.reconnect=!1!==t.reconnect,this.reconnectDelay=t.reconnectDelay||3e3,this.Ee=0,this.Te=t.maxReconnectDelay||3e4,this.messageHandler=null,this.De=!1,this.Oe=!1}async fetch(){return new Promise((t,s)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this.De=!0,this.Ee=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=t=>{let s;try{s=JSON.parse(t.data)}catch(i){s=t.data}this.cache.set(this.cacheKey,s,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=t=>{this.De||s(new Bs("WebSocket connection failed","WS_ERROR",t))},this.ws.onclose=()=>{if(this.De=!1,this.reconnect&&!this.Oe){const t=this.reconnectDelay*Math.pow(2,this.Ee),s=Math.random()*t*.3,i=Math.min(t+s,this.Te);this.Ee++,setTimeout(()=>{this.Oe||this.fetch().catch(()=>{})},i)}}}catch(t){s(new Bs("WebSocket creation failed","WS_ERROR",t))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("string"==typeof t?t:JSON.stringify(t))}destroy(){this.Oe=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Ks(t,s){const i=t.source;return"function"==typeof i?new Js(t,s):"string"==typeof i&&(i.startsWith("ws://")||i.startsWith("wss://"))?new Ws(t,s):"string"==typeof i&&(i.startsWith("/")||i.startsWith("http"))?new Hs(t,s):"string"==typeof i&&i.startsWith("localStorage:")?new Us(t,s):"string"==typeof i&&i.startsWith("route:")?new Vs(t,s):new qs(t,s)}function Ys(t){const s={};for(const i in t){const e=t[i];s[i]=e&&"object"==typeof e&&"value"in e?e.value:e}return s}class Zs{constructor(t,s={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=s,this.columns=(s.columns||[]).map((t,s)=>({...t,Fe:s})),this.rowKey=s.rowKey||"id",this.Ie=[],this.Ae=!1,this.striped=!1!==s.striped,this.bordered=s.bordered||!1,this.hoverable=!1!==s.hoverable,this.compact=s.compact||!1,this.emptyText=s.emptyText||"暂无数据",this.loadingText=s.loadingText||"加载中...",this.multiSort=s.multiSort||!1,this.Re=[],this.je="",this.Pe=!1!==s.pagination,this.Ne=s.pageSizes||[10,20,50,100],this.Be=s.pageSize||10,this.ze=1,this.Le=0,this.selection=s.selection||null,this.He=new Set,this.selectionColumnTitle=s.selectionColumnTitle||"",this.expandable=s.expandable||null,this.Ue=new Set,this.expandColumnTitle=s.expandColumnTitle||"",this.editable=s.editable||!1,this.Ve=null,this.Je={},this.resizable=s.resizable||!1,this.draggable=s.draggable||!1,this.qe=null,this.tree=s.tree||null,this.We=new Set,s.tree?.defaultExpandAll&&(this.Ke=!0),this.virtualScroll=s.virtualScroll||null,this.Ye=null,this.Yt=null,this.Ze=[],this.Ge=null,this.Xe=[],this.mergeCells=s.mergeCells||null,this.onSort=s.onSort||null,this.onPageChange=s.onPageChange||null,this.onRowClick=s.onRowClick||null,this.onFilter=s.onFilter||null,this.onSelect=s.onSelect||null,this.onExpand=s.onExpand||null,this.onEditSave=s.onEditSave||null,this.onEditCancel=s.onEditCancel||null,this.onRowDragEnd=s.onRowDragEnd||null,this.onColumnResize=s.onColumnResize||null,this.sortKey=J(null),this.sortOrder=J(null),this.currentPage=J(1),this.filterText=J(""),this.selectedKeys=J([]),this.xi()}xi(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&"object"==typeof t&&"value"in t?(this.Ie=Array.isArray(t.value)?t.value:[],t.subscribe&&this.Xe.push(t.subscribe(t=>{this.Ie=Array.isArray(t)?t:[],this.Le=this.Ie.length,this.render()}))):Array.isArray(t)?this.Ie=t:this.Ie=[],this.tree&&this.Ke&&this.Qe(this.Ie),this.Le=this.tn(this.Ie).length,this.render()}setLoading(t){t&&"object"==typeof t&&"value"in t?(this.Ae=t.value,t.subscribe&&this.Xe.push(t.subscribe(t=>{this.Ae=t,this.render()}))):this.Ae=!!t,this.render()}Qe(t,s=0,i=null){const e=this.tree?.childrenKey||"children",n=[];for(const h of t){const t=h[this.rowKey];n.push({...h,sn:s,en:i,nn:!(!h[e]||!h[e].length)}),h[e]&&h[e].length&&n.push(...this.Qe(h[e],s+1,t))}return n}tn(t){return this.tree?this.hn(t,0):t}hn(t,s){const i=this.tree?.childrenKey||"children",e=[];for(const n of t){const t=n[this.rowKey];e.push({...n,sn:s,nn:!(!n[i]||!n[i].length)}),n[i]&&n[i].length&&this.We.has(t)&&e.push(...this.hn(n[i],s+1))}return e}getProcessedData(){let t=(this.tree,[...this.Ie]);if(this.je){const s=this.je.toLowerCase();t=this.tree?this.rn(t,s):t.filter(t=>this.columns.some(i=>{const e=t[i.key];return null!=e&&String(e).toLowerCase().includes(s)}))}this.Re.length>0&&(t=this.tree?this.an(t):this.cn(t));const s=this.tree?this.hn(t):t;this.Le=s.length;let i=s;if(this.Pe&&this.Be>0){const t=(this.ze-1)*this.Be;i=s.slice(t,t+this.Be)}return i}rn(t,s){const i=this.tree?.childrenKey||"children";return t.reduce((t,e)=>{const n=e[i]?this.rn(e[i],s):[];return(this.columns.some(t=>{const i=e[t.key];return null!=i&&String(i).toLowerCase().includes(s)})||n.length>0)&&(t.push({...e,[i]:n}),n.length>0&&this.We.add(e[this.rowKey])),t},[])}cn(t){return[...t].sort((t,s)=>{for(const i of this.Re){const e=this.columns.find(t=>t.key===i.key);let n=t[i.key],h=s[i.key],o=0;if(o=e?.sorter?e.sorter(n,h,i.order):null==n?1:null==h?-1:"number"==typeof n&&"number"==typeof h?"asc"===i.order?n-h:h-n:"asc"===i.order?String(n).localeCompare(String(h)):String(h).localeCompare(String(n)),0!==o)return o}return 0})}an(t){const s=this.cn(t),i=this.tree?.childrenKey||"children";return s.map(t=>t[i]?.length?{...t,[i]:this.an(t[i])}:t)}render(){const t=this.getProcessedData(),s=this.element;s.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&s.appendChild(this.ln());const i=document.createElement("div");i.className="kupola-table-container";const e=document.createElement("table");e.className=this.dn(),e.appendChild(this.un()),this.virtualScroll?e.appendChild(this.pn(t)):e.appendChild(this.fn(t)),i.appendChild(e),s.appendChild(i),this.Pe&&this.Le>0&&s.appendChild(this.mn()),this.resizable&&this.gn(),this.draggable&&this._n(),this.bn()}un(){const t=document.createElement("thead"),s=document.createElement("tr");if(this.selection&&this.vn(s),this.expandable){const t=document.createElement("th");t.className="kupola-table-col-expand",s.appendChild(t)}return this.columns.forEach(t=>{const i=this.wn(t);s.appendChild(i)}),t.appendChild(s),t}vn(t){const s=document.createElement("th");if(s.className="kupola-table-col-selection","checkbox"===this.selection){const t=document.createElement("input");t.type="checkbox";const i=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=i.length>0&&i.every(t=>this.He.has(t)),t.addEventListener("change",()=>t.checked?this.selectAll():this.deselectAll()),s.appendChild(t)}t.appendChild(s)}wn(t){const s=document.createElement("th");if(s.textContent=t.title||t.key,t.width&&(s.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(s.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(s.style.textAlign=t.align),t.fixed&&s.setAttribute("data-fixed",t.fixed),t.sortable&&this.yn(s,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const i=document.createElement("span");i.className="kupola-table-resize-handle",i.setAttribute("data-col-key",t.key),s.appendChild(i)}return s}yn(t,s){t.classList.add("kupola-table-sortable");const i=this.Re.find(t=>t.key===s.key);i&&t.classList.add(`kupola-table-sort-${i.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this.kn(s.key)});const e=document.createElement("span");e.className="kupola-table-sort-icon",e.textContent=i?this.multiSort?` ${this.Re.indexOf(i)+1}${"asc"===i.order?"▲":"▼"}`:"asc"===i.order?" ▲":" ▼":" ⇅",t.appendChild(e)}fn(t){const s=document.createElement("tbody");if(this.Ae)s.appendChild(this.xn(this.loadingText,"kupola-table-loading"));else if(0===t.length)s.appendChild(this.xn(this.emptyText,"kupola-table-empty"));else{const i=this.mergeCells?this.mergeCells(t):[],e=new Map;i.forEach(t=>e.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,i)=>{const h=t[this.rowKey]??i,o=this.He.has(h),r=this.Ue.has(h),a=this.$n(t,i,h,o,n,e);if(s.appendChild(a),this.expandable&&r){const i=document.createElement("tr");i.className="kupola-table-expand-row";const e=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;e.colSpan=n,e.className="kupola-table-expand-content";const h=this.expandable(t);"string"==typeof h?e.innerHTML=h:h instanceof HTMLElement&&e.appendChild(h),i.appendChild(e),s.appendChild(i)}})}return s}$n(t,s,i,e,n,h){const o=document.createElement("tr");return o.setAttribute("data-row-key",i),e&&o.classList.add("kupola-table-row-selected"),this.draggable&&(o.draggable=!0,o.classList.add("kupola-table-draggable")),this.selection&&this.Mn(o,i,e),this.expandable&&this.Sn(o,i),this.columns.forEach((e,r)=>{if(n.has(`${s}-${r}`))return;const a=this.Cn(t,s,i,e,r,n,h);o.appendChild(a)}),this.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",i=>{i.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,s,i)})),o}Mn(t,s,i){const e=document.createElement("td");e.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=i,n.addEventListener("change",()=>{"radio"===this.selection?(this.He.clear(),this.He.add(s)):i?this.He.delete(s):this.He.add(s),this.selectedKeys.value=[...this.He],this.onSelect&&this.onSelect([...this.He],this.getSelectedRows()),this.render()}),e.appendChild(n),t.appendChild(e)}Sn(t,s){const i=document.createElement("td");i.className="kupola-table-col-expand";const e=document.createElement("button");e.className="kupola-table-expand-btn",e.textContent=this.Ue.has(s)?"▼":"▶",e.type="button",e.addEventListener("click",()=>this.En(s)),i.appendChild(e),t.appendChild(i)}Cn(t,s,i,e,n,h,o){const r=document.createElement("td");e.align&&(r.style.textAlign=e.align),e.fixed&&(r.setAttribute("data-fixed",e.fixed),r.classList.add(`kupola-table-fixed-${e.fixed}`));const a=o.get(`${s}-${n}`);if(a){a.rowSpan>1&&(r.rowSpan=a.rowSpan),a.colSpan>1&&(r.colSpan=a.colSpan);for(let t=0;t<(a.rowSpan||1);t++)for(let i=0;i<(a.colSpan||1);i++)0===t&&0===i||h.add(`${s+t}-${n+i}`)}this.tree&&0===n&&t.sn>0&&this.Tn(r,t);const c=this.Ve&&this.Ve.rowKey===i&&this.Ve.colKey===e.key;if(c)r.appendChild(this.Dn(e,t));else if(e.render){const i=e.render(t[e.key],t,s);"string"==typeof i?r.innerHTML=i:i instanceof HTMLElement&&r.appendChild(i)}else r.textContent=t[e.key]??"";return this.editable&&!c&&!1!==e.editable&&(r.classList.add("kupola-table-editable-cell"),r.addEventListener("dblclick",()=>this.On(i,e.key,t[e.key]))),r}Tn(t,s){const i=document.createElement("span");if(i.className="kupola-table-tree-indent",i.style.paddingLeft=20*s.sn+"px",t.appendChild(i),s.nn){const i=document.createElement("button");i.className="kupola-table-tree-toggle",i.textContent=this.We.has(s[this.rowKey])?"▼":"▶",i.type="button",i.addEventListener("click",t=>{t.stopPropagation(),this.Fn(s[this.rowKey])}),t.appendChild(i)}else{const s=document.createElement("span");s.className="kupola-table-tree-toggle-placeholder",t.appendChild(s)}}xn(t,s){const i=document.createElement("tr"),e=document.createElement("td");return e.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),e.className=s,e.textContent=t,i.appendChild(e),i}pn(t){const s=document.createElement("tbody"),{rowHeight:i=40,overscan:e=5}=this.virtualScroll,n=t.length*i;if(this.Ae)return this.fn(t);if(0===t.length)return this.fn(t);const h=document.createElement("tr");h.className="kupola-table-virtual-spacer-top",h.style.height="0px",s.appendChild(h),this.In={data:t,rowHeight:i,overscan:e,totalHeight:n,tbody:s,topSpacer:h},this.An();const o=document.createElement("tr");o.className="kupola-table-virtual-spacer-bottom",o.style.height="0px",s.appendChild(o);const r=this.element.querySelector(".kupola-table-container");return r&&(r.style.maxHeight=this.virtualScroll.maxHeight||"400px",r.style.overflowY="auto",this.Yt&&r.removeEventListener("scroll",this.Yt),this.Yt=()=>this.An(),r.addEventListener("scroll",this.Yt)),s}An(){if(!this.In)return;const{data:t,rowHeight:s,overscan:i,tbody:e,topSpacer:n}=this.In,h=this.element.querySelector(".kupola-table-container");if(!h)return;const o=h.scrollTop,r=h.clientHeight,a=Math.max(0,Math.floor(o/s)-i),c=Math.min(t.length,Math.ceil((o+r)/s)+i);e.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const l=document.createDocumentFragment();for(let i=a;i<c;i++){const e=t[i],n=e[this.rowKey]??i,h=this.$n(e,i,n,this.He.has(n),new Set,new Map);h.classList.add("kupola-table-virtual-row"),h.style.height=s+"px",l.appendChild(h)}n.style.height=a*s+"px";const d=e.querySelector(".kupola-table-virtual-spacer-bottom");d&&(d.style.height=(t.length-c)*s+"px"),n.after(l)}Dn(t,s){const i=document.createElement("div");i.className="kupola-table-edit-cell";const e=document.createElement("input");if(e.type=t.editType||"text",e.className="ds-input kupola-table-edit-input",e.value=this.Je[t.key]??s[t.key]??"",t.editOptions){const s=document.createElement("select");s.className="ds-input kupola-table-edit-input",t.editOptions.forEach(t=>{const i=document.createElement("option");i.value="object"==typeof t?t.value:t,i.textContent="object"==typeof t?t.label:t,String(i.value)===String(e.value)&&(i.selected=!0),s.appendChild(i)}),s.addEventListener("change",()=>{this.Je[t.key]=s.value}),i.appendChild(s)}else e.addEventListener("input",()=>{this.Je[t.key]=e.value}),i.appendChild(e);const n=document.createElement("div");n.className="kupola-table-edit-actions";const h=document.createElement("button");h.className="kupola-table-edit-save",h.textContent="✓",h.type="button",h.addEventListener("click",()=>this.Rn(s,t));const o=document.createElement("button");return o.className="kupola-table-edit-cancel",o.textContent="✗",o.type="button",o.addEventListener("click",()=>this.jn()),n.appendChild(h),n.appendChild(o),i.appendChild(n),e.addEventListener("keydown",i=>{"Enter"===i.key&&this.Rn(s,t),"Escape"===i.key&&this.jn()}),setTimeout(()=>e.focus?.(),0),i}On(t,s,i){this.Ve={rowKey:t,colKey:s},this.Je={[s]:i},this.render()}Rn(t,s){const i=this.Je[s.key];this.onEditSave?this.onEditSave(t,s.key,i,this.Ie):t[s.key]=i,this.Ve=null,this.Je={},this.render()}jn(){this.onEditCancel&&this.onEditCancel(this.Ve),this.Ve=null,this.Je={},this.render()}kn(t){if(this.multiSort){const s=this.Re.findIndex(s=>s.key===t);if(s>=0){const t=this.Re[s];"asc"===t.order?t.order="desc":this.Re.splice(s,1)}else this.Re.push({key:t,order:"asc"})}else{const s=this.Re.find(s=>s.key===t);s?"asc"===s.order?s.order="desc":this.Re=[]:this.Re=[{key:t,order:"asc"}]}this.sortKey.value=this.Re.map(t=>t.key).join(","),this.sortOrder.value=this.Re.map(t=>t.order).join(","),this.ze=1,this.onSort&&this.onSort(this.Re),this.render()}En(t){this.Ue.has(t)?this.Ue.delete(t):this.Ue.add(t),this.onExpand&&this.onExpand(t,this.Ue.has(t)),this.render()}Fn(t){this.We.has(t)?this.We.delete(t):this.We.add(t),this.render()}selectRow(t){this.He.add(t),this.Pn(),this.render()}deselectRow(t){this.He.delete(t),this.Pn(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this.He.add(t[this.rowKey])),this.Pn(),this.render()}deselectAll(){this.He.clear(),this.Pn(),this.render()}invertSelection(){this.getProcessedData().forEach(t=>{const s=t[this.rowKey];this.He.has(s)?this.He.delete(s):this.He.add(s)}),this.Pn(),this.render()}getSelectedKeys(){return[...this.He]}getSelectedRows(){return(this.tree?this.Qe(this.Ie):this.Ie).filter(t=>this.He.has(t[this.rowKey]))}Pn(){this.selectedKeys.value=[...this.He]}gn(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{t.addEventListener("mousedown",s=>{s.preventDefault();const i=t.getAttribute("data-col-key"),e=t.parentElement,n=s.clientX,h=e.offsetWidth,o=t=>{const s=Math.max(50,h+(t.clientX-n));e.style.width=s+"px";const o=this.columns.find(t=>t.key===i);o&&(o.width=s),this.onColumnResize&&this.onColumnResize(i,s)},r=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.Ze.push(r)})})}_n(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(t=>{t.addEventListener("dragstart",s=>{this.qe={fromKey:t.getAttribute("data-row-key")},t.classList.add("kupola-table-dragging"),s.dataTransfer.effectAllowed="move"}),t.addEventListener("dragover",s=>{s.preventDefault(),s.dataTransfer.dropEffect="move",t.classList.add("kupola-table-drag-over")}),t.addEventListener("dragleave",()=>t.classList.remove("kupola-table-drag-over")),t.addEventListener("drop",s=>this.Nn(s,t)),t.addEventListener("dragend",()=>{t.classList.remove("kupola-table-dragging"),this.qe=null})})}Nn(t,s){if(t.preventDefault(),s.classList.remove("kupola-table-drag-over"),!this.qe)return;const i=s.getAttribute("data-row-key");if(this.qe.fromKey===i)return;const e=this.Ie.findIndex(t=>String(t[this.rowKey])===this.qe.fromKey),n=this.Ie.findIndex(t=>String(t[this.rowKey])===i);if(e>=0&&n>=0){const[t]=this.Ie.splice(e,1);this.Ie.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,e,n,this.Ie),this.render()}}bn(){const t=this.columns.filter(t=>"left"===t.fixed);this.selection,this.expandable,t.forEach(t=>{const s=this.element.querySelectorAll('th[data-fixed="left"]'),i=this.element.querySelectorAll('td[data-fixed="left"]'),e=this.columns.indexOf(t);let n=(this.selection?40:0)+(this.expandable?40:0);for(let t=0;t<e;t++)"left"===this.columns[t].fixed&&(n+=this.columns[t].Bn||120);s.forEach(s=>{s.textContent.startsWith(t.title||t.key)&&(s.style.position="sticky",s.style.left=n+"px",s.style.zIndex="2",t.Bn=s.offsetWidth)}),i.forEach(t=>{t.style.position="sticky",t.style.left=n+"px",t.style.zIndex="1",t.style.background="inherit"})});let s=0;[...this.columns].filter(t=>"right"===t.fixed).reverse().forEach(t=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(t=>{t.style.position="sticky",t.style.right=s+"px",t.style.zIndex="1"}),s+=t.Bn||t.width||120})}ln(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const s=document.createElement("input");s.type="text",s.className="ds-input kupola-table-filter-input",s.placeholder=this.options.filterPlaceholder||"搜索...",s.value=this.je,s.addEventListener("input",()=>{clearTimeout(this.Ge),this.Ge=setTimeout(()=>{this.je=s.value,this.ze=1,this.filterText.value=this.je,this.onFilter&&this.onFilter(this.je),this.render()},300)}),t.appendChild(s)}const s=document.createElement("div");if(s.className="kupola-table-toolbar-right",this.selection&&this.He.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`已选 ${this.He.size} 项`,s.appendChild(t);const i=document.createElement("button");i.className="ds-btn ds-btn--sm",i.textContent="反选",i.type="button",i.addEventListener("click",()=>this.invertSelection()),s.appendChild(i)}if(this.options.showExport){const t=document.createElement("button");t.className="ds-btn ds-btn--sm ds-btn--secondary",t.textContent="导出 CSV",t.type="button",t.addEventListener("click",()=>this.exportCSV()),s.appendChild(t)}const i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this.Le} 条`,s.appendChild(i),t.appendChild(s),t}mn(){const t=Math.ceil(this.Le/this.Be);if(t<=1)return document.createElement("div");const s=document.createElement("div");if(s.className="kupola-table-pagination",this.options.showPageSize){const t=document.createElement("select");t.className="kupola-table-page-size",this.Ne.forEach(s=>{const i=document.createElement("option");i.value=s,i.textContent=`${s} 条/页`,s===this.Be&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>{this.Be=parseInt(t.value),this.ze=1,this.currentPage.value=1,this.render()}),s.appendChild(t)}const i=document.createElement("div");i.className="kupola-table-pages";const e=this.zn("‹",()=>this.Ln(this.ze-1));e.disabled=this.ze<=1,i.appendChild(e),this.Hn(this.ze,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",i.appendChild(t)}else{const s=this.zn(t,()=>this.Ln(t));t===this.ze&&s.classList.add("active"),i.appendChild(s)}});const n=this.zn("›",()=>this.Ln(this.ze+1));n.disabled=this.ze>=t,i.appendChild(n),s.appendChild(i);const h=document.createElement("span");return h.className="kupola-table-page-info",h.textContent=`${this.ze} / ${t}`,s.appendChild(h),s}zn(t,s){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=t,i.type="button",i.addEventListener("click",s),i}Ln(t){const s=Math.ceil(this.Le/this.Be);t<1||t>s||(this.ze=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this.Be),this.render())}Hn(t,s){if(s<=7)return Array.from({length:s},(t,s)=>s+1);const i=[];if(t<=3){for(let t=1;t<=5;t++)i.push(t);i.push("...",s)}else if(t>=s-2){i.push(1,"...");for(let t=s-4;t<=s;t++)i.push(t)}else{i.push(1,"...");for(let s=t-1;s<=t+1;s++)i.push(s);i.push("...",s)}return i}exportCSV(t="export.csv"){const s=this.getProcessedData(),i=this.columns.map(t=>t.title||t.key),e=s.map(t=>this.columns.map(s=>{let i=t[s.key];return null==i&&(i=""),i=String(i).replace(/"/g,'""'),`"${i}"`}).join(",")),n="\ufeff"+[i.join(","),...e].join("\n"),h=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(h),r=document.createElement("a");r.href=o,r.download=t,r.click(),URL.revokeObjectURL(o)}dn(){const t=["kupola-table"];return this.striped&&t.push("kupola-table-striped"),this.bordered&&t.push("kupola-table-bordered"),this.hoverable&&t.push("kupola-table-hover"),this.compact&&t.push("kupola-table-compact"),t.join(" ")}refresh(){this.render()}getPage(){return{current:this.ze,pageSize:this.Be,total:this.Le}}setColumns(t){this.columns=t.map((t,s)=>({...t,Fe:s})),this.render()}destroy(){if(this.Yt){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this.Yt),this.Yt=null}this.Ge&&(clearTimeout(this.Ge),this.Ge=null),this.Ze.forEach(t=>t()),this.Ze=[],this.Xe.forEach(t=>t.unsubscribe()),this.Xe=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this.Ie=[],this.In=null,this.qe=null,this.Ve=null,this.Je={}}}function Gs(t,s){return new Zs(t,s)}xt.register("table",Gs);class Xs{constructor(t,s={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=s,this.Un=s.current||1,this.Le=s.total||0,this.Be=s.pageSize||10,this.Vn=s.maxPages||7,this.Jn=!1!==s.showTotal,this.qn=s.showSizeChanger||!1,this.Ne=s.pageSizes||[10,20,50,100],this.Wn=s.simple||!1,this.current=J(this.Un),this.total=J(this.Le),this.onChange=s.onChange||null,this.onPageSizeChange=s.onPageSizeChange||null,this.xi()}xi(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this.Le/this.Be))}setCurrent(t){(t=Math.max(1,Math.min(t,this.totalPages)))!==this.Un&&(this.Un=t,this.current.value=t,this.onChange&&this.onChange(t,this.Be),this.render())}setTotal(t){t&&"object"==typeof t&&"value"in t?(this.Le=t.value||0,t.B?.add(t=>{this.Le=t||0,this.Un>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this.Le=t,this.total.value=this.Le,this.render()}setPageSize(t){this.Be=t,this.Un=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this.Un),this.render()}render(){const t=this.element;t.innerHTML="",this.Le<=0||(this.Wn?this.Kn(t):this.Yn(t))}Kn(t){const s=this.totalPages,i=this.Zn("‹",()=>this.setCurrent(this.Un-1));i.disabled=this.Un<=1,t.appendChild(i);const e=document.createElement("span");e.className="kupola-pagination-simple-info",e.textContent=`${this.Un} / ${s}`,t.appendChild(e);const n=this.Zn("›",()=>this.setCurrent(this.Un+1));n.disabled=this.Un>=s,t.appendChild(n)}Yn(t){const s=this.totalPages;if(this.Jn){const s=document.createElement("span");s.className="kupola-pagination-total",s.textContent=`共 ${this.Le} 条`,t.appendChild(s)}if(this.qn){const s=document.createElement("select");s.className="kupola-pagination-size",this.Ne.forEach(t=>{const i=document.createElement("option");i.value=t,i.textContent=`${t} 条/页`,t===this.Be&&(i.selected=!0),s.appendChild(i)}),s.addEventListener("change",()=>this.setPageSize(parseInt(s.value))),t.appendChild(s)}const i=document.createElement("div");i.className="kupola-pagination-pages";const e=this.Zn("‹",()=>this.setCurrent(this.Un-1));e.disabled=this.Un<=1,i.appendChild(e),this.Hn().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",i.appendChild(t)}else{const s=this.Zn(t,()=>this.setCurrent(t));t===this.Un&&s.classList.add("active"),i.appendChild(s)}});const n=this.Zn("›",()=>this.setCurrent(this.Un+1));if(n.disabled=this.Un>=s,i.appendChild(n),t.appendChild(i),s>10){const i=document.createElement("span");i.className="kupola-pagination-jumper",i.innerHTML='跳至 <input type="number" min="1" max="'+s+'" value="'+this.Un+'"> 页';const e=i.querySelector("input");e.addEventListener("change",()=>{const t=parseInt(e.value);t>=1&&t<=s&&this.setCurrent(t)}),e.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(e.value);t>=1&&t<=s&&this.setCurrent(t)}}),t.appendChild(i)}}Zn(t,s){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=t,i.type="button",i.addEventListener("click",s),i}Hn(){const t=this.totalPages,s=this.Vn;if(t<=s)return Array.from({length:t},(t,s)=>s+1);const i=[],e=Math.floor(s/2);if(this.Un<=e+1){for(let t=1;t<=s-2;t++)i.push(t);i.push("...",t)}else if(this.Un>=t-e){i.push(1,"...");for(let e=t-s+3;e<=t;e++)i.push(e)}else{i.push(1,"...");for(let t=this.Un-e+2;t<=this.Un+e-2;t++)i.push(t);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let Qs=!1;exports.BRAND_OPTIONS=ft,exports.CacheEntry=Ps,exports.CacheManager=Ns,exports.Calendar=ds,exports.Collapse=hs,exports.ColorPicker=as,exports.ComponentInitializerRegistry=kt,exports.Countdown=Cs,exports.Datepicker=Pt,exports.DependsError=Bs,exports.DependsSource=Ls,exports.Dialog=class{static normal(t={}){return this.Gn({type:"normal",...t})}static success(t={}){return this.Gn({type:"success",...t})}static warning(t={}){return this.Gn({type:"warning",...t})}static error(t={}){return this.Gn({type:"error",...t})}static info(t={}){return this.Gn({type:"info",...t})}static confirm(t={}){return this.Gn({type:"confirm",...t})}static Gn(t){const{type:s="normal",title:i="",content:e="",onConfirm:n,onCancel:h}=t,o={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},r=document.createElement("div");r.className="ds-modal-container",r.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal" style="max-width: 360px">\n <div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">\n <div class="ds-dialog__icon ds-dialog__icon--${s}">${o[s]}</div>\n ${i?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===s||h?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}\n <button class="ds-btn ${"confirm"===s?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>\n ${"confirm"===s?"Confirm":"OK"}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,document.body.appendChild(r),i&&(r.querySelector(".ds-dialog__title").textContent=i),r.querySelector(".ds-dialog__content").textContent=e;const a=r.querySelector(".ds-modal-mask"),c=r.querySelector("[data-dialog-confirm]"),l=r.querySelector("[data-dialog-cancel]"),d=function(t){"Escape"===t.key&&(h&&h(),m())},u=function(t){t.target===a&&(h&&h(),m())},p=function(){n&&n(),m()},f=function(){h&&h(),m()},m=()=>{a.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",d),a.removeEventListener("click",u),c&&c.removeEventListener("click",p),l&&l.removeEventListener("click",f),setTimeout(()=>r.remove(),300)};return a.classList.add("is-visible"),document.body.style.overflow="hidden",c&&c.addEventListener("click",p),l&&l.addEventListener("click",f),a.addEventListener("click",u),document.addEventListener("keydown",d),{close:m}}},exports.Drawer=qt,exports.Dropdown=Ot,exports.DynamicTags=fs,exports.FetchedSource=Hs,exports.FileUpload=is,exports.FunctionSource=Js,exports.GlobalEvents=Tt,exports.ImagePreview=_s,exports.KupolaComponent=Mt,exports.KupolaComponentRegistry=Ct,exports.KupolaDataBind=L,exports.KupolaEventBus=V,exports.KupolaForm=Is,exports.KupolaLifecycle=t,exports.KupolaPagination=Xs,exports.KupolaStore=H,exports.KupolaStoreManager=U,exports.KupolaTable=Zs,exports.KupolaUtils=R,exports.KupolaValidator=Ms,exports.Message=ts,exports.Modal=Yt,exports.Notification=Qt,exports.NumberInput=Ds,exports.RouteSource=Vs,exports.Scheduler=Rs,exports.Select=At,exports.Slider=Ut,exports.StaticSource=qs,exports.StorageSource=Us,exports.Tag=vs,exports.Timepicker=zt,exports.Tooltip=ks,exports.WebSocketSource=Ws,exports.alertModal=function(t){return"string"==typeof t&&(t={content:t}),Zt({...t,showCancel:!1,showConfirm:!0})},exports.applyMixin=St,exports.arrayUtils=o,exports.bootstrapComponents=function(t){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(t):Promise.resolve()},exports.cleanupAllDropdowns=function(){document.querySelectorAll(".ds-dropdown").forEach(t=>{It(t)})},exports.cleanupCalendar=ps,exports.cleanupCollapse=rs,exports.cleanupColorPicker=ls,exports.cleanupCountdown=Ts,exports.cleanupDatepicker=Bt,exports.cleanupDrawer=Kt,exports.cleanupDropdown=It,exports.cleanupDynamicTags=gs,exports.cleanupFileUpload=ns,exports.cleanupModal=Xt,exports.cleanupNumberInput=Fs,exports.cleanupSelect=jt,exports.cleanupSlider=Jt,exports.cleanupTag=ys,exports.cleanupTimepicker=Ht,exports.cleanupTooltip=$s,exports.clearCache=function(){},exports.configureHttpClient=function(t){if(!t||"function"!=typeof t.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");zs=t.fetch.bind(t)},exports.confirmModal=function(t){return"string"==typeof t&&(t={content:t}),Zt({...t,showCancel:!0,showConfirm:!0})},exports.createBrandPicker=function(){const t=document.createElement("div");t.id="brand-picker-auto",t.style.position="fixed",t.style.top="56px",t.style.right="16px",t.style.zIndex="9998",t.style.display="none",t.style.padding="12px",t.style.width="200px",t.style.gridTemplateColumns="repeat(3, 1fr)",t.style.gap="6px",t.style.backgroundColor="var(--bg-base-secondary)",t.style.border="1px solid var(--border-neutral-l1)",t.style.borderRadius="8px",t.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",t.style.overflow="hidden",ft.forEach(s=>{const i=document.createElement("button");i.setAttribute("data-brand-btn",s.id),i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.height="60px",i.style.backgroundColor=s.color,i.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(s.color)?"#0C0C0D":"#FFFFFF",i.style.fontWeight="500",i.style.borderRadius="4px",i.style.border="none",i.style.cursor="pointer",i.style.margin="0",i.style.padding="0",i.textContent=s.name,t.appendChild(i)}),document.body.appendChild(t);const s=document.createElement("button");s.setAttribute("data-brand-toggle",""),s.setAttribute("data-current-brand",_t()),s.className="ds-btn ds-btn--ghost ds-btn--sm",s.style.position="fixed",s.style.top="16px",s.style.right="56px",s.style.zIndex="9999",s.style.display="flex",s.style.alignItems="center",s.style.gap="6px";const i=document.createElement("span");i.className="brand-icon",i.style.width="12px",i.style.height="12px",i.style.borderRadius="50%",i.style.backgroundColor=ft.find(t=>t.id===_t()).color;const e=document.createElement("span");function n(i){t.contains(i.target)||s.contains(i.target)||(t.style.display="none",document.removeEventListener("click",n,!0))}return e.className="brand-name",e.style.fontSize="11px",e.textContent=ft.find(t=>t.id===_t()).name,s.appendChild(i),s.appendChild(e),document.body.appendChild(s),s.onclick=function(s){s.stopPropagation(),s.preventDefault();const i="none"===t.style.display;t.style.display=i?"grid":"none",i?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},t.onclick=function(t){t.stopPropagation()},t.querySelectorAll("[data-brand-btn]").forEach(s=>{s.addEventListener("click",i=>{i.stopPropagation();bt(s.getAttribute("data-brand-btn")),t.style.display="none"})}),{toggleBtn:s,container:t}},exports.createLifecycle=function(s="app"){return new t(s)},exports.createModal=Zt,exports.createSource=Ks,exports.createStore=function(t,s){return K.createStore(t,s)},exports.createThemeToggle=function(){const t=document.createElement("button");t.setAttribute("data-theme-toggle",""),t.setAttribute("data-current-theme",mt()),t.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",t.style.position="fixed",t.style.top="16px",t.style.right="16px",t.style.zIndex="9999";const s=document.createElement("img");s.className="theme-icon";const i=st();return s.src="dark"===mt()?i+"sun.svg":i+"moon.svg",s.width=14,s.height=14,s.alt="Toggle theme",t.appendChild(s),document.body.appendChild(t),t.onclick=function(t){t.preventDefault();gt("dark"===mt()?"light":"dark")},t},exports.cryptoUtils=T,exports.dateUtils=v,exports.debounce=w,exports.defineComponent=function(t,s){if(!s||"object"!=typeof s)throw new Error(`defineComponent("${t}"): options must be an object`);s.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(t,s.componentClass):s.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(t,s.lazy),s.init?xt.register(t,s.init,s.cleanup||null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass}):(s.dataAttribute||s.cssClass)&&xt.register(t,()=>{},null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass})},exports.defineMixin=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(t,s)},exports.emit=function(t,s,i){return Dt.emit(t,s,i)},exports.emitGlobal=function(t,s){return Dt.emitGlobal(t,s)},exports.escapeHtml=function(t){if("string"!=typeof t)return t;const s=document.createElement("div");return s.textContent=t,s.innerHTML},exports.generateSecureId=function(t,s){const i=ot(),e=i?.secureId||{},n=t||e.length||16,h=e.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if("undefined"==typeof crypto||!crypto.getRandomValues){let t="";for(let s=0;s<n;s++)t+=h[Math.floor(Math.random()*h.length)];return s?`${s}_${t}`:t}const o=new Uint32Array(n);crypto.getRandomValues(o);let r="";for(let t=0;t<n;t++)r+=h[o[t]%h.length];return s?`${s}_${r}`:r},exports.getBasePath=function(){return Y.paths.base},exports.getBrand=_t,exports.getConfig=tt,exports.getDefaultBrand=et,exports.getDefaultTheme=it,exports.getFormInstance=function(t){return t.be},exports.getHttpClient=function(){return zs},exports.getHttpConfig=function(){return Y.http},exports.getIconsPath=st,exports.getListenerCount=function(t,s){return Dt.getListenerCount(t,s)},exports.getMessageConfig=at,exports.getNotificationConfig=ct,exports.getPerformanceConfig=rt,exports.getSecurityConfig=ot,exports.getStore=function(t){return K.getStore(t)},exports.getTheme=mt,exports.getUiConfig=nt,exports.getValidationConfig=lt,exports.globalEvents=Dt,exports.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const s=t.getAttribute("data-kupola-table");let i={};if(s)try{i=JSON.parse(s)}catch(t){}Gs(t,i)})},exports.initCalendar=us,exports.initCalendars=function(){document.querySelectorAll(".ds-calendar").forEach(t=>{us(t)})},exports.initCollapse=os,exports.initCollapses=function(){document.querySelectorAll(".ds-collapse").forEach(t=>{os(t)})},exports.initColorPicker=cs,exports.initColorPickers=function(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{cs(t)})},exports.initCountdown=Es,exports.initCountdowns=function(){document.querySelectorAll(".ds-countdown").forEach(t=>{Es(t)})},exports.initDatepicker=Nt,exports.initDatepickers=function(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{Nt(t)})},exports.initDrawer=Wt,exports.initDrawers=function(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const s=t.getAttribute("data-drawer"),i=document.getElementById(s);i&&(Wt(i,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),i.nt?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const s=t.parentElement;s&&Wt(s)})},exports.initDropdown=Ft,exports.initDropdowns=function(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{Ft(t)})},exports.initDynamicTags=ms,exports.initDynamicTagsAll=function(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{ms(t)})},exports.initFileUpload=es,exports.initFileUploads=function(){document.querySelectorAll(".ds-fileupload").forEach(t=>{es(t)})},exports.initFormValidation=As,exports.initImagePreview=function(){bs||(bs=new _s),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const s=JSON.parse(t.getAttribute("data-image-preview")),i=parseInt(t.getAttribute("data-image-index"))||0;bs.show(s,i)})})},exports.initMessages=function(){},exports.initModal=Gt,exports.initModals=function(){document.querySelectorAll(".ds-modal-container").forEach(t=>{Gt(t)})},exports.initNotifications=function(){},exports.initNumberInput=Os,exports.initNumberInputs=function(){document.querySelectorAll(".ds-number-input").forEach(t=>{Os(t)})},exports.initPagination=function(t,s){return function(){if(Qs||"undefined"==typeof document)return;const t=document.createElement("style");t.textContent="\n .kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }\n .kupola-pagination-btn { min-width: 32px; height: 32px; border: 1px solid #d9d9d9; border-radius: 4px; background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }\n .kupola-pagination-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }\n .kupola-pagination-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }\n .kupola-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }\n .kupola-pagination-ellipsis { padding: 0 4px; color: #999; user-select: none; }\n .kupola-pagination-total { color: #666; font-size: 14px; }\n .kupola-pagination-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }\n .kupola-pagination-simple-info { padding: 0 8px; font-size: 14px; color: #333; }\n .kupola-pagination-jumper { font-size: 14px; color: #666; }\n .kupola-pagination-jumper input { width: 50px; height: 28px; margin: 0 4px; padding: 0 8px; border: 1px solid #d9d9d9; border-radius: 4px; text-align: center; font-size: 13px; }\n .kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }\n ",document.head.appendChild(t),Qs=!0}(),new Xs(t,s)},exports.initSelect=Rt,exports.initSelects=function(t=document){t.querySelectorAll(".ds-select").forEach(t=>{Rt(t)})},exports.initSlider=Vt,exports.initSliders=function(){document.querySelectorAll(".ds-slider").forEach(t=>{Vt(t)})},exports.initTable=Gs,exports.initTag=ws,exports.initTags=function(){document.querySelectorAll(".ds-tag").forEach(t=>{ws(t)})},exports.initTheme=yt,exports.initTimepicker=Lt,exports.initTimepickers=function(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{Lt(t)})},exports.initTooltip=xs,exports.initTooltips=function(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{xs(t)})},exports.kupolaBootstrap=Et,exports.kupolaData=q,exports.kupolaEvents=W,exports.kupolaInitializer=xt,exports.kupolaLifecycle=s,exports.kupolaStoreManager=K,exports.maskData=function(t,s,i={}){const e=ot(),n=e?.maskData||{};if(!n.enabled&&!i.force)return t;if(null==t)return t;const h=(i.patterns||n.patterns||{})[s];if(!h)return t;const o="string"==typeof h.regex?new RegExp(h.regex):h.regex;return String(t).replace(o,h.replace)},exports.numberUtils=u,exports.objectUtils=a,exports.off=function(t,s,i){Dt.off(t,s,i)},exports.offAll=function(t,s){Dt.offAll(t,s)},exports.offByScope=function(t){Dt.offByScope(t)},exports.offConfigChange=function(t){const s=Z.indexOf(t);s>-1&&Z.splice(s,1)},exports.on=function(t,s,i,e){return Dt.on(t,s,i,e)},exports.onConfigChange=Q,exports.once=function(t,s,i,e){return Dt.once(t,s,i,e)},exports.preloadUtils=A,exports.ref=J,exports.registerComponent=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.register(t,s)},exports.registerLazyComponent=function(t,s){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(t,s)},exports.resetHttpClient=function(){zs="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null},exports.sanitizeHtml=function(t,s={}){const i=ot(),e=i?.sanitizeHtml||{};if(!e.enabled&&!s.force)return t;const n=s.allowedTags||e.allowedTags||[],h=s.allowedAttributes||e.allowedAttributes||{};if("string"!=typeof t)return t;const o=(new DOMParser).parseFromString(t,"text/html");return o.body.querySelectorAll("*").forEach(t=>{const s=t.tagName.toLowerCase();n.includes(s)?Array.from(t.attributes).forEach(i=>{const e=i.name.toLowerCase();(h[s]||[]).includes(e)||t.removeAttribute(i.name)}):t.remove()}),o.body.innerHTML},exports.setBrand=bt,exports.setConfig=function(t){dt(Y,t),X()},exports.setTheme=gt,exports.showImagePreview=function(t,s=0){bs||(bs=new _s),bs.show(t,s)},exports.stringUtils=n,exports.stripHtml=function(t){return"string"!=typeof t?t:(new DOMParser).parseFromString(t,"text/html").body.textContent||""},exports.throttle=y,exports.useDeps=function(t,s){const i={},e=new Ns,n=[];for(const h in s){let o=s[h];"string"==typeof o&&(o={source:o});const r=Ks({...o,cacheKey:o.cacheKey||`${h}-${JSON.stringify(Ys(t))}`},e),a=J(null),c=J(!0),l=J(null),d=J(null);let u=0;async function p(){const s=++u;c.value=!0,l.value=null;try{const i=await r.getValue(Ys(t));if(s!==u)return;a.value=i,d.value=Date.now()}catch(t){if(s!==u)return;l.value=t.message||"Unknown error"}finally{s===u&&(c.value=!1)}}p();const f=r.subscribe(()=>{const t=e.getStale(r.cacheKey);null!=t&&(a.value=t,d.value=Date.now())});n.push(f);const m=Object.keys(t);m.length>0&&m.forEach(s=>{const i=t[s];if(i&&"object"==typeof i&&"value"in i&&i.B){const t=()=>{r.invalidate(),p()};i.B.add(t),n.push(()=>i.B.delete(t))}}),i[h]={data:a,loading:c,error:l,lastUpdated:d,refresh:()=>(r.invalidate(),p()),setValue(t){r instanceof Us&&(r.setValue(t),a.value=t)},send(t){r instanceof Ws&&r.send(t)},Xn:r}}return i.Qn=()=>{if(n.forEach(t=>t()),window.__kupolaDepInstances){const t=window.__kupolaDepInstances.indexOf(i);-1!==t&&window.__kupolaDepInstances.splice(t,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(i),i},exports.useMixin=function(t,...s){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(t,...s)},exports.useQuery=function(t){const s=new Ns,i=Ks(t,s),e=J(null),n=J(!0),h=J(null);let o=0;async function r(){const s=++o;n.value=!0,h.value=null;try{const n=await i.getValue(t.params||{});if(s!==o)return;e.value=n}catch(t){if(s!==o)return;h.value=t.message||"Unknown error"}finally{s===o&&(n.value=!1)}}return r(),i.subscribe(()=>{const t=s.getStale(i.cacheKey);null!=t&&(e.value=t)}),{data:e,loading:n,error:h,refresh:()=>(i.invalidate(),r())}},exports.validateForm=function(t){const s=t.be;return!!s&&s.validate()},exports.validator=Ss,exports.validatorUtils=E;