@kupola/kupola 1.7.9 → 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
+ 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 i=this.transitions.get(this.state);if(!i||!i.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 i=this.hooks.get(t);i&&i.forEach(t=>{t.resolved=!1})}on(t,i,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const e=this.hooks.get(t);return e.push({handler:i,priority:s.priority||0,depends:s.depends||[],name:s.name||i.name||`anonymous_${e.length}`}),e.sort((t,i)=>i.priority-t.priority),()=>{const t=e.findIndex(t=>t.handler===i);t>-1&&e.splice(t,1)}}async u(t,i){if(t&&0!==t.length)for(const s of t){const t=this.hooks.get(i).find(t=>t.name===s);t&&!t.resolved&&(await t.handler(),t.resolved=!0)}}async emit(t,...i){if("destroyed"===this.state&&"error"!==t)return;const s=this.hooks.get(t);if(!s||0===s.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 s){await this.u(n.depends,t);const s=performance.now();let h,o;try{h=n.handler(...i),h instanceof Promise&&await h,n.resolved=!0}catch(s){o=s,"error"!==t&&await this.p({phase:t,hook:n.name,error:s,args:i})}const r=performance.now()-s;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,...i){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const s=this.phaseStateMap[t];if(s)if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`);const 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,...i),await this.emit(t,...i),s&&this.o(s.to),this.allPhases.includes(n)&&await this.emit(n,...i)}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 i=()=>{document.removeEventListener("DOMContentLoaded",i),window.removeEventListener("load",i),t()};document.addEventListener("DOMContentLoaded",i),window.addEventListener("load",i)})}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 i=this.hooks.get(t);return i&&i.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",i=>"function"==typeof t?t(i):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 i=this.hooks.get("errorBoundary");if(i&&i.length>0)for(const s of i)try{const i=s.handler(t);if(i instanceof Promise&&await i,"handled"===i)return}catch(t){}}}const i=new t("app");function s(i="app"){return new t(i)}const e=new Set(["__proto__","prototype","constructor"]);function n(t){return e.has(t)}const h={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,i)=>i?i.toUpperCase():""):""},hyphenate:function(t){return t?t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart:function(t,i,s=" "){return(String(t)||"").padStart(i,s)},padEnd:function(t,i,s=" "){return(String(t)||"").padEnd(i,s)},truncate:function(t,i,s="..."){return!t||t.length<=i?t||"":t.slice(0,i)+s},replaceAll:function(t,i,s){return t?t.split(i).join(s):""},format:function(t,i){return t?t.replace(/\{\{(\w+)\}\}/g,(t,s)=>void 0!==i[s]?i[s]:`{{${s}}}`):""},startsWith:function(t,i){return(t||"").startsWith(i)},endsWith:function(t,i){return(t||"").endsWith(i)},includes:function(t,i){return(t||"").includes(i)},repeat:function(t,i){return(t||"").repeat(i)},reverse:function(t){return(t||"").split("").reverse().join("")},countOccurrences:function(t,i){return t&&i?t.split(i).length-1:0},escapeHtml:function(t){if(!t)return"";const i=document.createElement("div");return i.textContent=t,i.innerHTML},unescapeHtml:function(t){if(!t)return"";const i=document.createElement("div");return i.innerHTML=t,i.textContent},generateRandom:function(t=8){const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let e=0;e<t;e++)s+=i.charAt(Math.floor(62*Math.random()));return s},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const i=16*Math.random()|0;return("x"===t?i:3&i|8).toString(16)})}};function o(t){return t?t.reduce((t,i)=>t+(Number(i)||0),0):0}const r={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,i){return t&&t.length>0?t[0]:i},last:function(t,i){return t&&t.length>0?t[t.length-1]:i},get:function(t,i,s){return t&&void 0!==t[i]?t[i]:s},slice:function(t,i,s){return t?t.slice(i,s):[]},concat:function(...t){return t.reduce((t,i)=>t.concat(i||[]),[])},join:function(t,i=","){return t?t.join(i):""},indexOf:function(t,i,s=0){if(!t)return-1;if(Number.isNaN(i)){for(let i=s;i<t.length;i++)if(Number.isNaN(t[i]))return i;return-1}return t.indexOf(i,s)},lastIndexOf:function(t,i,s){if(!t)return-1;if(Number.isNaN(i)){for(let i=void 0!==s?s:t.length-1;i>=0;i--)if(Number.isNaN(t[i]))return i;return-1}return t.lastIndexOf(i,s)},includes:function(t,i){return!!t&&t.includes(i)},push:function(t,...i){return t&&t.push(...i),t},pop:function(t){return t?t.pop():void 0},shift:function(t){return t?t.shift():void 0},unshift:function(t,...i){return t&&t.unshift(...i),t},remove:function(t,i){if(!t)return t;const s=Number.isNaN(i)?t.findIndex(t=>Number.isNaN(t)):t.indexOf(i);return s>-1&&t.splice(s,1),t},removeAt:function(t,i){return!t||i<0||i>=t.length||t.splice(i,1),t},insert:function(t,i,s){return t?(t.splice(i,0,s),t):t},reverse:function(t){return t?t.slice().reverse():[]},sort:function(t,i){return t?t.slice().sort(i):[]},sortBy:function(t,i,s="asc"){return t?t.slice().sort((t,e)=>{const n="object"==typeof t?t[i]:t,h="object"==typeof e?e[i]:e;return n<h?"asc"===s?-1:1:n>h?"asc"===s?1:-1:0}):[]},filter:function(t,i){return t?t.filter(i):[]},map:function(t,i){return t?t.map(i):[]},reduce:function(t,i,s){return t?t.reduce(i,s):s},forEach:function(t,i){t&&t.forEach(i)},every:function(t,i){return!t||t.every(i)},some:function(t,i){return!!t&&t.some(i)},find:function(t,i){return t?t.find(i):void 0},findIndex:function(t,i){return t?t.findIndex(i):-1},flat:function(t,i=1){return t?t.flat(i):[]},flattenDeep:function t(i){return i?i.reduce((i,s)=>Array.isArray(s)?i.concat(t(s)):i.concat(s),[]):[]},unique:function(t){return t?[...new Set(t)]:[]},uniqueBy:function(t,i){if(!t)return[];const s=new Set;return t.filter(t=>{const e="object"==typeof t?t[i]:t;return!s.has(e)&&(s.add(e),!0)})},chunk:function(t,i){if(!t||i<=0)return[];const s=[];for(let e=0;e<t.length;e+=i)s.push(t.slice(e,e+i));return s},shuffle:function(t){if(!t)return[];const i=t.slice();for(let t=i.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[i[t],i[s]]=[i[s],i[t]]}return i},sum:o,average:function(t){return t&&0!==t.length?o(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,i)=>t.filter(t=>i&&i.includes(t)))},union:function(...t){return[...new Set(t.flat().filter(Boolean))]},difference:function(t,i){return t?t.filter(t=>!i||!i.includes(t)):[]},zip:function(...t){if(0===t.length)return[];const i=Math.max(...t.map(t=>t?t.length:0));return Array.from({length:i},(i,s)=>t.map(t=>t&&t[s]))}};function a(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}const c={isObject:a,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,i){return!!t&&Object.prototype.hasOwnProperty.call(t,i)},get:function(t,i,s){if(!t)return s;const e=i.split(".");return e.some(n)?s:e.reduce((t,i)=>t&&t[i],t)??s},set:function(t,i,s){if(!t||"object"!=typeof t)return t;const e=i.split(".");if(e.some(n))return t;const h=e.pop();let o=t;return e.forEach(t=>{o[t]&&"object"==typeof o[t]||(o[t]={}),o=o[t]}),o[h]=s,t},pick:function(t,i){return t?i.reduce((i,s)=>(void 0!==t[s]&&(i[s]=t[s]),i),{}):{}},omit:function(t,i){return t?Object.keys(t).reduce((s,e)=>(i.includes(e)||(s[e]=t[e]),s),{}):{}},merge:function t(...i){return i.reduce((i,s)=>(s&&"object"==typeof s&&Object.keys(s).forEach(e=>{n(e)||(a(s[e])&&a(i[e])?i[e]=t(i[e],s[e]):i[e]=s[e])}),i),{})},clone:function(t){return t?JSON.parse(JSON.stringify(t)):t},deepClone:function t(i,s=new WeakMap){if(!i||"object"!=typeof i)return i;if(s.has(i))return s.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const e=new Map;return s.set(i,e),i.forEach((i,n)=>e.set(n,t(i,s))),e}if(i instanceof Set){const e=new Set;return s.set(i,e),i.forEach(i=>e.add(t(i,s))),e}if(Array.isArray(i)){const e=[];return s.set(i,e),i.forEach(i=>e.push(t(i,s))),e}const e={};return s.set(i,e),Object.keys(i).forEach(h=>{n(h)||(e[h]=t(i[h],s))}),e},forEach:function(t,i){t&&Object.keys(t).forEach(s=>i(t[s],s,t))},map:function(t,i){if(!t)return{};const s={};return Object.keys(t).forEach(e=>{s[e]=i(t[e],e,t)}),s},filter:function(t,i){if(!t)return{};const s={};return Object.keys(t).forEach(e=>{i(t[e],e,t)&&(s[e]=t[e])}),s},reduce:function(t,i,s){return t?Object.keys(t).reduce((s,e)=>i(s,t[e],e,t),s):s},toArray:function(t){return t?Object.keys(t).map(i=>({key:i,value:t[i]})):[]},fromArray:function(t,i,s){return t?t.reduce((t,e)=>{const n="object"==typeof e?e[i]:e,h=s?e[s]: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 i={};return Object.keys(t).forEach(s=>{i[t[s]]=s}),i},isEqual:function t(i,s){if(i===s)return!0;if(!i||!s||"object"!=typeof i||"object"!=typeof s)return!1;const e=Object.keys(i),n=Object.keys(s);return e.length===n.length&&e.every(e=>t(i[e],s[e]))},freeze:function t(i){return i?(Object.freeze(i),Object.keys(i).forEach(s=>{"object"==typeof i[s]&&t(i[s])}),i):i},seal:function(t){return t?Object.seal(t):t}};function l(t){return"number"==typeof t&&!isNaN(t)}function d(...t){return t.flat().filter(l).reduce((t,i)=>t+i,0)}function u(t=0,i=1){return Math.random()*(i-t)+t}const p={isNumber:l,isInteger:function(t){return Number.isInteger(t)},isFloat:function(t){return l(t)&&!Number.isInteger(t)},isPositive:function(t){return l(t)&&t>0},isNegative:function(t){return l(t)&&t<0},isZero:function(t){return l(t)&&0===t},clamp:function(t,i,s){return l(t)?Math.min(Math.max(t,i),s):t},round:function(t,i=0){if(!l(t))return t;const s=Math.pow(10,i);return Math.round(t*s)/s},floor:function(t){return l(t)?Math.floor(t):t},ceil:function(t){return l(t)?Math.ceil(t):t},abs:function(t){return l(t)?Math.abs(t):t},min:function(...t){const i=t.filter(l);return i.length>0?Math.min(...i):void 0},max:function(...t){const i=t.filter(l);return i.length>0?Math.max(...i):void 0},sum:d,average:function(...t){const i=t.flat().filter(l);return i.length>0?d(i)/i.length:0},random:u,randomInt:function(t,i){return Math.floor(u(t,i+1))},format:function(t,i=2){return l(t)?t.toFixed(i):String(t)},formatCurrency:function(t,i="CNY",s=2){return l(t)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:i,minimumFractionDigits:s,maximumFractionDigits:s}).format(t):String(t)},formatPercent:function(t,i=0){return l(t)?`${(100*t).toFixed(i)}%`:String(t)},toFixed:function(t,i=0){return l(t)?t.toFixed(i):String(t)},toPrecision:function(t,i=6){return l(t)?t.toPrecision(i):String(t)},isNaN:function(t){return Number.isNaN(t)},isFinite:function(t){return Number.isFinite(t)},parseInt:function(t,i=10){return Number.parseInt(t,i)},parseFloat:function(t){return Number.parseFloat(t)},toNumber:function(t,i=0){const s=Number(t);return isNaN(s)?i:s},safeDivide:function(t,i,s=0){return l(t)&&l(i)&&0!==i?t/i:s},safeMultiply:function(...t){return t.reduce((t,i)=>l(t)&&l(i)?t*i:0,1)}};function f(){return Date.now()}function m(){const t=new Date;return t.setHours(0,0,0,0),t}function g(t){return t instanceof Date&&!isNaN(t.getTime())}function _(t){return g(t)}function b(t,i){if(!g(t)||!g(i))return 0;const s=new Date(t);s.setHours(0,0,0,0);const e=new Date(i);return e.setHours(0,0,0,0),Math.floor((s.getTime()-e.getTime())/864e5)}function v(t,i=1){if(!g(t))return t;const s=new Date(t),e=s.getDay(),n=e>=i?e-i:e+(7-i);return s.setDate(s.getDate()-n),s.setHours(0,0,0,0),s}const w={now:f,today:m,tomorrow:function(){const t=m();return t.setDate(t.getDate()+1),t},yesterday:function(){const t=m();return t.setDate(t.getDate()-1),t},isDate:g,isValid:_,parse:function(t){const i=new Date(t);return _(i)?i:null},format:function(t,i="YYYY-MM-DD HH:mm:ss"){if(!g(t))return"";const s=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 i.replace("YYYY",s).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 g(t)?t.toISOString():""},toUTC:function(t){return g(t)?new Date(t.toUTCString()):null},addDays:function(t,i){if(!g(t))return t;const s=new Date(t);return s.setDate(s.getDate()+i),s},addHours:function(t,i){if(!g(t))return t;const s=new Date(t);return s.setHours(s.getHours()+i),s},addMinutes:function(t,i){if(!g(t))return t;const s=new Date(t);return s.setMinutes(s.getMinutes()+i),s},addSeconds:function(t,i){if(!g(t))return t;const s=new Date(t);return s.setSeconds(s.getSeconds()+i),s},diffDays:b,diffHours:function(t,i){return g(t)&&g(i)?Math.floor((t.getTime()-i.getTime())/36e5):0},diffMinutes:function(t,i){return g(t)&&g(i)?Math.floor((t.getTime()-i.getTime())/6e4):0},diffSeconds:function(t,i){return g(t)&&g(i)?Math.floor((t.getTime()-i.getTime())/1e3):0},isToday:function(t){return!!g(t)&&0===b(t,m())},isYesterday:function(t){return!!g(t)&&-1===b(t,m())},isTomorrow:function(t){return!!g(t)&&1===b(t,m())},isFuture:function(t){return!!g(t)&&t.getTime()>f()},isPast:function(t){return!!g(t)&&t.getTime()<f()},isLeapYear:function(t){if(!g(t))return!1;const i=t.getFullYear();return i%4==0&&(i%100!=0||i%400==0)},getDaysInMonth:function(t){return g(t)?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():0},getWeekOfYear:function(t){if(!g(t))return 0;const i=new Date(t.getFullYear(),0,1),s=t.getTime()-i.getTime();return Math.ceil(s/6048e5)},getQuarter:function(t){return g(t)?Math.ceil((t.getMonth()+1)/3):0},startOfDay:function(t){if(!g(t))return t;const i=new Date(t);return i.setHours(0,0,0,0),i},endOfDay:function(t){if(!g(t))return t;const i=new Date(t);return i.setHours(23,59,59,999),i},startOfMonth:function(t){return g(t)?new Date(t.getFullYear(),t.getMonth(),1):t},endOfMonth:function(t){return g(t)?new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59,999):t},startOfWeek:v,endOfWeek:function(t,i=1){if(!g(t))return t;const s=v(t,i),e=new Date(s);return e.setDate(e.getDate()+6),e.setHours(23,59,59,999),e},getAge:function(t){if(!g(t))return 0;const i=new Date;let s=i.getFullYear()-t.getFullYear();return(i.getMonth()<t.getMonth()||i.getMonth()===t.getMonth()&&i.getDate()<t.getDate())&&s--,Math.max(0,s)},fromNow:function(t){if(!g(t))return"";const i=f()-t.getTime(),s=6e4,e=36e5,n=24*e,h=7*n,o=30*n,r=365*n;return i<s?"刚刚":i<e?`${Math.floor(i/s)}分钟前`:i<n?`${Math.floor(i/e)}小时前`:i<h?`${Math.floor(i/n)}天前`:i<o?`${Math.floor(i/h)}周前`:i<r?`${Math.floor(i/o)}个月前`:`${Math.floor(i/r)}年前`}};function y(t,i,s={}){let e=null,n=null,h=null,o=0;const r=s.leading||!1,a=!1!==s.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,i-(Date.now()-o)))):(o=Date.now(),r?(e=setTimeout(l,i),c()):e=setTimeout(l,i))}}function k(t,i,s={}){let e=!1;const n=s.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()},i))}}function x(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 $(t){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t||"")}function M(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t||"")}function S(t){const i=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(t||"");return!!i&&i.slice(1).every(t=>parseInt(t)>=0&&parseInt(t)<=255)}function C(t){const i=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(t||"");if(!i)return!1;const[,s,e,n,h]=i;return parseInt(s)>=0&&parseInt(s)<=255&&parseInt(e)>=0&&parseInt(e)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(h)>=0&&parseFloat(h)<=1}function E(t,i){return(t||"").includes(i)}const T={isEmail:function(t){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t||"")},isPhone:function(t){return/^1[3-9]\d{9}$/.test(t||"")},isURL:function(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(t||"")},isIPv4:x,isIPv6:$,isIP:function(t){return x(t)||$(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 i=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(i))return!1;let s=0,e=!1;for(let t=i.length-1;t>=0;t--){let n=parseInt(i[t],10);e&&(n*=2,n>9&&(n-=9)),s+=n,e=!e}return s%10==0},isHexColor:M,isRGB:S,isRGBA:C,isColor:function(t){return M(t)||S(t)||C(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 i=parseFloat(t);return!isNaN(i)&&i>0},isNegative:function(t){const i=parseFloat(t);return!isNaN(i)&&i<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,i,s){const e=(t||"").length;return e>=i&&(void 0===s||e<=s)},minLength:function(t,i){return(t||"").length>=i},maxLength:function(t,i){return(t||"").length<=i},matches:function(t,i){return i instanceof RegExp&&i.test(t||"")},equals:function(t,i){return String(t)===String(i)},contains:E,notContains:function(t,i){return!E(t,i)},isArray:function(t){return Array.isArray(t)},arrayLength:function(t,i,s){const e=t?t.length:0;return e>=i&&(void 0===s||e<=s)},arrayMinLength:function(t,i){return!!t&&t.length>=i},arrayMaxLength:function(t,i){return!!t&&t.length<=i},isObject:function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},hasKeys:function(t,i){return!!(t&&i&&Array.isArray(i))&&i.every(i=>Object.prototype.hasOwnProperty.call(t,i))},validate:function(t,i){const s={};return Object.keys(i).forEach(e=>{const n=t[e],h=i[e],o=[];h.forEach(i=>{if("string"==typeof i){const[t,...s]=i.split(":");T[t](n,...s)||o.push(t)}else if("function"==typeof i){const s=i(n,t);!0!==s&&o.push(s||"validation_failed")}}),o.length>0&&(s[e]=o)}),{valid:0===Object.keys(s).length,errors:s}}};const D={md5:function(t){const i=t?String(t):"",s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(t,i){return t<<i|t>>>32-i}function h(t,i){const[h,o,r,a]=i,c=[];for(let i=0;i<16;i++)c[i]=255&t.charCodeAt(4*i)|(255&t.charCodeAt(4*i+1))<<8|(255&t.charCodeAt(4*i+2))<<16|(255&t.charCodeAt(4*i+3))<<24;let l=h,d=o,u=r,p=a;for(let t=0;t<64;t++){let i,h;const o=Math.floor(t/16),r=t%16;0===o?(i=d&u|~d&p,h=r):1===o?(i=p&d|~p&u,h=(5*r+1)%16):2===o?(i=d^u^p,h=(3*r+5)%16):(i=u^(d|~p),h=7*r%16);const a=p;p=u,u=d,d+=n(l+i+s[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 i=8*t.length;for(t+="€";t.length%64!=56;)t+="\0";const s=4294967295&i,e=i>>>32&4294967295;for(let i=0;i<4;i++)t+=String.fromCharCode(s>>>8*i&255);for(let i=0;i<4;i++)t+=String.fromCharCode(e>>>8*i&255);return t}(i);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 i=0;i<4;i++)a+=(t>>>8*i&255).toString(16).padStart(2,"0")}),a},sha256:function(t){const i=t?String(t):"",s=[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,i){return t>>>i|t<<32-i}function n(t,i){const n=[];for(let i=0;i<16;i++)n[i]=255&t.charCodeAt(4*i)|(255&t.charCodeAt(4*i+1))<<8|(255&t.charCodeAt(4*i+2))<<16|(255&t.charCodeAt(4*i+3))<<24;for(let t=16;t<64;t++){const i=e(n[t-15],7)^e(n[t-15],18)^n[t-15]>>>3,s=e(n[t-2],17)^e(n[t-2],19)^n[t-2]>>>10;n[t]=n[t-16]+i+n[t-7]+s&4294967295}let[h,o,r,a,c,l,d,u]=i;for(let t=0;t<64;t++){const i=u+(e(c,6)^e(c,11)^e(c,25))+(c&l^~c&d)+s[t]+n[t]&4294967295,p=h&o^h&r^o&r;u=d,d=l,l=c,c=a+i&4294967295,a=r,r=o,o=h,h=i+((e(h,2)^e(h,13)^e(h,22))+p&4294967295)&4294967295}return[i[0]+h&4294967295,i[1]+o&4294967295,i[2]+r&4294967295,i[3]+a&4294967295,i[4]+c&4294967295,i[5]+l&4294967295,i[6]+d&4294967295,i[7]+u&4294967295]}const h=function(t){const i=8*t.length;for(t+="€";t.length%64!=56;)t+="\0";const s=4294967295&i,e=i>>>32&4294967295;for(let i=0;i<4;i++)t+=String.fromCharCode(e>>>8*i&255);for(let i=0;i<4;i++)t+=String.fromCharCode(s>>>8*i&255);return t}(i);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 i=3;i>=0;i--)r+=(t>>>8*i&255).toString(16).padStart(2,"0")}),r},base64Encode:function(t){const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let s="",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;s+=i[t>>2]+i[(3&t)<<4|h>>4]+(e>n.length+1?"=":i[r])+(e>n.length?"=":i[a])}return s},base64Decode:function(t){const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let s="",e=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");e<t.length;){const n=i.indexOf(t.charAt(e++)),h=i.indexOf(t.charAt(e++)),o=i.indexOf(t.charAt(e++)),r=i.indexOf(t.charAt(e++)),a=n<<2|h>>4,c=(15&h)<<4|o>>2,l=(3&o)<<6|r;s+=String.fromCharCode(a),64!==o&&(s+=String.fromCharCode(c)),64!==r&&(s+=String.fromCharCode(l))}return s},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const i=16*Math.random()|0;return("x"===t?i:3&i|8).toString(16)})}},O=new Map;async function F(t,i={}){const{crossOrigin:s="anonymous"}=i;return O.has(t)?O.get(t):new Promise((i,e)=>{const n=new Image;n.crossOrigin=s,n.onload=()=>{O.set(t,n),i(n)},n.onerror=()=>{e(new Error(`Failed to load image: ${t}`))},n.src=t})}async function I(t,i={}){const{type:s="text/javascript",async:e=!0,defer:n=!1}=i;return O.has(t)?O.get(t):new Promise((i,h)=>{const o=document.createElement("script");o.type=s,o.async=e,o.defer=n,o.onload=()=>{O.set(t,o),i(o)},o.onerror=()=>{o.remove(),h(new Error(`Failed to load script: ${t}`))},o.src=t,document.head.appendChild(o)})}async function A(t,i={}){const{media:s="all"}=i;return O.has(t)?O.get(t):new Promise((i,e)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=t,n.media=s,n.onload=()=>{O.set(t,n),i(n)},n.onerror=()=>{n.remove(),e(new Error(`Failed to load stylesheet: ${t}`))},document.head.appendChild(n)})}const R={loadImage:F,loadImages:async function(t,i={}){const{parallel:s=!0}=i;if(s)return Promise.all(t.map(t=>F(t,i)));const e=[];for(const s of t)e.push(await F(s,i));return e},loadScript:I,loadStylesheet:A,loadFont:async function(t,i,s={}){const{weight:e="normal",style:n="normal"}=s,h=new FontFace(t,`url(${i})`,{weight:e,style:n});try{return await h.load(),document.fonts.add(h),h}catch(i){throw new Error(`Failed to load font: ${t}`)}},preload:async function(t,i="image"){switch(i){case"image":return F(t);case"script":return I(t);case"stylesheet":case"style":return A(t);default:throw new Error(`Unsupported preload type: ${i}`)}},isLoaded:function(t){return O.has(t)},clearCache:function(){O.clear()},clearCacheByUrl:function(t){O.delete(t)}},j={string:h,array:r,object:c,number:p,date:w,debounce:y,throttle:k,validator:T,crypto:D,preload:R};class P{constructor(){this.children={},this.keys=[]}}class N{constructor(){this.root=new P}insert(t){let i=this.root;const s=t.split(".");s.forEach((e,n)=>{i.children[e]||(i.children[e]=new P),i=i.children[e],n===s.length-1&&i.keys.push(t)})}getSubKeys(t){let i=this.root;const s=t.split("."),e=[];for(let t=0;t<s.length;t++){const n=s[t];if(!i.children[n])break;i=i.children[n];const h=t=>{t.keys.length>0&&e.push(...t.keys),Object.values(t.children).forEach(t=>h(t))};h(i)}return[...new Set(e)]}getParentKeys(t){const i=t.split("."),s=[];for(let t=1;t<=i.length;t++){const e=i.slice(0,t).join(".");s.push(e)}return s}}const B=Symbol("reactive_parent"),z=Symbol("reactive_path"),L=Symbol("reactive_is_reactive");class H{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new N,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,i,s)=>{if("__raw__"===i)return t;const e=Reflect.get(t,i,s);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,i):e},set:(t,i,s,e)=>{const n=Reflect.get(t,i,e),h=Reflect.set(t,i,s,e),o=this.resolvePath(t,i);return this.notify(o,s,n),this.queueUpdate(o,s),h},deleteProperty:(t,i)=>{const s=Reflect.get(t,i,receiver),e=Reflect.deleteProperty(t,i),n=this.resolvePath(t,i);return this.notify(n,void 0,s),this.queueUpdate(n,void 0),e}};this.data=new Proxy(this.rawData,t),this.data.v=null,this.data.k=""}wrapReactive(t,i){if(t[L])return t;if(this._.has(t))return this._.get(t);const s=new Proxy(t,{get:(t,i,s)=>{if("__raw__"===i)return t;if(i===B||"__parent__"===i)return t[B];if(i===z||"__path__"===i)return t[z];if(i===L||"__isReactive__"===i)return!0;const e=Reflect.get(t,i,s);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[z]}${t[z]?".":""}${i}`):e},set:(t,i,s,e)=>{if(i===B||i===z||i===L||"__parent__"===i||"__path__"===i||"__isReactive__"===i)return!0;const n=Reflect.get(t,i,e),h=Reflect.set(t,i,s,e),o=`${t[z]}${t[z]?".":""}${i}`;return this.notify(o,s,n),this.queueUpdate(o,s),h},deleteProperty:(t,i)=>{if(i===B||i===z||i===L)return!1;const s=Reflect.get(t,i),e=Reflect.deleteProperty(t,i),n=`${t[z]}${t[z]?".":""}${i}`;return this.notify(n,void 0,s),this.queueUpdate(n,void 0),e},has:(t,i)=>"__raw__"===i||i===B||i===z||i===L||"__parent__"===i||"__path__"===i||"__isReactive__"===i||i in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==B&&t!==z&&t!==L),getOwnPropertyDescriptor:(t,i)=>i===B||i===z||i===L?{configurable:!1,enumerable:!1,writable:!1,value:t[i]}:Reflect.getOwnPropertyDescriptor(t,i)});return t[B]=t,t[z]=i,t[L]=!0,this._.set(t,s),Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])&&(t[s]=this.wrapReactive(t[s],`${i}${i?".":""}${s}`))}),s}resolvePath(t,i){return t[z]?`${t[z]}.${i}`:i}queueUpdate(t,i){this.updateQueue.set(t,i),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((i,s)=>{t.add(s),this.updateElementsDirect(s,i);this.pathTrie.getSubKeys(s).forEach(i=>{if(!t.has(i)){const s=this.get(i);this.updateElementsDirect(i,s),t.add(i)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,i){this.elements[t]&&this.elements[t].forEach(t=>{this.updateElement(t,i)})}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,i,s=!1){const e=this.get(t);"object"==typeof t?(Object.assign(this.rawData,t),Object.keys(t).forEach(i=>{s||(this.notify(i,t[i],e?.[i]),this.queueUpdate(i,t[i]))})):(t.includes(".")?this.setNested(t,i):this.rawData[t]=i,s||(this.notify(t,i,e),this.queueUpdate(t,i))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((t,i)=>t?.[i],this.rawData)}setNested(t,i){const s=t.split("."),e=s.pop(),n=s.reduce((t,i)=>(t[i]||(t[i]={}),t[i]),this.rawData),h=n[e];n[e]=i,this.notify(t,i,h),this.queueUpdate(t,i)}observe(t,i){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(i)}unobserve(t,i){this.observers[t]&&(this.observers[t]=this.observers[t].filter(t=>t!==i))}notify(t,i,s){this.observers[t]&&this.observers[t].forEach(t=>{try{t(i,s)}catch(t){}}),this.observers["*"]?.forEach(e=>{try{e(t,i,s)}catch(t){}})}updateElement(t,i){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(s=>{const e=s.split(":"),n=e[0].trim(),h=e[1]?.trim();switch(n){case"text":t.textContent!==String(i??"")&&(t.textContent=i??"");break;case"html":const s=function(t){if(!t)return"";let i=String(t);const s=/<\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=i,i=i.replace(s,"")}while(i!==e);return i=i.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),i=i.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),i=i.replace(/expression\s*\([^)]*\)/gi,""),i}(i);t.innerHTML!==s&&(t.innerHTML=s);break;case"value":"checkbox"===t.type?t.checked!==!!i&&(t.checked=!!i):t.value!==String(i??"")&&(t.value=i??"");break;case"checked":t.checked!==!!i&&(t.checked=!!i);break;case"disabled":t.disabled!==!!i&&(t.disabled=!!i);break;case"hidden":const e=i?"none":"";t.style.display!==e&&(t.style.display=e);break;case"class":h&&(i?t.classList.add(h):t.classList.remove(h));break;case"style":h&&t.style[h]!==String(i??"")&&(t.style[h]=i??"");break;case"attr":if(h){t.getAttribute(h)!==String(i??"")&&t.setAttribute(h,i??"")}break;case"src":t.src!==String(i??"")&&(t.src=i??"");break;case"href":t.href!==String(i??"")&&(t.href=i??"");break;case"placeholder":t.placeholder!==String(i??"")&&(t.placeholder=i??"")}})}computed(t,i,s){this.computedProperties[t]={deps:i,callback:s},i.forEach(t=>{this.pathTrie.insert(t)}),this.updateComputedProperty(t)}updateComputedProperty(t){const i=this.computedProperties[t];if(i)try{const s=i.deps.map(t=>this.get(t)),e=i.callback(...s);this.set(t,e,!0)}catch(t){}}load(t){Object.keys(t).forEach(i=>{t[i]&&"object"==typeof t[i]&&!Array.isArray(t[i])?this.rawData[i]=this.wrapReactive(t[i],i):this.rawData[i]=t[i],this.queueUpdate(i,this.rawData[i])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new N,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,i={}){const{storage:s="local",debounce:e=0,version:n=1,encrypt:h=!1,encryptionKey:o=null}=i,r="session"===s?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,i=>{const s=this.persistedKeys.get(t);s&&(s.debounce>0?(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(()=>{this.$(t,i,s.storage,{version:s.version,encrypt:s.encrypt,encryptionKey:s.encryptionKey})},s.debounce)):this.$(t,i,s.storage,{version:s.version,encrypt:s.encrypt,encryptionKey:s.encryptionKey}))})}$(t,i,s,e={}){try{const{version:n=1,encrypt:h=!1,encryptionKey:o=null}=e,r={value:i,version:n,timestamp:Date.now()};let a=JSON.stringify(r);h&&o&&(a=this.M(a,o)),this.S(s),s.setItem(`kupola:${t}`,a)}catch(e){if("QuotaExceededError"===e.name&&s===localStorage)try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:i,version:1}))}catch(t){}}}S(t){try{const i="kupola:__storage_test__";t.setItem(i,"test"),t.removeItem(i)}catch(i){"QuotaExceededError"===i.name&&this.C(t)}}C(t){const i=Date.now();for(let s=0;s<t.length;s++){const e=t.key(s);if(e?.startsWith("kupola:"))try{const s=JSON.parse(t.getItem(e));s.timestamp&&i-s.timestamp>2592e6&&t.removeItem(e)}catch(i){t.removeItem(e)}}}M(t,i){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,i).toString():t}T(t,i){if(!window.CryptoJS)return t;try{return window.CryptoJS.AES.decrypt(t,i).toString(window.CryptoJS.enc.Utf8)}catch(i){return t}}unpersist(t){const i=this.persistedKeys.get(t);i&&(i.timeout&&clearTimeout(i.timeout),i.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const i={},{encryptionKey:s=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(s){const t=this.T(h,s);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;i[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(s){const t=this.T(h,s);o=JSON.parse(t)}else o=JSON.parse(h);if(void 0!==o.version&&o.version!==t.version)continue;i[e]=void 0!==o.value?o.value:o}catch(t){}}}return Object.keys(i).length>0&&this.load(i),i}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 i=t>=0?t:this.snapshots.length-1,s=this.snapshots[i];return!!s&&(this.rawData=this.D(s),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 i={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("data-bind");if(!s)return;const e=s.split(":"),n=e[1]?.trim();n&&("checkbox"===t.type?(i[n]||(i[n]=[]),t.checked&&i[n].push(t.value)):"radio"===t.type?t.checked&&(i[n]=t.value):i[n]=t.value)}),i}fillForm(t,i){Object.keys(i).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(t=>{"checkbox"===t.type?t.checked=Array.isArray(i[s])?i[s].includes(t.value):!!i[s]:"radio"===t.type?t.checked=t.value===i[s]:t.value=i[s]??""})})}createReactive(t,i=""){if(t[L])return t;if(this._.has(t))return this._.get(t);const s={get:(t,i,s)=>{if("__raw__"===i)return t;if(i===B||"__parent__"===i)return t[B];if(i===z||"__path__"===i)return t[z];if(i===L||"__isReactive__"===i)return!0;const e=Reflect.get(t,i,s);return e&&"object"==typeof e&&!Array.isArray(e)?this.wrapReactive(e,`${t[z]}${t[z]?".":""}${i}`):e},set:(t,i,s,e)=>{if(i===B||i===z||i===L||"__parent__"===i||"__path__"===i||"__isReactive__"===i)return!0;const n=Reflect.get(t,i,e),h=Reflect.set(t,i,s,e),o=`${t[z]}${t[z]?".":""}${i}`;return this.notify(o,s,n),this.queueUpdate(o,s),h},deleteProperty:(t,i)=>{if(i===B||i===z||i===L)return!1;const s=Reflect.get(t,i),e=Reflect.deleteProperty(t,i),n=`${t[z]}${t[z]?".":""}${i}`;return this.notify(n,void 0,s),this.queueUpdate(n,void 0),e},has:(t,i)=>"__raw__"===i||i===B||i===z||i===L||"__parent__"===i||"__path__"===i||"__isReactive__"===i||i in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==B&&t!==z&&t!==L),getOwnPropertyDescriptor:(t,i)=>i===B||i===z||i===L?{configurable:!1,enumerable:!1,writable:!1,value:t[i]}:Reflect.getOwnPropertyDescriptor(t,i)},e=new Proxy(t,s);return t[B]=t,t[z]=i,t[L]=!0,this._.set(t,e),Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])&&(t[s]=this.wrapReactive(t[s],`${i}${i?".":""}${s}`))}),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 i=t.getAttribute("data-bind").split(":");i[0].split("|")[0].trim();const s=i[1]?.trim();if(s){if(this.pathTrie.insert(s),this.elements[s]||(this.elements[s]=[]),this.elements[s].includes(t)||this.elements[s].push(t),"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const i=t.A;i&&t.removeEventListener("input",i);const e=()=>{const i="checkbox"===t.type?t.checked:t.value;s.includes(".")?this.setNested(s,i):this.set(s,i)};t.A=e,t.addEventListener("input",e)}void 0!==this.rawData[s]&&this.updateElement(t,this.rawData[s])}}destroy(){this.F&&(this.F.disconnect(),this.F=null),Object.values(this.elements).forEach(t=>{t.forEach(t=>{const i=t.A;i&&(t.removeEventListener("input",i),delete t.A)})}),this.persistedKeys.forEach((t,i)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new N,this.updateQueue.clear(),this.snapshots=[]}}class U{constructor(t,i={}){this.name=t,this.R=`__store_${t}__`;const s=i.state?i.state():{};this.getters=i.getters||{},this.actions=i.actions||{},this.mutations=i.mutations||{},this.observers={},W?(W.set(this.R,s),this.state=W.data?.[this.R]||W.createReactive(s,this.R),W.observe(this.R,t=>{this.notify(t)})):this.state=s,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]=(...i)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...i)})}commit(t,i){const s=this.mutations[t];s&&s(this.state,i)}dispatch(t,i){const s=this.actions[t];if(s)return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},i)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(i=>i!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(i=>{try{i(t)}catch(t){}}),W&&W.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,i)=>(t[i]=this[i],t),{})}}}class V{constructor(){this.stores=new Map}createStore(t,i){const s=new U(t,i);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof U&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class J{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,i){return this.events[t]||(this.events[t]=[]),this.events[t].push(i),i}off(t,i){this.events[t]&&(this.events[t]=this.events[t].filter(t=>t!==i))}emit(t,i){this.events[t]&&this.events[t].forEach(t=>{try{t(i)}catch(t){}}),this.events["*"]?.forEach(s=>{try{s(t,i)}catch(t){}})}once(t,i){const s=e=>{i(e),this.off(t,s)};return this.on(t,s),s}delegate(t,i,s){if(!this.delegatedEvents[i]){this.delegatedEvents[i]=[];const t=t=>{this.delegatedEvents[i].forEach(({selector:i,cb:s})=>{(t.target.matches(i)||t.target.closest(i))&&s(t)})};document.addEventListener(i,t),this.eventListeners[i]=t}return this.delegatedEvents[i].push({selector:t,cb:s}),s}undelegate(t,i){if(this.delegatedEvents[i]&&(this.delegatedEvents[i]=this.delegatedEvents[i].filter(i=>i.selector!==t),0===this.delegatedEvents[i].length)){const t=this.eventListeners[i];t&&(document.removeEventListener(i,t),delete this.eventListeners[i]),delete this.delegatedEvents[i]}}destroy(){Object.entries(this.eventListeners).forEach(([t,i])=>{document.removeEventListener(t,i)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function q(t=null){const i={N:t,B:new Set};return Object.defineProperty(i,"value",{configurable:!0,enumerable:!0,get:()=>i.N,set(t){t!==i.N&&(i.N=t,i.B.forEach(i=>i(t)))}}),i.subscribe=t=>(i.B.add(t),{unsubscribe(){i.B.delete(t)}}),i}const W=new H,K=new J,Y=new V;function Z(t,i){return Y.createStore(t,i)}function G(t){return Y.getStore(t)}const X={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}},Q=[];function tt(){if("undefined"!=typeof window&&window.kupolaConfig)try{bt(X,window.kupolaConfig),it()}catch(t){}}function it(){Q.forEach(t=>{try{t(X)}catch(t){}})}function st(t){"function"==typeof t&&Q.push(t)}function et(t){const i=Q.indexOf(t);i>-1&&Q.splice(i,1)}function nt(t){bt(X,t),it()}function ht(t){return t?function(t,i){return i.split(".").reduce((t,i)=>void 0!==(t&&t[i])?t[i]:void 0,t)}(X,t):X}function ot(){return X.paths.base+X.paths.icons.replace(/^\//,"")}function rt(){return X.paths.base}function at(){return X.theme.default}function ct(){return X.theme.brand}function lt(){return X.http}function dt(){return X.ui}function ut(){return X.zIndex}function pt(){return X.security}function ft(){return X.performance}function mt(){return X.message}function gt(){return X.notification}function _t(){return X.validation}function bt(t,i){for(const s in i)i[s]instanceof Object&&s in t&&t[s]instanceof Object?bt(t[s],i[s]):t[s]=i[s];return t}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",tt):tt());const vt="kupola-theme",wt="kupola-brand";st(t=>{const i=document.querySelector("[data-theme-toggle]");if(i){const t=kt();St(i),xt(t)}});const yt=[{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 kt(){return localStorage.getItem(vt)||at()}function xt(t){if("dark"!==t&&"light"!==t)return;var i=document.documentElement;i.hasAttribute("data-kupola-theme-preloaded")&&(i.style.removeProperty("--bg-base-default"),i.style.removeProperty("--text-default"),i.removeAttribute("data-kupola-theme-preloaded")),i.setAttribute("data-theme",t),localStorage.setItem(vt,t);const s=document.querySelector("[data-theme-toggle]");s&&(s.setAttribute("data-current-theme",t),St(s))}function $t(){return localStorage.getItem(wt)||ct()}function Mt(t){const i=yt.find(i=>i.id===t);if(!i)return;document.documentElement.setAttribute("data-brand",t),localStorage.setItem(wt,t);const s=document.querySelector("[data-brand-toggle]");if(s){s.setAttribute("data-current-brand",t);const e=s.querySelector(".brand-icon");e&&(e.style.backgroundColor=i.color);const n=s.querySelector(".brand-name");n&&(n.textContent=i.name)}document.querySelectorAll("[data-brand-btn]").forEach(i=>{i.getAttribute("data-brand-btn")===t?i.classList.add("is-active"):i.classList.remove("is-active")})}function St(t){const i=t.querySelector(".theme-icon");if(i){const t=kt(),s=ot();i.src="dark"===t?s+"sun.svg":s+"moon.svg"}}function Ct(t){t.preventDefault();xt("dark"===kt()?"light":"dark")}function Et(){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 i=document.querySelector("[data-theme-toggle]");xt(kt());Mt($t()),i&&(St(i),i.removeEventListener("click",Ct),i.addEventListener("click",Ct));let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",yt.forEach(t=>{const i=document.createElement("button");i.setAttribute("data-brand-btn",t.id),i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.height="60px",i.style.backgroundColor=t.color,i.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.color)?"#0C0C0D":"#FFFFFF",i.style.fontWeight="500",i.style.borderRadius="4px",i.style.border="none",i.style.cursor="pointer",i.style.margin="0",i.style.padding="0",i.textContent=t.name,s.appendChild(i)}),document.body.appendChild(s));const e=document.querySelector("[data-brand-toggle]");function n(t){s&&e&&(s.contains(t.target)||e.contains(t.target)||(s.style.display="none",document.removeEventListener("click",n,!0)))}e&&s&&(e.onclick=function(t){t.stopPropagation(),t.preventDefault();const i="none"===s.style.display;s.style.display=i?"grid":"none",i?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},s.onclick=function(t){t.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",i=>{i.stopPropagation();Mt(t.getAttribute("data-brand-btn")),s&&(s.style.display="none")})})}function Tt(){const t=document.createElement("button");t.setAttribute("data-theme-toggle",""),t.setAttribute("data-current-theme",kt()),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 i=document.createElement("img");i.className="theme-icon";const s=ot();return i.src="dark"===kt()?s+"sun.svg":s+"moon.svg",i.width=14,i.height=14,i.alt="Toggle theme",t.appendChild(i),document.body.appendChild(t),t.onclick=function(t){t.preventDefault();xt("dark"===kt()?"light":"dark")},t}function Dt(){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",yt.forEach(i=>{const s=document.createElement("button");s.setAttribute("data-brand-btn",i.id),s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="60px",s.style.backgroundColor=i.color,s.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(i.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=i.name,t.appendChild(s)}),document.body.appendChild(t);const i=document.createElement("button");i.setAttribute("data-brand-toggle",""),i.setAttribute("data-current-brand",$t()),i.className="ds-btn ds-btn--ghost ds-btn--sm",i.style.position="fixed",i.style.top="16px",i.style.right="56px",i.style.zIndex="9999",i.style.display="flex",i.style.alignItems="center",i.style.gap="6px";const s=document.createElement("span");s.className="brand-icon",s.style.width="12px",s.style.height="12px",s.style.borderRadius="50%",s.style.backgroundColor=yt.find(t=>t.id===$t()).color;const e=document.createElement("span");function n(s){t.contains(s.target)||i.contains(s.target)||(t.style.display="none",document.removeEventListener("click",n,!0))}e.className="brand-name",e.style.fontSize="11px",e.textContent=yt.find(t=>t.id===$t()).name,i.appendChild(s),i.appendChild(e),document.body.appendChild(i),i.onclick=function(i){i.stopPropagation(),i.preventDefault();const s="none"===t.style.display;t.style.display=s?"grid":"none",s?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},t.onclick=function(t){t.stopPropagation()};return t.querySelectorAll("[data-brand-btn]").forEach(i=>{i.addEventListener("click",s=>{s.stopPropagation();Mt(i.getAttribute("data-brand-btn")),t.style.display="none"})}),{toggleBtn:i,container:t}}function Ot(t,i={}){const s=pt(),e=s?.sanitizeHtml||{};if(!e.enabled&&!i.force)return t;const n=i.allowedTags||e.allowedTags||[],h=i.allowedAttributes||e.allowedAttributes||{};if("string"!=typeof t)return t;const o=(new DOMParser).parseFromString(t,"text/html");return o.body.querySelectorAll("*").forEach(t=>{const i=t.tagName.toLowerCase();n.includes(i)?Array.from(t.attributes).forEach(s=>{const e=s.name.toLowerCase();(h[i]||[]).includes(e)||t.removeAttribute(s.name)}):t.remove()}),o.body.innerHTML}function Ft(t){if("string"!=typeof t)return t;const i=document.createElement("div");return i.textContent=t,i.innerHTML}function It(t){if("string"!=typeof t)return t;return(new DOMParser).parseFromString(t,"text/html").body.textContent||""}function At(t,i,s={}){const e=pt(),n=e?.maskData||{};if(!n.enabled&&!s.force)return t;if(null==t)return t;const h=(s.patterns||n.patterns||{})[i];if(!h)return t;const o="string"==typeof h.regex?new RegExp(h.regex):h.regex;return String(t).replace(o,h.replace)}function Rt(t,i){const s=pt(),e=s?.secureId||{},n=t||e.length||16,h=e.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if("undefined"==typeof crypto||!crypto.getRandomValues){let t="";for(let i=0;i<n;i++)t+=h[Math.floor(Math.random()*h.length)];return i?`${i}_${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 i?`${i}_${r}`:r}class jt{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this.L=["data-component"],this.H=[],this.U=null}register(t,i,s=null,e={}){this.initializers.set(t,i),s&&this.cleanupFunctions.set(t,s),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 i of this.H)t.push(`.${i}`);return this.U=t.join(", "),this.U}async initialize(t){if(this.processedElements.has(t))return;for(const i of this.L){const s=t.getAttribute(i);if(null!==s){const e=s||i.replace("data-",""),n=this.initializers.get(e)||this.initializers.get(i.replace("data-",""));if(n){try{await n(t),this.processedElements.add(t)}catch(t){}return}}}const i=t.className;if("string"==typeof i)for(const s of this.H){if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(i)){const i=s.replace("ds-",""),e=this.initializers.get(i)||this.initializers.get(s);if(e){try{await e(t),this.processedElements.add(t)}catch(t){}return}}}}cleanup(t){for(const i of this.L){const s=t.getAttribute(i);if(null!==s){const e=s||i.replace("data-",""),n=this.cleanupFunctions.get(e)||this.cleanupFunctions.get(i.replace("data-",""));if(n){try{n(t)}catch(t){}return void this.processedElements.delete(t)}}}const i=t.className;if("string"==typeof i)for(const s of this.H){if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(i)){const i=s.replace("ds-",""),e=this.cleanupFunctions.get(i)||this.cleanupFunctions.get(s);if(e){try{e(t)}catch(t){}return void this.processedElements.delete(t)}}}}async initializeAll(t=document){const i=this.V();if(!i)return;const s=t.querySelectorAll(i),e=[];s.forEach(t=>{this.processedElements.has(t)||e.push(this.initialize(t))}),await Promise.all(e)}}const Pt=new jt,Nt=[{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 Nt)t.attr&&!Pt.L.includes(t.attr)&&Pt.L.push(t.attr),t.cls&&!Pt.H.includes(t.cls)&&Pt.H.push(t.cls);class Bt{constructor(i){this.element=i,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 i of this.element.attributes)if(i.name.startsWith("data-prop-")){const s=i.name.replace("data-prop-","");let e=i.value;try{e=JSON.parse(e)}catch(t){}t[s]=e}return t}q(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(i=>{const s=i.getAttribute("data-slot")||"default";t[s]=i.innerHTML.trim(),i.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,i){if((this.W[t]||[]).forEach(t=>{try{t(i)}catch(t){}}),this.element){const s=new CustomEvent(`kupola:${t}`,{detail:i,bubbles:!0,cancelable:!0});this.element.dispatchEvent(s)}}$on(t,i){return this.W[t]||(this.W[t]=[]),this.W[t].push(i),i}$off(t,i){this.W[t]&&(this.W[t]=this.W[t].filter(t=>t!==i))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?.Y()}catch(i){this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"update",hook:"setProps",error:i,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?.Y()}catch(i){this.lifecycle&&"function"==typeof this.lifecycle.p&&await this.lifecycle.p({phase:"update",hook:"setState",error:i,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 i=Object.getPrototypeOf(this);const s=new Set;for(;i&&i.constructor!==Object&&i.constructor!==Bt;){for(const[e,n]of Object.entries(t))s.has(e)||i.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]?.()),s.add(e));i=Object.getPrototypeOf(i)}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 zt(t,i){Object.keys(i).forEach(s=>{if("constructor"!==s)if("function"==typeof i[s]){const e=t.prototype[s];t.prototype[s]=e?function(...t){return i[s].apply(this,t),e.apply(this,t)}:i[s]}else t.prototype[s]=i[s]})}class Lt{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,i){if(!(i.prototype instanceof Bt))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,i)}registerLazy(t,i){this.lazyComponents.set(t,i)}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 i=this.components.get(t)||this.loadedComponents.get(t);if(i)return i;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const s=this.lazyComponents.get(t);if(!s)throw new Error(`Component ${t} not found`);const e=(async()=>{try{const i=await s(),e=i.default||i;if(!(e.prototype instanceof Bt))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,e),e}catch(i){throw this.loadingPromises.delete(t),i}})();return this.loadingPromises.set(t,e),e}defineMixin(t,i){this.mixins.set(t,i)}useMixin(t,...i){i.forEach(i=>{const s=this.mixins.get(i);s&&zt(t,s)})}async bootstrap(t=document){await this.it(t),this.st(t)}async it(t){const i=t.querySelectorAll("[data-component]"),s=[];i.forEach(t=>{s.push(this.et(t))}),await Promise.all(s)}async et(t){if(!t.nt&&!t.ht){t.ht=!0;try{const i=t.getAttribute("data-component");if(i){const s=Pt.get(i);if(s)try{return void await s(t)}catch(t){}}let s=this.components.get(i);if(!s){try{s=await this.getAsync(i)}catch(t){return}if(!t.isConnected)return}const e=t.getAttribute("data-mixins"),n=s;e&&e.split(",").forEach(t=>{const i=this.mixins.get(t.trim());i&&zt(n,i)});const h=new n(t);t.nt=h,this.instances.set(t,h),h.mount()}finally{t.ht=!1}}}st(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.it(t).catch(t=>{}),Pt.initialize(t).catch(()=>{});const i=Pt.V();i&&t.querySelectorAll?.(i).forEach(t=>{Pt.initialize(t).catch(()=>{})})}}),t.removedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const i=this.instances.get(t);i&&(i.unmount(),this.instances.delete(t)),t.querySelectorAll("[data-component]").forEach(t=>{const i=this.instances.get(t);i&&(i.unmount(),this.instances.delete(t))}),Pt.cleanup(t),t.querySelectorAll?.("*").forEach(t=>{Pt.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()}}let Ht=null;async function Ut(){if("undefined"!=typeof window){!function(){if(pt().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=ht();W.loadPersisted(),W.bind(),Et(),!1!==t.components?.autoInit&&(await Pt.initializeAll(),Ht&&await Ht.bootstrap())}}function Vt(t,i){Ht&&Ht.register(t,i)}function Jt(t,i){Ht&&Ht.registerLazy(t,i)}function qt(t){return Ht?Ht.bootstrap(t):Promise.resolve()}function Wt(t,i){Ht&&Ht.defineMixin(t,i)}function Kt(t,...i){Ht&&Ht.useMixin(t,...i)}function Yt(t,i){if(!i||"object"!=typeof i)throw new Error(`defineComponent("${t}"): options must be an object`);i.componentClass?Ht&&Ht.register(t,i.componentClass):i.lazy&&Ht&&Ht.registerLazy(t,i.lazy),i.init?Pt.register(t,i.init,i.cleanup||null,{dataAttribute:i.dataAttribute,cssClass:i.cssClass}):(i.dataAttribute||i.cssClass)&&Pt.register(t,()=>{},null,{dataAttribute:i.dataAttribute,cssClass:i.cssClass})}"undefined"!=typeof window&&(Ht=new Lt),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ut):"undefined"!=typeof window&&setTimeout(Ut,0);class Zt{constructor(){this.ot=new Map,this.rt=new Map}on(t,i,s,e={}){const{scope:n=null,once:h=!1,passive:o=!1,capture:r=!1}=e,a=this.ct(),c={id:a,target:t,eventName:i,handler:s,scope:n,once:h,wrappedHandler:null};c.wrappedHandler=i=>{h&&this.offById(a),s.call(t,i)};const l=this.lt(t,i);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(i,c.wrappedHandler,{passive:o,capture:r}),{unsubscribe:()=>this.offById(a)}}once(t,i,s,e={}){return this.on(t,i,s,{...e,once:!0})}off(t,i,s){const e=this.lt(t,i);if(!this.ot.has(e))return;const n=this.ot.get(e),h=n.filter(t=>t.handler!==s);n.forEach(e=>{e.handler===s&&(t.removeEventListener(i,e.wrappedHandler),this.dt(e))}),0===h.length?this.ot.delete(e):this.ot.set(e,h)}offById(t){for(const[i,s]of this.ot){const e=s.findIndex(i=>i.id===t);if(-1!==e){const t=s[e];return t.target.removeEventListener(t.eventName,t.wrappedHandler),s.splice(e,1),0===s.length&&this.ot.delete(i),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,i=null){if(i){const s=this.lt(t,i);if(!this.ot.has(s))return;this.ot.get(s).forEach(s=>{t.removeEventListener(i,s.wrappedHandler),this.dt(s)}),this.ot.delete(s)}else for(const[i,s]of this.ot){const[e]=i.split(":");this.ut(t)===e&&(s.forEach(i=>{t.removeEventListener(i.eventName,i.wrappedHandler),this.dt(i)}),this.ot.delete(i))}}emit(t,i,s={}){const e=new CustomEvent(i,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(e),e}emitGlobal(t,i={}){return this.emit(document,t,i)}emitToScope(t,i,s={}){if(!this.rt.has(t))return;const e=this.rt.get(t),n=new Set;for(const[t,i]of this.ot)i.forEach(t=>{e.includes(t.id)&&n.add(t.target)});n.forEach(t=>{this.emit(t,i,s)})}getListenerCount(t,i=null){if(i){const s=this.lt(t,i);return this.ot.has(s)?this.ot.get(s).length:0}let s=0;const e=this.ut(t);for(const[t,i]of this.ot){const[n]=t.split(":");n===e&&(s+=i.length)}return s}getScopeListenerCount(t){return this.rt.has(t)?this.rt.get(t).length:0}hasListeners(t,i=null){return this.getListenerCount(t,i)>0}lt(t,i){return`${this.ut(t)}:${i}`}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 i=this.rt.get(t.scope),s=i.indexOf(t.id);-1!==s&&(i.splice(s,1),0===i.length&&this.rt.delete(t.scope))}destroy(){for(const[t,i]of this.ot)i.forEach(t=>{t.target.removeEventListener(t.eventName,t.wrappedHandler)});this.ot.clear(),this.rt.clear()}}const Gt=new Zt;function Xt(t,i,s,e){return Gt.on(t,i,s,e)}function Qt(t,i,s,e){return Gt.once(t,i,s,e)}function ti(t,i,s){Gt.off(t,i,s)}function ii(t,i,s){return Gt.emit(t,i,s)}function si(t,i){return Gt.emitGlobal(t,i)}function ei(t){Gt.offByScope(t)}function ni(t,i){Gt.offAll(t,i)}function hi(t,i){return Gt.getListenerCount(t,i)}class oi{constructor(t,i={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=dt();this.triggerMode=i.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=i.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=i.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==i.keyboardNav,this.autoPosition=!1!==i.autoPosition,this.closeOnClick=void 0!==i.closeOnClick?i.closeOnClick:void 0===s.dropdown?.closeOnClick||s.dropdown.closeOnClick,this.appendToBody=!1!==i.appendToBody,this.onSelect=i.onSelect||null,this.onShow=i.onShow||null,this.onHide=i.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 i=t.currentTarget;i.classList.contains("is-disabled")||i.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.triggerText&&!i.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=i.textContent.trim()),this.element.setAttribute("data-value",i.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:i,value:i.getAttribute("data-value"),text:i.textContent.trim()}),!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 i=this.Ft();if(i.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,i.length-1),this.It(i);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.It(i);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&i[this.focusIndex]&&i[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this.It(i);break;case"End":t.preventDefault(),this.focusIndex=i.length-1,this.It(i)}},"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 i=this.element.contains(t.target),s=this.menu&&this.menu.contains(t.target);i||s||this.hideMenu()},this.kt=Gt.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(),i=window.innerHeight,s=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const e=this.menu.getBoundingClientRect(),n=i-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>s?(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=i-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>s?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this.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(),i=ut().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=i,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 i=t.currentTarget;i.classList.contains("is-disabled")||i.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.triggerText&&!i.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=i.textContent.trim()),this.element.setAttribute("data-value",i.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:i,value:i.getAttribute("data-value"),text:i.textContent.trim()}),!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,i)=>{if("divider"===t.type){const t=document.createElement("div");t.className="ds-dropdown__divider",this.menu.appendChild(t)}else{const i=document.createElement("div");i.className="ds-dropdown__item"+(t.disabled?" is-disabled":"")+(t.active?" is-selected":""),i.textContent=t.text||t.label||"",void 0!==t.value&&i.setAttribute("data-value",t.value),t.icon&&(i.innerHTML=t.icon+i.innerHTML),t.disabled&&i.classList.add("is-disabled"),i.At=t=>this.xt(t),i.addEventListener("click",i.At),this.menu.appendChild(i)}})}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 ri(t,i){t.Zt&&t.Zt.destroy();const s=new oi(t,i);s.init(),t.Zt=s}function ai(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{ri(t)})}function ci(t){t.Zt&&(t.Zt.destroy(),t.Zt=null)}function li(){document.querySelectorAll(".ds-dropdown").forEach(t=>{ci(t)})}Pt.register("dropdown",ri,ci);class di{constructor(t,i={}){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=i.multiple||t.hasAttribute("data-select-multiple"),this.searchable=i.searchable||t.hasAttribute("data-select-search"),this.clearable=i.clearable||t.hasAttribute("data-select-clear"),this.placeholder=i.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=i.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=i.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=i.remoteMethod||null,this.onChange=i.onChange||null,this.appendToBody=!1!==i.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.ti(),this.multiple&&this.ii(),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 i=t.currentTarget;if(i.classList.contains("is-disabled"))return;const s=i.getAttribute("data-value");this.multiple?this.si(s,i):this.ei(s,i)},this.ni(),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 i=this.hi();if(i.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,i.length-1),this.oi(i);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this.oi(i);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&i[this.focusIndex]&&i[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 i=this.element.contains(t.target),s=this.optionsEl&&this.optionsEl.contains(t.target);i||s||this.hideOptions()},this.kt=Gt.on(document,"click",this.yt,{scope:this.scope}),this.ri(),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.ai()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}ti(){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)}ii(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}ai(){const t=this.searchInput.value.toLowerCase().trim();this.remoteMethod?this.remoteMethod(t,t=>{this.ci(t)}):(this.filteredOptions=this.allOptions.filter(i=>i.text.toLowerCase().includes(t)),this.allOptions.forEach(t=>{const i=this.filteredOptions.includes(t);t.el.style.display=i?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(t=>{const i=t.getAttribute("data-group"),s=this.filteredOptions.some(t=>t.group===i);t.style.display=s?"":"none"}),this.focusIndex=-1)}ci(t){this.Gt||(this.Gt=t=>{t.stopPropagation();const i=t.currentTarget;if(i.classList.contains("is-disabled"))return;const s=i.getAttribute("data-value");this.multiple?this.si(s,i):this.ei(s,i)}),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.li&&t.removeEventListener("click",t.li),t.remove()}),t.forEach(t=>{const i=document.createElement("div");i.className="ds-select__option",i.setAttribute("data-value",t.value),i.textContent=t.text||t.label,t.disabled&&i.classList.add("is-disabled"),this.selectedValues.has(t.value)&&i.classList.add("is-selected"),i.li=t=>this.Gt(t),i.addEventListener("click",i.li),this.optionsEl.appendChild(i)}),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]}ei(t,i){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),i.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(i.textContent.trim()),this.di(),this.hideOptions(),this.pi(),this.fi()}si(t,i){if(this.selectedValues.has(t))this.selectedValues.delete(t),i.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),i.classList.add("is-selected")}this.mi(),this.gi(),this.di(),this.pi(),this.fi()}mi(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const i=this.allOptions.find(i=>i.value===t);if(!i)return;const s=document.createElement("span");s.className="ds-select__tag",s.textContent=i.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",i=>{i.stopPropagation(),this.selectedValues.delete(t);const s=this.optionsEl.querySelector(`[data-value="${t}"]`);s&&s.classList.remove("is-selected"),this.mi(),this.gi(),this.di(),this.pi(),this.fi()}),s.appendChild(e),this.tagsWrap.appendChild(s)}))}gi(){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"))}pi(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}di(){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]||"")}fi(){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}))}ri(){if(this.nativeSelect)if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const i=this.optionsEl.querySelector(`[data-value="${t.value}"]`);i&&i.classList.add("is-selected")}),this.mi(),this.gi();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.pi()}ni(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.li=t=>this.Gt(t),t.addEventListener("click",t.li)})}hi(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>"none"!==t.style.display&&!t.classList.contains("is-disabled"))}oi(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._i(),this.Pt()),this.optionsEl.style.display="block",this.bi(),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.wi(),this.Bt()),this.searchInput&&(this.searchInput.value="",this.ai()),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)}_i(){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(),i=ut().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=i,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}wi(){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)}bi(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),i=window.innerHeight,s=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const e=this.optionsEl.getBoundingClientRect(),n=i-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>s?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.mi(),this.gi(),this.di(),this.pi(),this.fi()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const i=this.allOptions.find(i=>i.value===t);return i?{value:i.value,text:i.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.mi(),this.gi()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(i=>{const s=i.getAttribute("data-value")===t;i.classList.toggle("is-selected",s),s&&this.updateValue(i.textContent.trim())})),this.di(),this.pi()}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.li&&t.removeEventListener("click",t.li)}),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.wi(),this.yt=null,this.kt=null,this.wt=null,this.Gt=null,this.$t=null,this.element.Dt=!1)}}function ui(t,i){const s=new di(t,i);s.init(),t.yi=s}function pi(t=document){t.querySelectorAll(".ds-select").forEach(t=>{ui(t)})}function fi(t){t.yi&&(t.yi.destroy(),t.yi=null)}Pt.register("select",ui,fi);class mi{constructor(t,i={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=dt(),e=void 0!==s.datepicker?.weekStart?s.datepicker.weekStart:1;this.format=i.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=i.range||t.hasAttribute("data-datepicker-range"),this.minDate=i.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=i.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=i.disabledDate||null,this.weekStart=void 0!==i.weekStart?i.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||e,this.appendToBody=!1!==i.appendToBody,this.placeholder=i.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==i.showToday,this.showWeekNumber=i.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=i.onChange||null,this.months=i.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=i.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=i.todayText||"Today",this.clearText=i.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.ki=null,this.xi=null,this.$i=null,this.yt=null,this.bt=null,this.kt=null,this.Mi=null,this.Si=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.Ci(t[0].trim()),this.rangeEnd=this.Ci(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this.Ci(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.ki=t=>this.toggleCalendar(t),this.xi=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this.ki),this.input&&this.input.addEventListener("click",this.xi),this.endInput&&(this.$i=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this.$i)),this.kt=Gt.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this.Si=Gt.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.Ei()}}Ci(t){if(!t)return null;const i=t.split("-");return 3===i.length?new Date(parseInt(i[0]),parseInt(i[1])-1,parseInt(i[2])):null}Ti(t){if(!t)return"";const i=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",i).replace("MM",s).replace("DD",e)}Di(t){if(this.minDate){if(t<("string"==typeof this.minDate?this.Ci(this.minDate):this.minDate))return!0}if(this.maxDate){if(t>("string"==typeof this.maxDate?this.Ci(this.maxDate):this.maxDate))return!0}return!!this.disabledDate&&this.disabledDate(t)}Oi(t){const i=new Date;return t.getFullYear()===i.getFullYear()&&t.getMonth()===i.getMonth()&&t.getDate()===i.getDate()}Fi(t,i){return!(!t||!i)&&(t.getFullYear()===i.getFullYear()&&t.getMonth()===i.getMonth()&&t.getDate()===i.getDate())}Ii(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const i=t.getTime(),s=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),e=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return i>=s&&i<=e}calculatePosition(){const t=this.element.getBoundingClientRect(),i=this.calendarEl.getBoundingClientRect(),s=window.innerHeight-t.bottom,e=t.top,n=i.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,s>=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")):s>=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 i="block"===this.calendarEl.style.display;document.querySelectorAll(".ds-datepicker__calendar").forEach(t=>{t!==this.calendarEl&&(t.style.display="none",t.setAttribute("hidden",""))}),i||(this.appendToBody&&(this.Ai(),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.Ri(),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)}Ai(){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=ut().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}Ri(){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()}Ei(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.ji&&t.removeEventListener("click",t.ji)}),"years"===this.viewMode)return void this.Pi();if("months"===this.viewMode)return void this.Ni();const i=this.currentDate.getFullYear(),s=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.Bi()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${i} ${this.months[s]}`,h.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",this.Ei()});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.zi()}),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 i=document.createElement("span");i.className="ds-datepicker__weekday",i.textContent=t,r.appendChild(i)}),t.appendChild(r);const a=document.createElement("div");a.className="ds-datepicker__days";const c=new Date(i,s,1).getDay(),l=new Date(i,s+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(i,s,t),n=document.createElement("button");n.className="ds-datepicker__day",n.type="button",n.textContent=t,this.Ti(e),this.Oi(e)&&n.classList.add("is-today"),this.range?((this.Fi(e,this.rangeStart)||this.Fi(e,this.rangeEnd))&&n.classList.add("is-selected"),this.Ii(e)&&n.classList.add("is-in-range")):this.Fi(e,this.selectedDate)&&n.classList.add("is-selected"),this.Di(e)&&(n.classList.add("is-disabled"),n.disabled=!0);const h=()=>this.Li(e);n.addEventListener("click",h),n.ji=h,a.appendChild(n)}if(t.appendChild(a),this.showToday){const i=document.createElement("div");i.className="ds-datepicker__footer";const s=document.createElement("button");s.className="ds-datepicker__today-btn",s.type="button",s.textContent=this.todayText,s.addEventListener("click",t=>{t.stopPropagation(),this.Hi()});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.Ui()}),i.appendChild(s),i.appendChild(e),t.appendChild(i)}}Pi(){const t=this.calendarEl;t.innerHTML="";const i=this.currentDate.getFullYear(),s=i-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.Ei()});const h=document.createElement("button");h.className="ds-datepicker__title",h.type="button",h.textContent=`${s} - ${s+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.Ei()}),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=s+t,n=document.createElement("button");n.className="ds-datepicker__year-cell",n.type="button",n.textContent=e,e===i&&n.classList.add("is-selected"),n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(e),this.viewMode="months",this.Ei()}),r.appendChild(n)}t.appendChild(r)}Ni(){const t=this.calendarEl;t.innerHTML="";const i=this.currentDate.getFullYear(),s=document.createElement("div");s.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.Ei()});const n=document.createElement("button");n.className="ds-datepicker__title",n.type="button",n.textContent=i,n.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="years",this.Ei()});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.Ei()}),s.appendChild(e),s.appendChild(n),s.appendChild(h),t.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((t,i)=>{const s=document.createElement("button");s.className="ds-datepicker__month-cell",s.type="button",s.textContent=t,i===this.currentDate.getMonth()&&s.classList.add("is-selected"),s.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(i),this.viewMode="days",this.Ei()}),o.appendChild(s)}),t.appendChild(o)}Li(t){if(!this.Di(t)){if(!this.range)return this.selectedDate=t,this.input&&(this.input.value=this.Ti(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this.fi();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.Ti(this.rangeStart)),this.endInput&&(this.endInput.value=this.Ti(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this.fi();this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0,this.Ei()}}fi(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this.Ti(this.rangeStart),endStr:this.Ti(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this.Ti(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this.Ti(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}Bi(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.Ei()}zi(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.Ei()}Hi(){const t=new Date;this.currentDate=new Date(t),this.Di(t)?this.Ei():this.Li(t)}Ui(){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.fi()}setDate(t){const i="string"==typeof t?this.Ci(t):t;i&&(this.selectedDate=i,this.currentDate=new Date(i),this.input&&(this.input.value=this.Ti(i)),this.Ei())}getDate(){return this.selectedDate}setRange(t,i){this.rangeStart="string"==typeof t?this.Ci(t):t,this.rangeEnd="string"==typeof i?this.Ci(i):i,this.input&&(this.input.value=this.Ti(this.rangeStart)),this.endInput&&(this.endInput.value=this.Ti(this.rangeEnd)),this.Ei()}destroy(){this.element.Dt&&(this.icon&&this.ki&&this.icon.removeEventListener("click",this.ki),this.input&&this.xi&&this.input.removeEventListener("click",this.xi),this.endInput&&this.$i&&this.endInput.removeEventListener("click",this.$i),this.$t&&document.removeEventListener("keydown",this.$t),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.Si&&this.Si.unsubscribe?this.Si.unsubscribe():this.Mi&&window.removeEventListener("resize",this.Mi),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t.ji&&t.removeEventListener("click",t.ji)}),this.appendToBody&&this.bt&&this.Ri(),this.yt=null,this.Mi=null,this.kt=null,this.Si=null,this.ki=null,this.xi=null,this.$i=null,this.$t=null,this.element.Dt=!1)}}function gi(t,i){const s=new mi(t,i);s.init(),t.Vi=s}function _i(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{gi(t)})}function bi(t){t.Vi&&(t.Vi.destroy(),t.Vi=null)}Pt.register("datepicker",gi,bi);class vi{constructor(t,i={}){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=i.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=i.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=i.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=i.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=i.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=i.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=i.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=i.disabledTime||null,this.placeholder=i.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=i.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=i.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this.Ji=null,this.yt=null,this.kt=null,this.Mi=null,this.Si=null,this.$t=null}init(){this.element.Dt||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this.qi(),this.Ji=t=>{t.stopPropagation(),this.panelEl&&"block"===this.panelEl.style.display?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this.Ji),this.kt=Gt.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this.Si=Gt.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)}qi(){const t=this.input.value.trim();if(!t)return;const i=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(i)return this.selectedHour=parseInt(i[1])%12,"PM"===i[4].toUpperCase()&&(this.selectedHour+=12),this.selectedMinute=parseInt(i[2]),void(this.selectedSecond=i[3]?parseInt(i[3]):0);const s=t.split(":");s.length>=2&&(this.selectedHour=parseInt(s[0])||0,this.selectedMinute=parseInt(s[1])||0,this.selectedSecond=s[2]&&parseInt(s[2])||0)}Wi(t,i,s){if(this.disabledTime)return this.disabledTime(t,i,s);const e=3600*t+60*i+s;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}Ki(){let t=this.selectedHour,i=this.selectedMinute,s=this.selectedSecond;if(this.use12Hour){const e=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")} ${e}`:`${t}:${String(i).padStart(2,"0")} ${e}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(i).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),i=this.panelEl.getBoundingClientRect(),s=window.innerHeight-t.bottom,e=t.top,n=i.height||320;s>=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.Yi(),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.Zi(),this.Gi(),this.showSeconds&&this.Xi(),this.use12Hour&&this.Qi(),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.Yi(),setTimeout(()=>{this.calculatePosition(),this.ts()},0)}Zi(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;for(let i=this.use12Hour?1:0;i<(this.use12Hour?13:24);i+=this.hourStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(i).padStart(2,"0"),s.dataset.value=i,s.addEventListener("click",()=>{let t=i;this.use12Hour&&(t=12===i?this.isPM?12:0:this.isPM?i+12:i),this.selectedHour=t,this.ss(),this.es("hour",i),this.ns()}),t.appendChild(s)}}Gi(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let i=0;i<60;i+=this.minuteStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(i).padStart(2,"0"),s.dataset.value=i,s.addEventListener("click",()=>{this.selectedMinute=i,this.ss(),this.es("minute",i),this.ns()}),t.appendChild(s)}}Xi(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let i=0;i<60;i+=this.secondStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(i).padStart(2,"0"),s.dataset.value=i,s.addEventListener("click",()=>{this.selectedSecond=i,this.ss(),this.es("second",i),this.ns()}),t.appendChild(s)}}Qi(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(i=>{const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=i,s.dataset.value=i,s.addEventListener("click",()=>{this.isPM="PM"===i,this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this.ss(),t.querySelectorAll(".ds-timepicker__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.ns()}),t.appendChild(s)})}ss(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),i=this.panelEl.querySelector(".ds-timepicker__display-minute"),s=this.panelEl.querySelector(".ds-timepicker__display-second"),e=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const i=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(i).padStart(2,"0")}i&&(i.textContent=String(this.selectedMinute).padStart(2,"0")),s&&(s.textContent=String(this.selectedSecond).padStart(2,"0")),e&&(e.textContent=this.selectedHour>=12?"PM":"AM")}Yi(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this.es("hour",t),this.es("minute",this.selectedMinute),this.es("second",this.selectedSecond);const i=this.panelEl.querySelector('[data-type="ampm"]');i&&i.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected","PM"===t.dataset.value==this.selectedHour>=12)}),this.ss()}es(t,i){const s=this.panelEl.querySelector(`[data-type="${t}"]`);s&&s.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected",parseInt(t.dataset.value)===i)})}ts(){["hour","minute","second"].forEach(t=>{const i=this.panelEl.querySelector(`[data-type="${t}"]`);if(!i)return;const s=i.querySelector(".is-selected");s&&s.scrollIntoView({block:"center"})})}ns(){this.input.value=this.Ki()}hideTimepicker(t){this.panelEl&&"block"===this.panelEl.style.display&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this.Ki(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this.Ki()})))}resizeHandler(){this.panelEl&&"block"===this.panelEl.style.display&&this.calculatePosition()}setTime(t,i,s){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,i)),this.selectedSecond=Math.max(0,Math.min(59,s||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this.Ki()),this.panelEl&&this.Yi()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.Dt&&(this.inputWrap&&this.Ji&&this.inputWrap.removeEventListener("click",this.Ji),this.kt&&this.kt.unsubscribe?this.kt.unsubscribe():this.yt&&document.removeEventListener("click",this.yt),this.Si&&this.Si.unsubscribe?this.Si.unsubscribe():this.Mi&&window.removeEventListener("resize",this.Mi),this.$t&&document.removeEventListener("keydown",this.$t),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this.Ji=null,this.yt=null,this.kt=null,this.Mi=null,this.Si=null,this.$t=null,this.element.Dt=!1)}}function wi(t,i){const s=new vi(t,i);s.init(),t.hs=s}function yi(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{wi(t)})}function ki(t){t.hs&&(t.hs.destroy(),t.hs=null)}Pt.register("timepicker",wi,ki);class xi{constructor(t,i={}){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=i.range||t.hasAttribute("data-slider-range"),this.vertical=i.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=i.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=!1!==i.showTooltip,this.showMarks=i.marks||t.hasAttribute("data-slider-marks"),this.markStep=i.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=i.tooltipFormat||(t=>t),this.onChange=i.onChange||null,this.onInput=i.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.rs=!1,this.cs=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this.ls(),this.ds(),this.updateSlider()}ls(){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.us()}us(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),i=parseFloat(this.input?.max||100);for(let s=t;s<=i;s+=this.markStep){const e=document.createElement("div");e.className="ds-slider__mark";const n=(s-t)/(i-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=s,e.appendChild(h),this.marksEl.appendChild(e)}this.element.appendChild(this.marksEl)}ds(){if(this.input){const t=()=>this.updateSlider(),i=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",i),this.ot.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:i})}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.ps(this.thumbStart,"start"),this.thumbEnd&&this.ps(this.thumbEnd,"end"),this.track){const t=t=>{this.disabled||this.fs(t)};this.track.addEventListener("click",t),this.ot.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=t=>this.gs(t,"start");this.thumbStart.addEventListener("keydown",t),this.ot.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=t=>this.gs(t,"end");this.thumbEnd.addEventListener("keydown",t),this.ot.push({el:this.thumbEnd,event:"keydown",handler:t})}}ps(t,i){const s=t=>{this.disabled||(t.preventDefault(),this.rs=!0,this.cs=i,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.rs)return;t.preventDefault();const s=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:(s-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"===i&&this.range&&this.inputEnd){const t=parseFloat(this.inputEnd.value);c>t&&(c=t)}if("end"===i&&this.range&&this.input){const t=parseFloat(this.input.value);c<t&&(c=t)}"start"===i&&this.input?this.input.value=c:"end"===i&&this.inputEnd&&(this.inputEnd.value=c),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:h})},n=()=>{this.rs=!1,this.cs=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",s),t.addEventListener("touchstart",s,{passive:!1}),this.ot.push({el:t,event:"mousedown",handler:s},{el:t,event:"touchstart",handler:s})}fs(t){if(t.target.classList.contains("ds-slider__thumb"))return;const i=this.track.getBoundingClientRect(),s=t.clientX,e=t.clientY;let n;n=this.vertical?1-(e-i.top)/i.height:(s-i.left)/i.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),i=parseFloat(this.inputEnd?.value||0);Math.abs(a-t)<=Math.abs(a-i)?this.input&&(this.input.value=Math.min(a,i)):this.inputEnd&&(this.inputEnd.value=Math.max(a,t))}else this.input&&(this.input.value=a);this.updateSlider()}gs(t,i){if(this.disabled)return;const s="start"===i?this.input:this.inputEnd;if(!s)return;const e=parseFloat(s.step||1),n=parseFloat(s.min||0),h=parseFloat(s.max||100);let o=parseFloat(s.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}s.value=o,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),i=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const s=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0),n=(s-t)/(i-t)*100,h=(e-t)/(i-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(s)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(e)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(s)} - ${this.tooltipFormat(e)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",e)}else{const s=this.input?.value||0,e=(s-t)/(i-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(s))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(s))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.element.setAttribute("aria-valuenow",s)}}destroy(){this.ot?.forEach(({el:t,event:i,handler:s})=>{t.removeEventListener(i,s)}),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,i){this.input&&(this.input.value=t),void 0!==i&&this.inputEnd&&(this.inputEnd.value=i),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 $i(t,i){if(!t.Dt)try{const s=new xi(t,i);t.nt=s,t.Dt=!0}catch(t){}}function Mi(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Si(){document.querySelectorAll(".ds-slider").forEach(t=>{$i(t)})}Pt.register("slider",$i,Mi);class Ci{constructor(t,i={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=i.placement||t.getAttribute("data-drawer-placement")||"right",this.width=i.width||t.getAttribute("data-drawer-width")||"400px",this.height=i.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=!1!==i.escClose,this.maskClosable=!1!==i.maskClosable,this.showMask=!1!==i.showMask,this.onOpen=i.onOpen||null,this.onClose=i.onClose||null,this.onBeforeClose=i.onBeforeClose||null,this.$t=null,this.ds()}ds(){const t=this.mask?.querySelector(".ds-drawer__close"),i=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),s=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),i&&i.addEventListener("click",this.closeDrawer),s&&s.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:i,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer}].filter(t=>t.el)}_s(){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:i,handler:s})=>{t.removeEventListener(i,s)}),this.$t&&document.removeEventListener("keydown",this.$t),this.ot=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._s(),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 Ei(t,i){if(t.Dt)return;const s=new Ci(t,i);t.nt=s,t.Dt=!0}function Ti(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Di(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const i=t.getAttribute("data-drawer"),s=document.getElementById(i);s&&(Ei(s,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),s.nt?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const i=t.parentElement;i&&Ei(i)})}Pt.register("drawer",Ei,Ti);class Oi{constructor(t,i={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close");const s=dt(),e=void 0===s.modal?.backdropClick||s.modal.backdropClick;this.fullscreen=i.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=void 0!==i.closableOnMask?i.closableOnMask:e,this.escClose=!1!==i.escClose,this.width=i.width||t.getAttribute("data-modal-width")||"",this.center=!1!==i.center,this.onBeforeOpen=i.onBeforeOpen||null,this.onBeforeClose=i.onBeforeClose||null,this.onOpened=i.onOpened||null,this.onClosed=i.onClosed||null,this.bs=!1,this.$t=t=>{this.escClose&&"Escape"===t.key&&this.isVisible()&&this.close()},this.vs=()=>this.close(),this.ys=t=>{this.closableOnMask&&t.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this.vs),this.mask&&this.mask.addEventListener("click",this.ys),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.bs||(Oi.ks=(Oi.ks||0)+1,this.bs=!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.bs&&(Oi.ks=Math.max(0,(Oi.ks||0)-1),this.bs=!1,0===Oi.ks&&(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.vs),this.mask&&this.mask.removeEventListener("click",this.ys),this.bs&&(Oi.ks=Math.max(0,(Oi.ks||0)-1),this.bs=!1,0===Oi.ks&&(document.body.style.overflow=""))}}function Fi(t={}){const{title:i="",content:s="",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=dt().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 Oi(y,{fullscreen:h,closableOnMask:p}),$=y.querySelector(".ds-modal__title");$&&($.textContent=i);const M=y.querySelector(".ds-modal__body");M&&(e?M.innerHTML=s:M.textContent=s);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 Ii(t){return"string"==typeof t&&(t={content:t}),Fi({...t,showCancel:!0,showConfirm:!0})}function Ai(t){return"string"==typeof t&&(t={content:t}),Fi({...t,showCancel:!1,showConfirm:!0})}function Ri(t){if(t.Dt)return;const i=new Oi(t);t.nt=i,t.Dt=!0}function ji(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Pi(){document.querySelectorAll(".ds-modal-container").forEach(t=>{Ri(t)})}Oi.ks=0,Pt.register("modal",Ri,ji);class Ni{static normal(t={}){return this.xs({type:"normal",...t})}static success(t={}){return this.xs({type:"success",...t})}static warning(t={}){return this.xs({type:"warning",...t})}static error(t={}){return this.xs({type:"error",...t})}static info(t={}){return this.xs({type:"info",...t})}static confirm(t={}){return this.xs({type:"confirm",...t})}static xs(t){const{type:i="normal",title:s="",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--${i}">${o[i]}</div>\n ${s?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===i||h?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}\n <button class="ds-btn ${"confirm"===i?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>\n ${"confirm"===i?"Confirm":"OK"}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,document.body.appendChild(r),s&&(r.querySelector(".ds-dialog__title").textContent=s),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}}}const Bi={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 i=gt(),{title:s,message:e,type:n="normal",duration:h=i.duration,position:o=i.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 ${s?'<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 `,s&&(r.querySelector(".ds-notification__title").textContent=s),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=ut().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)}};function zi(){}const Li={normal:function(t,i={}){this.show(t,"normal",i)},success:function(t,i={}){this.show(t,"success",i)},error:function(t,i={}){this.show(t,"error",i)},warning:function(t,i={}){this.show(t,"warning",i)},info:function(t,i={}){this.show(t,"info",i)},show:function(t,i="normal",s={}){const e=mt(),{duration:n=e.duration,position:h=e.position}=s,o=e.maxCount||5,r=document.createElement("div");r.className=`ds-message__item ds-message__item--${i}`;r.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${i}">${{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>'}[i]}</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=ut().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 Hi(){}function Ui(t){return t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}class Vi{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()},i=t=>{const i=Array.from(t.target.files);this.addFiles(i),t.target.value=""},s=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 i=Array.from(t.dataTransfer.files);this.addFiles(i)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",i),this.dropzone.addEventListener("dragover",s),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:i},{el:this.dropzone,event:"dragover",handler:s},{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 i=this.input.getAttribute("accept");if(i&&""!==i){const s=i.split(",").map(t=>t.trim()),e=t.type,n=t.name.toLowerCase();if(!s.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 i=document.createElement("div");i.className="ds-fileupload__item",i.dataset.filename=t.name;const s=this.getFileIcon(t.type);i.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${s}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(Ui(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=i.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,i)};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(i)}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,i=20){if(t.length<=i)return t;const s=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,i-s.length-3)+"..."+s}formatSize(t){if(0===t)return"0 B";const i=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,i)).toFixed(1))+" "+["B","KB","MB","GB"][i]}removeFile(t,i){this.files=this.files.filter(i=>i!==t),i&&i.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 i=document.createElement("div");i.className="ds-fileupload__error",i.textContent=t,i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),this.dropzone.appendChild(i),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 i=new FileReader;i.onload=i=>{const s=document.createElement("div");s.className="ds-fileupload__preview-item",s.innerHTML=`\n <img src="${i.target.result}" alt="${Ui(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=s.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),s.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(s)},i.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 i=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");i.className="ds-fileupload__progress-bar",i.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(i),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const i=100;let s=0;Math.max(1,Math.floor(t.size/i));const e=setInterval(()=>{s++;const t=Math.min(100,Math.floor(s/i*100));this.updateProgress(t),s>=i&&(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:i,handler:s})=>{t.removeEventListener(i,s)}),this.ot=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function Ji(t){if(t.Dt)return;const i=new Vi(t);t.nt=i,t.Dt=!0}function qi(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Wi(){document.querySelectorAll(".ds-fileupload").forEach(t=>{Ji(t)})}Pt.register("fileupload",Ji,qi);class Ki{constructor(t,i={}){this.element=t,this.headers=[],this.ot=[],this.accordion=i.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=i.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=i.disabledItems||[],this.defaultExpanded=i.defaultExpanded||[],this.$s()}$s(){this.element.querySelectorAll(".ds-collapse__header").forEach((t,i)=>{const s=t.closest(".ds-collapse__item"),e=t.nextElementSibling;if(!s||!e||!e.classList.contains("ds-collapse__content"))return;const n=s.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(i);n&&s.classList.add("is-disabled");let h=s.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(i))&&(h=!0),h?(s.classList.add("is-active"),e.style.height=e.scrollHeight+"px",e.style.overflow="hidden",setTimeout(()=>{s.classList.contains("is-active")&&(e.style.height="auto",e.style.overflow="visible")},this.animationDuration)):(s.classList.remove("is-active"),e.style.height="0",e.style.overflow="hidden");const o=()=>{if(n)return;const t=s.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,s)=>{s!==i&&t.item.classList.contains("is-active")&&this.Ms(t)}),t?this.Ms({item:s,content:e}):this.Ss({item:s,content:e}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:i,expanded:!t,item:s},bubbles:!0}))};t.addEventListener("click",o),this.headers.push({header:t,item:s,content:e,clickHandler:o,isDisabled:n}),this.ot.push({el:t,event:"click",handler:o})})}Ss(t){const{item:i,content:s}=t;s.style.overflow="hidden",s.style.height="0",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height=s.scrollHeight+"px",i.classList.add("is-active");const e=()=>{s.removeEventListener("transitionend",e),i.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible"),s.style.transition=""};s.addEventListener("transitionend",e),this.ot.push({el:s,event:"transitionend",handler:e})}Ms(t){const{item:i,content:s}=t;s.style.overflow="hidden",s.style.height=s.scrollHeight+"px",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height="0",i.classList.remove("is-active");const e=()=>{s.removeEventListener("transitionend",e),s.style.transition=""};s.addEventListener("transitionend",e),this.ot.push({el:s,event:"transitionend",handler:e})}destroy(){this.ot.forEach(({el:t,event:i,handler:s})=>{t.removeEventListener(i,s)}),this.ot=null,this.headers=null,this.element=null}toggle(t){const i=this.headers[t];i&&!i.isDisabled&&i.clickHandler()}expand(t){const i=this.headers[t];!i||i.item.classList.contains("is-active")||i.isDisabled||(this.accordion&&this.headers.forEach((i,s)=>{s!==t&&i.item.classList.contains("is-active")&&this.Ms(i)}),this.Ss(i))}collapse(t){const i=this.headers[t];i&&i.item.classList.contains("is-active")&&this.Ms(i)}expandAll(){this.accordion||this.headers.forEach((t,i)=>{t.item.classList.contains("is-active")||t.isDisabled||this.Ss(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this.Ms(t)})}getExpandedIndices(){return this.headers.map((t,i)=>t.item.classList.contains("is-active")?i:-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 Yi(t,i){if(t.Dt)return;const s=new Ki(t,i);t.nt=s,t.Dt=!0}function Zi(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Gi(){document.querySelectorAll(".ds-collapse").forEach(t=>{Yi(t)})}Pt.register("collapse",Yi,Zi);class Xi{constructor(t,i={}){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=i,this.value=i.value||"#007bff",this.showAlpha=!1!==i.showAlpha,this.mode=i.mode||"hex",this.previousColors=i.previousColors||this.Cs(),this.previousColorsLimit=i.previousColorsLimit||12,this.wt=null,this.yt=null,this.kt=null,this.Es=null,this.Ts=null,this.Ds=null,this.Os=null,this.Fs=null,this.Is=null,this.As=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this.Rs(this.value)}Cs(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}js(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}Ps(t){const i=this.previousColors.indexOf(t);-1!==i&&this.previousColors.splice(i,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this.js(),this.Ns()}Rs(t){const i=t.replace(/^#/,""),s=parseInt(i.substring(0,2),16)/255,e=parseInt(i.substring(2,4),16)/255,n=parseInt(i.substring(4,6),16)/255,h=8===i.length?parseInt(i.substring(6,8),16)/255:1,o=Math.max(s,e,n),r=Math.min(s,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 s:a=((e-n)/d+(e<n?6:0))/6;break;case e:a=((n-s)/d+2)/6;break;case n:a=((s-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)}Bs(t,i,s,e=1){i/=100,s/=100,e/=100;const n=i=>(i+t/60)%6,h=t=>s*(1-i*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*i)}%, ${Math.round(100*s)}%, ${e.toFixed(2)})`:`hsl(${t}, ${Math.round(100*i)}%, ${Math.round(100*s)}%)`;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}Ns(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(i=>{const s=document.createElement("button");s.className="ds-color-picker__color",s.style.backgroundColor=i,s.setAttribute("data-color",i),s.addEventListener("click",this.Es),t.appendChild(s)}))}zs(){const t=this.panel.querySelector(".ds-color-picker__hue"),i=this.panel.querySelector(".ds-color-picker__sv"),s=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),i&&(i.style.background=`hsl(${this.hue}, 100%, 50%)`),s&&this.showAlpha&&(s.value=this.alpha,s.style.background=`linear-gradient(to right, transparent, ${this.Bs(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.Es=t=>{const i=t.currentTarget.getAttribute("data-color");this.updateColor(i),this.hidePanel()},this.Ts=t=>{const i=t.target.value;this.Ls(i)&&this.updateColor(i)},this.Ds=t=>{this.alpha=parseInt(t.target.value),this.Hs()},this.Os=t=>{const i=t.currentTarget;this.mode=i.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>t.classList.remove("is-active")),i.classList.add("is-active"),this.ss()},this.Fs=t=>{this.hue=parseInt(t.target.value),this.zs(),this.Hs()},this.Is=t=>{const i=t.currentTarget.getBoundingClientRect(),s=t.clientX-i.left,e=t.clientY-i.top;this.saturation=Math.round(s/i.width*100),this.brightness=Math.round(100*(1-e/i.height)),this.Hs()},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.Es),t.Us=this.Es}),this.customInput&&(this.customInput.addEventListener("input",this.Ts),this.customInput.Vs=this.Ts);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this.Fs);const i=this.panel.querySelector(".ds-color-picker__sv");i&&(i.addEventListener("click",this.Is),i.addEventListener("mousemove",t=>{1===t.buttons&&this.Is(t)}));const s=this.panel.querySelector(".ds-color-picker__alpha");s&&this.showAlpha&&s.addEventListener("input",this.Ds),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.addEventListener("click",this.Os),t.getAttribute("data-mode")===this.mode&&t.classList.add("is-active")}),this.kt=Gt.on(document,"click",this.yt,{scope:this.scope}),this.Ns(),this.zs(),this.ss(),this.element.Dt=!0}Ls(t){const i=(new Option).style;return i.color=t,""!==i.color}Hs(){const t=this.Bs(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this.ss(),this.Ps(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}}))}ss(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this.zs()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this.Ls(t)&&(this.value=t,this.Rs(t),this.ss(),this.Ps(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.ss())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this.Hs()}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.Us&&t.removeEventListener("click",t.Us)}),this.customInput&&this.Ts&&this.customInput.removeEventListener("input",this.Ts);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this.Fs&&t.removeEventListener("input",this.Fs);const i=this.panel?.querySelector(".ds-color-picker__sv");i&&this.Is&&(i.removeEventListener("click",this.Is),i.removeEventListener("mousemove",this.Is));const s=this.panel?.querySelector(".ds-color-picker__alpha");s&&this.Ds&&s.removeEventListener("input",this.Ds),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.removeEventListener("click",this.Os)}),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.Es=null,this.Ts=null,this.Ds=null,this.Os=null,this.Fs=null,this.Is=null,this.As=null,this.element.Dt=!1}}function Qi(t,i){const s=new Xi(t,i);s.init(),t.Js=s}function ts(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{Qi(t)})}function is(t){t.Js&&(t.Js.destroy(),t.Js=null)}Pt.register("color-picker",Qi,is);class ss{constructor(t,i={}){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=i.selectedDate?new Date(i.selectedDate):null,this.rangeStart=i.rangeStart?new Date(i.rangeStart):null,this.rangeEnd=i.rangeEnd?new Date(i.rangeEnd):null,this.isRangeMode=i.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=i.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=i.events||[],this.i18n=i.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=i.onSelect||null,this.onRangeSelect=i.onRangeSelect||null,this.onChange=i.onChange||null,this.onEventClick=i.onEventClick||null,this.$s()}$s(){this.render();const t=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.qs()},i=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.qs()},s=()=>{this.currentDate=new Date,this.render(),this.qs()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this.ot.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",i),this.ot.push({el:this.nextBtn,event:"click",handler:i})),this.todayBtn&&(this.todayBtn.addEventListener("click",s),this.ot.push({el:this.todayBtn,event:"click",handler:s}))}qs(){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}))}Ti(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}Fi(t,i){return!(!t||!i)&&this.Ti(t)===this.Ti(i)}Ws(t){if(!this.rangeStart||!this.rangeEnd)return!1;const i=this.Ti(t),s=this.Ti(this.rangeStart),e=this.Ti(this.rangeEnd);return i>=s&&i<=e}Ks(t){return this.Fi(t,this.rangeStart)}Ys(t){return this.Fi(t,this.rangeEnd)}Zs(t){const i=this.Ti(t);return this.events.filter(t=>{const s=t.date||t.start,e=t.end;if(!s)return!1;const n="string"==typeof s?s:this.Ti(s);if(!e)return n===i;const h="string"==typeof e?e:this.Ti(e);return i>=n&&i<=h})}render(){const t=this.currentDate.getFullYear(),i=this.currentDate.getMonth();"week"===this.viewMode?this.Gs(t,i):this.Xs(t,i)}Xs(t,i){this.titleEl.textContent=`${t} ${this.i18n.months[i]}`;const s=new Date(t,i,1).getDay(),e=new Date(t,i+1,0).getDate();this.daysEl.innerHTML="";for(let t=0;t<s;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.Ti(n);for(let s=1;s<=e;s++){const e=new Date(t,i,s),n=document.createElement("button");n.className="ds-calendar__day",n.textContent=s;const o=this.Ti(e);o===h&&n.classList.add("is-today"),this.Fi(e,this.selectedDate)&&n.classList.add("is-selected"),this.isRangeMode&&(this.Ks(e)&&n.classList.add("is-range-start"),this.Ys(e)&&n.classList.add("is-range-end"),this.Ws(e)&&n.classList.add("is-in-range"));const r=this.Zs(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.Fi(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)}}Gs(t,i){const s=this.currentDate.getDay(),e=new Date(t,i,this.currentDate.getDate()-s+(0===s?-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.Ti(o);for(let t=0;t<7;t++){const i=new Date(e);i.setDate(e.getDate()+t);const s=document.createElement("button");s.className="ds-calendar__day ds-calendar__day--week";const n=document.createElement("span");n.className="ds-calendar__day-header",n.textContent=this.i18n.shortWeekdays[i.getDay()],s.appendChild(n);const h=document.createElement("span");h.className="ds-calendar__day-number",h.textContent=i.getDate(),s.appendChild(h);const o=this.Ti(i);o===r&&s.classList.add("is-today"),this.Fi(i,this.selectedDate)&&s.classList.add("is-selected");const a=this.Zs(i);if(a.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",a.slice(0,3).forEach(i=>{const s=document.createElement("span");s.className="ds-calendar__day-event",s.style.backgroundColor=i.color||"#007bff",t.appendChild(s)}),s.appendChild(t)}const c=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.selectedDate=i,this.onSelect&&this.onSelect({date:i,dateStr:o}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:i,dateStr:o},bubbles:!0})),this.render()};s.addEventListener("click",c),this.ot.push({el:s,event:"click",handler:c}),this.daysEl.appendChild(s)}}destroy(){this.ot.forEach(({el:t,event:i,handler:s})=>{t.removeEventListener(i,s)}),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.qs()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,i){this.rangeStart=t?new Date(t):null,this.rangeEnd=i?new Date(i):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(i=>i.id!==t),this.render()}setViewMode(t){"month"!==t&&"week"!==t||(this.viewMode=t,this.render(),this.qs())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this.qs()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this.qs()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this.qs()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this.qs()}goToToday(){this.currentDate=new Date,this.render(),this.qs()}goToDate(t){this.currentDate=new Date(t),this.render(),this.qs()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this.qs()}}function es(t,i){if(!t.Dt)try{const s=new ss(t,i);t.nt=s,t.Dt=!0}catch(t){}}function ns(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function hs(){document.querySelectorAll(".ds-calendar").forEach(t=>{es(t)})}Pt.register("calendar",es,ns);class os{constructor(t,i={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this.ot=[],this.maxCount=i.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=!1!==i.allowDuplicates,this.color=i.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 i=t.querySelector(".ds-dynamic-tags__remove");if(i){const s=i=>{i.stopPropagation(),t.remove(),this.dispatchChange()};i.addEventListener("click",s),this.ot.push({el:i,event:"click",handler:s})}}),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 i=this.createTag(t);this.element.insertBefore(i,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},i=i=>{"Enter"===i.key&&(i.preventDefault(),i.stopPropagation(),t())};this.input.addEventListener("keydown",i),this.ot.push({el:this.input,event:"keydown",handler:i});const s=()=>{this.input.focus()};this.element.addEventListener("click",s),this.ot.push({el:this.element,event:"click",handler:s})}}createTag(t){const i=document.createElement("span");i.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const s=document.createTextNode(t);i.appendChild(s);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>',i.appendChild(e);const n=t=>{t.stopPropagation(),i.remove(),this.dispatchChange()};return e.addEventListener("click",n),this.ot.push({el:e,event:"click",handler:n}),i}hasTag(t){const i=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of i)if(s.textContent.trim()===t)return!0;return!1}addTag(t,i){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 s=this.createTag(t);if(i){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=>s.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${i}`)&&s.classList.add(`ds-dynamic-tags__tag--${i}`)}this.element.insertBefore(s,this.input),this.dispatchChange()}removeTag(t){const i=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];i&&(i.remove(),this.dispatchChange())}removeTagByValue(t){const i=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of i)if(s.textContent.trim()===t)return s.remove(),void this.dispatchChange()}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(i=>{t.push(i.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(i=>{const s=Array.from(i.classList).find(t=>t.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:i.textContent.trim(),color:s})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(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:i,handler:s})=>{t.removeEventListener(i,s)}),this.ot=null,this.input=null,this.element=null}}function rs(t,i){if(t.Dt)return;const s=new os(t,i);t.nt=s,t.Dt=!0}function as(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function cs(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{rs(t)})}Pt.register("dynamic-tags",rs,as);class ls{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"),i=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this.Qs=()=>this.prev(),this.te=()=>this.next(),t.addEventListener("click",this.closeHandler),i.addEventListener("click",this.Qs),s.addEventListener("click",this.te);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",i=>{const s=t.getAttribute("data-action");this.handleToolbarAction(s)})});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,i=0){this.images=t,this.currentIndex=Math.min(Math.max(i,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"),i=this.overlay.querySelector(".ds-image-preview__title"),s=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||"",i.textContent=o.title||"",s.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,i)=>`\n <button class="ds-image-preview__indicator${i===this.currentIndex?" is-active":""}" type="button" data-index="${i}" aria-label="Go to image ${i+1}"></button>\n `).join(""),e.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{const i=()=>{this.goTo(parseInt(t.dataset.index))};t.addEventListener("click",i),t.ie=i})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{t.ie&&t.removeEventListener("click",t.ie)});const i=this.overlay?.querySelector(".ds-image-preview__close"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),e=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");i&&i.removeEventListener("click",this.closeHandler),s&&this.Qs&&s.removeEventListener("click",this.Qs),e&&this.te&&e.removeEventListener("click",this.te),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let ds=null;function us(){ds||(ds=new ls),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const i=JSON.parse(t.getAttribute("data-image-preview")),s=parseInt(t.getAttribute("data-image-index"))||0;ds.show(i,s)})})}function ps(t,i=0){ds||(ds=new ls),ds.show(t,i)}class fs{constructor(t,i={}){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=i.color||t.getAttribute("data-tag-color")||"default",this.size=i.size||t.getAttribute("data-tag-size")||"default",this.checkable=i.checkable||t.hasAttribute("data-tag-checkable"),this.checked=i.checked||t.hasAttribute("data-tag-checked"),this.editable=i.editable||t.hasAttribute("data-tag-editable"),this.maxLength=i.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()},i=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};this.editInput.addEventListener("blur",t),this.editInput.addEventListener("keydown",i),this.ot.push({el:this.editInput,event:"blur",handler:t}),this.ot.push({el:this.editInput,event:"keydown",handler:i})}}}se(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],i=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(t=>this.element.classList.remove(t)),i.forEach(t=>this.element.classList.remove(t)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),i.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 i=[];this.element.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE&&i.push(t)}),i.forEach(t=>t.remove());const s=this.element.querySelector(".ds-tag__close"),e=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),h=s||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 i=document.createElement("input");i.type="text",i.className="ds-tag__input",i.value=t,i.maxLength=this.maxLength,this.editInput=i;const s=this.element.querySelector(".ds-tag__close");this.element.insertBefore(i,s);const e=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};i.addEventListener("blur",e),i.addEventListener("keydown",n),this.ot.push({el:i,event:"blur",handler:e}),this.ot.push({el:i,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:i,handler:s})=>{t.removeEventListener(i,s)}),this.ot=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function ms(t,i){if(t.Dt)return;const s=new fs(t,i);t.nt=s,t.Dt=!0}function gs(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function _s(){document.querySelectorAll(".ds-tag").forEach(t=>{ms(t)})}Pt.register("tag",ms,gs);class bs{constructor(t,i={}){this.element=t,this.tooltipEl=null,this.options=i;const s=dt(),e=void 0!==s.tooltip?.delay?s.tooltip.delay:300;this.delay=void 0!==i.delay?i.delay:parseInt(t.getAttribute("data-tooltip-delay"))||e,this.hideDelay=i.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=i.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=i.html||t.hasAttribute("data-tooltip-html"),this.theme=i.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=i.position||t.getAttribute("data-tooltip-position")||"top",this.animation=!1!==i.animation,this.mouseFollow=i.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this.ee=null,this.ne=null,this.he=null,this.oe=null,this.ie=null,this.re=null,this.ae=null,this.ce=null,this.isVisible=!1}init(){this.element.Dt||(this.ee=()=>{this.delay>0?this.he=setTimeout(()=>this.show(),this.delay):this.show()},this.ne=()=>{this.he&&(clearTimeout(this.he),this.he=null),this.hideDelay>0?this.oe=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this.ie=()=>{this.isVisible?this.hide():this.show()},this.ce=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const i=this.tooltipEl.getBoundingClientRect();let s=t.clientX+10,e=t.clientY+10;const n=window.innerWidth,h=window.innerHeight;s+i.width>n&&(s=t.clientX-i.width-10),e+i.height>h&&(e=t.clientY-i.height-10),this.tooltipEl.style.left=`${s}px`,this.tooltipEl.style.top=`${e}px`},"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.addEventListener("mouseenter",this.ee),this.element.addEventListener("mouseleave",this.ne),this.mouseFollow&&this.element.addEventListener("mousemove",this.ce)),"click"===this.trigger&&(this.element.addEventListener("click",this.ie),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.ee),this.element.addEventListener("blur",this.ne)),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 i=ut().tooltip;this.tooltipEl.style.zIndex=i,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.le(),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()}le(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),i=this.tooltipEl.getBoundingClientRect(),s=window.innerWidth,e=window.innerHeight;let n,h;switch(this.position){case"bottom":n=t.left+t.width/2-i.width/2,h=t.bottom+8;break;case"right":n=t.right+8,h=t.top+t.height/2-i.height/2;break;case"left":n=t.left-i.width-8,h=t.top+t.height/2-i.height/2;break;default:n=t.left+t.width/2-i.width/2,h=t.top-i.height-8}n<8&&(n=8),n+i.width>s&&(n=s-i.width-8),h<8&&(h=8),h+i.height>e&&(h=e-i.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${h}px`,this.tooltipEl.style.position="fixed"}updateContent(t,i=!1){this.element.setAttribute("data-tooltip",t),i?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=i,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this.le())}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.le()))}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.ce)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this.ce))}destroy(){this.element.Dt&&(this.he&&(clearTimeout(this.he),this.he=null),this.oe&&(clearTimeout(this.oe),this.oe=null),"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.removeEventListener("mouseenter",this.ee),this.element.removeEventListener("mouseleave",this.ne)),"click"===this.trigger&&this.element.removeEventListener("click",this.ie),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.removeEventListener("focus",this.ee),this.element.removeEventListener("blur",this.ne)),this.mouseFollow&&this.element.removeEventListener("mousemove",this.ce),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this.ee=null,this.ne=null,this.ie=null,this.ce=null,this.element.Dt=!1)}}function vs(t,i){const s=new bs(t,i);s.init(),t.de=s}function ws(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{vs(t)})}function ys(t){t.de&&(t.de.destroy(),t.de=null)}Pt.register("tooltip",vs,ys);class ks{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,i){this.customValidators[t]=i}addAsyncValidator(t,i){this.customAsyncValidators[t]=i}validate(t){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s={},e=t.querySelectorAll("[data-validate]");let n=!1;return e.forEach(t=>{const i=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){s[i]=this.getErrorMessage(o,r,t),this.showError(t,s[i]),n=!0;break}this.clearError(t)}}),this.formStates[i]={valid:!n,errors:s,errorCount:Object.keys(s).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 i=t.closest(".ds-select"),s=i.querySelector(".ds-select__value")||i.querySelector(".ds-select__trigger span");return s?s.textContent.trim():""}if(t.closest(".ds-fileupload")){const i=t.closest(".ds-fileupload").ue;return i&&i.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const i=this.parseRules(t.getAttribute("data-validate")),s=this.getValue(t);for(const[e,n]of Object.entries(i)){const i=this.customValidators[e]||this.validators[e],h=i?.(s,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 i=!0;return t.forEach(t=>{this.validate(t)||(i=!1)}),i}async validateAsync(t,i={}){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,e=i.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 i=t.name||t.id,s=t.parentElement.querySelector(".ds-input__error");s&&(o[i]=s.textContent)}),this.formStates[s]={valid:!h,errors:o,errorCount:Object.keys(o).length},this.updateFormState(t),!h}async validateInputAsync(t){const i=this.parseRules(t.getAttribute("data-validate")),s=this.parseRules(t.getAttribute("data-validate-async")||""),e=this.getValue(t);for(const[s,n]of Object.entries(i)){const i=this.customValidators[s]||this.validators[s],h=i?.(e,n);if(!h)return this.showError(t,this.getErrorMessage(s,n,t)),!1}for(const[i,n]of Object.entries(s)){const s=this.customAsyncValidators[i]||this.asyncValidators[i];if(s)try{if(!await s(e,n,t))return this.showError(t,this.getErrorMessage(i,n,t)),!1}catch(i){return this.showError(t,i.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,i){const s=t.querySelectorAll(`[data-validate][data-validate-group="${i}"]`);let e=!1;for(const t of s){await this.validateInputAsync(t)||(e=!0)}return!e}getGroups(t){const i=new Set;return t.querySelectorAll("[data-validate-group]").forEach(t=>{i.add(t.getAttribute("data-validate-group"))}),Array.from(i)}getFormState(t){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[i]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const i=this.getFormState(t);i.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")),i.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),i.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),i.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 s=t.querySelector(".ds-form__status");s&&(i.errorCount>0?(s.textContent=`${i.errorCount} ${1===i.errorCount?"error":"errors"} found`,s.classList.add("ds-form__status--error")):(s.textContent="All fields are valid",s.classList.remove("ds-form__status--error")))}setFormLoading(t,i){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].loading=i,this.updateFormState(t)}setFormSubmitting(t,i){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].submitting=i,this.updateFormState(t)}setFormDisabled(t,i){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].disabled=i,this.updateFormState(t)}resetForm(t){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]={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 i=t.parentElement?.querySelector(".ds-input__error");i&&(i.textContent="")}),this.updateFormState(t)}parseRules(t){const i={};return t.split("|").forEach(t=>{const[s,e]=t.split(":");i[s]=e?e.split(","):[]}),i}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,[i]){return t.length>=parseInt(i)}validateMaxLength(t,[i]){return t.length<=parseInt(i)}validatePattern(t,[i]){return new RegExp(i).test(t)}validateMin(t,[i]){return parseFloat(t)>=parseFloat(i)}validateMax(t,[i]){return parseFloat(t)<=parseFloat(i)}validateEqualTo(t,[i]){const s=document.getElementById(i);return s&&t===s.value}validatePhone(t){return/^[\d\s\-+()]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,i){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let s=t.parentElement.querySelector(".ds-input__error");s||(s=document.createElement("span"),s.className="ds-input__error",s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),t.parentElement.appendChild(s)),s.textContent=i,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:i}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const i=t.parentElement.querySelector(".ds-input__error");i&&i.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 i=document.createElement("span");i.className="ds-input__status-icon ds-input__status-icon--success",i.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(i)}removeStatusIcon(t){const i=t.parentElement.querySelector(".ds-input__status-icon");i&&i.remove()}getErrorMessage(t,i,s){const e=s.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 ${i[0]} characters`,maxLength:`Maximum length is ${i[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${i[0]}`,max:`Maximum value is ${i[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 xs=new ks;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(t=>{t.addEventListener("submit",async i=>{const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;if(xs.submitting.has(s))return void i.preventDefault();i.preventDefault();let e;if(e=null!==t.querySelector("[data-validate-async]")?await xs.validateAsync(t):xs.validate(t),e){xs.submitting.add(s);const i=t.querySelector('button[type="submit"]');if(i){const t=i.textContent;i.setAttribute("data-original-text",t),i.textContent="Submitting...",i.disabled=!0}try{const i=t.getAttribute("data-on-submit");i&&window[i]?await window[i](t):t.submit()}finally{xs.submitting.delete(s),i&&(i.textContent=i.getAttribute("data-original-text")||"Submit",i.disabled=!1)}}else{const i=t.querySelector(".ds-input--error");i&&i.focus()}}),t.querySelectorAll("[data-validate]").forEach(t=>{const i=_t(),s=i.trigger||"blur",e=()=>{i.showErrors&&setTimeout(()=>{const i=document.activeElement;if(i&&i.closest(".ds-select"))return;xs.validateInput(t)&&t.value.trim()&&xs.showSuccess(t)},50)};"blur"!==s&&"both"!==s||t.addEventListener("blur",e);const n=((t,i)=>{let s;return(...e)=>{clearTimeout(s),s=setTimeout(()=>t(...e),i)}})(()=>{if(!i.showErrors)return;const s=xs.getValue(t);if(s.length>0||t.classList.contains("ds-input--error")){xs.validateInput(t)&&s&&xs.showSuccess(t)}else xs.removeStatusIcon(t)},ft().debounceDelay);"input"!==s&&"both"!==s||t.addEventListener("input",n),t.addEventListener("keyup",i=>{if("Enter"===i.key){xs.validateInput(t)&&t.value.trim()&&xs.showSuccess(t)}})})})}));class $s{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 i=parseInt(this.element.getAttribute("data-hours"))||0,s=parseInt(this.element.getAttribute("data-minutes"))||0,e=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*i+60*s+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(),i=this.endTime-t;if(i<=0)return this.stop(),this.displayTime(0,0,0),void this.dispatchComplete();const s=Math.floor(i%864e5/36e5),e=Math.floor(i%36e5/6e4),n=Math.floor(i%6e4/1e3);this.displayTime(s,e,n)}displayTime(t,i,s){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(i).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(s).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=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 Ms(t){if(t.Dt)return;const i=new $s(t);t.nt=i,t.Dt=!0}function Ss(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Cs(){document.querySelectorAll(".ds-countdown").forEach(t=>{Ms(t)})}Pt.register("countdown",Ms,Ss);class Es{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),i=()=>this.updateValue(this.step),s=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",i),this.inputEl.addEventListener("input",s),this.ot.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:i},{el:this.inputEl,event:"input",handler:s})}updateValue(t){let i=parseInt(this.inputEl.value)||0;i+=t,i<this.min&&(i=this.min),i>this.max&&(i=this.max),this.inputEl.value=i,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,i){this.min=t,this.max=i,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this.ot.forEach(({el:t,event:i,handler:s})=>{t.removeEventListener(i,s)}),this.ot=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Ts(t){if(!t.Dt)try{const i=new Es(t);t.nt=i,t.Dt=!0}catch(t){}}function Ds(t){if(!t.Dt||!t.nt)return;t.nt.destroy(),t.nt=null,t.Dt=!1}function Os(){document.querySelectorAll(".ds-number-input").forEach(t=>{Ts(t)})}Pt.register("number-input",Ts,Ds);class Fs{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this.pe=null,this.fe=new Map,this.$s()}$s(){this.me(),this.ge(),this.ds()}me(){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,i)=>!t||t.length>=parseInt(i),maxlength:(t,i)=>!t||t.length<=parseInt(i),min:(t,i)=>!t||parseFloat(t)>=parseFloat(i),max:(t,i)=>!t||parseFloat(t)<=parseFloat(i),pattern:(t,i)=>{if(!t)return!0;return new RegExp(i).test(t)},equalTo:(t,i)=>{const s=document.getElementById(i);return!s||t===s.value}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}ge(){this.form.querySelectorAll("input, select, textarea").forEach(t=>{t.hasAttribute("data-kupola-ignore")||this.fields.push(t)})}ds(){this.pe=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this.pe),this.fields.forEach(t=>{const i=()=>this.validateField(t),s=()=>this.clearError(t);this.fe.set(t,{blur:i,input:s}),t.addEventListener("blur",i),t.addEventListener("input",s)})}validate(){let t=!0;return this.fields.forEach(i=>{this.validateField(i)||(t=!1)}),t}validateField(t){const i=this._e(t);return i.length>0?(this.showError(t,i[0]),!1):(this.clearError(t),!0)}_e(t){const i=[],s=this.be(t);for(const[e,n]of Object.entries(this.validators)){const h=t.getAttribute(`data-${e}`);if(null!==h){if(!n(s,h)){let t=this.errorMessages[e];"function"==typeof t&&(t=t(h)),i.push(t)}}}return i}be(t){const i=t.type;if("checkbox"===i)return t.checked;if("radio"===i){const i=t.name,s=this.form.querySelector(`input[name="${i}"]:checked`);return s?s.value:null}return"select-multiple"===i?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,i){this.clearError(t);const s=document.createElement("span");s.className="ds-form-error",s.textContent=i,t.classList.add("ds-form-field--error");const e=t.parentElement;e.classList.contains("ds-form-field")?e.appendChild(s):t.parentNode.insertBefore(s,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const i=t.parentElement.querySelector(".ds-form-error");i&&i.remove()}addValidator(t,i,s){this.validators[t]=i,this.errorMessages[t]=s}getData(){const t={};return this.fields.forEach(i=>{const s=i.name;if(!s)return;const e=this.be(i);"checkbox"===i.type?(t[s]||(t[s]=[]),i.checked&&t[s].push(i.value)):"radio"===i.type?!t[s]&&i.checked&&(t[s]=i.value):t[s]=e}),t}setData(t){Object.keys(t).forEach(i=>{this.form.querySelectorAll(`[name="${i}"]`).forEach(s=>{const e=s.type;if("checkbox"===e){const e=Array.isArray(t[i])?t[i]:[t[i]];s.checked=e.includes(s.value)}else if("radio"===e)s.checked=s.value===t[i];else if("select-multiple"===e){const e=Array.isArray(t[i])?t[i]:[t[i]];Array.from(s.options).forEach(t=>{t.selected=e.includes(t.value)})}else s.value=t[i]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this.pe&&this.form&&this.form.removeEventListener("submit",this.pe),this.fe.forEach((t,i)=>{i.removeEventListener("blur",t.blur),i.removeEventListener("input",t.input)}),this.pe=null,this.fe.clear(),this.fe=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function Is(t){const i=document.querySelectorAll(t||".ds-form");return i.forEach(t=>{if(t.ve)return;const i=new Fs(t);t.ve=i}),i.length}function As(t){return t.ve}function Rs(t){const i=t.ve;return!!i&&i.validate()}Pt.register("form-validation",Is);class js{constructor(){this.we=new Set,this.ye=!1,this.ke=0,this.xe=10}schedule(t){this.we.add(t),this.ye||(this.ye=!0,queueMicrotask(()=>this.$e()))}$e(){if(this.ke>=this.xe)return this.we.clear(),void(this.ye=!1);const t=Array.from(this.we);this.we.clear(),this.ye=!1,this.ke++;const i=new Set;for(const s of t)if(!i.has(s)){i.add(s);try{s()}catch(t){}}this.ke--}}const Ps=new js;class Ns{constructor(t,i){this.data=t,this.createdAt=Date.now(),this.ttl=i}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class Bs{constructor(){this.Me=new Map}get(t){const i=this.Me.get(t);return i||null}set(t,i,s=6e4){this.Me.set(t,new Ns(i,s))}has(t){return this.Me.has(t)}delete(t){this.Me.delete(t)}clear(){this.Me.clear()}getStale(t){const i=this.Me.get(t);return i?i.data:null}}class zs extends Error{constructor(t,i,s){super(t),this.name="DependsError",this.code=i,this.cause=s,this.timestamp=Date.now()}}let Ls="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;function Hs(t){if(!t||"function"!=typeof t.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");Ls=t.fetch.bind(t)}function Us(){return Ls}function Vs(){Ls="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null}class Js{constructor(t,i){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=i,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 i=this.subscribers.indexOf(t);i>-1&&this.subscribers.splice(i,1)}}notify(){Ps.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(t){}})})}async fetch(t){throw new zs("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const i=this.cache.get(this.cacheKey);return i&&i.isFresh?i.data:i&&i.isStale?(this.Se(t),i.data):this.Ce(t)}async Ce(t,i=0){try{const i=await this.fetch(t);return this.cache.set(this.cacheKey,i,this.staleTime),this.notify(),i}catch(s){if(i<this.retryCount){const s=this.retryDelay*Math.pow(2,i),e=s+Math.random()*s*.5;return await new Promise(t=>setTimeout(t,e)),this.Ce(t,i+1)}const e=s instanceof zs?s:new zs(s.message||"Fetch failed","FETCH_ERROR",s);if(this.onError)try{this.onError(e)}catch(t){}throw e}}async Se(t){try{await this.Ce(t)}catch(t){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class qs extends Js{constructor(t,i){super(t,i),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let i=this.config.source;const s=ht("http");!s?.baseURL||i.startsWith("http://")||i.startsWith("https://")||(i=s.baseURL+i.replace(/^\//,""));for(const s in t)i=i.replace(`:${s}`,encodeURIComponent(t[s]));const e=[];for(const[t,i]of Object.entries(this.queryParams||{}))e.push(`${encodeURIComponent(t)}=${encodeURIComponent(i)}`);for(const i in t)this.config.source.includes(`:${i}`)||e.push(`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`);e.length>0&&(i+=(i.includes("?")?"&":"?")+e.join("&"));const n=s?.headers||{},h={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...n,...this.headers}};s?.withCredentials&&(h.credentials="include"),["POST","PUT","PATCH"].includes(h.method)&&(h.body=JSON.stringify(t));const o=Ls;if(!o)throw new zs("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const r=await o(i,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 zs(`HTTP ${c}`,"HTTP_ERROR");return"function"==typeof r.json?await r.json():void 0!==r.data?r.data:r}}class Ws extends Js{constructor(t,i){super(t,i),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=!1!==t.sync,this.sync&&"undefined"!=typeof window&&(this.Ee=t=>{t.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this.Ee))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(null===t)return this.defaultValue;try{return JSON.parse(t)}catch(i){return t}}catch(t){return this.defaultValue}}setValue(t){const i="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(this.storageKey,i),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this.Ee&&window.removeEventListener("storage",this.Ee)}}class Ks extends Js{constructor(t,i){super(t,i),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 Ys extends Js{async fetch(t){return await this.config.source(t)}}class Zs extends Js{async fetch(){return this.config.source}}class Gs extends Js{constructor(t,i){super(t,i),this.ws=null,this.reconnect=!1!==t.reconnect,this.reconnectDelay=t.reconnectDelay||3e3,this.Te=0,this.De=t.maxReconnectDelay||3e4,this.messageHandler=null,this.Oe=!1,this.Fe=!1}async fetch(){return new Promise((t,i)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this.Oe=!0,this.Te=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=t=>{let i;try{i=JSON.parse(t.data)}catch(s){i=t.data}this.cache.set(this.cacheKey,i,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=t=>{this.Oe||i(new zs("WebSocket connection failed","WS_ERROR",t))},this.ws.onclose=()=>{if(this.Oe=!1,this.reconnect&&!this.Fe){const t=this.reconnectDelay*Math.pow(2,this.Te),i=Math.random()*t*.3,s=Math.min(t+i,this.De);this.Te++,setTimeout(()=>{this.Fe||this.fetch().catch(()=>{})},s)}}}catch(t){i(new zs("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.Fe=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Xs(t,i){const s=t.source;return"function"==typeof s?new Ys(t,i):"string"==typeof s&&(s.startsWith("ws://")||s.startsWith("wss://"))?new Gs(t,i):"string"==typeof s&&(s.startsWith("/")||s.startsWith("http"))?new qs(t,i):"string"==typeof s&&s.startsWith("localStorage:")?new Ws(t,i):"string"==typeof s&&s.startsWith("route:")?new Ks(t,i):new Zs(t,i)}function Qs(t,i){const s={},e=new Bs,n=[];for(const h in i){let o=i[h];"string"==typeof o&&(o={source:o});const r=Xs({...o,cacheKey:o.cacheKey||`${h}-${JSON.stringify(ie(t))}`},e),a=q(null),c=q(!0),l=q(null),d=q(null);let u=0;async function p(){const i=++u;c.value=!0,l.value=null;try{const s=await r.getValue(ie(t));if(i!==u)return;a.value=s,d.value=Date.now()}catch(t){if(i!==u)return;l.value=t.message||"Unknown error"}finally{i===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(i=>{const s=t[i];if(s&&"object"==typeof s&&"value"in s&&s.B){const t=()=>{r.invalidate(),p()};s.B.add(t),n.push(()=>s.B.delete(t))}}),s[h]={data:a,loading:c,error:l,lastUpdated:d,refresh:()=>(r.invalidate(),p()),setValue(t){r instanceof Ws&&(r.setValue(t),a.value=t)},send(t){r instanceof Gs&&r.send(t)},Ie:r}}return s.Ae=()=>{if(n.forEach(t=>t()),window.__kupolaDepInstances){const t=window.__kupolaDepInstances.indexOf(s);-1!==t&&window.__kupolaDepInstances.splice(t,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(s),s}function te(t){const i=new Bs,s=Xs(t,i),e=q(null),n=q(!0),h=q(null);let o=0;async function r(){const i=++o;n.value=!0,h.value=null;try{const n=await s.getValue(t.params||{});if(i!==o)return;e.value=n}catch(t){if(i!==o)return;h.value=t.message||"Unknown error"}finally{i===o&&(n.value=!1)}}return r(),s.subscribe(()=>{const t=i.getStale(s.cacheKey);null!=t&&(e.value=t)}),{data:e,loading:n,error:h,refresh:()=>(s.invalidate(),r())}}function ie(t){const i={};for(const s in t){const e=t[s];i[s]=e&&"object"==typeof e&&"value"in e?e.value:e}return i}function se(){}class ee{constructor(t,i={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=i,this.columns=(i.columns||[]).map((t,i)=>({...t,Re:i})),this.rowKey=i.rowKey||"id",this.je=[],this.Pe=!1,this.striped=!1!==i.striped,this.bordered=i.bordered||!1,this.hoverable=!1!==i.hoverable,this.compact=i.compact||!1,this.emptyText=i.emptyText||"暂无数据",this.loadingText=i.loadingText||"加载中...",this.multiSort=i.multiSort||!1,this.Ne=[],this.Be="",this.ze=!1!==i.pagination,this.Le=i.pageSizes||[10,20,50,100],this.He=i.pageSize||10,this.Ue=1,this.Ve=0,this.selection=i.selection||null,this.Je=new Set,this.selectionColumnTitle=i.selectionColumnTitle||"",this.expandable=i.expandable||null,this.qe=new Set,this.expandColumnTitle=i.expandColumnTitle||"",this.editable=i.editable||!1,this.We=null,this.Ke={},this.resizable=i.resizable||!1,this.draggable=i.draggable||!1,this.Ye=null,this.tree=i.tree||null,this.Ze=new Set,i.tree?.defaultExpandAll&&(this.Ge=!0),this.virtualScroll=i.virtualScroll||null,this.Xe=null,this.Yt=null,this.Qe=[],this.tn=null,this.sn=[],this.mergeCells=i.mergeCells||null,this.onSort=i.onSort||null,this.onPageChange=i.onPageChange||null,this.onRowClick=i.onRowClick||null,this.onFilter=i.onFilter||null,this.onSelect=i.onSelect||null,this.onExpand=i.onExpand||null,this.onEditSave=i.onEditSave||null,this.onEditCancel=i.onEditCancel||null,this.onRowDragEnd=i.onRowDragEnd||null,this.onColumnResize=i.onColumnResize||null,this.sortKey=q(null),this.sortOrder=q(null),this.currentPage=q(1),this.filterText=q(""),this.selectedKeys=q([]),this.$s()}$s(){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.je=Array.isArray(t.value)?t.value:[],t.subscribe&&this.sn.push(t.subscribe(t=>{this.je=Array.isArray(t)?t:[],this.Ve=this.je.length,this.render()}))):Array.isArray(t)?this.je=t:this.je=[],this.tree&&this.Ge&&this.en(this.je),this.Ve=this.nn(this.je).length,this.render()}setLoading(t){t&&"object"==typeof t&&"value"in t?(this.Pe=t.value,t.subscribe&&this.sn.push(t.subscribe(t=>{this.Pe=t,this.render()}))):this.Pe=!!t,this.render()}en(t,i=0,s=null){const e=this.tree?.childrenKey||"children",n=[];for(const h of t){const t=h[this.rowKey];n.push({...h,hn:i,rn:s,an:!(!h[e]||!h[e].length)}),h[e]&&h[e].length&&n.push(...this.en(h[e],i+1,t))}return n}nn(t){return this.tree?this.cn(t,0):t}cn(t,i){const s=this.tree?.childrenKey||"children",e=[];for(const n of t){const t=n[this.rowKey];e.push({...n,hn:i,an:!(!n[s]||!n[s].length)}),n[s]&&n[s].length&&this.Ze.has(t)&&e.push(...this.cn(n[s],i+1))}return e}getProcessedData(){let t=(this.tree,[...this.je]);if(this.Be){const i=this.Be.toLowerCase();t=this.tree?this.ln(t,i):t.filter(t=>this.columns.some(s=>{const e=t[s.key];return null!=e&&String(e).toLowerCase().includes(i)}))}this.Ne.length>0&&(t=this.tree?this.dn(t):this.un(t));const i=this.tree?this.cn(t):t;this.Ve=i.length;let s=i;if(this.ze&&this.He>0){const t=(this.Ue-1)*this.He;s=i.slice(t,t+this.He)}return s}ln(t,i){const s=this.tree?.childrenKey||"children";return t.reduce((t,e)=>{const n=e[s]?this.ln(e[s],i):[];return(this.columns.some(t=>{const s=e[t.key];return null!=s&&String(s).toLowerCase().includes(i)})||n.length>0)&&(t.push({...e,[s]:n}),n.length>0&&this.Ze.add(e[this.rowKey])),t},[])}un(t){return[...t].sort((t,i)=>{for(const s of this.Ne){const e=this.columns.find(t=>t.key===s.key);let n=t[s.key],h=i[s.key],o=0;if(o=e?.sorter?e.sorter(n,h,s.order):null==n?1:null==h?-1:"number"==typeof n&&"number"==typeof h?"asc"===s.order?n-h:h-n:"asc"===s.order?String(n).localeCompare(String(h)):String(h).localeCompare(String(n)),0!==o)return o}return 0})}dn(t){const i=this.un(t),s=this.tree?.childrenKey||"children";return i.map(t=>t[s]?.length?{...t,[s]:this.dn(t[s])}:t)}render(){const t=this.getProcessedData(),i=this.element;i.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&i.appendChild(this.pn());const s=document.createElement("div");s.className="kupola-table-container";const e=document.createElement("table");e.className=this.fn(),e.appendChild(this.mn()),this.virtualScroll?e.appendChild(this.gn(t)):e.appendChild(this._n(t)),s.appendChild(e),i.appendChild(s),this.ze&&this.Ve>0&&i.appendChild(this.bn()),this.resizable&&this.vn(),this.draggable&&this.wn(),this.yn()}mn(){const t=document.createElement("thead"),i=document.createElement("tr");if(this.selection&&this.kn(i),this.expandable){const t=document.createElement("th");t.className="kupola-table-col-expand",i.appendChild(t)}return this.columns.forEach(t=>{const s=this.xn(t);i.appendChild(s)}),t.appendChild(i),t}kn(t){const i=document.createElement("th");if(i.className="kupola-table-col-selection","checkbox"===this.selection){const t=document.createElement("input");t.type="checkbox";const s=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=s.length>0&&s.every(t=>this.Je.has(t)),t.addEventListener("change",()=>t.checked?this.selectAll():this.deselectAll()),i.appendChild(t)}t.appendChild(i)}xn(t){const i=document.createElement("th");if(i.textContent=t.title||t.key,t.width&&(i.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(i.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(i.style.textAlign=t.align),t.fixed&&i.setAttribute("data-fixed",t.fixed),t.sortable&&this.$n(i,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const s=document.createElement("span");s.className="kupola-table-resize-handle",s.setAttribute("data-col-key",t.key),i.appendChild(s)}return i}$n(t,i){t.classList.add("kupola-table-sortable");const s=this.Ne.find(t=>t.key===i.key);s&&t.classList.add(`kupola-table-sort-${s.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this.Mn(i.key)});const e=document.createElement("span");e.className="kupola-table-sort-icon",e.textContent=s?this.multiSort?` ${this.Ne.indexOf(s)+1}${"asc"===s.order?"▲":"▼"}`:"asc"===s.order?" ▲":" ▼":" ⇅",t.appendChild(e)}_n(t){const i=document.createElement("tbody");if(this.Pe)i.appendChild(this.Sn(this.loadingText,"kupola-table-loading"));else if(0===t.length)i.appendChild(this.Sn(this.emptyText,"kupola-table-empty"));else{const s=this.mergeCells?this.mergeCells(t):[],e=new Map;s.forEach(t=>e.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,s)=>{const h=t[this.rowKey]??s,o=this.Je.has(h),r=this.qe.has(h),a=this.Cn(t,s,h,o,n,e);if(i.appendChild(a),this.expandable&&r){const s=document.createElement("tr");s.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),s.appendChild(e),i.appendChild(s)}})}return i}Cn(t,i,s,e,n,h){const o=document.createElement("tr");return o.setAttribute("data-row-key",s),e&&o.classList.add("kupola-table-row-selected"),this.draggable&&(o.draggable=!0,o.classList.add("kupola-table-draggable")),this.selection&&this.En(o,s,e),this.expandable&&this.Tn(o,s),this.columns.forEach((e,r)=>{if(n.has(`${i}-${r}`))return;const a=this.Dn(t,i,s,e,r,n,h);o.appendChild(a)}),this.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",s=>{s.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,i,s)})),o}En(t,i,s){const e=document.createElement("td");e.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=s,n.addEventListener("change",()=>{"radio"===this.selection?(this.Je.clear(),this.Je.add(i)):s?this.Je.delete(i):this.Je.add(i),this.selectedKeys.value=[...this.Je],this.onSelect&&this.onSelect([...this.Je],this.getSelectedRows()),this.render()}),e.appendChild(n),t.appendChild(e)}Tn(t,i){const s=document.createElement("td");s.className="kupola-table-col-expand";const e=document.createElement("button");e.className="kupola-table-expand-btn",e.textContent=this.qe.has(i)?"▼":"▶",e.type="button",e.addEventListener("click",()=>this.On(i)),s.appendChild(e),t.appendChild(s)}Dn(t,i,s,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(`${i}-${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 s=0;s<(a.colSpan||1);s++)0===t&&0===s||h.add(`${i+t}-${n+s}`)}this.tree&&0===n&&t.hn>0&&this.Fn(r,t);const c=this.We&&this.We.rowKey===s&&this.We.colKey===e.key;if(c)r.appendChild(this.In(e,t));else if(e.render){const s=e.render(t[e.key],t,i);"string"==typeof s?r.innerHTML=s:s instanceof HTMLElement&&r.appendChild(s)}else r.textContent=t[e.key]??"";return this.editable&&!c&&!1!==e.editable&&(r.classList.add("kupola-table-editable-cell"),r.addEventListener("dblclick",()=>this.An(s,e.key,t[e.key]))),r}Fn(t,i){const s=document.createElement("span");if(s.className="kupola-table-tree-indent",s.style.paddingLeft=20*i.hn+"px",t.appendChild(s),i.an){const s=document.createElement("button");s.className="kupola-table-tree-toggle",s.textContent=this.Ze.has(i[this.rowKey])?"▼":"▶",s.type="button",s.addEventListener("click",t=>{t.stopPropagation(),this.Rn(i[this.rowKey])}),t.appendChild(s)}else{const i=document.createElement("span");i.className="kupola-table-tree-toggle-placeholder",t.appendChild(i)}}Sn(t,i){const s=document.createElement("tr"),e=document.createElement("td");return e.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),e.className=i,e.textContent=t,s.appendChild(e),s}gn(t){const i=document.createElement("tbody"),{rowHeight:s=40,overscan:e=5}=this.virtualScroll,n=t.length*s;if(this.Pe)return this._n(t);if(0===t.length)return this._n(t);const h=document.createElement("tr");h.className="kupola-table-virtual-spacer-top",h.style.height="0px",i.appendChild(h),this.jn={data:t,rowHeight:s,overscan:e,totalHeight:n,tbody:i,topSpacer:h},this.Pn();const o=document.createElement("tr");o.className="kupola-table-virtual-spacer-bottom",o.style.height="0px",i.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.Pn(),r.addEventListener("scroll",this.Yt)),i}Pn(){if(!this.jn)return;const{data:t,rowHeight:i,overscan:s,tbody:e,topSpacer:n}=this.jn,h=this.element.querySelector(".kupola-table-container");if(!h)return;const o=h.scrollTop,r=h.clientHeight,a=Math.max(0,Math.floor(o/i)-s),c=Math.min(t.length,Math.ceil((o+r)/i)+s);e.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const l=document.createDocumentFragment();for(let s=a;s<c;s++){const e=t[s],n=e[this.rowKey]??s,h=this.Cn(e,s,n,this.Je.has(n),new Set,new Map);h.classList.add("kupola-table-virtual-row"),h.style.height=i+"px",l.appendChild(h)}n.style.height=a*i+"px";const d=e.querySelector(".kupola-table-virtual-spacer-bottom");d&&(d.style.height=(t.length-c)*i+"px"),n.after(l)}In(t,i){const s=document.createElement("div");s.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.Ke[t.key]??i[t.key]??"",t.editOptions){const i=document.createElement("select");i.className="ds-input kupola-table-edit-input",t.editOptions.forEach(t=>{const s=document.createElement("option");s.value="object"==typeof t?t.value:t,s.textContent="object"==typeof t?t.label:t,String(s.value)===String(e.value)&&(s.selected=!0),i.appendChild(s)}),i.addEventListener("change",()=>{this.Ke[t.key]=i.value}),s.appendChild(i)}else e.addEventListener("input",()=>{this.Ke[t.key]=e.value}),s.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.Nn(i,t));const o=document.createElement("button");return o.className="kupola-table-edit-cancel",o.textContent="✗",o.type="button",o.addEventListener("click",()=>this.Bn()),n.appendChild(h),n.appendChild(o),s.appendChild(n),e.addEventListener("keydown",s=>{"Enter"===s.key&&this.Nn(i,t),"Escape"===s.key&&this.Bn()}),setTimeout(()=>e.focus?.(),0),s}An(t,i,s){this.We={rowKey:t,colKey:i},this.Ke={[i]:s},this.render()}Nn(t,i){const s=this.Ke[i.key];this.onEditSave?this.onEditSave(t,i.key,s,this.je):t[i.key]=s,this.We=null,this.Ke={},this.render()}Bn(){this.onEditCancel&&this.onEditCancel(this.We),this.We=null,this.Ke={},this.render()}Mn(t){if(this.multiSort){const i=this.Ne.findIndex(i=>i.key===t);if(i>=0){const t=this.Ne[i];"asc"===t.order?t.order="desc":this.Ne.splice(i,1)}else this.Ne.push({key:t,order:"asc"})}else{const i=this.Ne.find(i=>i.key===t);i?"asc"===i.order?i.order="desc":this.Ne=[]:this.Ne=[{key:t,order:"asc"}]}this.sortKey.value=this.Ne.map(t=>t.key).join(","),this.sortOrder.value=this.Ne.map(t=>t.order).join(","),this.Ue=1,this.onSort&&this.onSort(this.Ne),this.render()}On(t){this.qe.has(t)?this.qe.delete(t):this.qe.add(t),this.onExpand&&this.onExpand(t,this.qe.has(t)),this.render()}Rn(t){this.Ze.has(t)?this.Ze.delete(t):this.Ze.add(t),this.render()}selectRow(t){this.Je.add(t),this.zn(),this.render()}deselectRow(t){this.Je.delete(t),this.zn(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this.Je.add(t[this.rowKey])),this.zn(),this.render()}deselectAll(){this.Je.clear(),this.zn(),this.render()}invertSelection(){this.getProcessedData().forEach(t=>{const i=t[this.rowKey];this.Je.has(i)?this.Je.delete(i):this.Je.add(i)}),this.zn(),this.render()}getSelectedKeys(){return[...this.Je]}getSelectedRows(){return(this.tree?this.en(this.je):this.je).filter(t=>this.Je.has(t[this.rowKey]))}zn(){this.selectedKeys.value=[...this.Je]}vn(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{t.addEventListener("mousedown",i=>{i.preventDefault();const s=t.getAttribute("data-col-key"),e=t.parentElement,n=i.clientX,h=e.offsetWidth,o=t=>{const i=Math.max(50,h+(t.clientX-n));e.style.width=i+"px";const o=this.columns.find(t=>t.key===s);o&&(o.width=i),this.onColumnResize&&this.onColumnResize(s,i)},r=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.Qe.push(r)})})}wn(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(t=>{t.addEventListener("dragstart",i=>{this.Ye={fromKey:t.getAttribute("data-row-key")},t.classList.add("kupola-table-dragging"),i.dataTransfer.effectAllowed="move"}),t.addEventListener("dragover",i=>{i.preventDefault(),i.dataTransfer.dropEffect="move",t.classList.add("kupola-table-drag-over")}),t.addEventListener("dragleave",()=>t.classList.remove("kupola-table-drag-over")),t.addEventListener("drop",i=>this.Ln(i,t)),t.addEventListener("dragend",()=>{t.classList.remove("kupola-table-dragging"),this.Ye=null})})}Ln(t,i){if(t.preventDefault(),i.classList.remove("kupola-table-drag-over"),!this.Ye)return;const s=i.getAttribute("data-row-key");if(this.Ye.fromKey===s)return;const e=this.je.findIndex(t=>String(t[this.rowKey])===this.Ye.fromKey),n=this.je.findIndex(t=>String(t[this.rowKey])===s);if(e>=0&&n>=0){const[t]=this.je.splice(e,1);this.je.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,e,n,this.je),this.render()}}yn(){const t=this.columns.filter(t=>"left"===t.fixed);this.selection,this.expandable,t.forEach(t=>{const i=this.element.querySelectorAll('th[data-fixed="left"]'),s=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].Hn||120);i.forEach(i=>{i.textContent.startsWith(t.title||t.key)&&(i.style.position="sticky",i.style.left=n+"px",i.style.zIndex="2",t.Hn=i.offsetWidth)}),s.forEach(t=>{t.style.position="sticky",t.style.left=n+"px",t.style.zIndex="1",t.style.background="inherit"})});let i=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=i+"px",t.style.zIndex="1"}),i+=t.Hn||t.width||120})}pn(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const i=document.createElement("input");i.type="text",i.className="ds-input kupola-table-filter-input",i.placeholder=this.options.filterPlaceholder||"搜索...",i.value=this.Be,i.addEventListener("input",()=>{clearTimeout(this.tn),this.tn=setTimeout(()=>{this.Be=i.value,this.Ue=1,this.filterText.value=this.Be,this.onFilter&&this.onFilter(this.Be),this.render()},300)}),t.appendChild(i)}const i=document.createElement("div");if(i.className="kupola-table-toolbar-right",this.selection&&this.Je.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`已选 ${this.Je.size} 项`,i.appendChild(t);const s=document.createElement("button");s.className="ds-btn ds-btn--sm",s.textContent="反选",s.type="button",s.addEventListener("click",()=>this.invertSelection()),i.appendChild(s)}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()),i.appendChild(t)}const s=document.createElement("span");return s.className="kupola-table-info",s.textContent=`共 ${this.Ve} 条`,i.appendChild(s),t.appendChild(i),t}bn(){const t=Math.ceil(this.Ve/this.He);if(t<=1)return document.createElement("div");const i=document.createElement("div");if(i.className="kupola-table-pagination",this.options.showPageSize){const t=document.createElement("select");t.className="kupola-table-page-size",this.Le.forEach(i=>{const s=document.createElement("option");s.value=i,s.textContent=`${i} 条/页`,i===this.He&&(s.selected=!0),t.appendChild(s)}),t.addEventListener("change",()=>{this.He=parseInt(t.value),this.Ue=1,this.currentPage.value=1,this.render()}),i.appendChild(t)}const s=document.createElement("div");s.className="kupola-table-pages";const e=this.Un("‹",()=>this.Vn(this.Ue-1));e.disabled=this.Ue<=1,s.appendChild(e),this.Jn(this.Ue,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",s.appendChild(t)}else{const i=this.Un(t,()=>this.Vn(t));t===this.Ue&&i.classList.add("active"),s.appendChild(i)}});const n=this.Un("›",()=>this.Vn(this.Ue+1));n.disabled=this.Ue>=t,s.appendChild(n),i.appendChild(s);const h=document.createElement("span");return h.className="kupola-table-page-info",h.textContent=`${this.Ue} / ${t}`,i.appendChild(h),i}Un(t,i){const s=document.createElement("button");return s.className="kupola-table-page-btn",s.textContent=t,s.type="button",s.addEventListener("click",i),s}Vn(t){const i=Math.ceil(this.Ve/this.He);t<1||t>i||(this.Ue=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this.He),this.render())}Jn(t,i){if(i<=7)return Array.from({length:i},(t,i)=>i+1);const s=[];if(t<=3){for(let t=1;t<=5;t++)s.push(t);s.push("...",i)}else if(t>=i-2){s.push(1,"...");for(let t=i-4;t<=i;t++)s.push(t)}else{s.push(1,"...");for(let i=t-1;i<=t+1;i++)s.push(i);s.push("...",i)}return s}exportCSV(t="export.csv"){const i=this.getProcessedData(),s=this.columns.map(t=>t.title||t.key),e=i.map(t=>this.columns.map(i=>{let s=t[i.key];return null==s&&(s=""),s=String(s).replace(/"/g,'""'),`"${s}"`}).join(",")),n="\ufeff"+[s.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)}fn(){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.Ue,pageSize:this.He,total:this.Ve}}setColumns(t){this.columns=t.map((t,i)=>({...t,Re:i})),this.render()}destroy(){if(this.Yt){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this.Yt),this.Yt=null}this.tn&&(clearTimeout(this.tn),this.tn=null),this.Qe.forEach(t=>t()),this.Qe=[],this.sn.forEach(t=>t.unsubscribe()),this.sn=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this.je=[],this.jn=null,this.Ye=null,this.We=null,this.Ke={}}}function ne(t,i){return new ee(t,i)}function he(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const i=t.getAttribute("data-kupola-table");let s={};if(i)try{s=JSON.parse(i)}catch(t){}ne(t,s)})}Pt.register("table",ne);class oe{constructor(t,i={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=i,this.qn=i.current||1,this.Ve=i.total||0,this.He=i.pageSize||10,this.Wn=i.maxPages||7,this.Kn=!1!==i.showTotal,this.Yn=i.showSizeChanger||!1,this.Le=i.pageSizes||[10,20,50,100],this.Zn=i.simple||!1,this.current=q(this.qn),this.total=q(this.Ve),this.onChange=i.onChange||null,this.onPageSizeChange=i.onPageSizeChange||null,this.$s()}$s(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this.Ve/this.He))}setCurrent(t){(t=Math.max(1,Math.min(t,this.totalPages)))!==this.qn&&(this.qn=t,this.current.value=t,this.onChange&&this.onChange(t,this.He),this.render())}setTotal(t){t&&"object"==typeof t&&"value"in t?(this.Ve=t.value||0,t.B?.add(t=>{this.Ve=t||0,this.qn>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this.Ve=t,this.total.value=this.Ve,this.render()}setPageSize(t){this.He=t,this.qn=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this.qn),this.render()}render(){const t=this.element;t.innerHTML="",this.Ve<=0||(this.Zn?this.Gn(t):this.Xn(t))}Gn(t){const i=this.totalPages,s=this.Qn("‹",()=>this.setCurrent(this.qn-1));s.disabled=this.qn<=1,t.appendChild(s);const e=document.createElement("span");e.className="kupola-pagination-simple-info",e.textContent=`${this.qn} / ${i}`,t.appendChild(e);const n=this.Qn("›",()=>this.setCurrent(this.qn+1));n.disabled=this.qn>=i,t.appendChild(n)}Xn(t){const i=this.totalPages;if(this.Kn){const i=document.createElement("span");i.className="kupola-pagination-total",i.textContent=`共 ${this.Ve} 条`,t.appendChild(i)}if(this.Yn){const i=document.createElement("select");i.className="kupola-pagination-size",this.Le.forEach(t=>{const s=document.createElement("option");s.value=t,s.textContent=`${t} 条/页`,t===this.He&&(s.selected=!0),i.appendChild(s)}),i.addEventListener("change",()=>this.setPageSize(parseInt(i.value))),t.appendChild(i)}const s=document.createElement("div");s.className="kupola-pagination-pages";const e=this.Qn("‹",()=>this.setCurrent(this.qn-1));e.disabled=this.qn<=1,s.appendChild(e),this.Jn().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",s.appendChild(t)}else{const i=this.Qn(t,()=>this.setCurrent(t));t===this.qn&&i.classList.add("active"),s.appendChild(i)}});const n=this.Qn("›",()=>this.setCurrent(this.qn+1));if(n.disabled=this.qn>=i,s.appendChild(n),t.appendChild(s),i>10){const s=document.createElement("span");s.className="kupola-pagination-jumper",s.innerHTML='跳至 <input type="number" min="1" max="'+i+'" value="'+this.qn+'"> 页';const e=s.querySelector("input");e.addEventListener("change",()=>{const t=parseInt(e.value);t>=1&&t<=i&&this.setCurrent(t)}),e.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(e.value);t>=1&&t<=i&&this.setCurrent(t)}}),t.appendChild(s)}}Qn(t,i){const s=document.createElement("button");return s.className="kupola-pagination-btn",s.textContent=t,s.type="button",s.addEventListener("click",i),s}Jn(){const t=this.totalPages,i=this.Wn;if(t<=i)return Array.from({length:t},(t,i)=>i+1);const s=[],e=Math.floor(i/2);if(this.qn<=e+1){for(let t=1;t<=i-2;t++)s.push(t);s.push("...",t)}else if(this.qn>=t-e){s.push(1,"...");for(let e=t-i+3;e<=t;e++)s.push(e)}else{s.push(1,"...");for(let t=this.qn-e+2;t<=this.qn+e-2;t++)s.push(t);s.push("...",t)}return s}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let re=!1;function ae(t,i){return function(){if(re||"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),re=!0}(),new oe(t,i)}export{yt as BRAND_OPTIONS,Ns as CacheEntry,Bs as CacheManager,ss as Calendar,Ki as Collapse,Xi as ColorPicker,jt as ComponentInitializerRegistry,$s as Countdown,mi as Datepicker,zs as DependsError,Js as DependsSource,Ni as Dialog,Ci as Drawer,oi as Dropdown,os as DynamicTags,qs as FetchedSource,Vi as FileUpload,Ys as FunctionSource,Zt as GlobalEvents,ls as ImagePreview,Bt as KupolaComponent,Lt as KupolaComponentRegistry,H as KupolaDataBind,J as KupolaEventBus,Fs as KupolaForm,t as KupolaLifecycle,oe as KupolaPagination,U as KupolaStore,V as KupolaStoreManager,ee as KupolaTable,j as KupolaUtils,ks as KupolaValidator,Li as Message,Oi as Modal,Bi as Notification,Es as NumberInput,Ks as RouteSource,js as Scheduler,di as Select,xi as Slider,Zs as StaticSource,Ws as StorageSource,fs as Tag,vi as Timepicker,bs as Tooltip,Gs as WebSocketSource,Ai as alertModal,zt as applyMixin,r as arrayUtils,qt as bootstrapComponents,li as cleanupAllDropdowns,ns as cleanupCalendar,Zi as cleanupCollapse,is as cleanupColorPicker,Ss as cleanupCountdown,bi as cleanupDatepicker,Ti as cleanupDrawer,ci as cleanupDropdown,as as cleanupDynamicTags,qi as cleanupFileUpload,ji as cleanupModal,Ds as cleanupNumberInput,fi as cleanupSelect,Mi as cleanupSlider,gs as cleanupTag,ki as cleanupTimepicker,ys as cleanupTooltip,se as clearCache,Hs as configureHttpClient,Ii as confirmModal,Dt as createBrandPicker,s as createLifecycle,Fi as createModal,Xs as createSource,Z as createStore,Tt as createThemeToggle,D as cryptoUtils,w as dateUtils,y as debounce,Yt as defineComponent,Wt as defineMixin,ii as emit,si as emitGlobal,Ft as escapeHtml,Rt as generateSecureId,rt as getBasePath,$t as getBrand,ht as getConfig,ct as getDefaultBrand,at as getDefaultTheme,As as getFormInstance,Us as getHttpClient,lt as getHttpConfig,ot as getIconsPath,hi as getListenerCount,mt as getMessageConfig,gt as getNotificationConfig,ft as getPerformanceConfig,pt as getSecurityConfig,G as getStore,kt as getTheme,dt as getUiConfig,_t as getValidationConfig,Gt as globalEvents,he as initAllTables,es as initCalendar,hs as initCalendars,Yi as initCollapse,Gi as initCollapses,Qi as initColorPicker,ts as initColorPickers,Ms as initCountdown,Cs as initCountdowns,gi as initDatepicker,_i as initDatepickers,Ei as initDrawer,Di as initDrawers,ri as initDropdown,ai as initDropdowns,rs as initDynamicTags,cs as initDynamicTagsAll,Ji as initFileUpload,Wi as initFileUploads,Is as initFormValidation,us as initImagePreview,Hi as initMessages,Ri as initModal,Pi as initModals,zi as initNotifications,Ts as initNumberInput,Os as initNumberInputs,ae as initPagination,ui as initSelect,pi as initSelects,$i as initSlider,Si as initSliders,ne as initTable,ms as initTag,_s as initTags,Et as initTheme,wi as initTimepicker,yi as initTimepickers,vs as initTooltip,ws as initTooltips,Ut as kupolaBootstrap,W as kupolaData,K as kupolaEvents,Pt as kupolaInitializer,i as kupolaLifecycle,Ht as kupolaRegistry,Y as kupolaStoreManager,At as maskData,p as numberUtils,c as objectUtils,ti as off,ni as offAll,ei as offByScope,et as offConfigChange,Xt as on,st as onConfigChange,Qt as once,R as preloadUtils,q as ref,Vt as registerComponent,Jt as registerLazyComponent,Vs as resetHttpClient,Ot as sanitizeHtml,Mt as setBrand,nt as setConfig,xt as setTheme,ps as showImagePreview,h as stringUtils,It as stripHtml,k as throttle,Qs as useDeps,Kt as useMixin,te as useQuery,Rs as validateForm,xs as validator,T as validatorUtils};