@kupola/kupola 1.2.0 → 1.3.1

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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -286
  3. package/adapters/axios.d.ts +34 -0
  4. package/adapters/axios.js +122 -0
  5. package/adapters/navios-http.d.ts +110 -0
  6. package/adapters/navios-http.js +151 -0
  7. package/dist/css/accessibility.css +119 -0
  8. package/dist/css/animations.css +224 -0
  9. package/dist/css/brand-themes.css +300 -0
  10. package/dist/css/colors_and_type.css +441 -0
  11. package/dist/css/components-ext.css +4165 -0
  12. package/dist/css/components.css +1483 -0
  13. package/dist/css/responsive.css +697 -0
  14. package/dist/css/scaffold.css +145 -0
  15. package/dist/css/states.css +316 -0
  16. package/dist/css/theme-dark.css +296 -0
  17. package/dist/css/theme-light.css +296 -0
  18. package/dist/css/utilities.css +171 -0
  19. package/dist/kupola.cjs.js +219 -161
  20. package/dist/kupola.cjs.js.map +1 -1
  21. package/dist/kupola.esm.js +6643 -5709
  22. package/dist/kupola.esm.js.map +1 -1
  23. package/dist/kupola.umd.js +219 -161
  24. package/dist/kupola.umd.js.map +1 -1
  25. package/dist/plugins/vite-plugin-kupola.js +120 -0
  26. package/dist/types/kupola.d.ts +421 -323
  27. package/js/calendar.js +334 -25
  28. package/js/carousel.js +182 -48
  29. package/js/collapse.js +148 -34
  30. package/js/color-picker.js +416 -108
  31. package/js/component.js +8 -19
  32. package/js/countdown.js +9 -8
  33. package/js/data-bind.js +73 -16
  34. package/js/datepicker.js +488 -110
  35. package/js/depends.js +710 -0
  36. package/js/dialog.js +4 -2
  37. package/js/drawer.js +172 -8
  38. package/js/dropdown.js +272 -17
  39. package/js/dynamic-tags.js +156 -40
  40. package/js/fileupload.js +9 -8
  41. package/js/form.js +280 -254
  42. package/js/global-events.js +281 -188
  43. package/js/heatmap.js +10 -7
  44. package/js/i18n.js +18 -10
  45. package/js/icons.js +141 -161
  46. package/js/image-preview.js +146 -2
  47. package/js/initializer.js +113 -71
  48. package/js/kupola-core.js +123 -45
  49. package/js/kupola-lifecycle.js +13 -11
  50. package/js/message.js +8 -1
  51. package/js/modal.js +207 -59
  52. package/js/notification.js +8 -1
  53. package/js/numberinput.js +9 -8
  54. package/js/pagination.js +263 -0
  55. package/js/registry.js +29 -12
  56. package/js/select.js +482 -27
  57. package/js/slide-captcha.js +11 -2
  58. package/js/slider.js +442 -25
  59. package/js/statcard.js +9 -7
  60. package/js/table.js +1210 -0
  61. package/js/tag.js +268 -14
  62. package/js/theme.js +14 -43
  63. package/js/timepicker.js +335 -66
  64. package/js/tooltip.js +317 -86
  65. package/js/utils.js +6 -2
  66. package/js/validation.js +6 -2
  67. package/js/virtual-list.js +11 -7
  68. package/js/web-components.js +288 -0
  69. package/package.json +77 -67
  70. package/plugins/vite-plugin-kupola.js +120 -0
  71. package/types/kupola.d.ts +421 -323
  72. package/CHANGELOG.md +0 -130
  73. package/INTEGRATION.md +0 -440
  74. package/PROJECT_SUMMARY.md +0 -312
  75. package/SKILL.md +0 -572
  76. package/dist/utils/utils/Kupola.cs +0 -77
  77. package/dist/utils/utils/Kupola.java +0 -104
  78. package/dist/utils/utils/kupola.go +0 -120
  79. package/dist/utils/utils/kupola.js +0 -63
  80. package/dist/utils/utils/kupola.py +0 -1392
  81. package/dist/utils/utils/kupola.rb +0 -69
  82. package/js/composition-api.js +0 -458
  83. package/js/error-handler.js +0 -181
  84. package/js/http.js +0 -419
  85. package/js/kupola-devtools.js +0 -598
  86. package/js/performance.js +0 -250
  87. package/js/router.js +0 -396
  88. package/js/security.js +0 -189
  89. package/js/test-utils.js +0 -251
  90. package/templates/base.html +0 -30
  91. package/templates/base_dashboard.html +0 -99
  92. package/utils/Kupola.cs +0 -77
  93. package/utils/Kupola.java +0 -104
  94. package/utils/kupola.go +0 -120
  95. package/utils/kupola.js +0 -63
  96. package/utils/kupola.py +0 -1392
  97. package/utils/kupola.rb +0 -69
@@ -1,83 +1,116 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var P={exports:{}},pt;function Ft(){return pt||(pt=1,function(s){class t{constructor(o){this.element=o,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=window.KupolaLifecycle?new window.KupolaLifecycle:{on:()=>()=>{},emit:()=>{},bootstrap:()=>{},mount:()=>{},update:()=>{},unmount:()=>{},destroy:()=>{},state:"created"},this.setupContext=null}_parseProps(){const o={};for(const n of this.element.attributes)if(n.name.startsWith("data-prop-")){const i=n.name.replace("data-prop-","");let a=n.value;try{a=JSON.parse(a)}catch{}o[i]=a}return o}_parseSlots(){const o={};return this.element.querySelectorAll("[data-slot]").forEach(i=>{const a=i.getAttribute("data-slot")||"default";o[a]=i.innerHTML.trim(),i.remove()}),!o.default&&this.element.children.length>0&&(o.default=this.element.innerHTML.trim()),o}$slot(o="default"){return this.slots[o]||""}$emit(o,n){if((this._eventListeners[o]||[]).forEach(a=>{try{a(n)}catch(l){console.error(`Error in event handler for ${o}:`,l)}}),this.element){const a=new CustomEvent(`kupola:${o}`,{detail:n,bubbles:!0,cancelable:!0});this.element.dispatchEvent(a)}}$on(o,n){return this._eventListeners[o]||(this._eventListeners[o]=[]),this._eventListeners[o].push(n),n}$off(o,n){this._eventListeners[o]&&(this._eventListeners[o]=this._eventListeners[o].filter(i=>i!==n))}async setProps(o){try{this.props={...this.props,...o},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(n){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,n),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:n,args:[o]})}}async setState(o){try{this.state={...this.state,...o},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(n){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,n),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:n,args:[o]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),window._setCurrentSetupContext&&window.SetupContext&&(this.setupContext=new window.SetupContext(this),window._setCurrentSetupContext(this.setupContext),typeof this.setup=="function")){const o=this.setup();o instanceof Promise&&await o}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted(),window._clearSetupContext&&window._clearSetupContext()}catch(o){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,o),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:o,args:[]}),typeof this.renderError=="function")try{this.renderError(o)}catch(n){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,n)}else this.element.innerHTML=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class R{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(i=>{i.resolved=!1})}on(t,e,i={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:i.priority||0,depends:i.depends||[],name:i.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const i of t){const r=this.hooks.get(e).find(a=>a.name===i);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const i=this.hooks.get(t);if(!i||i.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const o of i){await this._resolveDepends(o.depends,t);const l=performance.now();let c,d;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){d=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const h=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:h,status:d?"error":"success",error:d?d.message:null,timestamp:Date.now()})}const a=performance.now()-r;console.debug(`[KupolaLifecycle] ${t} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const i=this.phaseStateMap[t];if(i){if(Array.isArray(i.from)){if(!i.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${i.from.join(", ")}`)}else if(this.state!==i.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${i.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),i&&this._updateState(i.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(i){console.error("[KupolaLifecycle] Error in onError callback:",i)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const i of e)try{const n=i.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${i.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${i.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}class Fe{constructor(){this.plugins=new Map,this.enabledPlugins=new Set,this.pluginHooks=new Map}register(t,e){this.plugins.has(t)&&console.warn(`Plugin ${t} already registered, overriding`),this.plugins.set(t,{...e,name:t,enabled:!1,instance:null,lifecycle:new R(`plugin:${t}`)})}async enable(t){const e=this.plugins.get(t);if(!e)throw new Error(`Plugin ${t} not found`);if(!e.enabled)try{await e.lifecycle.bootstrap(),e.install&&(e.instance=await e.install()),e.enabled=!0,this.enabledPlugins.add(t),await e.lifecycle.mount(),e.hooks&&this._registerPluginHooks(t,e.hooks),console.log(`Plugin ${t} enabled`)}catch(i){throw console.error(`Failed to enable plugin ${t}:`,i),i}}async disable(t){const e=this.plugins.get(t);if(!(!e||!e.enabled))try{await e.lifecycle.unmount(),e.uninstall&&await e.uninstall(e.instance),e.hooks&&this._unregisterPluginHooks(t),e.enabled=!1,this.enabledPlugins.delete(t),e.instance=null,await e.lifecycle.destroy(),console.log(`Plugin ${t} disabled`)}catch(i){throw console.error(`Failed to disable plugin ${t}:`,i),i}}get(t){return this.plugins.get(t)?.instance||null}getAll(){const t={};return this.plugins.forEach((e,i)=>{t[i]={name:e.name,enabled:e.enabled,instance:e.instance,state:e.lifecycle.getState()}}),t}getEnabled(){const t={};return this.enabledPlugins.forEach(e=>{const i=this.plugins.get(e);i&&(t[e]=i.instance)}),t}async enableAll(){const t=[];this.plugins.forEach((e,i)=>{t.push(this.enable(i))}),await Promise.all(t)}async disableAll(){const t=[];this.enabledPlugins.forEach(e=>{t.push(this.disable(e))}),await Promise.all(t)}_registerPluginHooks(t,e){this.pluginHooks.has(t)||this.pluginHooks.set(t,[]);const i=this.pluginHooks.get(t);Object.keys(e).forEach(n=>{const r=typeof window<"u"&&window.kupolaLifecycle?.on(n,e[n],{name:`${t}:${n}`});r&&i.push({phase:n,unsubscribe:r})})}_unregisterPluginHooks(t){const e=this.pluginHooks.get(t);e&&(e.forEach(({unsubscribe:i})=>{i&&i()}),this.pluginHooks.delete(t))}}const Ne=new R("app"),_s=new Fe;function Oe(s="app"){return new R(s)}typeof window<"u"&&(window.KupolaLifecycle=R,window.KupolaPluginManager=Fe,window.kupolaLifecycle=Ne,window.kupolaPluginManager=_s,window.createLifecycle=Oe);const Tt={string:{trim(s){return s?s.trim():""},trimLeft(s){return s?s.replace(/^\s+/,""):""},trimRight(s){return s?s.replace(/\s+$/,""):""},toUpperCase(s){return s?s.toUpperCase():""},toLowerCase(s){return s?s.toLowerCase():""},capitalize(s){return s?s.charAt(0).toUpperCase()+s.slice(1):""},camelize(s){return s?s.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""},hyphenate(s){return s?s.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart(s,t,e=" "){return(String(s)||"").padStart(t,e)},padEnd(s,t,e=" "){return(String(s)||"").padEnd(t,e)},truncate(s,t,e="..."){return!s||s.length<=t?s||"":s.slice(0,t)+e},replaceAll(s,t,e){return s?s.split(t).join(e):""},format(s,t){return s?s.replace(/\{\{(\w+)\}\}/g,(e,i)=>t[i]!==void 0?t[i]:`{{${i}}}`):""},startsWith(s,t){return(s||"").startsWith(t)},endsWith(s,t){return(s||"").endsWith(t)},includes(s,t){return(s||"").includes(t)},repeat(s,t){return(s||"").repeat(t)},reverse(s){return(s||"").split("").reverse().join("")},countOccurrences(s,t){return!s||!t?0:s.split(t).length-1},escapeHtml(s){if(!s)return"";const t=document.createElement("div");return t.textContent=s,t.innerHTML},unescapeHtml(s){if(!s)return"";const t=document.createElement("div");return t.innerHTML=s,t.textContent},generateRandom(s=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let i=0;i<s;i++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}},array:{isArray(s){return Array.isArray(s)},isEmpty(s){return!s||s.length===0},size(s){return s?s.length:0},first(s,t){return s&&s.length>0?s[0]:t},last(s,t){return s&&s.length>0?s[s.length-1]:t},get(s,t,e){return s&&s[t]!==void 0?s[t]:e},slice(s,t,e){return s?s.slice(t,e):[]},concat(...s){return s.reduce((t,e)=>t.concat(e||[]),[])},join(s,t=","){return s?s.join(t):""},indexOf(s,t,e=0){return s?s.indexOf(t,e):-1},lastIndexOf(s,t,e){return s?s.lastIndexOf(t,e):-1},includes(s,t){return s?s.includes(t):!1},push(s,...t){return s&&s.push(...t),s},pop(s){return s?s.pop():void 0},shift(s){return s?s.shift():void 0},unshift(s,...t){return s&&s.unshift(...t),s},remove(s,t){if(!s)return s;const e=s.indexOf(t);return e>-1&&s.splice(e,1),s},removeAt(s,t){return!s||t<0||t>=s.length||s.splice(t,1),s},insert(s,t,e){return s&&(s.splice(t,0,e),s)},reverse(s){return s?s.slice().reverse():[]},sort(s,t){return s?s.slice().sort(t):[]},sortBy(s,t,e="asc"){return s?s.slice().sort((i,n)=>{const r=typeof i=="object"?i[t]:i,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]},filter(s,t){return s?s.filter(t):[]},map(s,t){return s?s.map(t):[]},reduce(s,t,e){return s?s.reduce(t,e):e},forEach(s,t){s&&s.forEach(t)},every(s,t){return s?s.every(t):!0},some(s,t){return s?s.some(t):!1},find(s,t){return s?s.find(t):void 0},findIndex(s,t){return s?s.findIndex(t):-1},flat(s,t=1){return s?s.flat(t):[]},flattenDeep(s){return s?s.reduce((t,e)=>Array.isArray(e)?t.concat(this.flattenDeep(e)):t.concat(e),[]):[]},unique(s){return s?[...new Set(s)]:[]},uniqueBy(s,t){if(!s)return[];const e=new Set;return s.filter(i=>{const n=typeof i=="object"?i[t]:i;return e.has(n)?!1:(e.add(n),!0)})},chunk(s,t){if(!s||t<=0)return[];const e=[];for(let i=0;i<s.length;i+=t)e.push(s.slice(i,i+t));return e},shuffle(s){if(!s)return[];const t=s.slice();for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t},sum(s){return s?s.reduce((t,e)=>t+(Number(e)||0),0):0},average(s){return!s||s.length===0?0:this.sum(s)/s.length},max(s){return s&&s.length>0?Math.max(...s):-1/0},min(s){return s&&s.length>0?Math.min(...s):1/0},intersection(...s){return s.length===0?[]:s.reduce((t,e)=>t.filter(i=>e&&e.includes(i)))},union(...s){return[...new Set(s.flat().filter(Boolean))]},difference(s,t){return s?s.filter(e=>!t||!t.includes(e)):[]},zip(...s){if(s.length===0)return[];const t=Math.max(...s.map(e=>e?e.length:0));return Array.from({length:t},(e,i)=>s.map(n=>n&&n[i]))}},object:{isObject(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)},isEmpty(s){return!s||typeof s!="object"?!0:Object.keys(s).length===0},keys(s){return s?Object.keys(s):[]},values(s){return s?Object.values(s):[]},entries(s){return s?Object.entries(s):[]},has(s,t){return s?Object.prototype.hasOwnProperty.call(s,t):!1},get(s,t,e){return s&&t.split(".").reduce((n,r)=>n&&n[r],s)||e},set(s,t,e){if(!s||typeof s!="object")return s;const i=t.split("."),n=i.pop();let r=s;return i.forEach(a=>{r[a]||(r[a]={}),r=r[a]}),r[n]=e,s},pick(s,t){return s?t.reduce((e,i)=>(s[i]!==void 0&&(e[i]=s[i]),e),{}):{}},omit(s,t){return s?Object.keys(s).reduce((e,i)=>(t.includes(i)||(e[i]=s[i]),e),{}):{}},merge(...s){return s.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(i=>{this.isObject(e[i])&&this.isObject(t[i])?t[i]=this.merge(t[i],e[i]):t[i]=e[i]}),t),{})},clone(s){return s&&JSON.parse(JSON.stringify(s))},deepClone(s,t=new WeakMap){if(!s||typeof s!="object")return s;if(t.has(s))return t.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const i=new Map;return t.set(s,i),s.forEach((n,r)=>i.set(r,this.deepClone(n,t))),i}if(s instanceof Set){const i=new Set;return t.set(s,i),s.forEach(n=>i.add(this.deepClone(n,t))),i}if(Array.isArray(s)){const i=[];return t.set(s,i),s.forEach(n=>i.push(this.deepClone(n,t))),i}const e={};return t.set(s,e),Object.keys(s).forEach(i=>{e[i]=this.deepClone(s[i],t)}),e},forEach(s,t){s&&Object.keys(s).forEach(e=>t(s[e],e,s))},map(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{e[i]=t(s[i],i,s)}),e},filter(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(i=>{t(s[i],i,s)&&(e[i]=s[i])}),e},reduce(s,t,e){return s?Object.keys(s).reduce((i,n)=>t(i,s[n],n,s),e):e},toArray(s){return s?Object.keys(s).map(t=>({key:t,value:s[t]})):[]},fromArray(s,t,e){return s?s.reduce((i,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(i[r]=a),i},{}):{}},size(s){return s?Object.keys(s).length:0},invert(s){if(!s)return{};const t={};return Object.keys(s).forEach(e=>{t[s[e]]=e}),t},isEqual(s,t){if(s===t)return!0;if(!s||!t||typeof s!="object"||typeof t!="object")return!1;const e=Object.keys(s),i=Object.keys(t);return e.length!==i.length?!1:e.every(n=>this.isEqual(s[n],t[n]))},freeze(s){return s&&(Object.freeze(s),Object.keys(s).forEach(t=>{typeof s[t]=="object"&&this.freeze(s[t])}),s)},seal(s){return s&&Object.seal(s)}},number:{isNumber(s){return typeof s=="number"&&!isNaN(s)},isInteger(s){return Number.isInteger(s)},isFloat(s){return this.isNumber(s)&&!Number.isInteger(s)},isPositive(s){return this.isNumber(s)&&s>0},isNegative(s){return this.isNumber(s)&&s<0},isZero(s){return this.isNumber(s)&&s===0},clamp(s,t,e){return this.isNumber(s)?Math.min(Math.max(s,t),e):s},round(s,t=0){if(!this.isNumber(s))return s;const e=Math.pow(10,t);return Math.round(s*e)/e},floor(s){return this.isNumber(s)?Math.floor(s):s},ceil(s){return this.isNumber(s)?Math.ceil(s):s},abs(s){return this.isNumber(s)?Math.abs(s):s},min(...s){const t=s.filter(this.isNumber);return t.length>0?Math.min(...t):void 0},max(...s){const t=s.filter(this.isNumber);return t.length>0?Math.max(...t):void 0},sum(...s){return s.flat().filter(this.isNumber).reduce((e,i)=>e+i,0)},average(...s){const t=s.flat().filter(this.isNumber);return t.length>0?this.sum(t)/t.length:0},random(s=0,t=1){return Math.random()*(t-s)+s},randomInt(s,t){return Math.floor(this.random(s,t+1))},format(s,t=2){return this.isNumber(s)?s.toFixed(t):String(s)},formatCurrency(s,t="CNY",e=2){return this.isNumber(s)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(s):String(s)},formatPercent(s,t=0){return this.isNumber(s)?`${(s*100).toFixed(t)}%`:String(s)},toFixed(s,t=0){return this.isNumber(s)?s.toFixed(t):String(s)},toPrecision(s,t=6){return this.isNumber(s)?s.toPrecision(t):String(s)},isNaN(s){return Number.isNaN(s)},isFinite(s){return Number.isFinite(s)},parseInt(s,t=10){return Number.parseInt(s,t)},parseFloat(s){return Number.parseFloat(s)},toNumber(s,t=0){const e=Number(s);return isNaN(e)?t:e},safeDivide(s,t,e=0){return!this.isNumber(s)||!this.isNumber(t)||t===0?e:s/t},safeMultiply(...s){return s.reduce((t,e)=>!this.isNumber(t)||!this.isNumber(e)?0:t*e,1)}},date:{now(){return Date.now()},today(){const s=new Date;return s.setHours(0,0,0,0),s},tomorrow(){const s=this.today();return s.setDate(s.getDate()+1),s},yesterday(){const s=this.today();return s.setDate(s.getDate()-1),s},isDate(s){return s instanceof Date&&!isNaN(s.getTime())},isValid(s){return this.isDate(s)},parse(s){const t=new Date(s);return this.isValid(t)?t:null},format(s,t="YYYY-MM-DD HH:mm:ss"){if(!this.isDate(s))return"";const e=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),r=String(s.getHours()).padStart(2,"0"),a=String(s.getMinutes()).padStart(2,"0"),o=String(s.getSeconds()).padStart(2,"0"),l=String(s.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][s.getDay()];return t.replace("YYYY",e).replace("MM",i).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",s.getDate()).replace("M",s.getMonth()+1).replace("H",s.getHours()).replace("m",s.getMinutes()).replace("s",s.getSeconds()).replace("W",d)},toISO(s){return this.isDate(s)?s.toISOString():""},toUTC(s){return this.isDate(s)?new Date(s.toUTCString()):null},addDays(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setDate(e.getDate()+t),e},addHours(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setHours(e.getHours()+t),e},addMinutes(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setMinutes(e.getMinutes()+t),e},addSeconds(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setSeconds(e.getSeconds()+t),e},diffDays(s,t){if(!this.isDate(s)||!this.isDate(t))return 0;const e=this.today(),i=this.today();return e.setTime(s.getTime()),i.setTime(t.getTime()),Math.floor((e.getTime()-i.getTime())/(1e3*60*60*24))},diffHours(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60*60))},diffMinutes(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60))},diffSeconds(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/1e3)},isToday(s){return this.isDate(s)?this.diffDays(s,this.today())===0:!1},isYesterday(s){return this.isDate(s)?this.diffDays(s,this.today())===-1:!1},isTomorrow(s){return this.isDate(s)?this.diffDays(s,this.today())===1:!1},isFuture(s){return this.isDate(s)?s.getTime()>this.now():!1},isPast(s){return this.isDate(s)?s.getTime()<this.now():!1},isLeapYear(s){if(!this.isDate(s))return!1;const t=s.getFullYear();return t%4===0&&(t%100!==0||t%400===0)},getDaysInMonth(s){if(!this.isDate(s))return 0;const t=s.getFullYear(),e=s.getMonth();return new Date(t,e+1,0).getDate()},getWeekOfYear(s){if(!this.isDate(s))return 0;const t=new Date(s.getFullYear(),0,1),e=s.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))},getQuarter(s){return this.isDate(s)?Math.ceil((s.getMonth()+1)/3):0},startOfDay(s){if(!this.isDate(s))return s;const t=new Date(s);return t.setHours(0,0,0,0),t},endOfDay(s){if(!this.isDate(s))return s;const t=new Date(s);return t.setHours(23,59,59,999),t},startOfMonth(s){return this.isDate(s)?new Date(s.getFullYear(),s.getMonth(),1):s},endOfMonth(s){return this.isDate(s)?new Date(s.getFullYear(),s.getMonth()+1,0,23,59,59,999):s},startOfWeek(s,t=1){if(!this.isDate(s))return s;const e=new Date(s),i=e.getDay(),n=i>=t?i-t:i+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e},endOfWeek(s,t=1){if(!this.isDate(s))return s;const e=this.startOfWeek(s,t),i=new Date(e);return i.setDate(i.getDate()+6),i.setHours(23,59,59,999),i},getAge(s){if(!this.isDate(s))return 0;const t=new Date;let e=t.getFullYear()-s.getFullYear();return(t.getMonth()<s.getMonth()||t.getMonth()===s.getMonth()&&t.getDate()<s.getDate())&&e--,Math.max(0,e)},fromNow(s){if(!this.isDate(s))return"";const e=this.now()-s.getTime(),i=60*1e3,n=60*i,r=24*n,a=7*r,o=30*r,l=365*r;return e<i?"刚刚":e<n?`${Math.floor(e/i)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}},debounce(s,t,e={}){let i=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){s.apply(r,n)}function d(){a=Date.now(),o?(i=setTimeout(h,t),c()):i=setTimeout(h,t)}function h(){i=null,l&&n&&c(),n=null,r=null}function u(){const f=Date.now()-a;return Math.max(0,t-f)}return function(...f){n=f,r=this,a=Date.now(),i?(clearTimeout(i),i=setTimeout(h,u())):d()}},throttle(s,t,e={}){let i=!1;const n=e.trailing||!1;let r=null,a=null;function o(){s.apply(a,r),r=null,a=null}return function(...l){i?n&&(r=l,a=this):(i=!0,r=l,a=this,o(),setTimeout(()=>{i=!1,n&&r&&o()},t))}},validator:{isEmail(s){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s||"")},isPhone(s){return/^1[3-9]\d{9}$/.test(s||"")},isURL(s){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(s||"")},isIPv4(s){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(s||"")},isIPv6(s){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(s||"")},isIP(s){return this.isIPv4(s)||this.isIPv6(s)},isIDCard(s){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(s||"")},isPassport(s){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(s||"")},isCreditCard(s){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=s.replace(/\s/g,"");if(!t.test(e))return!1;let i=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),i+=a,n=!n}return i%10===0},isHexColor(s){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(s||"")},isRGB(s){const e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s||"");return e?e.slice(1).every(i=>parseInt(i)>=0&&parseInt(i)<=255):!1},isRGBA(s){const e=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(s||"");if(!e)return!1;const[,i,n,r,a]=e;return parseInt(i)>=0&&parseInt(i)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseInt(r)>=0&&parseInt(r)<=255&&parseFloat(a)>=0&&parseFloat(a)<=1},isColor(s){return this.isHexColor(s)||this.isRGB(s)||this.isRGBA(s)},isDate(s){return!isNaN(new Date(s).getTime())},isJSON(s){try{return JSON.parse(s),!0}catch{return!1}},isEmpty(s){return!s||s.trim()===""},isWhitespace(s){return/^\s+$/.test(s||"")},isNumber(s){return!isNaN(parseFloat(s))&&isFinite(s)},isInteger(s){return/^-?\d+$/.test(s||"")},isFloat(s){return/^-?\d+\.\d+$/.test(s||"")},isPositive(s){const t=parseFloat(s);return!isNaN(t)&&t>0},isNegative(s){const t=parseFloat(s);return!isNaN(t)&&t<0},isAlpha(s){return/^[a-zA-Z]+$/.test(s||"")},isAlphaNumeric(s){return/^[a-zA-Z0-9]+$/.test(s||"")},isChinese(s){return/^[\u4e00-\u9fa5]+$/.test(s||"")},isLength(s,t,e){const i=(s||"").length;return i>=t&&(e===void 0||i<=e)},minLength(s,t){return(s||"").length>=t},maxLength(s,t){return(s||"").length<=t},matches(s,t){return t instanceof RegExp?t.test(s||""):!1},equals(s,t){return String(s)===String(t)},contains(s,t){return(s||"").includes(t)},notContains(s,t){return!this.contains(s,t)},isArray(s){return Array.isArray(s)},arrayLength(s,t,e){const i=s?s.length:0;return i>=t&&(e===void 0||i<=e)},arrayMinLength(s,t){return s?s.length>=t:!1},arrayMaxLength(s,t){return s?s.length<=t:!1},isObject(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)},hasKeys(s,t){return!s||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(s,e))},validate(s,t){const e={};return Object.keys(t).forEach(i=>{const n=s[i],r=t[i],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");this[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,s);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[i]=a)}),{valid:Object.keys(e).length===0,errors:e}}},crypto:{md5(s){const t=s?String(s):"",e=[1732584193,4023233417,2562383102,271733878],i=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(h,u){return h<<u|h>>>32-u}function a(h){const u=h.length*8;for(h+="€";h.length%64!==56;)h+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)h+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)h+=String.fromCharCode(p>>>8*m&255);return h}function o(h,u){const[f,p,m,y]=u,_=[];for(let E=0;E<16;E++)_[E]=h.charCodeAt(E*4)&255|(h.charCodeAt(E*4+1)&255)<<8|(h.charCodeAt(E*4+2)&255)<<16|(h.charCodeAt(E*4+3)&255)<<24;let b=f,v=p,w=m,k=y;for(let E=0;E<64;E++){let x,C;const M=Math.floor(E/16),H=E%16;M===0?(x=v&w|~v&k,C=H):M===1?(x=k&v|~k&w,C=(5*H+1)%16):M===2?(x=v^w^k,C=(3*H+5)%16):(x=w^(v|~k),C=7*H%16);const P=k;k=w,w=v,v=v+r(b+x+i[E]+_[C]&4294967295,n[M][E%4]),b=P}return[f+b&4294967295,p+v&4294967295,m+w&4294967295,y+k&4294967295]}const l=a(t);let c=[...e];for(let h=0;h<l.length;h+=64)c=o(l.substring(h,h+64),c);let d="";return c.forEach(h=>{for(let u=0;u<4;u++)d+=(h>>>8*u&255).toString(16).padStart(2,"0")}),d},sha256(s){const t=s?String(s):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function i(c,d){return c>>>d|c<<32-d}function n(c){const d=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const h=d&4294967295,u=d>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(h>>>8*f&255);return c}function r(c,d){const h=[];for(let w=0;w<16;w++)h[w]=c.charCodeAt(w*4)&255|(c.charCodeAt(w*4+1)&255)<<8|(c.charCodeAt(w*4+2)&255)<<16|(c.charCodeAt(w*4+3)&255)<<24;for(let w=16;w<64;w++){const k=i(h[w-15],7)^i(h[w-15],18)^h[w-15]>>>3,E=i(h[w-2],17)^i(h[w-2],19)^h[w-2]>>>10;h[w]=h[w-16]+k+h[w-7]+E&4294967295}let[u,f,p,m,y,_,b,v]=d;for(let w=0;w<64;w++){const k=i(y,6)^i(y,11)^i(y,25),E=y&_^~y&b,x=v+k+E+e[w]+h[w]&4294967295,C=i(u,2)^i(u,13)^i(u,22),M=u&f^u&p^f&p,H=C+M&4294967295;v=b,b=_,_=y,y=m+x&4294967295,m=p,p=f,f=u,u=x+H&4294967295}return[d[0]+u&4294967295,d[1]+f&4294967295,d[2]+p&4294967295,d[3]+m&4294967295,d[4]+y&4294967295,d[5]+_&4294967295,d[6]+b&4294967295,d[7]+v&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let d=3;d>=0;d--)l+=(c>>>8*d&255).toString(16).padStart(2,"0")}),l},base64Encode(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;const n=s?s.split("").map(r=>r.charCodeAt(0)):[];for(;i<n.length;){const r=n[i++],a=n[i++]||0,o=n[i++]||0,l=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|o>>6,h=o&63;e+=t[l]+t[c]+(i>n.length+1?"=":t[d])+(i>n.length?"=":t[h])}return e},base64Decode(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;for(s=s.replace(/[^A-Za-z0-9+/=]/g,"");i<s.length;){const n=t.indexOf(s.charAt(i++)),r=t.indexOf(s.charAt(i++)),a=t.indexOf(s.charAt(i++)),o=t.indexOf(s.charAt(i++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(d))}return e},uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}},preload:{cache:new Map,async loadImage(s,t={}){const{crossOrigin:e="anonymous"}=t;return this.cache.has(s)?this.cache.get(s):new Promise((i,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{this.cache.set(s,r),i(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${s}`))},r.src=s})},async loadImages(s,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(s.map(n=>this.loadImage(n,t)));const i=[];for(const n of s)i.push(await this.loadImage(n,t));return i},async loadScript(s,t={}){const{type:e="text/javascript",async:i=!0,defer:n=!1}=t;return this.cache.has(s)?this.cache.get(s):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=i,o.defer=n,o.onload=()=>{this.cache.set(s,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${s}`))},o.src=s,document.head.appendChild(o)})},async loadStylesheet(s,t={}){const{media:e="all"}=t;return this.cache.has(s)?this.cache.get(s):new Promise((i,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=s,r.media=e,r.onload=()=>{this.cache.set(s,r),i(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${s}`))},document.head.appendChild(r)})},async loadFont(s,t,e={}){const{weight:i="normal",style:n="normal"}=e,r=new FontFace(s,`url(${t})`,{weight:i,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${s}`)}},async preload(s,t="image"){switch(t){case"image":return this.loadImage(s);case"script":return this.loadScript(s);case"stylesheet":case"style":return this.loadStylesheet(s);default:throw new Error(`Unsupported preload type: ${t}`)}},isLoaded(s){return this.cache.has(s)},clearCache(){this.cache.clear()},clearCacheByUrl(s){this.cache.delete(s)}}};typeof window<"u"&&(window.KupolaUtils=Tt,window.kupolaUtils=Tt);function ys(s){return s?String(s).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi,"").replace(/<embed\b[^>]*\/?>/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""):""}class ze{constructor(){this.children={},this.keys=[]}}class It{constructor(){this.root=new ze}insert(t){let e=this.root;const i=t.split(".");i.forEach((n,r)=>{e.children[n]||(e.children[n]=new ze),e=e.children[n],r===i.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const i=t.split("."),n=[];for(let r=0;r<i.length;r++){const a=i[r];if(!e.children[a])break;e=e.children[a];const o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),i=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");i.push(r)}return i}}const g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class Gt{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new It,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,i,n)=>{if(i==="__raw__")return e;const r=Reflect.get(e,i,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,i):r},set:(e,i,n,r)=>{const a=Reflect.get(e,i,r),o=Reflect.set(e,i,n,r),l=this.resolvePath(e,i);return this.notify(l,n,a),this.queueUpdate(l,n),o},deleteProperty:(e,i)=>{const n=Reflect.get(e,i,receiver),r=Reflect.deleteProperty(e,i),a=this.resolvePath(e,i);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),d=Reflect.set(r,a,o,l),h=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(h,o,c),this.queueUpdate(h,o),d},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[g.path]?`${t[g.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,i)=>{t.add(i),this.updateElementsDirect(i,e),this.pathTrie.getSubKeys(i).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(i=>{this.updateElement(i,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,i=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{i||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,i||(this.notify(t,e,n),this.queueUpdate(t,e))),i||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,i)=>e?.[i],this.rawData)}setNested(t,e){const i=t.split("."),n=i.pop(),r=i.reduce((o,l)=>(o[l]||(o[l]={}),o[l]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(i=>i!==e))}notify(t,e,i){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,i)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,i)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(r=>{const a=r.split(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ys(e);t.innerHTML!==c&&(t.innerHTML=c);break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const d=e?"none":"";t.style.display!==d&&(t.style.display=d);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,i){this.computedProperties[t]={deps:e,callback:i},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const i=e.deps.map(r=>this.get(r)),n=e.callback(...i);this.set(t,n,!0)}catch(i){console.error(`Computed error for ${t}:`,i)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new It,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:i="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:o=null}=e,l=i==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,d=>{const h=this.persistedKeys.get(t);h&&(h.debounce>0?(h.timeout&&clearTimeout(h.timeout),h.timeout=setTimeout(()=>{this._persistSave(t,d,h.storage,{version:h.version,encrypt:h.encrypt,encryptionKey:h.encryptionKey})},h.debounce)):this._persistSave(t,d,h.storage,{version:h.version,encrypt:h.encrypt,encryptionKey:h.encryptionKey}))})}_persistSave(t,e,i,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),this._ensureStorageCapacity(i),i.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&i===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),i=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>i&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(i){return console.warn("Decryption failed:",i),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:i=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=localStorage.getItem(r);let l;if(i){const c=this._decrypt(o,i);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(i){const c=this._decrypt(o,i);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,i=this.snapshots[e];return i?(this.rawData=this._clone(i),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(i=>{const n=i.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(i.type==="checkbox"?(e[a]||(e[a]=[]),i.checked&&e[a].push(i.value)):i.type==="radio"?i.checked&&(e[a]=i.value):e[a]=i.value)}),e}fillForm(t,e){Object.keys(e).forEach(i=>{t.querySelectorAll('[data-bind*=":'+i+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[i])?e[i].includes(n.value):!!e[i]:n.type==="radio"?n.checked=n.value===e[i]:n.value=e[i]??""})})}createReactive(t,e=""){if(t[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),d=Reflect.set(r,a,o,l),h=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(h,o,c),this.queueUpdate(h,o),d},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,i);return t[g.parent]=t,t[g.path]=e,t[g.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._mutationObserver=new MutationObserver(t=>{t.forEach(e=>{e.addedNodes.forEach(i=>{i.nodeType===Node.ELEMENT_NODE&&(i.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),i.hasAttribute&&i.hasAttribute("data-bind")&&this._bindElement(i))})})}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const i=t.getAttribute("data-bind").split(":");i[0].split("|")[0].trim();const n=i[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const i=e.__kupolaBindHandler;i&&(e.removeEventListener("input",i),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new It,this.updateQueue.clear(),this.snapshots=[]}}class U{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const i=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},window.kupolaData?(window.kupolaData.set(this._stateKey,i),this.state=window.kupolaData.data?.[this._stateKey]||window.kupolaData.createReactive(i,this._stateKey),window.kupolaData.observe(this._stateKey,n=>{this.notify(n)})):this.state=i,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const i=this.mutations[t];if(!i){console.warn(`Mutation ${t} not found in store ${this.name}`);return}i(this.state,e)}dispatch(t,e){const i=this.actions[t];if(!i){console.warn(`Action ${t} not found in store ${this.name}`);return}return i({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(i){console.error(`Observer error for store ${this.name}:`,i)}}),window.kupolaData&&window.kupolaData.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class Zt{constructor(){this.stores=new Map}createStore(t,e){const i=new U(t,e);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof U&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Qt{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(i=>i!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(i=>{try{i(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(i=>{try{i(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const i=n=>{e(n),this.off(t,i)};return this.on(t,i),i}delegate(t,e,i){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:i}),i}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(i=>i.selector!==t),this.delegatedEvents[e].length===0)){const i=this.eventListeners[e];i&&(document.removeEventListener(e,i),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function L(s=null){const t={_value:s,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(i=>i(e)))}}),t}const Y=new Gt,Re=new Qt,kt=new Zt;function Ve(s,t){return kt.createStore(s,t)}function Ke(s){return kt.getStore(s)}typeof window<"u"&&(window.KupolaDataBind=Gt,window.KupolaEventBus=Qt,window.KupolaStore=U,window.KupolaStoreManager=Zt,window.kupolaData=Y,window.kupolaEvents=Re,window.kupolaStoreManager=kt,window.createStore=Ve,window.getStore=Ke,window.kupolaRef=L);const We="kupola-theme",Ue="kupola-brand",$=[{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 q(){return localStorage.getItem(We)||"dark"}function V(s){if(s!=="dark"&&s!=="light")return;document.documentElement.setAttribute("data-theme",s),localStorage.setItem(We,s);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",s);const e=t.querySelector(".theme-icon");if(e){const i=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=s==="dark"?i+"sun.svg":i+"moon.svg"}}}function F(){return localStorage.getItem(Ue)||"zengqing"}function K(s){const t=$.find(n=>n.id===s);if(!t)return;document.documentElement.setAttribute("data-brand",s),localStorage.setItem(Ue,s);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",s);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===s?n.classList.add("is-active"):n.classList.remove("is-active")})}function te(){const s=q();V(s);const t=F();K(t);const e=document.querySelector("[data-theme-toggle]");e&&e.addEventListener("click",()=>{const l=q()==="dark"?"light":"dark";V(l)});let i=document.getElementById("brand-picker");i||(i=document.createElement("div"),i.id="brand-picker",i.style.position="fixed",i.style.top="64px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",$.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=o.name,i.appendChild(l)}),document.body.appendChild(i));const n=document.querySelector("[data-brand-toggle]");n&&i&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=i.style.display==="none";i.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},i.onclick=function(o){o.stopPropagation()});function r(o){i&&n&&!i.contains(o.target)&&!n.contains(o.target)&&(i.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");K(c),i&&(i.style.display="none")})})}function Ye(){const s=document.createElement("button");s.setAttribute("data-theme-toggle",""),s.setAttribute("data-current-theme",q()),s.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",s.style.position="fixed",s.style.top="16px",s.style.right="16px",s.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),i=e[e.length-1],n=i.src.substring(0,i.src.lastIndexOf("/")+1);return t.src=q()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",s.appendChild(t),document.body.appendChild(s),s.addEventListener("click",()=>{const a=q()==="dark"?"light":"dark";V(a)}),s}function Xe(){const s=document.createElement("div");s.id="brand-picker-auto",s.style.position="fixed",s.style.top="56px",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",$.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=a.name,s.appendChild(o)}),document.body.appendChild(s);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",F()),t.className="ds-btn ds-btn--ghost ds-btn--sm",t.style.position="fixed",t.style.top="16px",t.style.right="56px",t.style.zIndex="9999",t.style.display="flex",t.style.alignItems="center",t.style.gap="6px";const e=document.createElement("span");e.className="brand-icon",e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.backgroundColor=$.find(a=>a.id===F()).color;const i=document.createElement("span");i.className="brand-name",i.style.fontSize="11px",i.textContent=$.find(a=>a.id===F()).name,t.appendChild(e),t.appendChild(i),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=s.style.display==="none";s.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},s.onclick=function(a){a.stopPropagation()};function n(a){!s.contains(a.target)&&!t.contains(a.target)&&(s.style.display="none",document.removeEventListener("click",n,!0))}return s.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");K(l),s.style.display="none"})}),{toggleBtn:t,container:s}}typeof window<"u"&&(window.getTheme=q,window.setTheme=V,window.initTheme=te,window.createThemeToggle=Ye,window.getBrand=F,window.setBrand=K,window.BRAND_OPTIONS=$,window.createBrandPicker=Xe);class ee{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,i=null,n={}){this.initializers.set(t,e),i&&this.cleanupFunctions.set(t,i),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(i.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(e.includes(i)){const n=i.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(i);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const r=n||i.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(i.replace("data-",""));if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(e.includes(i)){const n=i.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(i);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const i=t.querySelectorAll(e),n=[];i.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const S=new ee,vs=[{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 s of vs)s.attr&&!S._dataAttrs.includes(s.attr)&&S._dataAttrs.push(s.attr),s.cls&&!S._cssClasses.includes(s.cls)&&S._cssClasses.push(s.cls);typeof window<"u"&&(window.ComponentInitializerRegistry=ee,window.kupolaInitializer=S);class O{constructor(t){this.element=t,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new R,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const i=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[i]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(i=>{const n=i.getAttribute("data-slot")||"default";t[n]=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,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(i=>i!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof window<"u"&&window._setCurrentSetupContext&&window.SetupContext&&(this.setupContext=new window.SetupContext(this),window._setCurrentSetupContext(this.setupContext),typeof this.setup=="function")){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted(),typeof window<"u"&&window._clearSetupContext&&window._clearSetupContext()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
2
2
  <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">
3
3
  <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>
4
- <div style="font-size: 12px; white-space: pre-wrap;">${o.message}</div>
4
+ <div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>
5
5
  </div>
6
- `}}_bindLifecycleHooks(){if(this._hooksBound)return;const o={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let n=Object.getPrototypeOf(this);const i=new Set;for(;n&&n.constructor!==Object&&n.constructor!==t;){for(const[a,l]of Object.entries(o))i.has(a)||n.hasOwnProperty(a)&&(Array.isArray(l)?l.forEach(c=>{a==="render"&&this.lifecycle.on(c,()=>this.render?.())}):a==="renderError"?this.lifecycle.on(l,c=>(this.renderError(c.error),"handled")):this.lifecycle.on(l,()=>this[a]?.()),i.add(a));n=Object.getPrototypeOf(n)}this._hooksBound=!0}async unmount(){if(!(!this.isMounted||this.isDestroyed))try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(o){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,o),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:o,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(o){}updated(){}setup(){}}function e(r,o){Object.keys(o).forEach(n=>{if(n!=="constructor")if(typeof o[n]=="function"){const i=r.prototype[n];i?r.prototype[n]=function(...a){return o[n].apply(this,a),i.apply(this,a)}:r.prototype[n]=o[n]}else r.prototype[n]=o[n]})}s.exports?s.exports={KupolaComponent:t,applyMixin:e}:(window.KupolaComponent=t,window.applyMixin=e)}(P)),P.exports}Ft();var $={exports:{}},ft;function Ot(){return ft||(ft=1,function(s){class t{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(r,o){if(!(o.prototype instanceof window.KupolaComponent))throw new Error(`Component ${r} must extend KupolaComponent`);this.components.set(r,o)}registerLazy(r,o){this.lazyComponents.set(r,o)}unregister(r){this.components.delete(r),this.lazyComponents.delete(r),this.loadedComponents.delete(r),this.loadingPromises.delete(r)}get(r){return this.components.get(r)||this.loadedComponents.get(r)}async getAsync(r){const o=this.components.get(r)||this.loadedComponents.get(r);if(o)return o;if(this.loadingPromises.has(r))return this.loadingPromises.get(r);const n=this.lazyComponents.get(r);if(!n)throw new Error(`Component ${r} not found`);const i=(async()=>{try{const a=await n(),l=a.default||a;if(!(l.prototype instanceof window.KupolaComponent))throw new Error(`Component ${r} must extend KupolaComponent`);return this.loadedComponents.set(r,l),l}catch(a){throw this.loadingPromises.delete(r),a}})();return this.loadingPromises.set(r,i),i}defineMixin(r,o){this.mixins.set(r,o)}useMixin(r,...o){o.forEach(n=>{const i=this.mixins.get(n);i&&window.applyMixin&&window.applyMixin(r,i)})}async bootstrap(r=document){await this._upgradeElements(r),this._startObserver(r)}async _upgradeElements(r){const o=r.querySelectorAll("[data-component]"),n=[];o.forEach(i=>{n.push(this._upgradeElement(i))}),await Promise.all(n)}async _upgradeElement(r){if(!(r.__kupolaInstance||r.__kupolaUpgrading)){r.__kupolaUpgrading=!0;try{const o=r.getAttribute("data-component");if(window.kupolaInitializer&&o){const c=window.kupolaInitializer.get(o);if(c)try{await c(r);return}catch(h){console.warn(`[KupolaComponentRegistry] Initializer for "${o}" failed, trying component class:`,h)}}let n=this.components.get(o);if(!n){try{n=await this.getAsync(o)}catch(c){console.error(`Failed to load component ${o}:`,c);return}if(!r.isConnected)return}const i=r.getAttribute("data-mixins"),a=n;i&&window.applyMixin&&i.split(",").forEach(c=>{const h=this.mixins.get(c.trim());h&&window.applyMixin(a,h)});const l=new a(r);r.__kupolaInstance=l,this.instances.set(r,l),l.mount()}finally{r.__kupolaUpgrading=!1}}}_startObserver(r){this.observer||(this.observer=new MutationObserver(o=>{o.forEach(n=>{n.addedNodes.forEach(i=>{i.nodeType===Node.ELEMENT_NODE&&(i.hasAttribute("data-component")&&this._upgradeElement(i).catch(a=>console.error(a)),this._upgradeElements(i).catch(a=>console.error(a)))}),n.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const a=this.instances.get(i);a&&(a.unmount(),this.instances.delete(i)),i.querySelectorAll("[data-component]").forEach(l=>{const c=this.instances.get(l);c&&(c.unmount(),this.instances.delete(l))})}})})}),this.observer.observe(r,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(r=>{r.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}s.exports?s.exports={KupolaComponentRegistry:t}:window.KupolaComponentRegistry=t}($)),$.exports}Ot();var R={exports:{}},mt;function Nt(){return mt||(mt=1,function(s){class t{constructor(o={}){this.mode=o.mode||"hash",this.routes=o.routes||[],this.base=o.base||"",this.currentRoute=null,this.beforeEachHandlers=[],this.afterEachHandlers=[],this.isStarted=!1,this.animationClass="fade",this.componentCache=new Map,this._routeHandler=()=>this._handleRoute(),this._setupRoutes(),this._bindEvents()}_setupRoutes(){this.routeMap=new Map,this._registerRoutes(this.routes,"")}_registerRoutes(o,n){o.forEach(i=>{const a=i.path.startsWith("/")?i.path:n+(n&&!i.path.startsWith("/")?"/":"")+i.path,l=this._pathToRegex(a);this.routeMap.set(a,{...i,regex:l,parentPath:n}),i.children&&i.children.length>0&&this._registerRoutes(i.children,a)})}_pathToRegex(o){const n=o.replace(/:(\w+)/g,"([^/]+)").replace(/\*/g,".*");return new RegExp(`^${n}$`)}_bindEvents(){this.mode==="hash"?window.addEventListener("hashchange",this._routeHandler):window.addEventListener("popstate",this._routeHandler)}_handleRoute(){const o=this._getCurrentPath();this.navigate(o)}_getCurrentPath(){return this.mode==="hash"?location.hash.slice(1)||"/":location.pathname.replace(this.base,"")||"/"}async navigate(o,n=!1){const i=this._matchRoute(o);if(!i)return;const a=this.currentRoute;for(const l of this.beforeEachHandlers)if(await l(i,a)===!1)return;this.currentRoute=i,this._updateURL(o,n),await this._renderRoute(i);for(const l of this.afterEachHandlers)l(i)}_matchRoute(o){for(const[,n]of this.routeMap){const i=o.match(n.regex);if(i){const a={};(n.path.match(/:(\w+)/g)||[]).forEach((h,u)=>{a[h.slice(1)]=i[u+1]});const c=this._parseQuery();return{...n,params:a,query:c,fullPath:o}}}return null}_parseQuery(){const o=location.search.slice(1),n={};return o&&o.split("&").forEach(i=>{const[a,l]=i.split("=");n[a]=decodeURIComponent(l||"")}),n}_updateURL(o,n){if(this.mode==="hash"){const i=`#${o}`;n?location.replace(i):location.hash=o}else{const i=this.base+o+location.search;n?history.replaceState({},"",i):history.pushState({},"",i)}}async _renderRoute(o){o.parentPath&&o.parentPath!==""?await this._renderNestedRoute(o):await this._renderRootRoute(o)}async _renderRootRoute(o){const n=document.querySelector("[data-router-view]");if(!n||!o.component)return;this._cleanupContainerComponents(n),n.classList.add("router-view-leave"),n.classList.remove("router-view-enter"),await this._waitForAnimation(n);const i=await this._resolveComponent(o.component);if(!i)return;const a=document.createElement("div");a.setAttribute("data-component",i),a.classList.add("router-view-enter"),Object.keys(o.params).forEach(l=>{a.setAttribute(`data-prop-${l}`,o.params[l])}),n.innerHTML="",n.appendChild(a),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap(n),setTimeout(()=>{n.classList.remove("router-view-leave"),a.classList.remove("router-view-enter")},10)}async _renderNestedRoute(o){const n=this.routeMap.get(o.parentPath);if(!n)return;const i=document.querySelector("[data-router-view]");if(!i)return;if(document.querySelector(`[data-component="${n.component}"]`))await this._renderChildComponent(o);else{this._cleanupContainerComponents(i),i.classList.add("router-view-leave"),i.classList.remove("router-view-enter"),await this._waitForAnimation(i);const l=await this._resolveComponent(n.component);if(!l)return;const c=document.createElement("div");c.setAttribute("data-component",l),i.innerHTML="",i.appendChild(c),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap(i),setTimeout(()=>{i.classList.remove("router-view-leave")},50),await this._renderChildComponent(o)}}async _renderChildComponent(o){const n=document.querySelector(`[data-component="${this._getParentComponent(o.parentPath)}"]`);if(!n)return;const i=n.querySelector("[data-router-view]");if(!i||!o.component)return;const a=await this._resolveComponent(o.component);if(!a)return;const l=document.createElement("div");l.setAttribute("data-component",a),l.classList.add("router-view-enter"),Object.keys(o.params).forEach(c=>{l.setAttribute(`data-prop-${c}`,o.params[c])}),i.innerHTML="",i.appendChild(l),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap(i),setTimeout(()=>{l.classList.remove("router-view-enter")},10)}async _resolveComponent(o){if(typeof o=="function"){const n=o.toString();if(this.componentCache.has(n))return this.componentCache.get(n);try{const i=await o(),a=i.default||i,l=`lazy-${Math.random().toString(36).substr(2,9)}`;return window.kupolaRegistry&&window.kupolaRegistry.register(l,a),this.componentCache.set(n,l),l}catch(i){return console.error("Failed to load lazy component:",i),null}}if(typeof o=="string"&&o.startsWith("lazy:")){const n=o.slice(5);if(window.kupolaRegistry)try{await window.kupolaRegistry.getAsync(n)}catch(i){return console.error(`Failed to load lazy component ${n}:`,i),null}return n}return o}_getParentComponent(o){for(const[n,i]of this.routeMap)if(n===o)return i.component;return null}setAnimation(o){this.animationClass=o}push(o){this.navigate(o,!1)}replace(o){this.navigate(o,!0)}go(o){history.go(o)}back(){history.back()}forward(){history.forward()}beforeEach(o){this.beforeEachHandlers.push(o)}afterEach(o){this.afterEachHandlers.push(o)}_waitForAnimation(o){return new Promise(n=>{const i=this._getTransitionDuration(o);if(i>0){const a=()=>{o.removeEventListener("transitionend",a),o.removeEventListener("animationend",a),n()};o.addEventListener("transitionend",a),o.addEventListener("animationend",a),setTimeout(a,i+100)}else n()})}_getTransitionDuration(o){const n=window.getComputedStyle(o),i=parseFloat(n.transitionDuration)||0,a=parseFloat(n.animationDuration)||0;return Math.max(i,a)*1e3}_cleanupContainerComponents(o){o.querySelectorAll("[data-component]").forEach(i=>{const a=i.__kupolaInstance;a&&typeof a.unmount=="function"&&a.unmount().catch(l=>console.error("Error unmounting component:",l))}),window.kupolaInitializer&&o.querySelectorAll("[data-component], [data-dropdown], [data-select], [data-datepicker], [data-timepicker], [data-slider], [data-carousel], [data-drawer], [data-modal], [data-dialog], [data-color-picker], [data-calendar], [data-slide-captcha], [data-heatmap]").forEach(a=>{window.kupolaInitializer.cleanup(a)})}destroy(){this.mode==="hash"?window.removeEventListener("hashchange",this._routeHandler):window.removeEventListener("popstate",this._routeHandler),this.routes=[],this.routeMap.clear(),this.beforeEachHandlers=[],this.afterEachHandlers=[]}}function e(r){return new t(r)}s.exports?s.exports={KupolaRouter:t,createRouter:e}:(window.KupolaRouter=t,window.createRouter=e)}(R)),R.exports}Nt();var F={exports:{}},gt;function Bt(){return gt||(gt=1,function(s){class t{constructor(o={}){this.baseURL=o.baseURL||"",this.timeout=o.timeout||3e4,this.headers=o.headers||{},this.cache=new Map,this.cacheTTL=o.cacheTTL||6e4,this.maxRetries=o.maxRetries||0,this.retryDelay=o.retryDelay||1e3,this.activeRequests=new Map,this.withCredentials=o.withCredentials||!1,this._useAxios=typeof axios<"u",this._useAxios&&this._initAxios(o),o.interceptors&&(this.interceptors=o.interceptors)}_initAxios(o){this.axios=axios.create({baseURL:this.baseURL,timeout:this.timeout,headers:this.headers}),this.axios.defaults.withCredentials=o.withCredentials||!1}_generateCacheKey(o){const{url:n,method:i="GET",params:a={},data:l=null}=o,c=a?new URLSearchParams(a).toString():"",h=l?JSON.stringify(l):"";return`${i}:${n}:${c}:${h}`}_getCache(o){const n=this.cache.get(o);return n&&Date.now()-n.timestamp<this.cacheTTL?n.data:(this.cache.delete(o),null)}_setCache(o,n){this.cache.set(o,{data:n,timestamp:Date.now()})}async _requestWithRetry(o,n=0){try{return await this._request(o)}catch(i){if(n<this.maxRetries)return await new Promise(a=>setTimeout(a,this.retryDelay*Math.pow(2,n))),this._requestWithRetry(o,n+1);throw i}}async _request(o){const{url:n,method:i="GET",headers:a={},params:l={},data:c=null,timeout:h=this.timeout,cache:u=!1}=o,d=this._generateCacheKey({url:n,method:i,params:l,data:c});if(u&&i==="GET"){const m=this._getCache(d);if(m)return m}const p=new AbortController;this.activeRequests.set(d,p);const g={...this.headers,...a};!g["Content-Type"]&&c&&!(c instanceof FormData)&&(g["Content-Type"]="application/json");let f={url:this.baseURL?new URL(n,this.baseURL).toString():n,method:i,headers:g,signal:p.signal,credentials:this.withCredentials?"include":"same-origin"};if(Object.keys(l).length>0){const m=new URL(f.url);Object.keys(l).forEach(v=>{m.searchParams.append(v,l[v])}),f.url=m.toString()}if(c!==null&&(f.body=c instanceof FormData?c:JSON.stringify(c)),this.interceptors&&this.interceptors.request)try{const m=await this.interceptors.request(f);m&&(f=m)}catch(m){if(this.activeRequests.delete(d),this.interceptors.requestError)return this.interceptors.requestError(m);throw m}try{let m;if(this._useAxios){const y={url:f.url.replace(this.baseURL,""),method:f.method,headers:f.headers,signal:f.signal,timeout:h};c!==null&&(y.data=c),l&&Object.keys(l).length>0&&(y.params=l),m=await this.axios(y)}else if(m=await this._fetchWithTimeout(f,h),!m.ok){const y=new Error(`HTTP error! status: ${m.status}`);throw y.status=m.status,y.statusText=m.statusText,y}const v={data:this._useAxios?m.data:await this._parseResponse(m),status:(this._useAxios,m.status),statusText:(this._useAxios,m.statusText),headers:this._useAxios?m.headers:this._parseHeaders(m.headers),config:f};return this.interceptors&&this.interceptors.response?this.interceptors.response(v):(u&&i==="GET"&&this._setCache(d,v),v)}catch(m){if(m.name==="AbortError"||this._useAxios&&m.code==="ERR_CANCELED")return null;if(this.interceptors&&this.interceptors.responseError)return this.interceptors.responseError(m);throw m}finally{this.activeRequests.delete(d)}}async _fetchWithTimeout(o,n){const i=new AbortController,a=i.signal,l=new Promise((h,u)=>{const d=setTimeout(()=>{i.abort(),u(new Error("Request timeout"))},n);a.addEventListener("abort",()=>{clearTimeout(d)})}),c=fetch({...o,signal:a});return Promise.race([c,l])}async _parseResponse(o){const n=o.headers.get("content-type");return n&&n.includes("application/json")?o.json():o.text()}_parseHeaders(o){const n={};return o.forEach((i,a)=>{n[a]=i}),n}cancelRequest(o,n={},i="GET",a=null){const l=this._generateCacheKey({url:o,method:i,params:n,data:a});return this.activeRequests.has(l)?(this.activeRequests.get(l).abort(),this.activeRequests.delete(l),!0):!1}cancelAllRequests(){this.activeRequests.forEach(o=>{o.abort()}),this.activeRequests.clear()}clearCache(){this.cache.clear()}clearCacheByUrl(o){this.cache.forEach((n,i)=>{i.startsWith(`GET:${o}`)&&this.cache.delete(i)})}get(o,n={}){const i=n.cache??!0,a=n.retry??this.maxRetries>0,l={...n,url:o,method:"GET",cache:i};return a?this._requestWithRetry(l):this._request(l)}post(o,n=null,i={}){const a=i.retry??this.maxRetries>0,l={...i,url:o,method:"POST",data:n,cache:!1};return a?this._requestWithRetry(l):this._request(l)}async uploadFile(o,n,i={}){const{chunkSize:a=2*1024*1024,onProgress:l,headers:c={},parallel:h=!1}=i,u=Math.ceil(n.size/a);let d=0,p=0;const g=this._generateFileId(n);if(h){const f=[];for(let m=0;m<u;m++){const v=this._uploadChunk(o,n,m,u,a,g,c).then(()=>{d++,p=Math.round(d/u*100),l&&l({progress:p,uploaded:d*a,total:n.size,currentChunk:d,totalChunks:u})});f.push(v)}return await Promise.all(f),this._completeUpload(o,g,u,n.name)}for(let f=0;f<u;f++)await this._uploadChunk(o,n,f,u,a,g,c),d++,p=Math.round(d/u*100),l&&l({progress:p,uploaded:d*a,total:n.size,currentChunk:f+1,totalChunks:u});return this._completeUpload(o,g,u,n.name)}async _uploadChunk(o,n,i,a,l,c,h){const u=i*l,d=Math.min(u+l,n.size),p=n.slice(u,d),g=new FormData;return g.append("chunk",p),g.append("chunkIndex",i),g.append("totalChunks",a),g.append("fileId",c),g.append("fileName",n.name),g.append("fileSize",n.size),this.post(`${o}/chunk`,g,{headers:h})}async _completeUpload(o,n,i,a){return this.post(`${o}/complete`,{fileId:n,totalChunks:i,fileName:a})}_generateFileId(o){const n=`${o.name}-${o.size}-${o.lastModified}`;let i=0;for(let a=0;a<n.length;a++)i=(i<<5)-i+n.charCodeAt(a),i|=0;return Math.abs(i).toString(36)+Date.now().toString(36)}put(o,n=null,i={}){const a=i.retry??this.maxRetries>0,l={...i,url:o,method:"PUT",data:n,cache:!1};return a?this._requestWithRetry(l):this._request(l)}delete(o,n={}){const i=n.retry??this.maxRetries>0,a={...n,url:o,method:"DELETE",cache:!1};return i?this._requestWithRetry(a):this._request(a)}patch(o,n=null,i={}){const a=i.retry??this.maxRetries>0,l={...i,url:o,method:"PATCH",data:n,cache:!1};return a?this._requestWithRetry(l):this._request(l)}setHeader(o,n){this.headers[o]=n,this.axios&&(this.axios.defaults.headers.common[o]=n)}setToken(o,n="Bearer"){this.headers.Authorization=`${n} ${o}`,this.axios&&(this.axios.defaults.headers.common.Authorization=`${n} ${o}`)}setCacheTTL(o){this.cacheTTL=o}setMaxRetries(o){this.maxRetries=o}}function e(r){return new t(r)}s.exports?s.exports={KupolaHttp:t,createHttp:e}:(window.KupolaHttp=t,window.createHttp=e)}(F)),F.exports}Bt();var O={exports:{}},yt;function Rs(){return yt||(yt=1,function(s){class t{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet}register(o,n,i=null){this.initializers.set(o,n),i&&this.cleanupFunctions.set(o,i)}unregister(o){this.initializers.delete(o),this.cleanupFunctions.delete(o)}has(o){return this.initializers.has(o)}get(o){return this.initializers.get(o)}async initialize(o){if(this.processedElements.has(o))return;const n=["data-component","data-dropdown","data-select","data-datepicker","data-timepicker","data-slider","data-carousel","data-drawer","data-modal","data-dialog","data-color-picker","data-calendar","data-slide-captcha","data-heatmap"];for(const l of n){const c=o.getAttribute(l);if(c){const h=c||l.replace("data-",""),u=this.initializers.get(h)||this.initializers.get(l.replace("data-",""));if(u){try{await u(o),this.processedElements.add(o)}catch(d){console.error(`[ComponentInitializerRegistry] Error initializing "${h}":`,d)}return}}}const i=o.className,a=[".ds-dropdown",".ds-select",".ds-datepicker",".ds-timepicker",".ds-slider",".ds-carousel",".ds-drawer",".ds-modal",".ds-dialog",".ds-color-picker",".ds-calendar",".ds-slider-captcha",".ds-heatmap",".ds-tooltip",".ds-tag",".ds-statcard",".ds-collapse",".ds-fileupload",".ds-notification",".ds-message"];for(const l of a){const c=l.replace(".","");if(i.includes(c)){const h=c.replace("ds-",""),u=this.initializers.get(h)||this.initializers.get(c);if(u){try{await u(o),this.processedElements.add(o)}catch(d){console.error(`[ComponentInitializerRegistry] Error initializing "${h}":`,d)}return}}}}cleanup(o){const n=["data-component","data-dropdown","data-select","data-datepicker","data-timepicker","data-slider","data-carousel","data-drawer","data-modal","data-dialog","data-color-picker","data-calendar","data-slide-captcha","data-heatmap"];for(const l of n){const c=o.getAttribute(l);if(c){const h=c||l.replace("data-",""),u=this.cleanupFunctions.get(h)||this.cleanupFunctions.get(l.replace("data-",""));if(u){try{u(o)}catch(d){console.error(`[ComponentInitializerRegistry] Error cleaning up "${h}":`,d)}this.processedElements.delete(o);return}}}const i=o.className,a=[".ds-dropdown",".ds-select",".ds-datepicker",".ds-timepicker",".ds-slider",".ds-carousel",".ds-drawer",".ds-modal",".ds-dialog",".ds-color-picker",".ds-calendar",".ds-slider-captcha",".ds-heatmap",".ds-tooltip",".ds-tag",".ds-statcard",".ds-collapse",".ds-fileupload",".ds-notification",".ds-message"];for(const l of a){const c=l.replace(".","");if(i.includes(c)){const h=c.replace("ds-",""),u=this.cleanupFunctions.get(h)||this.cleanupFunctions.get(c);if(u){try{u(o)}catch(d){console.error(`[ComponentInitializerRegistry] Error cleaning up "${h}":`,d)}this.processedElements.delete(o);return}}}}async initializeAll(o=document){const n=o.querySelectorAll("[data-component], [data-dropdown], [data-select], [data-datepicker], [data-timepicker], [data-slider], [data-carousel], [data-drawer], [data-modal], [data-dialog], [data-color-picker], [data-calendar], [data-slide-captcha], [data-heatmap], .ds-dropdown, .ds-select, .ds-datepicker, .ds-timepicker, .ds-slider, .ds-carousel, .ds-drawer, .ds-modal, .ds-dialog, .ds-color-picker, .ds-calendar, .ds-slider-captcha, .ds-heatmap, .ds-tooltip, .ds-tag, .ds-statcard, .ds-collapse, .ds-fileupload, .ds-notification, .ds-message"),i=[];n.forEach(a=>{this.processedElements.has(a)||i.push(this.initialize(a))}),await Promise.all(i)}}const e=new t;s.exports?s.exports={ComponentInitializerRegistry:t,kupolaInitializer:e}:(window.ComponentInitializerRegistry=t,window.kupolaInitializer=e)}(O)),O.exports}Rs();var N={exports:{}},vt;function Fs(){if(vt)return N.exports;if(vt=1,typeof window>"u"){const{KupolaComponent:t,applyMixin:e}=Ft(),{KupolaComponentRegistry:r}=Ot(),{KupolaRouter:o,createRouter:n}=Nt(),{KupolaHttp:i,createHttp:a}=Bt();N.exports={KupolaComponent:t,applyMixin:e,KupolaComponentRegistry:r,KupolaRouter:o,KupolaHttp:i,createRouter:n,createHttp:a}}window.KupolaComponentRegistry&&(window.kupolaRegistry=new window.KupolaComponentRegistry);async function s(){window.kupolaData&&window.kupolaData.loadPersisted(),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap()}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s):setTimeout(s,0),window.registerComponent=function(t,e){window.kupolaRegistry&&window.kupolaRegistry.register(t,e)},window.registerLazyComponent=function(t,e){window.kupolaRegistry&&window.kupolaRegistry.registerLazy(t,e)},window.bootstrapComponents=function(t){return window.kupolaRegistry?window.kupolaRegistry.bootstrap(t):Promise.resolve()},window.defineMixin=function(t,e){window.kupolaRegistry&&window.kupolaRegistry.defineMixin(t,e)},window.useMixin=function(t,...e){window.kupolaRegistry&&window.kupolaRegistry.useMixin(t,...e)},N.exports}Fs();let q=class{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(r=>{r.resolved=!1})}on(t,e,r={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const o=this.hooks.get(t);return o.push({handler:e,priority:r.priority||0,depends:r.depends||[],name:r.name||e.name||`anonymous_${o.length}`}),o.sort((n,i)=>i.priority-n.priority),()=>{const n=o.findIndex(i=>i.handler===e);n>-1&&o.splice(n,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const r of t){const n=this.hooks.get(e).find(i=>i.name===r);n&&!n.resolved&&(await n.handler(),n.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const r=this.hooks.get(t);if(!r||r.length===0)return;const o=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(o);const n=performance.now();try{for(const a of r){await this._resolveDepends(a.depends,t);const l=performance.now();let c,h;try{c=a.handler(...e),c instanceof Promise&&await c,a.resolved=!0}catch(d){h=d,console.error(`[KupolaLifecycle] Error in ${t} hook "${a.name}":`,d),t!=="error"&&await this._handleError({phase:t,hook:a.name,error:d,args:e})}const u=performance.now()-l;this.trace.push({emitId:o,phase:t,hookName:a.name,duration:u,status:h?"error":"success",error:h?h.message:null,timestamp:Date.now()})}const i=performance.now()-n;console.debug(`[KupolaLifecycle] ${t} completed in ${i.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(o)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const r=this.phaseStateMap[t];if(r){if(Array.isArray(r.from)){if(!r.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${r.from.join(", ")}`)}else if(this.state!==r.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${r.from}`)}const o=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,n=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(o),this._resetResolved(t),this._resetResolved(n),this.allPhases.includes(o)&&await this.emit(o,...e),await this.emit(t,...e),r&&this._updateState(r.to),this.allPhases.includes(n)&&await this.emit(n,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(r){console.error("[KupolaLifecycle] Error in onError callback:",r)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const r of e)try{const o=r.handler(t);if(o instanceof Promise&&await o,o==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${r.name}"`);return}}catch(o){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${r.name}":`,o)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}},Kt=class{constructor(){this.plugins=new Map,this.enabledPlugins=new Set,this.pluginHooks=new Map}register(t,e){this.plugins.has(t)&&console.warn(`Plugin ${t} already registered, overriding`),this.plugins.set(t,{...e,name:t,enabled:!1,instance:null,lifecycle:new q(`plugin:${t}`)})}async enable(t){const e=this.plugins.get(t);if(!e)throw new Error(`Plugin ${t} not found`);if(!e.enabled)try{await e.lifecycle.bootstrap(),e.install&&(e.instance=await e.install()),e.enabled=!0,this.enabledPlugins.add(t),await e.lifecycle.mount(),e.hooks&&this._registerPluginHooks(t,e.hooks),console.log(`Plugin ${t} enabled`)}catch(r){throw console.error(`Failed to enable plugin ${t}:`,r),r}}async disable(t){const e=this.plugins.get(t);if(!(!e||!e.enabled))try{await e.lifecycle.unmount(),e.uninstall&&await e.uninstall(e.instance),e.hooks&&this._unregisterPluginHooks(t),e.enabled=!1,this.enabledPlugins.delete(t),e.instance=null,await e.lifecycle.destroy(),console.log(`Plugin ${t} disabled`)}catch(r){throw console.error(`Failed to disable plugin ${t}:`,r),r}}get(t){return this.plugins.get(t)?.instance||null}getAll(){const t={};return this.plugins.forEach((e,r)=>{t[r]={name:e.name,enabled:e.enabled,instance:e.instance,state:e.lifecycle.getState()}}),t}getEnabled(){const t={};return this.enabledPlugins.forEach(e=>{const r=this.plugins.get(e);r&&(t[e]=r.instance)}),t}async enableAll(){const t=[];this.plugins.forEach((e,r)=>{t.push(this.enable(r))}),await Promise.all(t)}async disableAll(){const t=[];this.enabledPlugins.forEach(e=>{t.push(this.disable(e))}),await Promise.all(t)}_registerPluginHooks(t,e){this.pluginHooks.has(t)||this.pluginHooks.set(t,[]);const r=this.pluginHooks.get(t);Object.keys(e).forEach(o=>{const n=window.kupolaLifecycle?.on(o,e[o],{name:`${t}:${o}`});n&&r.push({phase:o,unsubscribe:n})})}_unregisterPluginHooks(t){const e=this.pluginHooks.get(t);e&&(e.forEach(({unsubscribe:r})=>{r&&r()}),this.pluginHooks.delete(t))}};const Os=new q("app"),Ns=new Kt;function Bs(s="app"){return new q(s)}window.KupolaLifecycle=q;window.KupolaPluginManager=Kt;window.kupolaLifecycle=Os;window.kupolaPluginManager=Ns;window.createLifecycle=Bs;const Ut={string:{trim(s){return s?s.trim():""},trimLeft(s){return s?s.replace(/^\s+/,""):""},trimRight(s){return s?s.replace(/\s+$/,""):""},toUpperCase(s){return s?s.toUpperCase():""},toLowerCase(s){return s?s.toLowerCase():""},capitalize(s){return s?s.charAt(0).toUpperCase()+s.slice(1):""},camelize(s){return s?s.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""},hyphenate(s){return s?s.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart(s,t,e=" "){return(String(s)||"").padStart(t,e)},padEnd(s,t,e=" "){return(String(s)||"").padEnd(t,e)},truncate(s,t,e="..."){return!s||s.length<=t?s||"":s.slice(0,t)+e},replaceAll(s,t,e){return s?s.split(t).join(e):""},format(s,t){return s?s.replace(/\{\{(\w+)\}\}/g,(e,r)=>t[r]!==void 0?t[r]:`{{${r}}}`):""},startsWith(s,t){return(s||"").startsWith(t)},endsWith(s,t){return(s||"").endsWith(t)},includes(s,t){return(s||"").includes(t)},repeat(s,t){return(s||"").repeat(t)},reverse(s){return(s||"").split("").reverse().join("")},countOccurrences(s,t){return!s||!t?0:s.split(t).length-1},escapeHtml(s){if(!s)return"";const t=document.createElement("div");return t.textContent=s,t.innerHTML},unescapeHtml(s){if(!s)return"";const t=document.createElement("div");return t.innerHTML=s,t.textContent},generateRandom(s=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let r=0;r<s;r++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}},array:{isArray(s){return Array.isArray(s)},isEmpty(s){return!s||s.length===0},size(s){return s?s.length:0},first(s,t){return s&&s.length>0?s[0]:t},last(s,t){return s&&s.length>0?s[s.length-1]:t},get(s,t,e){return s&&s[t]!==void 0?s[t]:e},slice(s,t,e){return s?s.slice(t,e):[]},concat(...s){return s.reduce((t,e)=>t.concat(e||[]),[])},join(s,t=","){return s?s.join(t):""},indexOf(s,t,e=0){return s?s.indexOf(t,e):-1},lastIndexOf(s,t,e){return s?s.lastIndexOf(t,e):-1},includes(s,t){return s?s.includes(t):!1},push(s,...t){return s&&s.push(...t),s},pop(s){return s?s.pop():void 0},shift(s){return s?s.shift():void 0},unshift(s,...t){return s&&s.unshift(...t),s},remove(s,t){if(!s)return s;const e=s.indexOf(t);return e>-1&&s.splice(e,1),s},removeAt(s,t){return!s||t<0||t>=s.length||s.splice(t,1),s},insert(s,t,e){return s&&(s.splice(t,0,e),s)},reverse(s){return s?s.slice().reverse():[]},sort(s,t){return s?s.slice().sort(t):[]},sortBy(s,t,e="asc"){return s?s.slice().sort((r,o)=>{const n=typeof r=="object"?r[t]:r,i=typeof o=="object"?o[t]:o;return n<i?e==="asc"?-1:1:n>i?e==="asc"?1:-1:0}):[]},filter(s,t){return s?s.filter(t):[]},map(s,t){return s?s.map(t):[]},reduce(s,t,e){return s?s.reduce(t,e):e},forEach(s,t){s&&s.forEach(t)},every(s,t){return s?s.every(t):!0},some(s,t){return s?s.some(t):!1},find(s,t){return s?s.find(t):void 0},findIndex(s,t){return s?s.findIndex(t):-1},flat(s,t=1){return s?s.flat(t):[]},flattenDeep(s){return s?s.reduce((t,e)=>Array.isArray(e)?t.concat(this.flattenDeep(e)):t.concat(e),[]):[]},unique(s){return s?[...new Set(s)]:[]},uniqueBy(s,t){if(!s)return[];const e=new Set;return s.filter(r=>{const o=typeof r=="object"?r[t]:r;return e.has(o)?!1:(e.add(o),!0)})},chunk(s,t){if(!s||t<=0)return[];const e=[];for(let r=0;r<s.length;r+=t)e.push(s.slice(r,r+t));return e},shuffle(s){if(!s)return[];const t=s.slice();for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t},sum(s){return s?s.reduce((t,e)=>t+(Number(e)||0),0):0},average(s){return!s||s.length===0?0:this.sum(s)/s.length},max(s){return s&&s.length>0?Math.max(...s):-1/0},min(s){return s&&s.length>0?Math.min(...s):1/0},intersection(...s){return s.length===0?[]:s.reduce((t,e)=>t.filter(r=>e&&e.includes(r)))},union(...s){return[...new Set(s.flat().filter(Boolean))]},difference(s,t){return s?s.filter(e=>!t||!t.includes(e)):[]},zip(...s){if(s.length===0)return[];const t=Math.max(...s.map(e=>e?e.length:0));return Array.from({length:t},(e,r)=>s.map(o=>o&&o[r]))}},object:{isObject(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)},isEmpty(s){return!s||typeof s!="object"?!0:Object.keys(s).length===0},keys(s){return s?Object.keys(s):[]},values(s){return s?Object.values(s):[]},entries(s){return s?Object.entries(s):[]},has(s,t){return s?Object.prototype.hasOwnProperty.call(s,t):!1},get(s,t,e){return s&&t.split(".").reduce((o,n)=>o&&o[n],s)||e},set(s,t,e){if(!s||typeof s!="object")return s;const r=t.split("."),o=r.pop();let n=s;return r.forEach(i=>{n[i]||(n[i]={}),n=n[i]}),n[o]=e,s},pick(s,t){return s?t.reduce((e,r)=>(s[r]!==void 0&&(e[r]=s[r]),e),{}):{}},omit(s,t){return s?Object.keys(s).reduce((e,r)=>(t.includes(r)||(e[r]=s[r]),e),{}):{}},merge(...s){return s.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(r=>{this.isObject(e[r])&&this.isObject(t[r])?t[r]=this.merge(t[r],e[r]):t[r]=e[r]}),t),{})},clone(s){return s&&JSON.parse(JSON.stringify(s))},deepClone(s,t=new WeakMap){if(!s||typeof s!="object")return s;if(t.has(s))return t.get(s);if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const r=new Map;return t.set(s,r),s.forEach((o,n)=>r.set(n,this.deepClone(o,t))),r}if(s instanceof Set){const r=new Set;return t.set(s,r),s.forEach(o=>r.add(this.deepClone(o,t))),r}if(Array.isArray(s)){const r=[];return t.set(s,r),s.forEach(o=>r.push(this.deepClone(o,t))),r}const e={};return t.set(s,e),Object.keys(s).forEach(r=>{e[r]=this.deepClone(s[r],t)}),e},forEach(s,t){s&&Object.keys(s).forEach(e=>t(s[e],e,s))},map(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(r=>{e[r]=t(s[r],r,s)}),e},filter(s,t){if(!s)return{};const e={};return Object.keys(s).forEach(r=>{t(s[r],r,s)&&(e[r]=s[r])}),e},reduce(s,t,e){return s?Object.keys(s).reduce((r,o)=>t(r,s[o],o,s),e):e},toArray(s){return s?Object.keys(s).map(t=>({key:t,value:s[t]})):[]},fromArray(s,t,e){return s?s.reduce((r,o)=>{const n=typeof o=="object"?o[t]:o,i=e?o[e]:o;return n!==void 0&&(r[n]=i),r},{}):{}},size(s){return s?Object.keys(s).length:0},invert(s){if(!s)return{};const t={};return Object.keys(s).forEach(e=>{t[s[e]]=e}),t},isEqual(s,t){if(s===t)return!0;if(!s||!t||typeof s!="object"||typeof t!="object")return!1;const e=Object.keys(s),r=Object.keys(t);return e.length!==r.length?!1:e.every(o=>this.isEqual(s[o],t[o]))},freeze(s){return s&&(Object.freeze(s),Object.keys(s).forEach(t=>{typeof s[t]=="object"&&this.freeze(s[t])}),s)},seal(s){return s&&Object.seal(s)}},number:{isNumber(s){return typeof s=="number"&&!isNaN(s)},isInteger(s){return Number.isInteger(s)},isFloat(s){return this.isNumber(s)&&!Number.isInteger(s)},isPositive(s){return this.isNumber(s)&&s>0},isNegative(s){return this.isNumber(s)&&s<0},isZero(s){return this.isNumber(s)&&s===0},clamp(s,t,e){return this.isNumber(s)?Math.min(Math.max(s,t),e):s},round(s,t=0){if(!this.isNumber(s))return s;const e=Math.pow(10,t);return Math.round(s*e)/e},floor(s){return this.isNumber(s)?Math.floor(s):s},ceil(s){return this.isNumber(s)?Math.ceil(s):s},abs(s){return this.isNumber(s)?Math.abs(s):s},min(...s){const t=s.filter(this.isNumber);return t.length>0?Math.min(...t):void 0},max(...s){const t=s.filter(this.isNumber);return t.length>0?Math.max(...t):void 0},sum(...s){return s.flat().filter(this.isNumber).reduce((e,r)=>e+r,0)},average(...s){const t=s.flat().filter(this.isNumber);return t.length>0?this.sum(t)/t.length:0},random(s=0,t=1){return Math.random()*(t-s)+s},randomInt(s,t){return Math.floor(this.random(s,t+1))},format(s,t=2){return this.isNumber(s)?s.toFixed(t):String(s)},formatCurrency(s,t="CNY",e=2){return this.isNumber(s)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(s):String(s)},formatPercent(s,t=0){return this.isNumber(s)?`${(s*100).toFixed(t)}%`:String(s)},toFixed(s,t=0){return this.isNumber(s)?s.toFixed(t):String(s)},toPrecision(s,t=6){return this.isNumber(s)?s.toPrecision(t):String(s)},isNaN(s){return Number.isNaN(s)},isFinite(s){return Number.isFinite(s)},parseInt(s,t=10){return Number.parseInt(s,t)},parseFloat(s){return Number.parseFloat(s)},toNumber(s,t=0){const e=Number(s);return isNaN(e)?t:e},safeDivide(s,t,e=0){return!this.isNumber(s)||!this.isNumber(t)||t===0?e:s/t},safeMultiply(...s){return s.reduce((t,e)=>!this.isNumber(t)||!this.isNumber(e)?0:t*e,1)}},date:{now(){return Date.now()},today(){const s=new Date;return s.setHours(0,0,0,0),s},tomorrow(){const s=this.today();return s.setDate(s.getDate()+1),s},yesterday(){const s=this.today();return s.setDate(s.getDate()-1),s},isDate(s){return s instanceof Date&&!isNaN(s.getTime())},isValid(s){return this.isDate(s)},parse(s){const t=new Date(s);return this.isValid(t)?t:null},format(s,t="YYYY-MM-DD HH:mm:ss"){if(!this.isDate(s))return"";const e=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),o=String(s.getDate()).padStart(2,"0"),n=String(s.getHours()).padStart(2,"0"),i=String(s.getMinutes()).padStart(2,"0"),a=String(s.getSeconds()).padStart(2,"0"),l=String(s.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][s.getDay()];return t.replace("YYYY",e).replace("MM",r).replace("DD",o).replace("HH",n).replace("mm",i).replace("ss",a).replace("SSS",l).replace("D",s.getDate()).replace("M",s.getMonth()+1).replace("H",s.getHours()).replace("m",s.getMinutes()).replace("s",s.getSeconds()).replace("W",h)},toISO(s){return this.isDate(s)?s.toISOString():""},toUTC(s){return this.isDate(s)?new Date(s.toUTCString()):null},addDays(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setDate(e.getDate()+t),e},addHours(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setHours(e.getHours()+t),e},addMinutes(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setMinutes(e.getMinutes()+t),e},addSeconds(s,t){if(!this.isDate(s))return s;const e=new Date(s);return e.setSeconds(e.getSeconds()+t),e},diffDays(s,t){if(!this.isDate(s)||!this.isDate(t))return 0;const e=this.today(),r=this.today();return e.setTime(s.getTime()),r.setTime(t.getTime()),Math.floor((e.getTime()-r.getTime())/(1e3*60*60*24))},diffHours(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60*60))},diffMinutes(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/(1e3*60))},diffSeconds(s,t){return!this.isDate(s)||!this.isDate(t)?0:Math.floor((s.getTime()-t.getTime())/1e3)},isToday(s){return this.isDate(s)?this.diffDays(s,this.today())===0:!1},isYesterday(s){return this.isDate(s)?this.diffDays(s,this.today())===-1:!1},isTomorrow(s){return this.isDate(s)?this.diffDays(s,this.today())===1:!1},isFuture(s){return this.isDate(s)?s.getTime()>this.now():!1},isPast(s){return this.isDate(s)?s.getTime()<this.now():!1},isLeapYear(s){if(!this.isDate(s))return!1;const t=s.getFullYear();return t%4===0&&(t%100!==0||t%400===0)},getDaysInMonth(s){if(!this.isDate(s))return 0;const t=s.getFullYear(),e=s.getMonth();return new Date(t,e+1,0).getDate()},getWeekOfYear(s){if(!this.isDate(s))return 0;const t=new Date(s.getFullYear(),0,1),e=s.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))},getQuarter(s){return this.isDate(s)?Math.ceil((s.getMonth()+1)/3):0},startOfDay(s){if(!this.isDate(s))return s;const t=new Date(s);return t.setHours(0,0,0,0),t},endOfDay(s){if(!this.isDate(s))return s;const t=new Date(s);return t.setHours(23,59,59,999),t},startOfMonth(s){return this.isDate(s)?new Date(s.getFullYear(),s.getMonth(),1):s},endOfMonth(s){return this.isDate(s)?new Date(s.getFullYear(),s.getMonth()+1,0,23,59,59,999):s},startOfWeek(s,t=1){if(!this.isDate(s))return s;const e=new Date(s),r=e.getDay(),o=r>=t?r-t:r+(7-t);return e.setDate(e.getDate()-o),e.setHours(0,0,0,0),e},endOfWeek(s,t=1){if(!this.isDate(s))return s;const e=this.startOfWeek(s,t),r=new Date(e);return r.setDate(r.getDate()+6),r.setHours(23,59,59,999),r},getAge(s){if(!this.isDate(s))return 0;const t=new Date;let e=t.getFullYear()-s.getFullYear();return(t.getMonth()<s.getMonth()||t.getMonth()===s.getMonth()&&t.getDate()<s.getDate())&&e--,Math.max(0,e)},fromNow(s){if(!this.isDate(s))return"";const e=this.now()-s.getTime(),r=60*1e3,o=60*r,n=24*o,i=7*n,a=30*n,l=365*n;return e<r?"刚刚":e<o?`${Math.floor(e/r)}分钟前`:e<n?`${Math.floor(e/o)}小时前`:e<i?`${Math.floor(e/n)}天前`:e<a?`${Math.floor(e/i)}周前`:e<l?`${Math.floor(e/a)}个月前`:`${Math.floor(e/l)}年前`}},debounce(s,t,e={}){let r=null,o=null,n=null,i=0;const a=e.leading||!1,l=e.trailing!==!1;function c(){s.apply(n,o)}function h(){i=Date.now(),a?(r=setTimeout(u,t),c()):r=setTimeout(u,t)}function u(){r=null,l&&o&&c(),o=null,n=null}function d(){const p=Date.now()-i;return Math.max(0,t-p)}return function(...p){o=p,n=this,i=Date.now(),r?(clearTimeout(r),r=setTimeout(u,d())):h()}},throttle(s,t,e={}){let r=!1;const o=e.trailing||!1;let n=null,i=null;function a(){s.apply(i,n),n=null,i=null}return function(...l){r?o&&(n=l,i=this):(r=!0,n=l,i=this,a(),setTimeout(()=>{r=!1,o&&n&&a()},t))}},validator:{isEmail(s){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s||"")},isPhone(s){return/^1[3-9]\d{9}$/.test(s||"")},isURL(s){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(s||"")},isIPv4(s){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(s||"")},isIPv6(s){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(s||"")},isIP(s){return this.isIPv4(s)||this.isIPv6(s)},isIDCard(s){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(s||"")},isPassport(s){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(s||"")},isCreditCard(s){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=s.replace(/\s/g,"");if(!t.test(e))return!1;let r=0,o=!1;for(let n=e.length-1;n>=0;n--){let i=parseInt(e[n],10);o&&(i*=2,i>9&&(i-=9)),r+=i,o=!o}return r%10===0},isHexColor(s){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(s||"")},isRGB(s){const e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s||"");return e?e.slice(1).every(r=>parseInt(r)>=0&&parseInt(r)<=255):!1},isRGBA(s){const e=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(s||"");if(!e)return!1;const[,r,o,n,i]=e;return parseInt(r)>=0&&parseInt(r)<=255&&parseInt(o)>=0&&parseInt(o)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(i)>=0&&parseFloat(i)<=1},isColor(s){return this.isHexColor(s)||this.isRGB(s)||this.isRGBA(s)},isDate(s){return!isNaN(new Date(s).getTime())},isJSON(s){try{return JSON.parse(s),!0}catch{return!1}},isEmpty(s){return!s||s.trim()===""},isWhitespace(s){return/^\s+$/.test(s||"")},isNumber(s){return!isNaN(parseFloat(s))&&isFinite(s)},isInteger(s){return/^-?\d+$/.test(s||"")},isFloat(s){return/^-?\d+\.\d+$/.test(s||"")},isPositive(s){const t=parseFloat(s);return!isNaN(t)&&t>0},isNegative(s){const t=parseFloat(s);return!isNaN(t)&&t<0},isAlpha(s){return/^[a-zA-Z]+$/.test(s||"")},isAlphaNumeric(s){return/^[a-zA-Z0-9]+$/.test(s||"")},isChinese(s){return/^[\u4e00-\u9fa5]+$/.test(s||"")},isLength(s,t,e){const r=(s||"").length;return r>=t&&(e===void 0||r<=e)},minLength(s,t){return(s||"").length>=t},maxLength(s,t){return(s||"").length<=t},matches(s,t){return t instanceof RegExp?t.test(s||""):!1},equals(s,t){return String(s)===String(t)},contains(s,t){return(s||"").includes(t)},notContains(s,t){return!this.contains(s,t)},isArray(s){return Array.isArray(s)},arrayLength(s,t,e){const r=s?s.length:0;return r>=t&&(e===void 0||r<=e)},arrayMinLength(s,t){return s?s.length>=t:!1},arrayMaxLength(s,t){return s?s.length<=t:!1},isObject(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)},hasKeys(s,t){return!s||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(s,e))},validate(s,t){const e={};return Object.keys(t).forEach(r=>{const o=s[r],n=t[r],i=[];n.forEach(a=>{if(typeof a=="string"){const[l,...c]=a.split(":");this[l](o,...c)||i.push(l)}else if(typeof a=="function"){const l=a(o,s);l!==!0&&i.push(l||"validation_failed")}}),i.length>0&&(e[r]=i)}),{valid:Object.keys(e).length===0,errors:e}}},crypto:{md5(s){const t=s?String(s):"",e=[1732584193,4023233417,2562383102,271733878],r=[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],o=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(u,d){return u<<d|u>>>32-d}function i(u){const d=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const p=d&4294967295,g=d>>>32&4294967295;for(let f=0;f<4;f++)u+=String.fromCharCode(p>>>8*f&255);for(let f=0;f<4;f++)u+=String.fromCharCode(g>>>8*f&255);return u}function a(u,d){const[p,g,f,m]=d,v=[];for(let k=0;k<16;k++)v[k]=u.charCodeAt(k*4)&255|(u.charCodeAt(k*4+1)&255)<<8|(u.charCodeAt(k*4+2)&255)<<16|(u.charCodeAt(k*4+3)&255)<<24;let y=p,w=g,_=f,b=m;for(let k=0;k<64;k++){let S,E;const C=Math.floor(k/16),L=k%16;C===0?(S=w&_|~w&b,E=L):C===1?(S=b&w|~b&_,E=(5*L+1)%16):C===2?(S=w^_^b,E=(3*L+5)%16):(S=_^(w|~b),E=7*L%16);const D=b;b=_,_=w,w=w+n(y+S+r[k]+v[E]&4294967295,o[C][k%4]),y=D}return[p+y&4294967295,g+w&4294967295,f+_&4294967295,m+b&4294967295]}const l=i(t);let c=[...e];for(let u=0;u<l.length;u+=64)c=a(l.substring(u,u+64),c);let h="";return c.forEach(u=>{for(let d=0;d<4;d++)h+=(u>>>8*d&255).toString(16).padStart(2,"0")}),h},sha256(s){const t=s?String(s):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function r(c,h){return c>>>h|c<<32-h}function o(c){const h=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=h&4294967295,d=h>>>32&4294967295;for(let p=0;p<4;p++)c+=String.fromCharCode(d>>>8*p&255);for(let p=0;p<4;p++)c+=String.fromCharCode(u>>>8*p&255);return c}function n(c,h){const u=[];for(let _=0;_<16;_++)u[_]=c.charCodeAt(_*4)&255|(c.charCodeAt(_*4+1)&255)<<8|(c.charCodeAt(_*4+2)&255)<<16|(c.charCodeAt(_*4+3)&255)<<24;for(let _=16;_<64;_++){const b=r(u[_-15],7)^r(u[_-15],18)^u[_-15]>>>3,k=r(u[_-2],17)^r(u[_-2],19)^u[_-2]>>>10;u[_]=u[_-16]+b+u[_-7]+k&4294967295}let[d,p,g,f,m,v,y,w]=h;for(let _=0;_<64;_++){const b=r(m,6)^r(m,11)^r(m,25),k=m&v^~m&y,S=w+b+k+e[_]+u[_]&4294967295,E=r(d,2)^r(d,13)^r(d,22),C=d&p^d&g^p&g,L=E+C&4294967295;w=y,y=v,v=m,m=f+S&4294967295,f=g,g=p,p=d,d=S+L&4294967295}return[h[0]+d&4294967295,h[1]+p&4294967295,h[2]+g&4294967295,h[3]+f&4294967295,h[4]+m&4294967295,h[5]+v&4294967295,h[6]+y&4294967295,h[7]+w&4294967295]}const i=o(t);let a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<i.length;c+=64)a=n(i.substring(c,c+64),a);let l="";return a.forEach(c=>{for(let h=3;h>=0;h--)l+=(c>>>8*h&255).toString(16).padStart(2,"0")}),l},base64Encode(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",r=0;const o=s?s.split("").map(n=>n.charCodeAt(0)):[];for(;r<o.length;){const n=o[r++],i=o[r++]||0,a=o[r++]||0,l=n>>2,c=(n&3)<<4|i>>4,h=(i&15)<<2|a>>6,u=a&63;e+=t[l]+t[c]+(r>o.length+1?"=":t[h])+(r>o.length?"=":t[u])}return e},base64Decode(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",r=0;for(s=s.replace(/[^A-Za-z0-9+/=]/g,"");r<s.length;){const o=t.indexOf(s.charAt(r++)),n=t.indexOf(s.charAt(r++)),i=t.indexOf(s.charAt(r++)),a=t.indexOf(s.charAt(r++)),l=o<<2|n>>4,c=(n&15)<<4|i>>2,h=(i&3)<<6|a;e+=String.fromCharCode(l),i!==64&&(e+=String.fromCharCode(c)),a!==64&&(e+=String.fromCharCode(h))}return e},uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}},preload:{cache:new Map,async loadImage(s,t={}){const{crossOrigin:e="anonymous"}=t;return this.cache.has(s)?this.cache.get(s):new Promise((r,o)=>{const n=new Image;n.crossOrigin=e,n.onload=()=>{this.cache.set(s,n),r(n)},n.onerror=()=>{o(new Error(`Failed to load image: ${s}`))},n.src=s})},async loadImages(s,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(s.map(o=>this.loadImage(o,t)));const r=[];for(const o of s)r.push(await this.loadImage(o,t));return r},async loadScript(s,t={}){const{type:e="text/javascript",async:r=!0,defer:o=!1}=t;return this.cache.has(s)?this.cache.get(s):new Promise((n,i)=>{const a=document.createElement("script");a.type=e,a.async=r,a.defer=o,a.onload=()=>{this.cache.set(s,a),n(a)},a.onerror=()=>{a.remove(),i(new Error(`Failed to load script: ${s}`))},a.src=s,document.head.appendChild(a)})},async loadStylesheet(s,t={}){const{media:e="all"}=t;return this.cache.has(s)?this.cache.get(s):new Promise((r,o)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=s,n.media=e,n.onload=()=>{this.cache.set(s,n),r(n)},n.onerror=()=>{n.remove(),o(new Error(`Failed to load stylesheet: ${s}`))},document.head.appendChild(n)})},async loadFont(s,t,e={}){const{weight:r="normal",style:o="normal"}=e,n=new FontFace(s,`url(${t})`,{weight:r,style:o});try{return await n.load(),document.fonts.add(n),n}catch{throw new Error(`Failed to load font: ${s}`)}},async preload(s,t="image"){switch(t){case"image":return this.loadImage(s);case"script":return this.loadScript(s);case"stylesheet":case"style":return this.loadStylesheet(s);default:throw new Error(`Unsupported preload type: ${t}`)}},isLoaded(s){return this.cache.has(s)},clearCache(){this.cache.clear()},clearCacheByUrl(s){this.cache.delete(s)}}};window.KupolaUtils=Ut;window.kupolaUtils=Ut;class _t{constructor(){this.children={},this.keys=[]}}class B{constructor(){this.root=new _t}insert(t){let e=this.root;const r=t.split(".");r.forEach((o,n)=>{e.children[o]||(e.children[o]=new _t),e=e.children[o],n===r.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const r=t.split("."),o=[];for(let n=0;n<r.length;n++){const i=r[n];if(!e.children[i])break;e=e.children[i];const a=l=>{l.keys.length>0&&o.push(...l.keys),Object.values(l.children).forEach(c=>a(c))};a(e)}return[...new Set(o)]}getParentKeys(t){const e=t.split("."),r=[];for(let o=1;o<=e.length;o++){const n=e.slice(0,o).join(".");r.push(n)}return r}}const x={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class Vt{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new B,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,r,o)=>{if(r==="__raw__")return e;const n=Reflect.get(e,r,o);return n&&typeof n=="object"&&!Array.isArray(n)?this.wrapReactive(n,r):n},set:(e,r,o,n)=>{const i=Reflect.get(e,r,n),a=Reflect.set(e,r,o,n),l=this.resolvePath(e,r);return this.notify(l,o,i),this.queueUpdate(l,o),a},deleteProperty:(e,r)=>{const o=Reflect.get(e,r,receiver),n=Reflect.deleteProperty(e,r),i=this.resolvePath(e,r);return this.notify(i,void 0,o),this.queueUpdate(i,void 0),n}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[x.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const r={get:(n,i,a)=>{if(i==="__raw__")return n;if(i===x.parent||i==="__parent__")return n[x.parent];if(i===x.path||i==="__path__")return n[x.path];if(i===x.isReactive||i==="__isReactive__")return!0;const l=Reflect.get(n,i,a);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${n[x.path]}${n[x.path]?".":""}${i}`):l},set:(n,i,a,l)=>{if(i===x.parent||i===x.path||i===x.isReactive||i==="__parent__"||i==="__path__"||i==="__isReactive__")return!0;const c=Reflect.get(n,i,l),h=Reflect.set(n,i,a,l),u=`${n[x.path]}${n[x.path]?".":""}${i}`;return this.notify(u,a,c),this.queueUpdate(u,a),h},deleteProperty:(n,i)=>{if(i===x.parent||i===x.path||i===x.isReactive)return!1;const a=Reflect.get(n,i),l=Reflect.deleteProperty(n,i),c=`${n[x.path]}${n[x.path]?".":""}${i}`;return this.notify(c,void 0,a),this.queueUpdate(c,void 0),l},has:(n,i)=>i==="__raw__"||i===x.parent||i===x.path||i===x.isReactive||i==="__parent__"||i==="__path__"||i==="__isReactive__"?!0:i in n,ownKeys:n=>Reflect.ownKeys(n).filter(i=>i!==x.parent&&i!==x.path&&i!==x.isReactive),getOwnPropertyDescriptor:(n,i)=>i===x.parent||i===x.path||i===x.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:n[i]}:Reflect.getOwnPropertyDescriptor(n,i)},o=new Proxy(t,r);return t[x.parent]=t,t[x.path]=e,t[x.isReactive]=!0,this._proxyCache.set(t,o),Object.keys(t).forEach(n=>{t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])&&(t[n]=this.wrapReactive(t[n],`${e}${e?".":""}${n}`))}),o}resolvePath(t,e){return t[x.path]?`${t[x.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,r)=>{t.add(r),this.updateElementsDirect(r,e),this.pathTrie.getSubKeys(r).forEach(n=>{if(!t.has(n)){const i=this.get(n);this.updateElementsDirect(n,i),t.add(n)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(r=>{this.updateElement(r,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(n=>this.updateQueue.has(n)||this.pathTrie.getSubKeys(n).some(i=>this.updateQueue.has(i)))&&this.updateComputedProperty(e)})}set(t,e,r=!1){const o=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(n=>{r||(this.notify(n,t[n],o?.[n]),this.queueUpdate(n,t[n]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,r||(this.notify(t,e,o),this.queueUpdate(t,e))),r||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,r)=>e?.[r],this.rawData)}setNested(t,e){const r=t.split("."),o=r.pop(),n=r.reduce((a,l)=>(a[l]||(a[l]={}),a[l]),this.rawData),i=n[o];n[o]=e,this.notify(t,e,i),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(r=>r!==e))}notify(t,e,r){this.observers[t]&&this.observers[t].forEach(o=>{try{o(e,r)}catch(n){console.error(`Observer error for ${t}:`,n)}}),this.observers["*"]?.forEach(o=>{try{o(t,e,r)}catch(n){console.error("Wildcard observer error:",n)}})}updateElement(t,e){const r=t.getAttribute("data-bind");if(!r)return;r.split("|").forEach(n=>{const i=n.split(":"),a=i[0].trim(),l=i[1]?.trim();switch(a){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":t.innerHTML!==String(e??"")&&(t.innerHTML=e??"");break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const c=e?"none":"";t.style.display!==c&&(t.style.display=c);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,r){this.computedProperties[t]={deps:e,callback:r},e.forEach(o=>{this.pathTrie.insert(o)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const r=e.deps.map(n=>this.get(n)),o=e.callback(...r);this.set(t,o,!0)}catch(r){console.error(`Computed error for ${t}:`,r)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new B,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:r="local",debounce:o=0,version:n=1,encrypt:i=!1,encryptionKey:a=null}=e,l=r==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:o,timeout:null,version:n,encrypt:i,encryptionKey:a});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:n,encrypt:i,encryptionKey:a}),this.observe(t,h=>{const u=this.persistedKeys.get(t);u&&(u.debounce>0?(u.timeout&&clearTimeout(u.timeout),u.timeout=setTimeout(()=>{this._persistSave(t,h,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey})},u.debounce)):this._persistSave(t,h,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey}))})}_persistSave(t,e,r,o={}){try{const{version:n=1,encrypt:i=!1,encryptionKey:a=null}=o,l={value:e,version:n,timestamp:Date.now()};let c=JSON.stringify(l);i&&a&&(c=this._encrypt(c,a)),this._ensureStorageCapacity(r),r.setItem(`kupola:${t}`,c)}catch(n){if(console.warn(`Failed to persist key ${t}:`,n),n.name==="QuotaExceededError"&&r===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(i){console.warn(`sessionStorage also failed for key ${t}:`,i)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),r=30*24*60*60*1e3;for(let o=0;o<t.length;o++){const n=t.key(o);if(n?.startsWith("kupola:"))try{const i=JSON.parse(t.getItem(n));i.timestamp&&e-i.timestamp>r&&t.removeItem(n)}catch{t.removeItem(n)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(r){return console.warn("Decryption failed:",r),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:r=null}=t;for(let o=0;o<localStorage.length;o++){const n=localStorage.key(o);if(n?.startsWith("kupola:")){const i=n.replace("kupola:","");try{const a=localStorage.getItem(n);let l;if(r){const c=this._decrypt(a,r);l=JSON.parse(c)}else l=JSON.parse(a);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${i} (version ${l.version})`);continue}e[i]=l.value!==void 0?l.value:l}catch(a){console.warn(`Failed to load persisted key ${i}:`,a)}}}for(let o=0;o<sessionStorage.length;o++){const n=sessionStorage.key(o);if(n?.startsWith("kupola:")){const i=n.replace("kupola:","");try{const a=sessionStorage.getItem(n);let l;if(r){const c=this._decrypt(a,r);l=JSON.parse(c)}else l=JSON.parse(a);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${i} (version ${l.version})`);continue}e[i]=l.value!==void 0?l.value:l}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,r=this.snapshots[e];return r?(this.rawData=this._clone(r),this.createReactiveData(),Object.keys(this.rawData).forEach(o=>{this.queueUpdate(o,this.rawData[o])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(r=>{const o=r.getAttribute("data-bind");if(!o)return;const i=o.split(":")[1]?.trim();i&&(r.type==="checkbox"?(e[i]||(e[i]=[]),r.checked&&e[i].push(r.value)):r.type==="radio"?r.checked&&(e[i]=r.value):e[i]=r.value)}),e}fillForm(t,e){Object.keys(e).forEach(r=>{t.querySelectorAll('[data-bind*=":'+r+'"]').forEach(o=>{o.type==="checkbox"?o.checked=Array.isArray(e[r])?e[r].includes(o.value):!!e[r]:o.type==="radio"?o.checked=o.value===e[r]:o.value=e[r]??""})})}createReactive(t,e=""){if(t[x.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const r={get:(n,i,a)=>{if(i==="__raw__")return n;if(i===x.parent||i==="__parent__")return n[x.parent];if(i===x.path||i==="__path__")return n[x.path];if(i===x.isReactive||i==="__isReactive__")return!0;const l=Reflect.get(n,i,a);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${n[x.path]}${n[x.path]?".":""}${i}`):l},set:(n,i,a,l)=>{if(i===x.parent||i===x.path||i===x.isReactive||i==="__parent__"||i==="__path__"||i==="__isReactive__")return!0;const c=Reflect.get(n,i,l),h=Reflect.set(n,i,a,l),u=`${n[x.path]}${n[x.path]?".":""}${i}`;return this.notify(u,a,c),this.queueUpdate(u,a),h},deleteProperty:(n,i)=>{if(i===x.parent||i===x.path||i===x.isReactive)return!1;const a=Reflect.get(n,i),l=Reflect.deleteProperty(n,i),c=`${n[x.path]}${n[x.path]?".":""}${i}`;return this.notify(c,void 0,a),this.queueUpdate(c,void 0),l},has:(n,i)=>i==="__raw__"||i===x.parent||i===x.path||i===x.isReactive||i==="__parent__"||i==="__path__"||i==="__isReactive__"?!0:i in n,ownKeys:n=>Reflect.ownKeys(n).filter(i=>i!==x.parent&&i!==x.path&&i!==x.isReactive),getOwnPropertyDescriptor:(n,i)=>i===x.parent||i===x.path||i===x.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:n[i]}:Reflect.getOwnPropertyDescriptor(n,i)},o=new Proxy(t,r);return t[x.parent]=t,t[x.path]=e,t[x.isReactive]=!0,this._proxyCache.set(t,o),Object.keys(t).forEach(n=>{t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])&&(t[n]=this.wrapReactive(t[n],`${e}${e?".":""}${n}`))}),o}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._mutationObserver=new MutationObserver(t=>{t.forEach(e=>{e.addedNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE&&(r.querySelectorAll("[data-bind]").forEach(n=>this._bindElement(n)),r.hasAttribute&&r.hasAttribute("data-bind")&&this._bindElement(r))})})}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const r=t.getAttribute("data-bind").split(":");r[0].split("|")[0].trim();const o=r[1]?.trim();if(o){if(this.pathTrie.insert(o),this.elements[o]||(this.elements[o]=[]),this.elements[o].includes(t)||this.elements[o].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const n=t.__kupolaBindHandler;n&&t.removeEventListener("input",n);const i=()=>{const a=t.type==="checkbox"?t.checked:t.value;o.includes(".")?this.setNested(o,a):this.set(o,a)};t.__kupolaBindHandler=i,t.addEventListener("input",i)}this.rawData[o]!==void 0&&this.updateElement(t,this.rawData[o])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const r=e.__kupolaBindHandler;r&&(e.removeEventListener("input",r),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new B,this.updateQueue.clear(),this.snapshots=[]}}class rt{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const r=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},window.kupolaData?(window.kupolaData.set(this._stateKey,r),this.state=window.kupolaData.data?.[this._stateKey]||window.kupolaData.createReactive(r,this._stateKey),window.kupolaData.observe(this._stateKey,o=>{this.notify(o)})):this.state=r,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const r=this.mutations[t];if(!r){console.warn(`Mutation ${t} not found in store ${this.name}`);return}r(this.state,e)}dispatch(t,e){const r=this.actions[t];if(!r){console.warn(`Action ${t} not found in store ${this.name}`);return}return r({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(r){console.error(`Observer error for store ${this.name}:`,r)}}),window.kupolaData&&window.kupolaData.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class Wt{constructor(){this.stores=new Map}createStore(t,e){const r=new rt(t,e);return this.stores.set(t,r),r}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof rt&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Yt{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(r=>r!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(r=>{try{r(e)}catch(o){console.error(`Error in event handler for ${t}:`,o)}}),this.events["*"]?.forEach(r=>{try{r(t,e)}catch(o){console.error("Error in wildcard event handler:",o)}})}once(t,e){const r=o=>{e(o),this.off(t,r)};return this.on(t,r),r}delegate(t,e,r){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const o=n=>{this.delegatedEvents[e].forEach(({selector:i,cb:a})=>{(n.target.matches(i)||n.target.closest(i))&&a(n)})};document.addEventListener(e,o),this.eventListeners[e]=o}return this.delegatedEvents[e].push({selector:t,cb:r}),r}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(r=>r.selector!==t),this.delegatedEvents[e].length===0)){const r=this.eventListeners[e];r&&(document.removeEventListener(e,r),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}const ot=new Vt,Ks=new Yt,lt=new Wt;function Us(s,t){return lt.createStore(s,t)}function Vs(s){return lt.getStore(s)}document.addEventListener("DOMContentLoaded",()=>{ot.loadPersisted(),ot.bind()});window.KupolaDataBind=Vt;window.KupolaEventBus=Yt;window.KupolaStore=rt;window.KupolaStoreManager=Wt;window.kupolaData=ot;window.kupolaEvents=Ks;window.kupolaStoreManager=lt;window.createStore=Us;window.getStore=Vs;var K={exports:{}},wt;function Ws(){return wt||(wt=1,function(s){const t="kupola-theme",e="kupola-brand",r=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function o(){return localStorage.getItem(t)||"dark"}function n(d){if(d!=="dark"&&d!=="light")return;document.documentElement.setAttribute("data-theme",d),localStorage.setItem(t,d);const p=document.querySelector("[data-theme-toggle]");if(p){p.setAttribute("data-current-theme",d);const g=p.querySelector(".theme-icon");if(g){const f=g.src.substring(0,g.src.lastIndexOf("/")+1);g.src=d==="dark"?f+"sun.svg":f+"moon.svg"}}}function i(){return localStorage.getItem(e)||"zengqing"}function a(d){const p=r.find(m=>m.id===d);if(!p)return;document.documentElement.setAttribute("data-brand",d),localStorage.setItem(e,d);const g=document.querySelector("[data-brand-toggle]");if(g){g.setAttribute("data-current-brand",d);const m=g.querySelector(".brand-icon");m&&(m.style.backgroundColor=p.color);const v=g.querySelector(".brand-name");v&&(v.textContent=p.name)}document.querySelectorAll("[data-brand-btn]").forEach(m=>{m.getAttribute("data-brand-btn")===d?m.classList.add("is-active"):m.classList.remove("is-active")})}function l(){const d=o();n(d);const p=i();a(p);const g=document.querySelector("[data-theme-toggle]");g&&g.addEventListener("click",()=>{const _=o()==="dark"?"light":"dark";n(_)});let f=document.getElementById("brand-picker");f||(f=document.createElement("div"),f.id="brand-picker",f.style.position="fixed",f.style.top="64px",f.style.right="16px",f.style.zIndex="9998",f.style.display="none",f.style.padding="12px",f.style.width="200px",f.style.gridTemplateColumns="repeat(3, 1fr)",f.style.gap="6px",f.style.backgroundColor="var(--bg-base-secondary)",f.style.border="1px solid var(--border-neutral-l1)",f.style.borderRadius="8px",f.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",f.style.overflow="hidden",r.forEach(w=>{const _=document.createElement("button");_.setAttribute("data-brand-btn",w.id),_.style.display="flex",_.style.justifyContent="center",_.style.alignItems="center",_.style.height="60px",_.style.backgroundColor=w.color,_.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(w.color)?"#0C0C0D":"#FFFFFF",_.style.fontWeight="500",_.style.borderRadius="4px",_.style.border="none",_.style.cursor="pointer",_.style.margin="0",_.style.padding="0",_.textContent=w.name,f.appendChild(_)}),document.body.appendChild(f));const m=document.querySelector("[data-brand-toggle]");m&&f&&(m.onclick=function(w){w.stopPropagation(),w.preventDefault();const _=f.style.display==="none";f.style.display=_?"grid":"none",_?setTimeout(()=>{document.addEventListener("click",v,!0)},0):document.removeEventListener("click",v,!0)},f.onclick=function(w){w.stopPropagation()});function v(w){f&&m&&!f.contains(w.target)&&!m.contains(w.target)&&(f.style.display="none",document.removeEventListener("click",v,!0))}document.querySelectorAll("[data-brand-btn]").forEach(w=>{w.addEventListener("click",_=>{_.stopPropagation();const b=w.getAttribute("data-brand-btn");a(b),f&&(f.style.display="none")})})}function c(){const d=document.createElement("button");d.setAttribute("data-theme-toggle",""),d.setAttribute("data-current-theme",o()),d.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",d.style.position="fixed",d.style.top="16px",d.style.right="16px",d.style.zIndex="9999";const p=document.createElement("img");p.className="theme-icon";const g=document.getElementsByTagName("script"),f=g[g.length-1],m=f.src.substring(0,f.src.lastIndexOf("/")+1);return p.src=o()==="dark"?m+"../icons/sun.svg":m+"../icons/moon.svg",p.width=14,p.height=14,p.alt="Toggle theme",d.appendChild(p),document.body.appendChild(d),d.addEventListener("click",()=>{const y=o()==="dark"?"light":"dark";n(y)}),d}function h(){const d=document.createElement("div");d.id="brand-picker-auto",d.style.position="fixed",d.style.top="56px",d.style.right="16px",d.style.zIndex="9998",d.style.display="none",d.style.padding="12px",d.style.width="200px",d.style.gridTemplateColumns="repeat(3, 1fr)",d.style.gap="6px",d.style.backgroundColor="var(--bg-base-secondary)",d.style.border="1px solid var(--border-neutral-l1)",d.style.borderRadius="8px",d.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",d.style.overflow="hidden",r.forEach(y=>{const w=document.createElement("button");w.setAttribute("data-brand-btn",y.id),w.style.display="flex",w.style.justifyContent="center",w.style.alignItems="center",w.style.height="60px",w.style.backgroundColor=y.color,w.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(y.color)?"#0C0C0D":"#FFFFFF",w.style.fontWeight="500",w.style.borderRadius="4px",w.style.border="none",w.style.cursor="pointer",w.style.margin="0",w.style.padding="0",w.textContent=y.name,d.appendChild(w)}),document.body.appendChild(d);const p=document.createElement("button");p.setAttribute("data-brand-toggle",""),p.setAttribute("data-current-brand",i()),p.className="ds-btn ds-btn--ghost ds-btn--sm",p.style.position="fixed",p.style.top="16px",p.style.right="56px",p.style.zIndex="9999",p.style.display="flex",p.style.alignItems="center",p.style.gap="6px";const g=document.createElement("span");g.className="brand-icon",g.style.width="12px",g.style.height="12px",g.style.borderRadius="50%",g.style.backgroundColor=r.find(y=>y.id===i()).color;const f=document.createElement("span");f.className="brand-name",f.style.fontSize="11px",f.textContent=r.find(y=>y.id===i()).name,p.appendChild(g),p.appendChild(f),document.body.appendChild(p),p.onclick=function(y){y.stopPropagation(),y.preventDefault();const w=d.style.display==="none";d.style.display=w?"grid":"none",w?setTimeout(()=>{document.addEventListener("click",m,!0)},0):document.removeEventListener("click",m,!0)},d.onclick=function(y){y.stopPropagation()};function m(y){!d.contains(y.target)&&!p.contains(y.target)&&(d.style.display="none",document.removeEventListener("click",m,!0))}return d.querySelectorAll("[data-brand-btn]").forEach(y=>{y.addEventListener("click",w=>{w.stopPropagation();const _=y.getAttribute("data-brand-btn");a(_),d.style.display="none"})}),{toggleBtn:p,container:d}}function u(){const d=new URLSearchParams(window.location.search);if(!(d.has("dev")||d.has("debug")))return;const g=document.querySelector('script[src*="theme.js"]');if(!g||!g.src)return;const f=g.src.substring(0,g.src.lastIndexOf("/")+1),m=document.createElement("script");m.src=f+"kupola-devtools.js?v=15",m.async=!0,document.head.appendChild(m)}if(s.exports)s.exports={getTheme:o,setTheme:n,initTheme:l,createThemeToggle:c,getBrand:i,setBrand:a,BRAND_OPTIONS:r,createBrandPicker:h,loadDevTools:u};else if(!window.__kupolaThemeInitialized){let d=function(){l(),u()};window.__kupolaThemeInitialized=!0,document.readyState==="loading"?document.addEventListener("readystatechange",function p(){document.readyState!=="loading"&&(document.removeEventListener("readystatechange",p),d())}):setTimeout(d,0)}}(K)),K.exports}Ws();class Ys{constructor(t){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{const e=t.currentTarget;this.triggerText&&(this.triggerText.textContent=e.textContent.trim()),this.hideMenu()},this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.addEventListener("click",this._itemClickHandler),t._dropdownItemClickHandler=this._itemClickHandler}),this._triggerClickHandler=t=>{t.stopPropagation(),this.toggleMenu()},this.trigger.addEventListener("click",this._triggerClickHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideMenu()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}toggleMenu(){const t=this.menu.style.display==="block";this.menu.style.display=t?"none":"block",this.element.classList.toggle("is-open",!t)}hideMenu(){this.menu.style.display="none",this.element.classList.remove("is-open")}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.menu&&this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this.element.__kupolaInitialized=!1)}}function Xs(s){const t=new Ys(s);t.init(),s._kupolaDropdown=t}function Js(s){s._kupolaDropdown&&(s._kupolaDropdown.destroy(),s._kupolaDropdown=null)}window.kupolaInitializer&&window.kupolaInitializer.register("dropdown",Xs,Js);class js{constructor(t){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._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._optionClickHandler=t=>{const e=t.currentTarget,r=e.getAttribute("data-value");this.nativeSelect&&(this.nativeSelect.value=r),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(o=>o.classList.remove("is-selected")),e.classList.add("is-selected"),this.updateValue(e.textContent.trim()),this.hideOptions(),this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change"))},this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler}),this._triggerClickHandler=t=>{t.stopPropagation(),this.showOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideOptions()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent)}showOptions(){const t=this.optionsEl.style.display==="block";this.optionsEl.style.display=t?"none":"block",this.icon&&(this.icon.style.transform=t?"rotate(0deg)":"rotate(180deg)"),this.element.classList.toggle("is-open",!t)}hideOptions(){this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open")}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this.element.__kupolaInitialized=!1)}}function Gs(s){const t=new js(s);t.init(),s._kupolaSelect=t}function Qs(s){s._kupolaSelect&&(s._kupolaSelect.destroy(),s._kupolaSelect=null)}window.kupolaInitializer&&window.kupolaInitializer.register("select",Gs,Qs);class Zs{constructor(t){this.element=t,this.input=t.querySelector("input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`,this._iconClickHandler=null,this._inputClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null}init(){this.calendarEl&&(this.element.__kupolaInitialized||(this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input.addEventListener("click",this._inputClickHandler),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",t=>this.hideCalendar(t)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=t=>this.hideCalendar(t),this._resizeHandler=()=>this.resizeHandler()),this.element.__kupolaInitialized=!0,this.initCalendar()))}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),o=window.innerHeight-t.bottom,n=t.top,i=e.height||280;o>=i?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):n>=i?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(r=>{r.style.display="none",r.setAttribute("hidden","")}),e||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""))}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}initCalendar(){const t=this.calendarEl,e=this.input,r=t.querySelector(".ds-datepicker__title"),o=t.querySelector(".ds-datepicker__days"),n=t.querySelector(".ds-datepicker__nav--prev"),i=t.querySelector(".ds-datepicker__nav--next");let a=new Date;if(e.value){const u=e.value.split("-");u.length===3&&(a=new Date(u[0],u[1]-1,u[2]))}function l(){o.querySelectorAll(".ds-datepicker__day").forEach(f=>{f._dayClickHandler&&f.removeEventListener("click",f._dayClickHandler)}),o.innerHTML="";const u=a.getFullYear(),d=a.getMonth();r.textContent=`${u} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][d]}`;const p=new Date(u,d,1).getDay(),g=new Date(u,d+1,0).getDate();for(let f=0;f<p;f++){const m=document.createElement("span");m.className="ds-datepicker__day--empty",o.appendChild(m)}for(let f=1;f<=g;f++){const m=document.createElement("button");m.className="ds-datepicker__day",m.textContent=f;const v=`${u}-${String(d+1).padStart(2,"0")}-${String(f).padStart(2,"0")}`;e.value===v&&m.classList.add("is-selected");const y=new Date,w=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`;v===w&&m.classList.add("is-today");const _=()=>{e.value=v,t.style.display="none",t.setAttribute("hidden",""),e.dispatchEvent(new Event("change"))};m.addEventListener("click",_),m._dayClickHandler=_,o.appendChild(m)}}const c=u=>{u.stopPropagation(),a.setMonth(a.getMonth()-1),l()},h=u=>{u.stopPropagation(),a.setMonth(a.getMonth()+1),l()};n&&(n.addEventListener("click",c),n._prevClickHandler=c),i&&(i.addEventListener("click",h),i._nextClickHandler=h),t._calendarInitialized=!0,l()}destroy(){if(this.element.__kupolaInitialized){if(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl){const t=this.calendarEl.querySelector(".ds-datepicker__days");t&&t.querySelectorAll(".ds-datepicker__day").forEach(o=>{o._dayClickHandler&&o.removeEventListener("click",o._dayClickHandler)});const e=this.calendarEl.querySelector(".ds-datepicker__nav--prev"),r=this.calendarEl.querySelector(".ds-datepicker__nav--next");e&&e._prevClickHandler&&e.removeEventListener("click",e._prevClickHandler),r&&r._nextClickHandler&&r.removeEventListener("click",r._nextClickHandler)}this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this.element.__kupolaInitialized=!1}}}function ti(s){const t=new Zs(s);t.init(),s._kupolaDatepicker=t}function ei(s){s._kupolaDatepicker&&(s._kupolaDatepicker.destroy(),s._kupolaDatepicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("datepicker",ti,ei);class si{constructor(t){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._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this.selectedHour=12,this.selectedMinute=0}init(){this.element.__kupolaInitialized||(this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.panelEl.style.display="none":this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",t=>this.hideTimepicker(t)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=t=>this.hideTimepicker(t),this._resizeHandler=()=>this.resizeHandler()),this.element.__kupolaInitialized=!0)}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),o=window.innerHeight-t.bottom,n=t.top,i=e.height||320;o>=i?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):n>=i?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this.calculatePosition();return}if(this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel",this.panelEl.innerHTML=`
6
+ `}}_bindLifecycleHooks(){if(this._hooksBound)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let e=Object.getPrototypeOf(this);const i=new Set;for(;e&&e.constructor!==Object&&e.constructor!==O;){for(const[n,r]of Object.entries(t))i.has(n)||e.hasOwnProperty(n)&&(Array.isArray(r)?r.forEach(a=>{n==="render"&&this.lifecycle.on(a,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(r,a=>(this.renderError(a.error),"handled")):this.lifecycle.on(r,()=>this[n]?.()),i.add(n));e=Object.getPrototypeOf(e)}this._hooksBound=!0}async unmount(){if(!(!this.isMounted||this.isDestroyed))try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(t){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function X(s,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const i=s.prototype[e];i?s.prototype[e]=function(...n){return t[e].apply(this,n),i.apply(this,n)}:s.prototype[e]=t[e]}else s.prototype[e]=t[e]})}typeof window<"u"&&(window.KupolaComponent=O,window.applyMixin=X);class ie{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(t,e){if(!(e.prototype instanceof O))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,e)}registerLazy(t,e){this.lazyComponents.set(t,e)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const e=this.components.get(t)||this.loadedComponents.get(t);if(e)return e;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const i=this.lazyComponents.get(t);if(!i)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await i(),a=r.default||r;if(!(a.prototype instanceof O))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,a),a}catch(r){throw this.loadingPromises.delete(t),r}})();return this.loadingPromises.set(t,n),n}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(i=>{const n=this.mixins.get(i);n&&X(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),i=[];e.forEach(n=>{i.push(this._upgradeElement(n))}),await Promise.all(i)}async _upgradeElement(t){if(!(t.__kupolaInstance||t.__kupolaUpgrading)){t.__kupolaUpgrading=!0;try{const e=t.getAttribute("data-component");if(e){const o=S.get(e);if(o)try{await o(t);return}catch(l){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,l)}}let i=this.components.get(e);if(!i){try{i=await this.getAsync(e)}catch(o){console.error(`Failed to load component ${e}:`,o);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=i;n&&n.split(",").forEach(o=>{const l=this.mixins.get(o.trim());l&&X(r,l)});const a=new r(t);t.__kupolaInstance=a,this.instances.set(t,a),a.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(i=>{i.addedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){n.hasAttribute("data-component")&&this._upgradeElement(n).catch(a=>console.error(a)),this._upgradeElements(n).catch(a=>console.error(a)),S.initialize(n).catch(()=>{});const r=S._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{S.initialize(a).catch(()=>{})})}}),i.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=this.instances.get(n);r&&(r.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(a=>{const o=this.instances.get(a);o&&(o.unmount(),this.instances.delete(a))}),S.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{S.cleanup(a)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}typeof window<"u"&&(window.KupolaComponentRegistry=ie);exports.kupolaRegistry=null;typeof window<"u"&&(exports.kupolaRegistry=new ie);async function J(){typeof window<"u"&&(Y.loadPersisted(),Y.bind(),te(),await S.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",J):typeof window<"u"&&setTimeout(J,0);function Je(s,t){exports.kupolaRegistry&&exports.kupolaRegistry.register(s,t)}function je(s,t){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(s,t)}function Ge(s){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(s):Promise.resolve()}function Ze(s,t){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(s,t)}function Qe(s,...t){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(s,...t)}function ti(s,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${s}"): options must be an object`);t.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(s,t.componentClass):t.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(s,t.lazy),t.init?S.register(s,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&S.register(s,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}typeof window<"u"&&(window.kupolaRegistry=exports.kupolaRegistry,window.kupolaInitializer=S,window.kupolaBootstrap=J,window.registerComponent=Je,window.registerLazyComponent=je,window.bootstrapComponents=Ge,window.defineMixin=Ze,window.useMixin=Qe,window.defineComponent=ti);class xt{constructor(t={}){this.locales=t.locales||{},this.currentLocale=t.defaultLocale||"zh-CN",this.fallbackLocale=t.fallbackLocale||"zh-CN",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(i=>{const n=i.dataset.kupolaI18n;if(n)try{const r=JSON.parse(i.textContent);this.addLocale(n,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const i of Object.keys(e))e[i]instanceof Object&&i in t?this._mergeDeep(t[i],e[i]):t[i]=e[i]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let i=this._getTranslation(t,this.currentLocale);return i||(i=this._getTranslation(t,this.fallbackLocale)),i?this._interpolate(i,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const i=t.split(this.delimiter);let n=this.locales[e];for(const r of i)if(n&&typeof n=="object"&&r in n)n=n[r];else return null;return typeof n=="string"?n:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(i,n)=>e[n]!==void 0?e[n]:i)}n(t,e,i={}){const n=this.t(t,{...i,count:e});if(!n)return n;const r=n.split("|");return r.length===1?n.replace("{count}",e):r.length===2?e===1?r[0]:r[1]:r.length>=3?e===0?r[0]:e===1?r[1]:r[2]:n}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const n=await(await fetch(e)).json();return this.addLocale(t,n),!0}catch(i){return console.error("Failed to load locale:",i),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const i=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(i,e).format(n)}formatNumber(t,e={}){const i=e.locale||this.currentLocale;return new Intl.NumberFormat(i,e).format(t)}formatCurrency(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...i}).format(t)}formatRelativeTime(t,e,i={}){const n=i.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,i).format(t,e)}}const z=new xt;function ei(s){return new xt(s)}function ii(s,t={}){return z.t(s,t)}function si(s,t,e={}){return z.n(s,t,e)}function ni(s){return z.setLocale(s)}function ri(){return z.getLocale()}function ai(s,t={}){return z.formatDate(s,t)}function oi(s,t={}){return z.formatNumber(s,t)}function li(s,t,e={}){return z.formatCurrency(s,t,e)}typeof window<"u"&&(window.KupolaI18n=xt,window.kupolaI18n=z,window.createI18n=ei,window.t=ii,window.n=si,window.setLocale=ni,window.getLocale=ri,window.formatDate=ai,window.formatNumber=oi,window.formatCurrency=li);class se{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`,this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.hideMenu(),this.trigger.focus())},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this.trigger.addEventListener("keydown",t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())}),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideMenu()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t.addEventListener("click",this._itemClickHandler),t._dropdownItemClickHandler=this._itemClickHandler})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=this.menu.getBoundingClientRect(),i=window.innerHeight,n=window.innerWidth;this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup");const r=i-t.bottom,a=t.top;r<e.height&&a>r?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+e.width>n?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.menu.style.display="block",this.element.classList.add("is-open"),this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach(e=>{if(e.type==="divider"){const i=document.createElement("div");i.className="ds-dropdown__divider",this.menu.appendChild(i)}else{const i=document.createElement("div");i.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),i.textContent=e.text||e.label||"",e.value!==void 0&&i.setAttribute("data-value",e.value),e.icon&&(i.innerHTML=e.icon+i.innerHTML),e.disabled&&i.classList.add("is-disabled"),this.menu.appendChild(i)}}),this._bindMenuItems()}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this.element.__kupolaInitialized=!1)}}function j(s,t){const e=new se(s,t);e.init(),s._kupolaDropdown=e}function ci(s=document){s.querySelectorAll(".ds-dropdown").forEach(t=>{j(t)})}function G(s){s._kupolaDropdown&&(s._kupolaDropdown.destroy(),s._kupolaDropdown=null)}function di(){document.querySelectorAll(".ds-dropdown").forEach(s=>{G(s)})}typeof window<"u"&&(window.Dropdown=se,window.initDropdown=j,window.initDropdowns=ci,window.cleanupDropdown=G,window.cleanupAllDropdowns=di,window.kupolaInitializer&&window.kupolaInitializer.register("dropdown",j,G));class ne{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,e)},this._bindOptionClicks(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getVisibleOptions();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusOption(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(e);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus();break}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideOptions()},window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const i=this.filteredOptions.includes(e);e.el.style.display=i?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const i=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===i);e.style.display=n?"":"none"}),this.focusIndex=-1}_renderRemoteOptions(t){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),t.forEach(e=>{const i=document.createElement("div");i.className="ds-select__option",i.setAttribute("data-value",e.value),i.textContent=e.text||e.label,e.disabled&&i.classList.add("is-disabled"),this.selectedValues.has(e.value)&&i.classList.add("is-selected"),i.addEventListener("click",this._optionClickHandler),i._selectOptionClickHandler=this._optionClickHandler,this.optionsEl.appendChild(i)}),this.allOptions=t.map(e=>({el:this.optionsEl.querySelector(`[data-value="${e.value}"]`),value:e.value,text:e.text||e.label,group:"",disabled:!!e.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(i=>i.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(e.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(t,e){if(this.selectedValues.has(t))this.selectedValues.delete(t),e.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),e.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const e=this.allOptions.find(r=>r.value===t);if(!e)return;const i=document.createElement("span");i.className="ds-select__tag",i.textContent=e.text;const n=document.createElement("button");n.className="ds-select__tag-close",n.type="button",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this.selectedValues.delete(t);const a=this.optionsEl.querySelector(`[data-value="${t}"]`);a&&a.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(n),this.tagsWrap.appendChild(i)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;t===0?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else this.selectedValues.size===0&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}_updateClearBtn(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}_syncNativeSelect(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect){if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const e=this.optionsEl.querySelector(`[data-value="${t.value}"]`);e&&e.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.optionsEl.style.display="block",this.icon&&(this.icon.style.transform="rotate(180deg)"),this.element.classList.add("is-open"),this.focusIndex=-1,this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(i=>i.value===t);return e?{value:e.value,text:e.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(e=>this.selectedValues.add(e)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.classList.toggle("is-selected",this.selectedValues.has(e.getAttribute("data-value")))}),this._updateTags(),this._updateValueDisplay()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{const i=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",i),i&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function Z(s,t){const e=new ne(s,t);e.init(),s._kupolaSelect=e}function hi(s=document){s.querySelectorAll(".ds-select").forEach(t=>{Z(t)})}function Q(s){s._kupolaSelect&&(s._kupolaSelect.destroy(),s._kupolaSelect=null)}function ws(){document.querySelectorAll(".ds-select").forEach(s=>{Q(s)})}typeof window<"u"&&(window.Select=ne,window.initSelect=Z,window.initSelects=hi,window.cleanupSelect=Q,window.cleanupAllSelects=ws,window.kupolaInitializer&&window.kupolaInitializer.register("select",Z,Q));class re{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`,this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart||parseInt(t.getAttribute("data-datepicker-week-start"))||0,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&this.endInput.addEventListener("click",t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)}),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",t=>this.hideCalendar(t)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=t=>this.hideCalendar(t),this._resizeHandler=()=>this.resizeHandler()),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",i).replace("DD",n)}_isDateDisabled(t){if(this.minDate){const e=typeof this.minDate=="string"?this._parseDate(this.minDate):this.minDate;if(t<e)return!0}if(this.maxDate){const e=typeof this.maxDate=="string"?this._parseDate(this.maxDate):this.maxDate;if(t>e)return!0}return this.disabledDate?this.disabledDate(t):!1}_isToday(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isSameDay(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isInRange(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const e=t.getTime(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=i&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(i=>{i!==this.calendarEl&&(i.style.display="none",i.setAttribute("hidden",""))}),e||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days")}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(p=>{p._dayClickHandler&&p.removeEventListener("click",p._dayClickHandler)}),this.viewMode==="years"){this._renderYearsView();return}if(this.viewMode==="months"){this._renderMonthsView();return}const e=this.currentDate.getFullYear(),i=this.currentDate.getMonth();t.innerHTML="";const n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",p=>{p.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[i]}`,a.addEventListener("click",p=>{p.stopPropagation(),this.viewMode="months",this._renderCalendar()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",p=>{p.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(p=>{const m=document.createElement("span");m.className="ds-datepicker__weekday",m.textContent=p,l.appendChild(m)}),t.appendChild(l);const d=document.createElement("div");d.className="ds-datepicker__days";const h=new Date(e,i,1).getDay(),u=new Date(e,i+1,0).getDate(),f=(h-this.weekStart+7)%7;for(let p=0;p<f;p++){const m=document.createElement("span");m.className="ds-datepicker__day ds-datepicker__day--empty",d.appendChild(m)}for(let p=1;p<=u;p++){const m=new Date(e,i,p),y=document.createElement("button");y.className="ds-datepicker__day",y.type="button",y.textContent=p,this._formatDate(m),this._isToday(m)&&y.classList.add("is-today"),this.range?((this._isSameDay(m,this.rangeStart)||this._isSameDay(m,this.rangeEnd))&&y.classList.add("is-selected"),this._isInRange(m)&&y.classList.add("is-in-range")):this._isSameDay(m,this.selectedDate)&&y.classList.add("is-selected"),this._isDateDisabled(m)&&(y.classList.add("is-disabled"),y.disabled=!0);const _=()=>this._selectDate(m);y.addEventListener("click",_),y._dayClickHandler=_,d.appendChild(y)}if(t.appendChild(d),this.showToday){const p=document.createElement("div");p.className="ds-datepicker__footer";const m=document.createElement("button");m.className="ds-datepicker__today-btn",m.type="button",m.textContent=this.todayText,m.addEventListener("click",_=>{_.stopPropagation(),this._goToToday()});const y=document.createElement("button");y.className="ds-datepicker__clear-btn",y.type="button",y.textContent=this.clearText,y.addEventListener("click",_=>{_.stopPropagation(),this._clearDate()}),p.appendChild(m),p.appendChild(y),t.appendChild(p)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=e-6,n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",c=>{c.stopPropagation()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const d=i+c,h=document.createElement("button");h.className="ds-datepicker__year-cell",h.type="button",h.textContent=d,d===e&&h.classList.add("is-selected"),h.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setFullYear(d),this.viewMode="months",this._renderCalendar()}),l.appendChild(h)}t.appendChild(l)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=e,r.addEventListener("click",l=>{l.stopPropagation(),this.viewMode="years",this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--next",a.type="button",a.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',a.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),i.appendChild(n),i.appendChild(r),i.appendChild(a),t.appendChild(i);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((l,c)=>{const d=document.createElement("button");d.className="ds-datepicker__month-cell",d.type="button",d.textContent=l,c===this.currentDate.getMonth()&&d.classList.add("is-selected"),d.addEventListener("click",h=>{h.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),o.appendChild(d)}),t.appendChild(o)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function tt(s,t){const e=new re(s,t);e.init(),s._kupolaDatepicker=e}function ui(s=document){s.querySelectorAll(".ds-datepicker").forEach(t=>{tt(t)})}function et(s){s._kupolaDatepicker&&(s._kupolaDatepicker.destroy(),s._kupolaDatepicker=null)}function bs(){document.querySelectorAll(".ds-datepicker").forEach(s=>{et(s)})}typeof window<"u"&&(window.Datepicker=re,window.initDatepicker=tt,window.initDatepickers=ui,window.cleanupDatepicker=et,window.cleanupAllDatepickers=bs,window.kupolaInitializer&&window.kupolaInitializer.register("datepicker",tt,et));class ae{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),window.globalEvents?(this._documentClickListener=window.globalEvents.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=window.globalEvents.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope})):(document.addEventListener("click",t=>this.hideTimepicker(t)),window.addEventListener("resize",()=>this.resizeHandler()),this._documentClickHandler=t=>this.hideTimepicker(t),this._resizeHandler=()=>this.resizeHandler()),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(t,e,i){if(this.disabledTime)return this.disabledTime(t,e,i);const n=t*3600+e*60+i;if(this.minTime){const r=this.minTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n<a)return!0}if(this.maxTime){const r=this.maxTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n>a)return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const n=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")} ${n}`:`${t}:${String(e).padStart(2,"0")} ${n}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):r>=a?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this._syncPanelSelection(),this.calculatePosition();return}this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+=`<div class="ds-timepicker__section">
7
+ <div class="ds-timepicker__section-label">Hour</div>
8
+ <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>
9
+ </div>`,t+=`<div class="ds-timepicker__section">
10
+ <div class="ds-timepicker__section-label">Min</div>
11
+ <div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>
12
+ </div>`,this.showSeconds&&(t+=`<div class="ds-timepicker__section">
13
+ <div class="ds-timepicker__section-label">Sec</div>
14
+ <div class="ds-timepicker__grid ds-timepicker__grid--second" data-type="second"></div>
15
+ </div>`),this.use12Hour&&(t+=`<div class="ds-timepicker__section ds-timepicker__section--ampm">
16
+ <div class="ds-timepicker__grid ds-timepicker__grid--ampm" data-type="ampm"></div>
17
+ </div>`),this.panelEl.innerHTML=`
7
18
  <div class="ds-timepicker__header">
8
19
  <div class="ds-timepicker__display">
9
- <span class="ds-timepicker__display-hour">12</span>
20
+ <span class="ds-timepicker__display-hour">${String(this.selectedHour).padStart(2,"0")}</span>
10
21
  <span class="ds-timepicker__separator">:</span>
11
- <span class="ds-timepicker__display-minute">00</span>
22
+ <span class="ds-timepicker__display-minute">${String(this.selectedMinute).padStart(2,"0")}</span>
23
+ ${this.showSeconds?'<span class="ds-timepicker__separator">:</span><span class="ds-timepicker__display-second">'+String(this.selectedSecond).padStart(2,"0")+"</span>":""}
24
+ ${this.use12Hour?'<span class="ds-timepicker__display-ampm">'+(this.selectedHour>=12?"PM":"AM")+"</span>":""}
12
25
  </div>
13
26
  </div>
14
- <div class="ds-timepicker__body">
15
- <div class="ds-timepicker__section">
16
- <div class="ds-timepicker__section-label">Hour</div>
17
- <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>
18
- </div>
19
- <div class="ds-timepicker__section">
20
- <div class="ds-timepicker__section-label">Minute</div>
21
- <div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>
27
+ <div class="ds-timepicker__body">${t}</div>
28
+ ${this.clearable?'<div class="ds-timepicker__footer"><button class="ds-timepicker__clear-btn" type="button">Clear</button></div>':""}
29
+ `,this.element.appendChild(this.panelEl),this._populateHourGrid(),this._populateMinuteGrid(),this.showSeconds&&this._populateSecondGrid(),this.use12Hour&&this._populateAmPmGrid(),this.clearable){const e=this.panelEl.querySelector(".ds-timepicker__clear-btn");e&&e.addEventListener("click",i=>{i.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",e=>e.stopPropagation()),this._syncPanelSelection(),setTimeout(()=>{this.calculatePosition(),this._scrollToSelection()},0)}_populateHourGrid(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;const e=this.use12Hour?1:0;for(let i=e;i<(this.use12Hour?13:24);i+=this.hourStep){const n=document.createElement("button");n.type="button",n.className="ds-timepicker__item",n.textContent=String(i).padStart(2,"0"),n.dataset.value=i,n.addEventListener("click",()=>{let r=i;this.use12Hour&&(i===12?r=this.isPM?12:0:r=this.isPM?i+12:i),this.selectedHour=r,this._updateDisplay(),this._syncGridSelection("hour",i),this._confirmSelection()}),t.appendChild(n)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(i)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(i)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=e,i.dataset.value=e,i.addEventListener("click",()=>{this.isPM=e==="PM",this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this._updateDisplay(),t.querySelectorAll(".ds-timepicker__item").forEach(n=>n.classList.remove("is-selected")),i.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(i)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),n=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const r=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(r).padStart(2,"0")}e&&(e.textContent=String(this.selectedMinute).padStart(2,"0")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),n&&(n.textContent=this.selectedHour>=12?"PM":"AM")}_syncPanelSelection(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this._syncGridSelection("hour",t),this._syncGridSelection("minute",this.selectedMinute),this._syncGridSelection("second",this.selectedSecond);const e=this.panelEl.querySelector('[data-type="ampm"]');e&&e.querySelectorAll(".ds-timepicker__item").forEach(i=>{i.classList.toggle("is-selected",i.dataset.value==="PM"==this.selectedHour>=12)}),this._updateDisplay()}_syncGridSelection(t,e){const i=this.panelEl.querySelector(`[data-type="${t}"]`);i&&i.querySelectorAll(".ds-timepicker__item").forEach(n=>{n.classList.toggle("is-selected",parseInt(n.dataset.value)===e)})}_scrollToSelection(){["hour","minute","second"].forEach(t=>{const e=this.panelEl.querySelector(`[data-type="${t}"]`);if(!e)return;const i=e.querySelector(".is-selected");i&&i.scrollIntoView({block:"center"})})}_confirmSelection(){this.input.value=this._formatTime()}hideTimepicker(t){this.panelEl&&this.panelEl.style.display==="block"&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this._formatTime(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this._formatTime()})))}resizeHandler(){this.panelEl&&this.panelEl.style.display==="block"&&this.calculatePosition()}setTime(t,e,i){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,e)),this.selectedSecond=Math.max(0,Math.min(59,i||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this._formatTime()),this.panelEl&&this._syncPanelSelection()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.__kupolaInitialized&&(this.inputWrap&&this._inputWrapClickHandler&&this.inputWrap.removeEventListener("click",this._inputWrapClickHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function it(s,t){const e=new ae(s,t);e.init(),s._kupolaTimepicker=e}function pi(s=document){s.querySelectorAll(".ds-timepicker").forEach(t=>{it(t)})}function At(s){s._kupolaTimepicker&&(s._kupolaTimepicker.destroy(),s._kupolaTimepicker=null)}typeof window<"u"&&(window.Timepicker=ae,window.initTimepicker=it,window.initTimepickers=pi,window.cleanupTimepicker=At,window.kupolaInitializer&&window.kupolaInitializer.register("timepicker",it,At));class oe{constructor(t,e={}){if(this.element=t,this.track=t.querySelector(".ds-slider__track"),this.fill=t.querySelector(".ds-slider__fill"),this.input=t.querySelector(".ds-slider__input"),this.valueEl=t.querySelector(".ds-slider__value"),this.range=e.range||t.hasAttribute("data-slider-range"),this.vertical=e.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=e.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=e.showTooltip!==!1,this.showMarks=e.marks||t.hasAttribute("data-slider-marks"),this.markStep=e.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=e.tooltipFormat||(i=>i),this.onChange=e.onChange||null,this.onInput=e.onInput||null,this.inputEnd=t.querySelector(".ds-slider__input--end"),this.fillEnd=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this._listeners=[],this._isDragging=!1,this._activeThumb=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this._build(),this._bindEvents(),this.updateSlider()}_build(){this.vertical&&this.element.classList.add("ds-slider--vertical"),this.disabled&&this.element.classList.add("is-disabled"),this.element.querySelector(".ds-slider__thumb")?this.thumbStart=this.element.querySelector(".ds-slider__thumb--start"):(this.thumbStart=document.createElement("div"),this.thumbStart.className="ds-slider__thumb ds-slider__thumb--start",this.thumbStart.setAttribute("role","slider"),this.thumbStart.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbStart),this.showTooltip&&(this.tooltipStart=document.createElement("div"),this.tooltipStart.className="ds-slider__tooltip",this.thumbStart.appendChild(this.tooltipStart))),this.range&&(this.element.classList.add("ds-slider--range"),this.element.querySelector(".ds-slider__thumb--end")?this.thumbEnd=this.element.querySelector(".ds-slider__thumb--end"):(this.thumbEnd=document.createElement("div"),this.thumbEnd.className="ds-slider__thumb ds-slider__thumb--end",this.thumbEnd.setAttribute("role","slider"),this.thumbEnd.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbEnd),this.showTooltip&&(this.tooltipEnd=document.createElement("div"),this.tooltipEnd.className="ds-slider__tooltip",this.thumbEnd.appendChild(this.tooltipEnd)))),this.showMarks&&this._renderMarks()}_renderMarks(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);for(let i=t;i<=e;i+=this.markStep){const n=document.createElement("div");n.className="ds-slider__mark";const r=(i-t)/(e-t)*100;this.vertical?n.style.bottom=r+"%":n.style.left=r+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=i,n.appendChild(a),this.marksEl.appendChild(n)}this.element.appendChild(this.marksEl)}_bindEvents(){if(this.input){const t=()=>this.updateSlider(),e=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",e),this._listeners.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:e})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this._listeners.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this._bindThumbDrag(this.thumbStart,"start"),this.thumbEnd&&this._bindThumbDrag(this.thumbEnd,"end"),this.track){const t=e=>{this.disabled||this._handleTrackClick(e)};this.track.addEventListener("click",t),this._listeners.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=e=>this._handleKeyboard(e,"start");this.thumbStart.addEventListener("keydown",t),this._listeners.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=e=>this._handleKeyboard(e,"end");this.thumbEnd.addEventListener("keydown",t),this._listeners.push({el:this.thumbEnd,event:"keydown",handler:t})}}_bindThumbDrag(t,e){const i=a=>{this.disabled||(a.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",r))},n=a=>{if(!this._isDragging)return;a.preventDefault();const o=a.touches?a.touches[0].clientX:a.clientX,l=a.touches?a.touches[0].clientY:a.clientY,c=this.track.getBoundingClientRect();let d;this.vertical?d=1-(l-c.top)/c.height:d=(o-c.left)/c.width,d=Math.max(0,Math.min(1,d));const h=parseFloat(this.input?.min||0),u=parseFloat(this.input?.max||100),f=parseFloat(this.input?.step||1);let p=h+d*(u-h);if(p=Math.round(p/f)*f,p=Math.max(h,Math.min(u,p)),e==="start"&&this.range&&this.inputEnd){const m=parseFloat(this.inputEnd.value);p>m&&(p=m)}if(e==="end"&&this.range&&this.input){const m=parseFloat(this.input.value);p<m&&(p=m)}e==="start"&&this.input?this.input.value=p:e==="end"&&this.inputEnd&&(this.inputEnd.value=p),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:d})},r=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",r),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:i},{el:t,event:"touchstart",handler:i})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),i=t.clientX,n=t.clientY;let r;this.vertical?r=1-(n-e.top)/e.height:r=(i-e.left)/e.width,r=Math.max(0,Math.min(1,r));const a=parseFloat(this.input?.min||0),o=parseFloat(this.input?.max||100),l=parseFloat(this.input?.step||1);let c=a+r*(o-a);if(c=Math.round(c/l)*l,this.range){const d=parseFloat(this.input?.value||0),h=parseFloat(this.inputEnd?.value||0),u=Math.abs(c-d),f=Math.abs(c-h);u<=f?this.input&&(this.input.value=Math.min(c,h)):this.inputEnd&&(this.inputEnd.value=Math.max(c,d))}else this.input&&(this.input.value=c);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const i=e==="start"?this.input:this.inputEnd;if(!i)return;const n=parseFloat(i.step||1),r=parseFloat(i.min||0),a=parseFloat(i.max||100);let o=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),o=Math.min(a,o+n);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),o=Math.max(r,o-n);break;case"Home":t.preventDefault(),o=r;break;case"End":t.preventDefault(),o=a;break;default:return}i.value=o,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const i=parseFloat(this.input?.value||0),n=parseFloat(this.inputEnd?.value||0),r=(i-t)/(e-t)*100,a=(n-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=r+"%",this.fill.style.height=a-r+"%"):(this.fill.style.left=r+"%",this.fill.style.width=a-r+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=r+"%":this.thumbStart.style.left=r+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(n)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(n)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",n)}else{const i=this.input?.value||0,n=(i-t)/(e-t)*100;this.vertical?this.fill.style.height=`${n}%`:this.fill.style.width=`${n}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(i))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(i))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.element.setAttribute("aria-valuenow",i)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.marksEl&&this.marksEl.remove(),this.track=null,this.fill=null,this.input=null,this.inputEnd=null,this.valueEl=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.element=null}setValue(t,e){this.input&&(this.input.value=t),e!==void 0&&this.inputEnd&&(this.inputEnd.value=e),this.updateSlider()}getValue(){return this.range&&this.inputEnd?[parseFloat(this.input?.value||0),parseFloat(this.inputEnd?.value||0)]:parseFloat(this.input?.value||0)}enable(){this.disabled=!1,this.element.classList.remove("is-disabled")}disable(){this.disabled=!0,this.element.classList.add("is-disabled")}}function st(s,t){if(!s.__kupolaInitialized)try{const e=new oe(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function zt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function fi(){document.querySelectorAll(".ds-slider").forEach(s=>{st(s)})}typeof window<"u"&&(window.Slider=oe,window.initSlider=st,window.initSliders=fi,window.cleanupSlider=zt,window.kupolaInitializer&&window.kupolaInitializer.register("slider",st,zt));class le{constructor(t,e={}){this.element=t,this.track=t.querySelector(".ds-carousel__track"),this.items=t.querySelectorAll(".ds-carousel__item"),this.prevBtn=t.querySelector(".ds-carousel__prev"),this.nextBtn=t.querySelector(".ds-carousel__next"),this.indicators=t.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=t.querySelector(".ds-carousel__auto"),this.mode=e.mode||t.getAttribute("data-carousel-mode")||"slide",this.vertical=e.vertical||t.hasAttribute("data-carousel-vertical"),this.autoPlay=e.autoPlay!==!1,this.interval=e.interval||parseInt(t.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=e.transitionDuration||parseInt(t.getAttribute("data-carousel-duration"))||500,this.loop=e.loop!==!1,this.pauseOnHover=e.pauseOnHover!==!1,this.swipe=e.swipe!==!1,this.swipeThreshold=e.swipeThreshold||50,this.keyboardNav=e.keyboardNav||t.hasAttribute("data-carousel-keyboard"),this.onChange=e.onChange||null,this.currentIndex=0,this.totalItems=this.items.length,this.autoPlayTimer=null,this.isAutoPlaying=!1,this.isTransitioning=!1,this.touchStartX=0,this.touchStartY=0,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!1,this._mouseEnterHandler=()=>{this.pauseOnHover&&this.stopAutoPlay()},this._mouseLeaveHandler=()=>{this.pauseOnHover&&this.autoPlay&&this.startAutoPlay()},this.init()}init(){this._prevClickHandler=()=>this.prev(),this._nextClickHandler=()=>this.next(),this._autoClickHandler=()=>this.toggleAutoPlay(),this._indicatorClickHandlers=[],this.prevBtn&&this.prevBtn.addEventListener("click",this._prevClickHandler),this.nextBtn&&this.nextBtn.addEventListener("click",this._nextClickHandler),this.indicators.forEach((t,e)=>{const i=()=>this.goTo(e);this._indicatorClickHandlers.push(i),t.addEventListener("click",i)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.swipe&&(this._touchStartHandler=t=>this._handleTouchStart(t),this._touchMoveHandler=t=>this._handleTouchMove(t),this._touchEndHandler=()=>this._handleTouchEnd(),this.element.addEventListener("touchstart",this._touchStartHandler,{passive:!0}),this.element.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),this.element.addEventListener("touchend",this._touchEndHandler)),this.keyboardNav&&(this._keydownHandler=t=>{this.element.contains(document.activeElement)&&(t.key==="ArrowLeft"||t.key==="ArrowUp"?(t.preventDefault(),this.prev()):(t.key==="ArrowRight"||t.key==="ArrowDown")&&(t.preventDefault(),this.next()))},this.element.addEventListener("keydown",this._keydownHandler)),this.mode==="fade"&&this.element.classList.add("ds-carousel--fade"),this.vertical&&this.element.classList.add("ds-carousel--vertical"),this.track&&(this.track.style.transitionDuration=this.transitionDuration+"ms"),this.updateIndicators(),this.autoPlay&&this.startAutoPlay(),this.element.addEventListener("mouseenter",this._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(t){if(this.isTransitioning||t<0||t>=this.totalItems)return;this.isTransitioning=!0;const e=this.currentIndex;if(this.currentIndex=t,this.mode==="fade")this.items.forEach((i,n)=>{i.style.opacity=n===t?"1":"0",i.style.zIndex=n===t?"1":"0"});else if(this.vertical){const i=-t*100;this.track.style.transform=`translateY(${i}%)`}else{const i=-t*100;this.track.style.transform=`translateX(${i}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:t,prevIndex:e,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:t,prevIndex:e,total:this.totalItems},bubbles:!0}))}prev(){this.currentIndex>0?this.goTo(this.currentIndex-1):this.loop&&this.goTo(this.totalItems-1)}next(){this.currentIndex<this.totalItems-1?this.goTo(this.currentIndex+1):this.loop&&this.goTo(0)}updateIndicators(){this.indicators.forEach((t,e)=>{t.classList.toggle("is-active",e===this.currentIndex)}),this.loop||(this.prevBtn&&(this.prevBtn.disabled=this.currentIndex===0),this.nextBtn&&(this.nextBtn.disabled=this.currentIndex===this.totalItems-1))}startAutoPlay(){this.totalItems<=1||(this.stopAutoPlay(),this.isAutoPlaying=!0,this.autoBtn&&this.autoBtn.classList.add("is-active"),this.autoPlayTimer=setInterval(()=>this.next(),this.interval))}stopAutoPlay(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.isAutoPlaying=!1,this.autoBtn&&this.autoBtn.classList.remove("is-active")}toggleAutoPlay(){this.isAutoPlaying?this.stopAutoPlay():this.startAutoPlay()}_handleTouchStart(t){this.touchStartX=t.touches[0].clientX,this.touchStartY=t.touches[0].clientY,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!0,this.isAutoPlaying&&(this.stopAutoPlay(),this._wasAutoPlaying=!0)}_handleTouchMove(t){if(!this.isSwiping)return;this.touchDeltaX=t.touches[0].clientX-this.touchStartX,this.touchDeltaY=t.touches[0].clientY-this.touchStartY;const e=Math.abs(this.touchDeltaX),i=Math.abs(this.touchDeltaY);e>i&&e>10&&t.preventDefault()}_handleTouchEnd(){if(!this.isSwiping)return;this.isSwiping=!1;const t=Math.abs(this.touchDeltaX),e=Math.abs(this.touchDeltaY);t>this.swipeThreshold&&t>e&&(this.touchDeltaX>0?this.prev():this.next()),this._wasAutoPlaying&&(this.startAutoPlay(),this._wasAutoPlaying=!1)}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this._mouseEnterHandler),this.element.removeEventListener("mouseleave",this._mouseLeaveHandler),this.prevBtn&&this._prevClickHandler&&this.prevBtn.removeEventListener("click",this._prevClickHandler),this.nextBtn&&this._nextClickHandler&&this.nextBtn.removeEventListener("click",this._nextClickHandler),this.autoBtn&&this._autoClickHandler&&this.autoBtn.removeEventListener("click",this._autoClickHandler),this.indicators.forEach((t,e)=>{const i=this._indicatorClickHandlers[e];i&&t.removeEventListener("click",i)}),this._touchStartHandler&&this.element.removeEventListener("touchstart",this._touchStartHandler),this._touchMoveHandler&&this.element.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndHandler&&this.element.removeEventListener("touchend",this._touchEndHandler),this._keydownHandler&&this.element.removeEventListener("keydown",this._keydownHandler),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function nt(s,t){if(s.__kupolaInitialized)return;const e=new le(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function mi(s=document){s.querySelectorAll(".ds-carousel").forEach(t=>{nt(t)})}function gi(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}typeof window<"u"&&(window.Carousel=le,window.initCarousel=nt,window.initCarousels=mi,window.kupolaInitializer&&window.kupolaInitializer.register("carousel",nt,gi));class Et{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=e.placement||t.getAttribute("data-drawer-placement")||"right",this.width=e.width||t.getAttribute("data-drawer-width")||"400px",this.height=e.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=e.escClose!==!1,this.maskClosable=e.maskClosable!==!1,this.showMask=e.showMask!==!1,this.onOpen=e.onOpen||null,this.onClose=e.onClose||null,this.onBeforeClose=e.onBeforeClose||null,this._keydownHandler=null,this._bindEvents()}_bindEvents(){const t=this.mask?.querySelector(".ds-drawer__close"),e=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),i=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible"),document.body.style.overflow="",this.onClose&&this.onClose(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-close",{bubbles:!0})))},this.handleMaskClick=n=>{this.maskClosable&&n.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),e&&e.addEventListener("click",this.closeDrawer),i&&i.addEventListener("click",this.closeDrawer),this.escClose&&(this._keydownHandler=n=>{n.key==="Escape"&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this._keydownHandler)),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:e,event:"click",handler:this.closeDrawer},{el:i,event:"click",handler:this.closeDrawer}].filter(n=>n.el)}_applyPlacement(){this.drawerEl&&(this.drawerEl.classList.remove("ds-drawer--right","ds-drawer--left","ds-drawer--top","ds-drawer--bottom"),this.drawerEl.classList.add(`ds-drawer--${this.placement}`),this.placement==="left"||this.placement==="right"?this.drawerEl.style.width=this.width:this.drawerEl.style.height=this.height,!this.showMask&&this.mask&&(this.mask.style.background="transparent",this.mask.style.pointerEvents="none",this.drawerEl.style.boxShadow="0 0 24px rgba(0,0,0,0.15)"))}destroy(){this._listeners?.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._listeners=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._applyPlacement(),this.mask&&this.mask.classList.add("is-visible"),this.drawerEl&&this.drawerEl.classList.add("is-visible"),document.body.style.overflow="hidden",this.onOpen&&this.onOpen(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-open",{bubbles:!0}))}close(){this.closeDrawer()}isOpen(){return this.drawerEl?.classList.contains("is-visible")||!1}}function ks(s={}){const{title:t="",content:e="",html:i=!1,placement:n="right",width:r="400px",height:a="400px",closable:o=!0,showMask:l=!0,footer:c=null,onClose:d,onOpen:h}=s,u=document.createElement("div");u.className="ds-drawer-container";let f="";c!==null&&(typeof c=="string"?f=`<div class="ds-drawer__footer">${c}</div>`:f=`<div class="ds-drawer__footer">
30
+ <button class="ds-btn ds-btn--ghost" data-drawer-cancel>Cancel</button>
31
+ <button class="ds-btn ds-btn--brand" data-drawer-confirm>OK</button>
32
+ </div>`),u.innerHTML=`
33
+ <div class="ds-drawer-mask">
34
+ <div class="ds-drawer ds-drawer--${n}" style="${n==="left"||n==="right"?"width:"+r:"height:"+a}">
35
+ <div class="ds-drawer__header">
36
+ <span class="ds-drawer__title"></span>
37
+ ${o?`<button class="ds-drawer__close" aria-label="Close">
38
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
39
+ <path d="M18 6L6 18M6 6l12 12"/>
40
+ </svg>
41
+ </button>`:""}
42
+ </div>
43
+ <div class="ds-drawer__body"></div>
44
+ ${f}
45
+ </div>
22
46
  </div>
23
- </div>
24
- `,this.element.appendChild(this.panelEl),this.input.value){const l=this.input.value.split(":");l.length>=2&&(this.selectedHour=parseInt(l[0])||0,this.selectedMinute=parseInt(l[1])||0)}const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute");function r(){t.textContent=String(this.selectedHour).padStart(2,"0"),e.textContent=String(this.selectedMinute).padStart(2,"0")}function o(){this.input.value=`${String(this.selectedHour).padStart(2,"0")}:${String(this.selectedMinute).padStart(2,"0")}`}function n(){o.call(this),this.panelEl.style.display="none",this.input.dispatchEvent(new Event("change"))}const i=this.panelEl.querySelector('[data-type="hour"]'),a=this.panelEl.querySelector('[data-type="minute"]');for(let l=0;l<24;l++){const c=document.createElement("button");c.className="ds-timepicker__item",c.textContent=String(l).padStart(2,"0"),l===this.selectedHour&&c.classList.add("is-selected"),c.addEventListener("click",()=>{i.querySelectorAll(".ds-timepicker__item").forEach(h=>h.classList.remove("is-selected")),c.classList.add("is-selected"),this.selectedHour=l,r.call(this),n.call(this)}),i.appendChild(c)}for(let l=0;l<60;l+=5){const c=document.createElement("button");c.className="ds-timepicker__item",c.textContent=String(l).padStart(2,"0"),l===this.selectedMinute&&c.classList.add("is-selected"),c.addEventListener("click",()=>{a.querySelectorAll(".ds-timepicker__item").forEach(h=>h.classList.remove("is-selected")),c.classList.add("is-selected"),this.selectedMinute=l,r.call(this),n.call(this)}),a.appendChild(c)}this.panelEl.addEventListener("click",l=>{l.stopPropagation()}),r.call(this),o.call(this),setTimeout(()=>{this.calculatePosition()},0)}hideTimepicker(t){this.panelEl&&this.panelEl.style.display==="block"&&(this.element.contains(t.target)||(this.panelEl.style.display="none"))}resizeHandler(){this.panelEl&&this.panelEl.style.display==="block"&&this.calculatePosition()}destroy(){this.element.__kupolaInitialized&&(this.inputWrap&&this._inputWrapClickHandler&&this.inputWrap.removeEventListener("click",this._inputWrapClickHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this.element.__kupolaInitialized=!1)}}function ii(s){const t=new si(s);t.init(),s._kupolaTimepicker=t}function ni(s){s._kupolaTimepicker&&(s._kupolaTimepicker.destroy(),s._kupolaTimepicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("timepicker",ii,ni);class ri{constructor(t){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.track||!this.fill||!this.input)throw new Error("Slider: Missing required elements");this._bindEvents(),this.updateSlider()}_bindEvents(){this.updateSlider=()=>{const t=this.input.value,e=this.input.min||0,r=this.input.max||100,o=(t-e)/(r-e)*100;this.fill.style.width=`${o}%`,this.valueEl&&(this.valueEl.textContent=t),this.element.setAttribute("aria-valuenow",t)},this.input.addEventListener("input",this.updateSlider),this.input.addEventListener("change",this.updateSlider),this._listeners=[{el:this.input,event:"input",handler:this.updateSlider},{el:this.input,event:"change",handler:this.updateSlider}]}destroy(){this._listeners?.forEach(({el:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=null,this.track=null,this.fill=null,this.input=null,this.valueEl=null,this.element=null}setValue(t){this.input&&(this.input.value=t,this.updateSlider())}getValue(){return this.input?.value}}function oi(s){if(!s.__kupolaInitialized)try{const t=new ri(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}catch(t){console.error("[Slider] Error initializing:",t)}}function ai(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}window.kupolaInitializer&&window.kupolaInitializer.register("slider",oi,ai);var U={exports:{}},xt;function li(){return xt||(xt=1,function(s){class t{constructor(i){this.element=i,this.track=i.querySelector(".ds-carousel__track"),this.items=i.querySelectorAll(".ds-carousel__item"),this.prevBtn=i.querySelector(".ds-carousel__prev"),this.nextBtn=i.querySelector(".ds-carousel__next"),this.indicators=i.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=i.querySelector(".ds-carousel__auto"),this.currentIndex=0,this.totalItems=this.items.length,this.autoPlayTimer=null,this.isAutoPlaying=!1,this._mouseEnterHandler=()=>this.stopAutoPlay(),this._mouseLeaveHandler=()=>{this.isAutoPlaying&&this.startAutoPlay()},this.init()}init(){this._prevClickHandler=()=>this.prev(),this._nextClickHandler=()=>this.next(),this._autoClickHandler=()=>this.toggleAutoPlay(),this._indicatorClickHandlers=[],this.prevBtn&&this.prevBtn.addEventListener("click",this._prevClickHandler),this.nextBtn&&this.nextBtn.addEventListener("click",this._nextClickHandler),this.indicators.forEach((i,a)=>{const l=()=>this.goTo(a);this._indicatorClickHandlers.push(l),i.addEventListener("click",l)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.updateIndicators(),this.startAutoPlay(),this.element.addEventListener("mouseenter",this._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(i){if(i<0||i>=this.totalItems)return;this.currentIndex=i;const a=-i*100;this.track.style.transform=`translateX(${a}%)`,this.updateIndicators()}prev(){const i=this.currentIndex>0?this.currentIndex-1:this.totalItems-1;this.goTo(i)}next(){const i=this.currentIndex<this.totalItems-1?this.currentIndex+1:0;this.goTo(i)}updateIndicators(){this.indicators.forEach((i,a)=>{a===this.currentIndex?i.classList.add("is-active"):i.classList.remove("is-active")})}startAutoPlay(){this.totalItems<=1||(this.stopAutoPlay(),this.isAutoPlaying=!0,this.autoBtn&&this.autoBtn.classList.add("is-active"),this.autoPlayTimer=setInterval(()=>this.next(),3e3))}stopAutoPlay(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.autoBtn&&this.autoBtn.classList.remove("is-active")}toggleAutoPlay(){this.isAutoPlaying?(this.isAutoPlaying=!1,this.stopAutoPlay()):this.startAutoPlay()}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this._mouseEnterHandler),this.element.removeEventListener("mouseleave",this._mouseLeaveHandler),this.prevBtn&&this._prevClickHandler&&this.prevBtn.removeEventListener("click",this._prevClickHandler),this.nextBtn&&this._nextClickHandler&&this.nextBtn.removeEventListener("click",this._nextClickHandler),this.autoBtn&&this._autoClickHandler&&this.autoBtn.removeEventListener("click",this._autoClickHandler),this.indicators.forEach((i,a)=>{const l=this._indicatorClickHandlers[a];l&&i.removeEventListener("click",l)}),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n=document){n.querySelectorAll(".ds-carousel").forEach(i=>{e(i)})}function o(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}s.exports?s.exports={Carousel:t,initCarousel:e,initCarousels:r,cleanupCarousel:o}:(window.Carousel=t,window.initCarousel=e,window.initCarousels=r,window.kupolaInitializer&&window.kupolaInitializer.register("carousel",e,o))}(U)),U.exports}li();class ci{constructor(t){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this._bindEvents()}_bindEvents(){const t=this.mask?.querySelector(".ds-drawer__close"),e=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),r=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible")},this.handleMaskClick=o=>{o.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),e&&e.addEventListener("click",this.closeDrawer),r&&r.addEventListener("click",this.closeDrawer),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:e,event:"click",handler:this.closeDrawer},{el:r,event:"click",handler:this.closeDrawer}].filter(o=>o.el)}destroy(){this._listeners?.forEach(({el:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this.mask&&this.mask.classList.add("is-visible"),this.drawerEl&&this.drawerEl.classList.add("is-visible")}close(){this.closeDrawer()}}function di(s){if(s.__kupolaInitialized)return;const t=new ci(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function hi(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}window.kupolaInitializer&&window.kupolaInitializer.register("drawer",di,hi);var V={exports:{}},bt;function ui(){return bt||(bt=1,function(s){class t{constructor(a){this.element=a,this.mask=a.querySelector(".ds-modal-mask"),this.modal=a.querySelector(".ds-modal"),this.closeBtn=a.querySelector(".ds-modal__close"),this._keydownHandler=l=>{l.key==="Escape"&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=l=>{l.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.addEventListener("click",this._maskClickHandler),document.addEventListener("keydown",this._keydownHandler)}open(){this.mask.classList.add("is-visible"),t._openCount=(t._openCount||0)+1,document.body.style.overflow="hidden"}close(){this.mask.classList.remove("is-visible"),t._openCount=Math.max(0,(t._openCount||0)-1),t._openCount===0&&(document.body.style.overflow="")}isVisible(){return this.mask.classList.contains("is-visible")}destroy(){document.removeEventListener("keydown",this._keydownHandler),this.closeBtn&&this.closeBtn.removeEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.removeEventListener("click",this._maskClickHandler),this.isVisible()&&this.close()}}t._openCount=0;function e(i={}){const{title:a="",content:l="",width:c="480px",onConfirm:h,onCancel:u}=i,d=document.createElement("div");d.className="ds-modal-container",d.innerHTML=`
47
+ `,document.body.appendChild(u);const p=new Et(u,{placement:n,width:r,height:a,showMask:l,onClose:d,onOpen:h}),m=u.querySelector(".ds-drawer__title");m&&(m.textContent=t);const y=u.querySelector(".ds-drawer__body");y&&(i?y.innerHTML=e:y.textContent=e);const _=u.querySelector("[data-drawer-confirm]"),b=u.querySelector("[data-drawer-cancel]");b&&b.addEventListener("click",()=>p.close()),_&&_.addEventListener("click",()=>{s.onConfirm&&s.onConfirm(),p.close()});const v=p.closeDrawer;return p.closeDrawer=()=>{v(),setTimeout(()=>{p.destroy(),u.remove()},300)},p.open(),p}function W(s,t){if(s.__kupolaInitialized)return;const e=new Et(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Pt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function _i(){document.querySelectorAll("[data-drawer]").forEach(s=>{s.addEventListener("click",()=>{const t=s.getAttribute("data-drawer"),e=document.getElementById(t);e&&(W(e,{placement:s.getAttribute("data-drawer-placement")||"right",width:s.getAttribute("data-drawer-width"),height:s.getAttribute("data-drawer-height")}),e.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(s=>{const t=s.parentElement;t&&W(t)})}typeof window<"u"&&(window.Drawer=Et,window.initDrawer=W,window.initDrawers=_i,window.cleanupDrawer=Pt,window.createDrawer=ks,window.kupolaInitializer&&window.kupolaInitializer.register("drawer",W,Pt));class I{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close"),this.fullscreen=e.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=e.closableOnMask!==!1,this.escClose=e.escClose!==!1,this.width=e.width||t.getAttribute("data-modal-width")||"",this.center=e.center!==!1,this.onBeforeOpen=e.onBeforeOpen||null,this.onBeforeClose=e.onBeforeClose||null,this.onOpened=e.onOpened||null,this.onClosed=e.onClosed||null,this._keydownHandler=i=>{this.escClose&&i.key==="Escape"&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=i=>{this.closableOnMask&&i.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.addEventListener("click",this._maskClickHandler),document.addEventListener("keydown",this._keydownHandler),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){this.onBeforeOpen&&this.onBeforeOpen()===!1||(this.mask&&(this.mask.classList.add("is-visible"),this.mask.classList.add("ds-modal-fade-enter"),requestAnimationFrame(()=>{this.mask.classList.add("ds-modal-fade-enter-active")})),this.modal&&(this.modal.classList.add("ds-modal-zoom-enter"),requestAnimationFrame(()=>{this.modal.classList.add("ds-modal-zoom-enter-active")})),I._openCount=(I._openCount||0)+1,document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0})))}close(){this.onBeforeClose&&this.onBeforeClose()===!1||(this.mask&&(this.mask.classList.remove("ds-modal-fade-enter-active"),this.mask.classList.add("ds-modal-fade-leave-active")),this.modal&&(this.modal.classList.remove("ds-modal-zoom-enter-active"),this.modal.classList.add("ds-modal-zoom-leave-active")),setTimeout(()=>{this.mask&&this.mask.classList.remove("is-visible","ds-modal-fade-enter","ds-modal-fade-leave-active"),this.modal&&this.modal.classList.remove("ds-modal-zoom-enter","ds-modal-zoom-leave-active")},300),I._openCount=Math.max(0,(I._openCount||0)-1),I._openCount===0&&(document.body.style.overflow=""),this.onClosed&&setTimeout(()=>this.onClosed(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-close",{bubbles:!0})))}toggleFullscreen(){this.fullscreen=!this.fullscreen,this.modal&&this.modal.classList.toggle("ds-modal--fullscreen",this.fullscreen)}isVisible(){return this.mask&&this.mask.classList.contains("is-visible")}destroy(){document.removeEventListener("keydown",this._keydownHandler),this.closeBtn&&this.closeBtn.removeEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.removeEventListener("click",this._maskClickHandler),this.isVisible()&&this.close()}}I._openCount=0;function Ct(s={}){const{title:t="",content:e="",html:i=!1,width:n="480px",fullscreen:r=!1,showCancel:a=!0,showConfirm:o=!0,confirmText:l="OK",cancelText:c="Cancel",confirmClass:d="ds-btn--brand",cancelClass:h="ds-btn--ghost",closable:u=!0,maskClosable:f=!0,onConfirm:p,onCancel:m,onOpen:y,onClose:_,footer:b=null}=s,v=document.createElement("div");v.className="ds-modal-container";let w="";b!==null&&(typeof b=="string"?w=`<div class="ds-modal__footer">${b}</div>`:(o||a)&&(w=`<div class="ds-modal__footer">
48
+ ${a?`<button class="ds-btn ${h}" data-modal-cancel>${c}</button>`:""}
49
+ ${o?`<button class="ds-btn ${d}" data-modal-confirm>${l}</button>`:""}
50
+ </div>`)),v.innerHTML=`
25
51
  <div class="ds-modal-mask">
26
- <div class="ds-modal" style="max-width: ${c}">
52
+ <div class="ds-modal${r?" ds-modal--fullscreen":""}" style="${r?"":"max-width: "+n}">
27
53
  <div class="ds-modal__header">
28
54
  <span class="ds-modal__title"></span>
29
- <button class="ds-modal__close" aria-label="Close">
55
+ ${u?`<button class="ds-modal__close" aria-label="Close">
30
56
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
31
57
  <path d="M18 6L6 18M6 6l12 12"/>
32
58
  </svg>
33
- </button>
59
+ </button>`:""}
34
60
  </div>
35
61
  <div class="ds-modal__body"></div>
36
- ${h||u?`
37
- <div class="ds-modal__footer">
38
- ${u?'<button class="ds-btn ds-btn--ghost" data-modal-cancel>Cancel</button>':""}
39
- ${h?'<button class="ds-btn ds-btn--brand" data-modal-confirm>OK</button>':""}
40
- </div>
41
- `:""}
62
+ ${w}
42
63
  </div>
43
64
  </div>
44
- `,document.body.appendChild(d);const p=new t(d),g=d.querySelector(".ds-modal__title");g&&(g.textContent=a);const f=d.querySelector(".ds-modal__body");f&&(f.textContent=l);const m=d.querySelector("[data-modal-confirm]"),v=d.querySelector("[data-modal-cancel]"),y=()=>{h&&h(),p.close()},w=()=>{u&&u(),p.close()};m&&m.addEventListener("click",y),v&&v.addEventListener("click",w);const _=()=>{setTimeout(()=>{m&&m.removeEventListener("click",y),v&&v.removeEventListener("click",w),p.destroy(),d.remove()},300)},b=p.close.bind(p);return p.close=()=>{b(),_()},p.open(),p}function r(i){if(i.__kupolaInitialized)return;const a=new t(i);i.__kupolaInstance=a,i.__kupolaInitialized=!0}function o(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function n(){document.querySelectorAll(".ds-modal-container").forEach(i=>{r(i)})}s.exports?s.exports={Modal:t,initModals:n,initModal:r,cleanupModal:o,createModal:e}:(window.initModal=r,window.cleanupModal=o),window.kupolaInitializer&&window.kupolaInitializer.register("modal",r,o)}(V)),V.exports}ui();var W={exports:{}},kt;function pi(){return kt||(kt=1,function(s){class t{static normal(r={}){return this._create({type:"normal",...r})}static success(r={}){return this._create({type:"success",...r})}static warning(r={}){return this._create({type:"warning",...r})}static error(r={}){return this._create({type:"error",...r})}static info(r={}){return this._create({type:"info",...r})}static confirm(r={}){return this._create({type:"confirm",...r})}static _create(r){const{type:o="normal",title:n="",content:i="",onConfirm:a,onCancel:l}=r,c={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>'},h=document.createElement("div");h.className="ds-modal-container",h.innerHTML=`
65
+ `,document.body.appendChild(v);const k=new I(v,{fullscreen:r,closableOnMask:f}),E=v.querySelector(".ds-modal__title");E&&(E.textContent=t);const x=v.querySelector(".ds-modal__body");x&&(i?x.innerHTML=e:x.textContent=e);const C=v.querySelector("[data-modal-confirm]"),M=v.querySelector("[data-modal-cancel]");let H=!1;const P=async()=>{if(p){C.disabled=!0,C.classList.add("is-loading");try{if(await p()===!1){C.disabled=!1,C.classList.remove("is-loading");return}}catch{C.disabled=!1,C.classList.remove("is-loading");return}}H=!0,k.close()},Ae=()=>{m&&m(),k.close()};C&&C.addEventListener("click",P),M&&M.addEventListener("click",Ae);const fs=()=>{setTimeout(()=>{C&&C.removeEventListener("click",P),M&&M.removeEventListener("click",Ae),k.destroy(),v.remove(),_&&_(H)},300)},ms=k.close.bind(k);return k.close=()=>{ms(),fs()},k.open(),y&&setTimeout(()=>y(),50),k}function yi(s){return typeof s=="string"&&(s={content:s}),Ct({...s,showCancel:!0,showConfirm:!0})}function vi(s){return typeof s=="string"&&(s={content:s}),Ct({...s,showCancel:!1,showConfirm:!0})}function rt(s){if(s.__kupolaInitialized)return;const t=new I(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function $t(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function wi(){document.querySelectorAll(".ds-modal-container").forEach(s=>{rt(s)})}typeof window<"u"&&(window.Modal=I,window.initModal=rt,window.cleanupModal=$t,window.initModals=wi,window.createModal=Ct,window.confirmModal=yi,window.alertModal=vi,window.kupolaInitializer&&window.kupolaInitializer.register("modal",rt,$t));class bi{static normal(t={}){return this._create({type:"normal",...t})}static success(t={}){return this._create({type:"success",...t})}static warning(t={}){return this._create({type:"warning",...t})}static error(t={}){return this._create({type:"error",...t})}static info(t={}){return this._create({type:"info",...t})}static confirm(t={}){return this._create({type:"confirm",...t})}static _create(t){const{type:e="normal",title:i="",content:n="",onConfirm:r,onCancel:a}=t,o={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},l=document.createElement("div");l.className="ds-modal-container",l.innerHTML=`
45
66
  <div class="ds-modal-mask">
46
67
  <div class="ds-modal" style="max-width: 360px">
47
68
  <div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">
48
- <div class="ds-dialog__icon ds-dialog__icon--${o}">${c[o]}</div>
49
- ${n?'<div class="ds-dialog__title"></div>':""}
69
+ <div class="ds-dialog__icon ds-dialog__icon--${e}">${o[e]}</div>
70
+ ${i?'<div class="ds-dialog__title"></div>':""}
50
71
  <div class="ds-dialog__content"></div>
51
72
  <div class="ds-dialog__actions">
52
- ${o==="confirm"||l?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}
53
- <button class="ds-btn ${o==="confirm"?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>
54
- ${o==="confirm"?"Confirm":"OK"}
73
+ ${e==="confirm"||a?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}
74
+ <button class="ds-btn ${e==="confirm"?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>
75
+ ${e==="confirm"?"Confirm":"OK"}
55
76
  </button>
56
77
  </div>
57
78
  </div>
58
79
  </div>
59
80
  </div>
60
- `,document.body.appendChild(h),n&&(h.querySelector(".ds-dialog__title").textContent=n),h.querySelector(".ds-dialog__content").textContent=i;const u=h.querySelector(".ds-modal-mask"),d=h.querySelector("[data-dialog-confirm]"),p=h.querySelector("[data-dialog-cancel]"),g=function(w){w.key==="Escape"&&(l&&l(),y())},f=function(w){w.target===u&&(l&&l(),y())},m=function(){a&&a(),y()},v=function(){l&&l(),y()},y=()=>{u.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",g),u.removeEventListener("click",f),d&&d.removeEventListener("click",m),p&&p.removeEventListener("click",v),setTimeout(()=>h.remove(),300)};return u.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",m),p&&p.addEventListener("click",v),u.addEventListener("click",f),document.addEventListener("keydown",g),{close:y}}}s.exports&&(s.exports=t)}(W)),W.exports}pi();var Y={exports:{}},Et;function fi(){return Et||(Et=1,function(s){class t{constructor(i){this.element=i,this.dropzone=i.querySelector(".ds-fileupload__dropzone"),this.input=i.querySelector(".ds-fileupload__input"),this.list=i.querySelector(".ds-fileupload__list"),this.progress=i.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(i.getAttribute("data-max-size"))||0,this.maxCount=parseInt(i.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const i=u=>{u.target===this.input||this.input.contains(u.target)||this.input.click()},a=u=>{const d=Array.from(u.target.files);this.addFiles(d),u.target.value=""},l=u=>{u.preventDefault(),u.stopPropagation(),this.dropzone.classList.add("is-dragging")},c=u=>{u.preventDefault(),u.stopPropagation(),this.dropzone.classList.remove("is-dragging")},h=u=>{u.preventDefault(),u.stopPropagation(),this.dropzone.classList.remove("is-dragging");const d=Array.from(u.dataTransfer.files);this.addFiles(d)};this.dropzone.addEventListener("click",i),this.input.addEventListener("change",a),this.dropzone.addEventListener("dragover",l),this.dropzone.addEventListener("dragleave",c),this.dropzone.addEventListener("drop",h),this._listeners.push({el:this.dropzone,event:"click",handler:i},{el:this.input,event:"change",handler:a},{el:this.dropzone,event:"dragover",handler:l},{el:this.dropzone,event:"dragleave",handler:c},{el:this.dropzone,event:"drop",handler:h})}addFiles(i){i.forEach(a=>{if(this.maxCount>0&&this.files.length>=this.maxCount){this.showError(`Maximum ${this.maxCount} files allowed`);return}this.isValidFile(a)&&(this.files.push(a),this.renderFileItem(a),this.showPreview(a))}),this.dispatchChange()}isValidFile(i){const a=this.input.getAttribute("accept");if(a&&a!==""){const l=a.split(",").map(d=>d.trim()),c=i.type,h=i.name.toLowerCase();if(!l.some(d=>d.startsWith(".")?h.endsWith(d):d.includes("/")?d.endsWith("/*")?c.startsWith(d.replace("/*","")):c===d:!0))return this.showError(`File type not allowed: ${i.type}`),!1}return this.maxSize>0&&i.size>this.maxSize?(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1):!0}renderFileItem(i){const a=document.createElement("div");a.className="ds-fileupload__item",a.dataset.filename=i.name;const l=this.getFileIcon(i.type);a.innerHTML=`
81
+ `,document.body.appendChild(l),i&&(l.querySelector(".ds-dialog__title").textContent=i),l.querySelector(".ds-dialog__content").textContent=n;const c=l.querySelector(".ds-modal-mask"),d=l.querySelector("[data-dialog-confirm]"),h=l.querySelector("[data-dialog-cancel]"),u=function(_){_.key==="Escape"&&(a&&a(),y())},f=function(_){_.target===c&&(a&&a(),y())},p=function(){r&&r(),y()},m=function(){a&&a(),y()},y=()=>{c.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",u),c.removeEventListener("click",f),d&&d.removeEventListener("click",p),h&&h.removeEventListener("click",m),setTimeout(()=>l.remove(),300)};return c.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",p),h&&h.addEventListener("click",m),c.addEventListener("click",f),document.addEventListener("keydown",u),{close:y}}}typeof window<"u"&&(window.Dialog=bi);const ki={normal:function(s){this.show({...s,type:"normal"})},success:function(s){this.show({...s,type:"success"})},error:function(s){this.show({...s,type:"error"})},warning:function(s){this.show({...s,type:"warning"})},info:function(s){this.show({...s,type:"info"})},show:function(s){const{title:t,message:e,type:i="normal",duration:n=4e3}=s,r=document.createElement("div");r.className=`ds-notification__item ds-notification__item--${i}`;const a={normal:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};r.innerHTML=`
82
+ <div class="ds-notification__icon ds-notification__icon--${i}">${a[i]}</div>
83
+ <div class="ds-notification__content">
84
+ ${t?'<div class="ds-notification__title"></div>':""}
85
+ ${e?'<div class="ds-notification__message"></div>':""}
86
+ </div>
87
+ <button class="ds-notification__close">
88
+ <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>
89
+ </button>
90
+ `,t&&(r.querySelector(".ds-notification__title").textContent=t),e&&(r.querySelector(".ds-notification__message").textContent=e);let o=document.querySelector(".ds-notification");o||(o=document.createElement("div"),o.className="ds-notification",document.body.appendChild(o)),o.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),r.querySelector(".ds-notification__close").addEventListener("click",()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)}),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};function xi(){}typeof window<"u"&&(window.Notification=ki,window.initNotifications=xi);const Ei={normal:function(s,t={}){this.show(s,"normal",t)},success:function(s,t={}){this.show(s,"success",t)},error:function(s,t={}){this.show(s,"error",t)},warning:function(s,t={}){this.show(s,"warning",t)},info:function(s,t={}){this.show(s,"info",t)},show:function(s,t="normal",e={}){const{duration:i=3e3}=e,n=document.createElement("div");n.className=`ds-message__item ds-message__item--${t}`;const r={normal:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};n.innerHTML=`
91
+ <div class="ds-message__icon ds-message__icon--${t}">${r[t]}</div>
92
+ <div class="ds-message__content"></div>
93
+ `,n.querySelector(".ds-message__content").textContent=s;let a=document.querySelector(".ds-message");a||(a=document.createElement("div"),a.className="ds-message",document.body.appendChild(a)),a.appendChild(n),setTimeout(()=>{n.classList.add("is-visible")},10),i>0&&setTimeout(()=>{n.classList.remove("is-visible"),n.classList.add("is-exiting"),setTimeout(()=>n.remove(),300)},i)}};function Ci(){}typeof window<"u"&&(window.Message=Ei,window.initMessages=Ci);class ce{constructor(t){this.element=t,this.dropzone=t.querySelector(".ds-fileupload__dropzone"),this.input=t.querySelector(".ds-fileupload__input"),this.list=t.querySelector(".ds-fileupload__list"),this.progress=t.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(t.getAttribute("data-max-size"))||0,this.maxCount=parseInt(t.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const t=a=>{a.target===this.input||this.input.contains(a.target)||this.input.click()},e=a=>{const o=Array.from(a.target.files);this.addFiles(o),a.target.value=""},i=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.add("is-dragging")},n=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.remove("is-dragging")},r=a=>{a.preventDefault(),a.stopPropagation(),this.dropzone.classList.remove("is-dragging");const o=Array.from(a.dataTransfer.files);this.addFiles(o)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",e),this.dropzone.addEventListener("dragover",i),this.dropzone.addEventListener("dragleave",n),this.dropzone.addEventListener("drop",r),this._listeners.push({el:this.dropzone,event:"click",handler:t},{el:this.input,event:"change",handler:e},{el:this.dropzone,event:"dragover",handler:i},{el:this.dropzone,event:"dragleave",handler:n},{el:this.dropzone,event:"drop",handler:r})}addFiles(t){t.forEach(e=>{if(this.maxCount>0&&this.files.length>=this.maxCount){this.showError(`Maximum ${this.maxCount} files allowed`);return}this.isValidFile(e)&&(this.files.push(e),this.renderFileItem(e),this.showPreview(e))}),this.dispatchChange()}isValidFile(t){const e=this.input.getAttribute("accept");if(e&&e!==""){const i=e.split(",").map(o=>o.trim()),n=t.type,r=t.name.toLowerCase();if(!i.some(o=>o.startsWith(".")?r.endsWith(o):o.includes("/")?o.endsWith("/*")?n.startsWith(o.replace("/*","")):n===o:!0))return this.showError(`File type not allowed: ${t.type}`),!1}return this.maxSize>0&&t.size>this.maxSize?(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1):!0}renderFileItem(t){const e=document.createElement("div");e.className="ds-fileupload__item",e.dataset.filename=t.name;const i=this.getFileIcon(t.type);e.innerHTML=`
61
94
  <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">
62
- ${l}
95
+ ${i}
63
96
  </div>
64
- <span class="ds-fileupload__filename">${this.truncateFilename(i.name)}</span>
65
- <span class="ds-fileupload__size">${this.formatSize(i.size)}</span>
97
+ <span class="ds-fileupload__filename">${this.truncateFilename(t.name)}</span>
98
+ <span class="ds-fileupload__size">${this.formatSize(t.size)}</span>
66
99
  <button class="ds-fileupload__remove" type="button" aria-label="Remove file">
67
100
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
68
101
  <path d="M18 6L6 18"/>
69
102
  <path d="M6 6l12 12"/>
70
103
  </svg>
71
104
  </button>
72
- `;const c=a.querySelector(".ds-fileupload__remove"),h=()=>{this.removeFile(i,a)};c.addEventListener("click",h),this._listeners.push({el:c,event:"click",handler:h}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(a)}getFileIcon(i){return i.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>':i.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>':i.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>':i.includes("pdf")||i.includes("document")||i.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>':i.includes("zip")||i.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(i,a=20){if(i.length<=a)return i;const l=i.substring(i.lastIndexOf("."));return i.substring(0,i.lastIndexOf(".")).substring(0,a-l.length-3)+"..."+l}formatSize(i){if(i===0)return"0 B";const a=1024,l=["B","KB","MB","GB"],c=Math.floor(Math.log(i)/Math.log(a));return parseFloat((i/Math.pow(a,c)).toFixed(1))+" "+l[c]}removeFile(i,a){this.files=this.files.filter(l=>l!==i),a&&a.remove(),this.files.length===0&&this.list&&(this.list.remove(),this.list=null),this.dispatchChange()}clearFiles(){this.files=[],this.list&&(this.list.remove(),this.list=null),this.preview&&(this.preview.innerHTML=""),this.clearError(),this.dispatchChange()}showError(i){this.clearError(),this.dropzone.classList.add("is-error");const a=document.createElement("div");a.className="ds-fileupload__error",a.textContent=i,a.setAttribute("role","alert"),a.setAttribute("aria-live","polite"),this.dropzone.appendChild(a),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const i=this.dropzone.querySelector(".ds-fileupload__error");i&&i.remove()}showPreview(i){if(!i.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 a=new FileReader;a.onload=l=>{const c=document.createElement("div");c.className="ds-fileupload__preview-item",c.innerHTML=`
73
- <img src="${l.target.result}" alt="${i.name}">
105
+ `;const n=e.querySelector(".ds-fileupload__remove"),r=()=>{this.removeFile(t,e)};n.addEventListener("click",r),this._listeners.push({el:n,event:"click",handler:r}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(e)}getFileIcon(t){return t.startsWith("image/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>':t.startsWith("video/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>':t.startsWith("audio/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>':t.includes("pdf")||t.includes("document")||t.includes("text")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>':t.includes("zip")||t.includes("archive")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M16 11V7a4 4 0 0 0-8 0v4"/><polyline points="10 14 8 16 6 14"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>'}truncateFilename(t,e=20){if(t.length<=e)return t;const i=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,e-i.length-3)+"..."+i}formatSize(t){if(t===0)return"0 B";const e=1024,i=["B","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,n)).toFixed(1))+" "+i[n]}removeFile(t,e){this.files=this.files.filter(i=>i!==t),e&&e.remove(),this.files.length===0&&this.list&&(this.list.remove(),this.list=null),this.dispatchChange()}clearFiles(){this.files=[],this.list&&(this.list.remove(),this.list=null),this.preview&&(this.preview.innerHTML=""),this.clearError(),this.dispatchChange()}showError(t){this.clearError(),this.dropzone.classList.add("is-error");const e=document.createElement("div");e.className="ds-fileupload__error",e.textContent=t,e.setAttribute("role","alert"),e.setAttribute("aria-live","polite"),this.dropzone.appendChild(e),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const t=this.dropzone.querySelector(".ds-fileupload__error");t&&t.remove()}showPreview(t){if(!t.type.startsWith("image/"))return;this.preview||(this.preview=document.createElement("div"),this.preview.className="ds-fileupload__preview",this.element.insertBefore(this.preview,this.list||null));const e=new FileReader;e.onload=i=>{const n=document.createElement("div");n.className="ds-fileupload__preview-item",n.innerHTML=`
106
+ <img src="${i.target.result}" alt="${t.name}">
74
107
  <button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">
75
108
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
76
109
  <path d="M18 6L6 18"/>
77
110
  <path d="M6 6l12 12"/>
78
111
  </svg>
79
112
  </button>
80
- `;const h=c.querySelector(".ds-fileupload__preview-remove"),u=()=>{this.removeFile(i,this.list?.querySelector(`[data-filename="${i.name}"]`)),c.remove(),this.preview&&this.preview.children.length===0&&(this.preview.remove(),this.preview=null)};h.addEventListener("click",u),this._listeners.push({el:h,event:"click",handler:u}),this.preview.appendChild(c)},a.readAsDataURL(i)}updateProgress(i){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 a=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");a.className="ds-fileupload__progress-bar",a.style.width=`${i}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(a),i>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(i){this.updateProgress(0);const a=100;let l=0;Math.max(1,Math.floor(i.size/a));const c=setInterval(()=>{l++;const h=Math.min(100,Math.floor(l/a*100));this.updateProgress(h),l>=a&&(clearInterval(c),this.updateProgress(100))},Math.max(50,Math.floor(5e3/a)));return c}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("ds-fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-fileupload").forEach(n=>{e(n)})}s.exports?s.exports={FileUpload:t,initFileUploads:o,initFileUpload:e,cleanupFileUpload:r}:(window.FileUpload=t,window.initFileUpload=e,window.cleanupFileUpload=r),window.kupolaInitializer&&window.kupolaInitializer.register("fileupload",e,r)}(Y)),Y.exports}fi();var X={exports:{}},Ct;function mi(){return Ct||(Ct=1,function(s){class t{constructor(i){this.element=i,this.headers=[],this._listeners=[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach(a=>{const l=a.closest(".ds-collapse__item"),c=a.nextElementSibling;if(!l||!c||!c.classList.contains("ds-collapse__content"))return;const h=l.classList.contains("is-active");c.style.height=h?c.scrollHeight+"px":"0";const u=()=>{if(c.style.height!=="0px")c.style.height="0",l.classList.remove("is-active");else{c.style.height=c.scrollHeight+"px",l.classList.add("is-active");const p=function(){c.removeEventListener("transitionend",p),c.style.height=""};c.addEventListener("transitionend",p),this._listeners.push({el:c,event:"transitionend",handler:p})}};a.addEventListener("click",u),this.headers.push({header:a,item:l,content:c,clickHandler:u}),this._listeners.push({el:a,event:"click",handler:u})})}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.headers=null,this.element=null}toggle(i){const a=this.headers[i];a&&a.clickHandler()}expand(i){const a=this.headers[i];a&&!a.item.classList.contains("is-active")&&a.clickHandler()}collapse(i){const a=this.headers[i];a&&a.item.classList.contains("is-active")&&a.clickHandler()}expandAll(){this.headers.forEach((i,a)=>{i.item.classList.contains("is-active")||this.toggle(a)})}collapseAll(){this.headers.forEach((i,a)=>{i.item.classList.contains("is-active")&&this.toggle(a)})}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-collapse").forEach(n=>{e(n)})}s.exports?s.exports={Collapse:t,initCollapses:o,initCollapse:e,cleanupCollapse:r}:(window.Collapse=t,window.initCollapse=e,window.cleanupCollapse=r),window.kupolaInitializer&&window.kupolaInitializer.register("collapse",e,r)}(X)),X.exports}mi();class gi{constructor(t){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._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._colorClickHandler=null,this._inputInputHandler=null}init(){!this.trigger||!this.panel||this.element.__kupolaInitialized||(this._triggerClickHandler=t=>{t.stopPropagation(),this.togglePanel()},this._colorClickHandler=t=>{const r=t.currentTarget.getAttribute("data-color");this.updateColor(r),this.hidePanel()},this._inputInputHandler=t=>{this.updateColor(t.target.value)},this._documentClickHandler=t=>{this.element.contains(t.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.addEventListener("click",this._colorClickHandler),t._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler),window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this.element.__kupolaInitialized=!0)}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}updateColor(t){this.trigger.style.backgroundColor=t,this.valueSpan&&(this.valueSpan.textContent=t.toUpperCase()),this.customInput&&(this.customInput.value=t),this.element.dispatchEvent(new CustomEvent("colorchange",{detail:{color:t}}))}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t._colorPickerColorHandler&&t.removeEventListener("click",t._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._colorClickHandler=null,this._inputInputHandler=null,this.element.__kupolaInitialized=!1)}}function yi(s){const t=new gi(s);t.init(),s._kupolaColorPicker=t}function vi(s){s._kupolaColorPicker&&(s._kupolaColorPicker.destroy(),s._kupolaColorPicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("color-picker",yi,vi);var J={exports:{}},St;function _i(){return St||(St=1,function(s){class t{constructor(i){if(this.element=i,this.titleEl=i.querySelector(".ds-calendar__title"),this.daysEl=i.querySelector(".ds-calendar__days"),this.prevBtn=i.querySelector(".ds-calendar__nav--prev"),this.nextBtn=i.querySelector(".ds-calendar__nav--next"),this.todayBtn=i.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this._init()}_init(){this.render();const i=()=>{this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render()},a=()=>{this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render()},l=()=>{this.currentDate=new Date,this.render()};this.prevBtn&&(this.prevBtn.addEventListener("click",i),this._listeners.push({el:this.prevBtn,event:"click",handler:i})),this.nextBtn&&(this.nextBtn.addEventListener("click",a),this._listeners.push({el:this.nextBtn,event:"click",handler:a})),this.todayBtn&&(this.todayBtn.addEventListener("click",l),this._listeners.push({el:this.todayBtn,event:"click",handler:l}))}render(){const i=this.currentDate.getFullYear(),a=this.currentDate.getMonth();this.titleEl.textContent=`${i} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a]}`;const l=new Date(i,a,1).getDay(),c=new Date(i,a+1,0).getDate();this.daysEl.innerHTML="";for(let d=0;d<l;d++){const p=document.createElement("span");p.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(p)}const h=new Date,u=`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`;for(let d=1;d<=c;d++){const p=document.createElement("button");p.className="ds-calendar__day",p.textContent=d;const g=`${i}-${String(a+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`;g===u&&p.classList.add("is-today");const f=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(m=>m.classList.remove("is-selected")),p.classList.add("is-selected"),this.$emit("select",{date:new Date(i,a,d),dateStr:g})};p.addEventListener("click",f),this._listeners.push({el:p,event:"click",handler:f}),this.daysEl.appendChild(p)}}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(i){this.currentDate=new Date(i),this.render()}getDate(){return this.currentDate}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render()}goToToday(){this.currentDate=new Date,this.render()}$emit(i,a){if(this.element){const l=new CustomEvent(`kupola:calendar:${i}`,{detail:a,bubbles:!0,cancelable:!0});this.element.dispatchEvent(l)}}}function e(n){if(!n.__kupolaInitialized)try{const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}catch(i){console.error("[Calendar] Error initializing:",i)}}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-calendar").forEach(n=>{e(n)})}s.exports?s.exports={Calendar:t,initCalendars:o,initCalendar:e,cleanupCalendar:r}:(window.Calendar=t,window.initCalendar=e,window.cleanupCalendar=r),window.kupolaInitializer&&window.kupolaInitializer.register("calendar",e,r)}(J)),J.exports}_i();var j={exports:{}},Lt;function wi(){return Lt||(Lt=1,function(s){class t{constructor(i){this.element=i,this.input=i.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__remove").forEach(i=>{const a=l=>{l.stopPropagation();const c=i.closest(".ds-dynamic-tags__tag");c&&(c.remove(),this.dispatchChange())};i.addEventListener("click",a),this._listeners.push({el:i,event:"click",handler:a})}),this.input){const i=()=>{const c=this.input.value.trim();if(!c)return;const h=document.createElement("span");h.className="ds-dynamic-tags__tag";const u=document.createTextNode(c);h.appendChild(u);const d=document.createElement("button");d.className="ds-dynamic-tags__remove",d.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>',h.appendChild(d);const p=g=>{g.stopPropagation(),h.remove(),this.dispatchChange()};d.addEventListener("click",p),this._listeners.push({el:d,event:"click",handler:p}),this.element.insertBefore(h,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},a=c=>{c.key==="Enter"&&(c.preventDefault(),c.stopPropagation(),i())};this.input.addEventListener("keydown",a),this._listeners.push({el:this.input,event:"keydown",handler:a});const l=()=>{this.input.focus()};this.element.addEventListener("click",l),this._listeners.push({el:this.element,event:"click",handler:l})}}addTag(i){!i||!this.input||(this.input.value=i,this.input.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})))}removeTag(i){const l=this.element.querySelectorAll(".ds-dynamic-tags__tag")[i];l&&(l.remove(),this.dispatchChange())}getTags(){const i=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(a=>{i.push(a.textContent)}),i}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(i=>{i.remove()}),this.dispatchChange()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("ds-dynamic-tags-change",{detail:{tags:this.getTags(),count:this.getTags().length}}))}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.input=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-dynamic-tags").forEach(n=>{e(n)})}s.exports?s.exports={DynamicTags:t,initDynamicTagsAll:o,initDynamicTags:e,cleanupDynamicTags:r}:(window.DynamicTags=t,window.initDynamicTags=e,window.cleanupDynamicTags=r),window.kupolaInitializer&&window.kupolaInitializer.register("dynamic-tags",e,r)}(j)),j.exports}wi();var G={exports:{}},Ht;function xi(){return Ht||(Ht=1,function(s){class t{constructor(i={}){this.images=i.images||[],this.currentIndex=i.currentIndex||0,this.overlay=null,this.closeHandler=this.close.bind(this),this.keyHandler=this.handleKeydown.bind(this),this.clickHandler=this.handleOverlayClick.bind(this),this.init()}init(){this.createOverlay()}createOverlay(){this.overlay=document.createElement("div"),this.overlay.className="ds-image-preview-overlay",this.overlay.innerHTML=`
113
+ `;const r=n.querySelector(".ds-fileupload__preview-remove"),a=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),n.remove(),this.preview&&this.preview.children.length===0&&(this.preview.remove(),this.preview=null)};r.addEventListener("click",a),this._listeners.push({el:r,event:"click",handler:a}),this.preview.appendChild(n)},e.readAsDataURL(t)}updateProgress(t){this.progress||(this.progress=document.createElement("div"),this.progress.className="ds-fileupload__progress",this.element.insertBefore(this.progress,this.list||null)),this.progress.style.display="block";const e=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");e.className="ds-fileupload__progress-bar",e.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(e),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const e=100;let i=0;Math.max(1,Math.floor(t.size/e));const n=setInterval(()=>{i++;const r=Math.min(100,Math.floor(i/e*100));this.updateProgress(r),i>=e&&(clearInterval(n),this.updateProgress(100))},Math.max(50,Math.floor(5e3/e)));return n}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function at(s){if(s.__kupolaInitialized)return;const t=new ce(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function qt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Si(){document.querySelectorAll(".ds-fileupload").forEach(s=>{at(s)})}typeof window<"u"&&(window.FileUpload=ce,window.initFileUpload=at,window.cleanupFileUpload=qt,window.initFileUploads=Si,window.kupolaInitializer&&window.kupolaInitializer.register("fileupload",at,qt));class de{constructor(t,e={}){this.element=t,this.headers=[],this._listeners=[],this.accordion=e.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=e.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=e.disabledItems||[],this.defaultExpanded=e.defaultExpanded||[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach((e,i)=>{const n=e.closest(".ds-collapse__item"),r=e.nextElementSibling;if(!n||!r||!r.classList.contains("ds-collapse__content"))return;const a=n.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(i);a&&n.classList.add("is-disabled");let o=n.classList.contains("is-active");(this.defaultExpanded==="all"||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(i))&&(o=!0),o?(n.classList.add("is-active"),r.style.height=r.scrollHeight+"px",r.style.overflow="hidden",setTimeout(()=>{n.classList.contains("is-active")&&(r.style.height="auto",r.style.overflow="visible")},this.animationDuration)):(n.classList.remove("is-active"),r.style.height="0",r.style.overflow="hidden");const l=()=>{if(a)return;const c=n.classList.contains("is-active");this.accordion&&!c&&this.headers.forEach((d,h)=>{h!==i&&d.item.classList.contains("is-active")&&this._collapseItem(d)}),c?this._collapseItem({item:n,content:r}):this._expandItem({item:n,content:r}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:i,expanded:!c,item:n},bubbles:!0}))};e.addEventListener("click",l),this.headers.push({header:e,item:n,content:r,clickHandler:l,isDisabled:a}),this._listeners.push({el:e,event:"click",handler:l})})}_expandItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",e.classList.add("is-active");const n=()=>{i.removeEventListener("transitionend",n),e.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",n),this._listeners.push({el:i,event:"transitionend",handler:n})}_collapseItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",e.classList.remove("is-active");const n=()=>{i.removeEventListener("transitionend",n),i.style.transition=""};i.addEventListener("transitionend",n),this._listeners.push({el:i,event:"transitionend",handler:n})}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.headers=null,this.element=null}toggle(t){const e=this.headers[t];e&&!e.isDisabled&&e.clickHandler()}expand(t){const e=this.headers[t];e&&!e.item.classList.contains("is-active")&&!e.isDisabled&&(this.accordion&&this.headers.forEach((i,n)=>{n!==t&&i.item.classList.contains("is-active")&&this._collapseItem(i)}),this._expandItem(e))}collapse(t){const e=this.headers[t];e&&e.item.classList.contains("is-active")&&this._collapseItem(e)}expandAll(){this.accordion||this.headers.forEach((t,e)=>{!t.item.classList.contains("is-active")&&!t.isDisabled&&this._expandItem(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this._collapseItem(t)})}getExpandedIndices(){return this.headers.map((t,e)=>t.item.classList.contains("is-active")?e:-1).filter(t=>t>=0)}disable(t){this.headers[t]&&(this.headers[t].isDisabled=!0,this.headers[t].item.classList.add("is-disabled"))}enable(t){this.headers[t]&&(this.headers[t].isDisabled=!1,this.headers[t].item.classList.remove("is-disabled"))}}function ot(s,t){if(s.__kupolaInitialized)return;const e=new de(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Bt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Li(){document.querySelectorAll(".ds-collapse").forEach(s=>{ot(s)})}typeof window<"u"&&(window.Collapse=de,window.initCollapse=ot,window.cleanupCollapse=Bt,window.initCollapses=Li,window.kupolaInitializer&&window.kupolaInitializer.register("collapse",ot,Bt));class he{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-color-picker__trigger"),this.panel=t.querySelector(".ds-color-picker__panel"),this.valueSpan=t.querySelector(".ds-color-picker__value"),this.customInput=t.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=e,this.value=e.value||"#007bff",this.showAlpha=e.showAlpha!==!1,this.mode=e.mode||"hex",this.previousColors=e.previousColors||this._getStoredColors(),this.previousColorsLimit=e.previousColorsLimit||12,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this._colorStringToHSB(this.value)}_getStoredColors(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}_storeColors(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}_addPreviousColor(t){const e=this.previousColors.indexOf(t);e!==-1&&this.previousColors.splice(e,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this._storeColors(),this._renderPreviousColors()}_colorStringToHSB(t){const e=t.replace(/^#/,""),i=parseInt(e.substring(0,2),16)/255,n=parseInt(e.substring(2,4),16)/255,r=parseInt(e.substring(4,6),16)/255,a=e.length===8?parseInt(e.substring(6,8),16)/255:1,o=Math.max(i,n,r),l=Math.min(i,n,r);let c=0,d=0,h=o;const u=o-l;if(d=o===0?0:u/o,o!==l)switch(o){case i:c=((n-r)/u+(n<r?6:0))/6;break;case n:c=((r-i)/u+2)/6;break;case r:c=((i-n)/u+4)/6;break}this.hue=Math.round(c*360),this.saturation=Math.round(d*100),this.brightness=Math.round(h*100),this.alpha=Math.round(a*100)}_HSBToColorString(t,e,i,n=1){e/=100,i/=100,n/=100;const r=h=>(h+t/60)%6,a=h=>i*(1-e*Math.max(0,Math.min(r(h),4-r(h),1))),o=Math.round(a(5)*255),l=Math.round(a(3)*255),c=Math.round(a(1)*255);if(this.mode==="rgb")return n<1?`rgba(${o}, ${l}, ${c}, ${n.toFixed(2)})`:`rgb(${o}, ${l}, ${c})`;if(this.mode==="hsl")return n<1?`hsla(${t}, ${Math.round(e*100)}%, ${Math.round(i*100)}%, ${n.toFixed(2)})`:`hsl(${t}, ${Math.round(e*100)}%, ${Math.round(i*100)}%)`;const d=`#${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`;return n<1?d+Math.round(n*255).toString(16).padStart(2,"0"):d}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=e,i.setAttribute("data-color",e),i.addEventListener("click",this._colorClickHandler),t.appendChild(i)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),i=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),e&&(e.style.background=`hsl(${this.hue}, 100%, 50%)`),i&&this.showAlpha&&(i.value=this.alpha,i.style.background=`linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel||this.element.__kupolaInitialized)return;this._triggerClickHandler=n=>{n.stopPropagation(),this.togglePanel()},this._colorClickHandler=n=>{const a=n.currentTarget.getAttribute("data-color");this.updateColor(a),this.hidePanel()},this._inputInputHandler=n=>{const r=n.target.value;this._isValidColor(r)&&this.updateColor(r)},this._alphaChangeHandler=n=>{this.alpha=parseInt(n.target.value),this._updateFromHSB()},this._modeChangeHandler=n=>{const r=n.currentTarget;this.mode=r.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(a=>a.classList.remove("is-active")),r.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=n=>{this.hue=parseInt(n.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=n=>{const r=n.currentTarget.getBoundingClientRect(),a=n.clientX-r.left,o=n.clientY-r.top;this.saturation=Math.round(a/r.width*100),this.brightness=Math.round((1-o/r.height)*100),this._updateFromHSB()},this._documentClickHandler=n=>{this.element.contains(n.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n.addEventListener("click",this._colorClickHandler),n._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this._hueChangeHandler);const e=this.panel.querySelector(".ds-color-picker__sv");e&&(e.addEventListener("click",this._saturationChangeHandler),e.addEventListener("mousemove",n=>{n.buttons===1&&this._saturationChangeHandler(n)}));const i=this.panel.querySelector(".ds-color-picker__alpha");i&&this.showAlpha&&i.addEventListener("input",this._alphaChangeHandler),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.addEventListener("click",this._modeChangeHandler),n.getAttribute("data-mode")===this.mode&&n.classList.add("is-active")}),window.globalEvents?this._documentClickListener=window.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}):document.addEventListener("click",this._documentClickHandler),this._renderPreviousColors(),this._renderColorPanel(),this._updateDisplay(),this.element.__kupolaInitialized=!0}_isValidColor(t){const e=new Option().style;return e.color=t,e.color!==""}_updateFromHSB(){const t=this._HSBToColorString(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}}))}_updateDisplay(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this._renderColorPanel()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this._isValidColor(t)&&(this.value=t,this._colorStringToHSB(t),this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}})))}setValue(t){this.updateColor(t)}getValue(){return this.value}setMode(t){(t==="hex"||t==="rgb"||t==="hsl")&&(this.mode=t,this._updateDisplay())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this._updateFromHSB()}getAlpha(){return this.alpha}destroy(){if(!this.element.__kupolaInitialized)return;this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(n=>{n._colorPickerColorHandler&&n.removeEventListener("click",n._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this._hueChangeHandler&&t.removeEventListener("input",this._hueChangeHandler);const e=this.panel?.querySelector(".ds-color-picker__sv");e&&this._saturationChangeHandler&&(e.removeEventListener("click",this._saturationChangeHandler),e.removeEventListener("mousemove",this._saturationChangeHandler));const i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this._alphaChangeHandler&&i.removeEventListener("input",this._alphaChangeHandler),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(n=>{n.removeEventListener("click",this._modeChangeHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.element.__kupolaInitialized=!1}}function lt(s,t){const e=new he(s,t);e.init(),s._kupolaColorPicker=e}function Di(s=document){s.querySelectorAll(".ds-color-picker").forEach(t=>{lt(t)})}function ct(s){s._kupolaColorPicker&&(s._kupolaColorPicker.destroy(),s._kupolaColorPicker=null)}function xs(){document.querySelectorAll(".ds-color-picker").forEach(s=>{ct(s)})}typeof window<"u"&&(window.ColorPicker=he,window.initColorPicker=lt,window.initColorPickers=Di,window.cleanupColorPicker=ct,window.cleanupAllColorPickers=xs,window.kupolaInitializer&&window.kupolaInitializer.register("color-picker",lt,ct));class ue{constructor(t,e={}){if(this.element=t,this.titleEl=t.querySelector(".ds-calendar__title"),this.daysEl=t.querySelector(".ds-calendar__days"),this.prevBtn=t.querySelector(".ds-calendar__nav--prev"),this.nextBtn=t.querySelector(".ds-calendar__nav--next"),this.todayBtn=t.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=e.selectedDate?new Date(e.selectedDate):null,this.rangeStart=e.rangeStart?new Date(e.rangeStart):null,this.rangeEnd=e.rangeEnd?new Date(e.rangeEnd):null,this.isRangeMode=e.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=e.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=e.events||[],this.i18n=e.i18n||{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortWeekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",selectRangeStart:"Select start date",selectRangeEnd:"Select end date"},this.onSelect=e.onSelect||null,this.onRangeSelect=e.onRangeSelect||null,this.onChange=e.onChange||null,this.onEventClick=e.onEventClick||null,this._init()}_init(){this.render();const t=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()},e=()=>{this.viewMode==="week"?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()},i=()=>{this.currentDate=new Date,this.render(),this._emitChange()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this._listeners.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",e),this._listeners.push({el:this.nextBtn,event:"click",handler:e})),this.todayBtn&&(this.todayBtn.addEventListener("click",i),this._listeners.push({el:this.todayBtn,event:"click",handler:i}))}_emitChange(){const t={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(t),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:t,bubbles:!0}))}_formatDate(t){const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${i}-${n}`}_isSameDay(t,e){return!t||!e?!1:this._formatDate(t)===this._formatDate(e)}_isDateInRange(t){if(!this.rangeStart||!this.rangeEnd)return!1;const e=this._formatDate(t),i=this._formatDate(this.rangeStart),n=this._formatDate(this.rangeEnd);return e>=i&&e<=n}_isRangeStart(t){return this._isSameDay(t,this.rangeStart)}_isRangeEnd(t){return this._isSameDay(t,this.rangeEnd)}_getEventsForDate(t){const e=this._formatDate(t);return this.events.filter(i=>{const n=i.date||i.start,r=i.end;if(!n)return!1;const a=typeof n=="string"?n:this._formatDate(n);if(!r)return a===e;const o=typeof r=="string"?r:this._formatDate(r);return e>=a&&e<=o})}render(){const t=this.currentDate.getFullYear(),e=this.currentDate.getMonth();this.viewMode==="week"?this._renderWeekView(t,e):this._renderMonthView(t,e)}_renderMonthView(t,e){this.titleEl.textContent=`${t} ${this.i18n.months[e]}`;const i=new Date(t,e,1).getDay(),n=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let o=0;o<i;o++){const l=document.createElement("span");l.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(l)}const r=new Date,a=this._formatDate(r);for(let o=1;o<=n;o++){const l=new Date(t,e,o),c=document.createElement("button");c.className="ds-calendar__day",c.textContent=o;const d=this._formatDate(l);d===a&&c.classList.add("is-today"),this._isSameDay(l,this.selectedDate)&&c.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(l)&&c.classList.add("is-range-start"),this._isRangeEnd(l)&&c.classList.add("is-range-end"),this._isDateInRange(l)&&c.classList.add("is-in-range"));const h=this._getEventsForDate(l);if(h.length>0){c.classList.add("has-events");const f=document.createElement("span");f.className="ds-calendar__day-event",f.style.backgroundColor=h[0].color||"#007bff",c.appendChild(f)}const u=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(f=>f.classList.remove("is-selected")),c.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(l,this.rangeEnd)?(this.rangeStart=l,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(l<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=l):this.rangeEnd=l,this.onRangeSelect&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-range-select",{detail:{start:this.rangeStart,end:this.rangeEnd},bubbles:!0}))):(this.selectedDate=l,this.onSelect&&this.onSelect({date:l,dateStr:d}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:l,dateStr:d},bubbles:!0}))),h.forEach(f=>{this.onEventClick&&this.onEventClick(f,l)}),this.render()};c.addEventListener("click",u),this._listeners.push({el:c,event:"click",handler:u}),this.daysEl.appendChild(c)}}_renderWeekView(t,e){const i=this.currentDate.getDay(),n=new Date(t,e,this.currentDate.getDate()-i+(i===0?-6:1)),r=n,a=new Date(n);a.setDate(n.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[r.getMonth()]} ${r.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${t}`,this.daysEl.innerHTML="";const o=new Date,l=this._formatDate(o);for(let c=0;c<7;c++){const d=new Date(n);d.setDate(n.getDate()+c);const h=document.createElement("button");h.className="ds-calendar__day ds-calendar__day--week";const u=document.createElement("span");u.className="ds-calendar__day-header",u.textContent=this.i18n.shortWeekdays[d.getDay()],h.appendChild(u);const f=document.createElement("span");f.className="ds-calendar__day-number",f.textContent=d.getDate(),h.appendChild(f);const p=this._formatDate(d);p===l&&h.classList.add("is-today"),this._isSameDay(d,this.selectedDate)&&h.classList.add("is-selected");const m=this._getEventsForDate(d);if(m.length>0){const _=document.createElement("span");_.className="ds-calendar__day-events",m.slice(0,3).forEach(b=>{const v=document.createElement("span");v.className="ds-calendar__day-event",v.style.backgroundColor=b.color||"#007bff",_.appendChild(v)}),h.appendChild(_)}const y=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(_=>_.classList.remove("is-selected")),h.classList.add("is-selected"),this.selectedDate=d,this.onSelect&&this.onSelect({date:d,dateStr:p}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:d,dateStr:p},bubbles:!0})),this.render()};h.addEventListener("click",y),this._listeners.push({el:h,event:"click",handler:y}),this.daysEl.appendChild(h)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,e){this.rangeStart=t?new Date(t):null,this.rangeEnd=e?new Date(e):null,this.render(),this.onRangeSelect&&this.rangeStart&&this.rangeEnd&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd})}getRange(){return{start:this.rangeStart,end:this.rangeEnd}}setEvents(t){this.events=t||[],this.render()}addEvent(t){this.events.push(t),this.render()}removeEvent(t){this.events=this.events.filter(e=>e.id!==t),this.render()}setViewMode(t){(t==="month"||t==="week")&&(this.viewMode=t,this.render(),this._emitChange())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this._emitChange()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this._emitChange()}goToToday(){this.currentDate=new Date,this.render(),this._emitChange()}goToDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this._emitChange()}}function dt(s,t){if(!s.__kupolaInitialized)try{const e=new ue(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function Ft(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Mi(){document.querySelectorAll(".ds-calendar").forEach(s=>{dt(s)})}typeof window<"u"&&(window.Calendar=ue,window.initCalendar=dt,window.cleanupCalendar=Ft,window.initCalendars=Mi,window.kupolaInitializer&&window.kupolaInitializer.register("calendar",dt,Ft));class pe{constructor(t,e={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.maxCount=e.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=e.allowDuplicates!==!1,this.color=e.color||t.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const e=t.querySelector(".ds-dynamic-tags__remove");if(e){const i=n=>{n.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",i),this._listeners.push({el:e,event:"click",handler:i})}}),this.input){const t=()=>{const n=this.input.value.trim();if(!n)return;if(!this.allowDuplicates&&this.hasTag(n)){this.input.value="";return}if(this.getTags().length>=this.maxCount){this.input.value="",this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const r=this.createTag(n);this.element.insertBefore(r,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},e=n=>{n.key==="Enter"&&(n.preventDefault(),n.stopPropagation(),t())};this.input.addEventListener("keydown",e),this._listeners.push({el:this.input,event:"keydown",handler:e});const i=()=>{this.input.focus()};this.element.addEventListener("click",i),this._listeners.push({el:this.element,event:"click",handler:i})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(t);e.appendChild(i);const n=document.createElement("button");n.className="ds-dynamic-tags__remove",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',e.appendChild(n);const r=a=>{a.stopPropagation(),e.remove(),this.dispatchChange()};return n.addEventListener("click",r),this._listeners.push({el:n,event:"click",handler:r}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of e)if(i.textContent.trim()===t)return!0;return!1}addTag(t,e){if(!t||!this.input||!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));return}const i=this.createTag(t);if(e){const n=["ds-dynamic-tags__tag--default","ds-dynamic-tags__tag--primary","ds-dynamic-tags__tag--success","ds-dynamic-tags__tag--warning","ds-dynamic-tags__tag--danger","ds-dynamic-tags__tag--info"];n.forEach(r=>i.classList.remove(r)),n.includes(`ds-dynamic-tags__tag--${e}`)&&i.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(i,this.input),this.dispatchChange()}removeTag(t){const i=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];i&&(i.remove(),this.dispatchChange())}removeTagByValue(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of e)if(i.textContent.trim()===t){i.remove(),this.dispatchChange();return}}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{t.push(e.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{const i=Array.from(e.classList).find(n=>n.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:e.textContent.trim(),color:i})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(e=>{typeof e=="string"?this.addTag(e):e&&typeof e=="object"&&e.value&&this.addTag(e.value,e.color)})}setMaxCount(t){this.maxCount=t,this.element.setAttribute("data-dynamic-tags-max",t)}getMaxCount(){return this.maxCount}setAllowDuplicates(t){this.allowDuplicates=t}isAllowDuplicates(){return this.allowDuplicates}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-dynamic-tags-color",t))}getColor(){return this.color}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-change",{detail:{tags:this.getTags(),tagsWithColor:this.getTagsWithColor(),count:this.getTags().length,maxCount:this.maxCount}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.input=null,this.element=null}}function ht(s,t){if(s.__kupolaInitialized)return;const e=new pe(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Nt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Hi(){document.querySelectorAll(".ds-dynamic-tags").forEach(s=>{ht(s)})}typeof window<"u"&&(window.DynamicTags=pe,window.initDynamicTags=ht,window.cleanupDynamicTags=Nt,window.initDynamicTagsAll=Hi,window.kupolaInitializer&&window.kupolaInitializer.register("dynamic-tags",ht,Nt));class St{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=`
81
114
  <button class="ds-image-preview__close" type="button" aria-label="Close preview">
82
115
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
83
116
  <path d="M18 6L6 18"/>
@@ -96,6 +129,38 @@
96
129
  </svg>
97
130
  </button>
98
131
  </div>
132
+ <div class="ds-image-preview__toolbar">
133
+ <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom in" data-action="zoom-in">
134
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
135
+ <line x1="12" y1="5" x2="12" y2="19"/>
136
+ <line x1="5" y1="12" x2="19" y2="12"/>
137
+ </svg>
138
+ </button>
139
+ <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom out" data-action="zoom-out">
140
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
141
+ <line x1="5" y1="12" x2="19" y2="12"/>
142
+ </svg>
143
+ </button>
144
+ <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Reset zoom" data-action="zoom-reset">
145
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
146
+ <path d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/>
147
+ <line x1="12" y1="5" x2="12" y2="19"/>
148
+ <line x1="5" y1="12" x2="19" y2="12"/>
149
+ </svg>
150
+ </button>
151
+ <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate left" data-action="rotate-left">
152
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
153
+ <polyline points="1 4 1 10 7 10"/>
154
+ <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>
155
+ </svg>
156
+ </button>
157
+ <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate right" data-action="rotate-right">
158
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
159
+ <polyline points="23 4 23 10 17 10"/>
160
+ <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
161
+ </svg>
162
+ </button>
163
+ </div>
99
164
  <div class="ds-image-preview__content">
100
165
  <img src="" alt="" />
101
166
  </div>
@@ -104,12 +169,12 @@
104
169
  <div class="ds-image-preview__meta"></div>
105
170
  </div>
106
171
  <div class="ds-image-preview__indicators"></div>
107
- `,document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const i=this.overlay.querySelector(".ds-image-preview__close"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),l=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this._prevHandler=()=>this.prev(),this._nextHandler=()=>this.next(),i.addEventListener("click",this.closeHandler),a.addEventListener("click",this._prevHandler),l.addEventListener("click",this._nextHandler)}handleKeydown(i){if(this.overlay.classList.contains("is-visible"))switch(i.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break}}handleOverlayClick(i){i.target===this.overlay&&this.close()}show(i,a=0){this.images=i,this.currentIndex=Math.min(Math.max(a,0),i.length-1),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.render())}next(){this.currentIndex<this.images.length-1&&(this.currentIndex++,this.render())}goTo(i){i>=0&&i<this.images.length&&(this.currentIndex=i,this.render())}render(){const i=this.overlay.querySelector(".ds-image-preview__content img"),a=this.overlay.querySelector(".ds-image-preview__title"),l=this.overlay.querySelector(".ds-image-preview__meta"),c=this.overlay.querySelector(".ds-image-preview__indicators"),h=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),u=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),d=this.images[this.currentIndex];i.src=d.src,i.alt=d.alt||"",a.textContent=d.title||"",l.textContent=d.meta||`${this.currentIndex+1} / ${this.images.length}`,h.disabled=this.currentIndex===0,u.disabled=this.currentIndex===this.images.length-1,c.innerHTML=this.images.map((p,g)=>`
108
- <button class="ds-image-preview__indicator${g===this.currentIndex?" is-active":""}" type="button" data-index="${g}" aria-label="Go to image ${g+1}"></button>
109
- `).join(""),c.querySelectorAll(".ds-image-preview__indicator").forEach(p=>{const g=()=>{this.goTo(parseInt(p.dataset.index))};p.addEventListener("click",g),p._clickHandler=g})}destroy(){this.close();const i=this.overlay?.querySelector(".ds-image-preview__indicators");i&&i.querySelectorAll(".ds-image-preview__indicator").forEach(h=>{h._clickHandler&&h.removeEventListener("click",h._clickHandler)});const a=this.overlay?.querySelector(".ds-image-preview__close"),l=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),c=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");a&&a.removeEventListener("click",this.closeHandler),l&&this._prevHandler&&l.removeEventListener("click",this._prevHandler),c&&this._nextHandler&&c.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let e=null;function r(){e||(e=new t),document.querySelectorAll("[data-image-preview]").forEach(n=>{n.addEventListener("click",()=>{const i=JSON.parse(n.getAttribute("data-image-preview")),a=parseInt(n.getAttribute("data-image-index"))||0;e.show(i,a)})})}function o(n,i=0){e||(e=new t),e.show(n,i)}s.exports&&(s.exports={ImagePreview:t,initImagePreview:r,showImagePreview:o})}(G)),G.exports}xi();var Q={exports:{}},Dt;function bi(){return Dt||(Dt=1,function(s){class t{constructor(i){this.element=i,this.closeBtn=i.querySelector(".ds-tag__close"),this._listeners=[],this.init()}init(){if(this.closeBtn){const i=a=>{a.stopPropagation(),this.element.dispatchEvent(new CustomEvent("ds-tag-remove",{detail:{tag:this.element},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",i),this._listeners.push({el:this.closeBtn,event:"click",handler:i})}}setContent(i){const a=[];this.element.childNodes.forEach(l=>{l.nodeType===Node.TEXT_NODE&&a.push(l)}),a.forEach(l=>l.remove()),this.element.insertBefore(document.createTextNode(i),this.closeBtn||null)}getContent(){return this.element.textContent.trim()}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.closeBtn=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-tag").forEach(n=>{e(n)})}s.exports?s.exports={Tag:t,initTags:o,initTag:e,cleanupTag:r}:(window.Tag=t,window.initTag=e,window.cleanupTag=r),window.kupolaInitializer&&window.kupolaInitializer.register("tag",e,r)}(Q)),Q.exports}bi();var Z={exports:{}},Mt;function ki(){return Mt||(Mt=1,function(s){class t{constructor(a){this.element=a,this.valueElement=a.querySelector(".ds-statcard__value"),this.progressFill=a.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(a=>{a.forEach(l=>{l.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this._observer.observe(this.element)}animateValue(){if(!this.valueElement)return;const a=this.valueElement.textContent,l=a.match(/[\d.,]+/);if(!l)return;const c=parseFloat(l[0].replace(",","")),h=a.substring(0,l.index),u=a.substring(l.index+l[0].length),d=1500,p=performance.now(),g=0,f=m=>{const v=m-p,y=Math.min(v/d,1),w=1-Math.pow(1-y,3),_=g+(c-g)*w;let b;c>=1e6?b=(_/1e6).toFixed(1)+"M":c>=1e3?b=(_/1e3).toFixed(1)+"K":Number.isInteger(c)?b=Math.floor(_).toLocaleString():b=_.toFixed(2),this.valueElement.textContent=h+b+u,y<1&&requestAnimationFrame(f)};requestAnimationFrame(f)}animateProgress(){if(!this.progressFill)return;const a=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=a}updateValue(a,l={}){if(!this.valueElement)return;const c=l.duration||800,h=this.valueElement.textContent,u=h.match(/[\d.,]+/);if(!u){this.valueElement.textContent=a;return}const d=h.substring(0,u.index),p=h.substring(u.index+u[0].length),g=parseFloat(u[0].replace(",","")),f=parseFloat(a),m=performance.now(),v=y=>{const w=y-m,_=Math.min(w/c,1),b=1-Math.pow(1-_,3),k=g+(f-g)*b;let S;f>=1e6?S=(k/1e6).toFixed(1)+"M":f>=1e3?S=(k/1e3).toFixed(1)+"K":Number.isInteger(f)?S=Math.floor(k).toLocaleString():S=k.toFixed(2),this.valueElement.textContent=d+S+p,_<1&&requestAnimationFrame(v)};requestAnimationFrame(v)}updateProgress(a,l={}){if(!this.progressFill)return;const c=l.duration||600,h=parseFloat(this.progressFill.style.width||"0"),u=Math.min(Math.max(a,0),100),d=performance.now(),p=g=>{const f=g-d,m=Math.min(f/c,1),v=1-Math.pow(1-m,3),y=h+(u-h)*v;this.progressFill.style.width=y+"%",m<1&&requestAnimationFrame(p)};requestAnimationFrame(p)}setTrend(a,l){const c=this.element.querySelector(".ds-statcard__trend");if(!c)return;c.className=`ds-statcard__trend ds-statcard__trend--${a}`;const h=a==="up"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/></svg>':a==="down"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 18 10.5 8.5 15.5 13.5 23 6"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="12 19 18 13 12 7 6 13"/></svg>';c.innerHTML=h+l}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function e(i){if(i.__kupolaInitialized)return;const a=new t(i);i.__kupolaInstance=a,i.__kupolaInitialized=!0}function r(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-statcard").forEach(i=>{e(i)})}function n(i,a){const l=document.querySelector(i);l&&l.__kupolaInstance&&l.__kupolaInstance.updateValue(a)}s.exports?s.exports={StatCard:t,initStatCards:o,initStatCard:e,cleanupStatCard:r,updateStatCard:n}:(window.StatCard=t,window.initStatCard=e,window.cleanupStatCard=r),window.kupolaInitializer&&window.kupolaInitializer.register("statcard",e,r)}(Z)),Z.exports}ki();var tt={exports:{}},It;function Ei(){return It||(It=1,function(s){class t{constructor(l,c={}){this.element=l,this.data=c.data||[],this.startDate=c.startDate||this.getOneYearAgo(),this.endDate=c.endDate||new Date,this.cellSize=c.cellSize||14,this.onCellClick=c.onCellClick||null,this.tooltip=null,this.baseColor=c.color||l.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const l=new Date;return l.setFullYear(l.getFullYear()-1),l}init(){this.render(),this.createTooltip()}getDataByDate(l){const c=this.formatDate(l),h=this.data.find(u=>u.date===c);return h?h.value:0}formatDate(l){const c=l.getFullYear(),h=String(l.getMonth()+1).padStart(2,"0"),u=String(l.getDate()).padStart(2,"0");return`${c}-${h}-${u}`}getLevel(l,c){if(l===0)return 0;(!c||c===0)&&(c=Math.max(...this.data.map(u=>u.value),1));const h=l/c;return h<.2?1:h<.4?2:h<.6?3:h<.8?4:5}hexToRgb(l){const c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(l);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:{r:34,g:197,b:94}}getCellColor(l){const c=this.hexToRgb(this.baseColor);if(l===0)return"rgba(0, 0, 0, 0.1)";const h=[.2,.4,.6,.8,1][l-1];return`rgba(${c.r}, ${c.g}, ${c.b}, ${h})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const l=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],c=[];let h=-1;for(let u=new Date(this.startDate);u<=this.endDate;u.setDate(u.getDate()+1)){const d=u.getMonth(),p=u.getDate();d!==h&&p===1&&(c.push({month:d,label:l[d],offset:Math.floor((u-this.startDate)/(1e3*60*60*24))}),h=d)}return c}getWeekCount(){let l=0;const h=new Date(this.startDate).getDay();for(let u=new Date(this.startDate);u<=this.endDate;u.setDate(u.getDate()+1))u.getDay()===0&&l++;return h!==0&&l++,l}render(){const l=this.element.querySelector(".ds-heatmap__body");if(!l)return;l.innerHTML="";const c=[];let h=[];const d=new Date(this.startDate).getDay();for(let E=1;E<d;E++)h.push(null);for(let E=new Date(this.startDate);E<=this.endDate;E.setDate(E.getDate()+1))h.push(new Date(E)),(E.getDay()===6||E.getTime()===this.endDate.getTime())&&(c.push(h),h=[]);const p=c.length,g=this.element.classList.contains("ds-heatmap--compact")?12:16,f=p*g,m=document.createElement("div");m.className="ds-heatmap__container";const v=document.createElement("div");v.className="ds-heatmap__labels-and-grid";const y=document.createElement("div");y.className="ds-heatmap__weekday-labels";const w=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(E=>{const C=document.createElement("div");C.className="ds-heatmap__weekday-label",C.textContent=E,C.style.height=w+"px",C.style.lineHeight=w+"px",y.appendChild(C)}),v.appendChild(y);const _=document.createElement("div");_.className="ds-heatmap__grid-container";const b=document.createElement("div");b.className="ds-heatmap__month-labels",b.style.width=f+"px";const k=this.getMonthLabels();k.forEach((E,C)=>{const L=document.createElement("div");L.className="ds-heatmap__month-label",L.textContent=E.label;const D=k[C+1];let T;D?T=Math.ceil((D.offset-E.offset)/7):T=p-Math.floor(E.offset/7),L.style.width=T*g+"px",b.appendChild(L)}),_.appendChild(b);const S=document.createElement("div");S.className="ds-heatmap__grid",c.forEach(E=>{const C=document.createElement("div");C.className="ds-heatmap__week-column",E.forEach(L=>{if(L===null){const D=document.createElement("div");D.className="ds-heatmap__cell",D.style.visibility="hidden",C.appendChild(D)}else{const D=this.getDataByDate(L),T=Math.max(...this.data.map(z=>z.value),1),$s=this.getLevel(D,T),M=document.createElement("div");M.className="ds-heatmap__cell",M.dataset.date=this.formatDate(L),M.dataset.value=D,M.style.backgroundColor=this.getCellColor($s);const dt=z=>this.showTooltip(z,L,D),ht=()=>this.hideTooltip(),ut=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(L),value:D})};M.addEventListener("mouseenter",dt),M.addEventListener("mouseleave",ht),M.addEventListener("click",ut),this._listeners.push({el:M,event:"mouseenter",handler:dt},{el:M,event:"mouseleave",handler:ht},{el:M,event:"click",handler:ut}),C.appendChild(M)}}),S.appendChild(C)}),_.appendChild(S),v.appendChild(_),m.appendChild(v),l.appendChild(m),this.renderLegend(l)}renderLegend(l){const c=document.createElement("div");c.className="ds-heatmap__legend";const h=document.createElement("span");h.className="ds-heatmap__legend-label",h.textContent="少";const u=document.createElement("div");u.className="ds-heatmap__legend-cells";for(let p=0;p<=5;p++){const g=document.createElement("div");g.className="ds-heatmap__legend-cell",g.style.backgroundColor=this.getCellColor(p),u.appendChild(g)}const d=document.createElement("span");d.className="ds-heatmap__legend-label",d.textContent="多",c.appendChild(h),c.appendChild(u),c.appendChild(d),l.appendChild(c)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(l,c,h){const u=l.target.getBoundingClientRect(),d=150;this.tooltip.innerHTML=`
110
- <div class="ds-heatmap__tooltip-date">${c.getFullYear()}年${c.getMonth()+1}月${c.getDate()}日</div>
111
- <div class="ds-heatmap__tooltip-value">${h} contributions</div>
112
- `,this.tooltip.style.left=Math.min(u.left+u.width/2-d/2,window.innerWidth-d-16)+"px",this.tooltip.style.top=u.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(l){this._listeners.forEach(({el:c,event:h,handler:u})=>{c.removeEventListener(h,u)}),this._listeners=[],this.data=l,this.render()}setDateRange(l,c){this.startDate=l,this.endDate=c,this.render()}destroy(){this._listeners.forEach(({el:l,event:c,handler:h})=>{l.removeEventListener(c,h)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function e(a){if(a.__kupolaInitialized)return;const l=a.getAttribute("data-heatmap-data");let c=[];if(l)try{c=JSON.parse(l)}catch{c=n()}else c=n();const h=new t(a,{data:c,onCellClick:u=>{}});a.__kupolaInstance=h,a.__kupolaInitialized=!0}function r(a){if(!a.__kupolaInitialized||!a.__kupolaInstance)return;a.__kupolaInstance.destroy(),a.__kupolaInstance=null,a.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-heatmap").forEach(a=>{e(a)})}function n(){const a=[],l=new Date,c=new Date;c.setFullYear(c.getFullYear()-1);for(let h=new Date(c);h<=l;h.setDate(h.getDate()+1)){const u=h.getFullYear(),d=String(h.getMonth()+1).padStart(2,"0"),p=String(h.getDate()).padStart(2,"0"),f=h.getDay()===0||h.getDay()===6?Math.random()*20:Math.random()*50,m=Math.floor(f);a.push({date:`${u}-${d}-${p}`,value:m>0?m:Math.floor(Math.random()*30)+1})}return a}function i(a,l={}){const c=document.querySelector(a);if(c){const h=l.data||n();return new t(c,{data:h,...l})}return null}s.exports?s.exports={Heatmap:t,initHeatmaps:o,initHeatmap:e,cleanupHeatmap:r,createHeatmap:i,generateMockHeatmapData:n}:(window.Heatmap=t,window.initHeatmap=e,window.cleanupHeatmap=r),window.kupolaInitializer&&window.kupolaInitializer.register("heatmap",e,r)}(tt)),tt.exports}Ei();class Ci{constructor(t){this.element=t,this.tooltipEl=null,this._showTooltip=null,this._hideTooltip=null}init(){this.element.__kupolaInitialized||(this._showTooltip=()=>{const t=this.element.getAttribute("data-tooltip"),e=this.element.getAttribute("data-tooltip-position")||"top";t&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className="ds-tooltip is-visible",this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{const r=this.element.getBoundingClientRect(),o=this.tooltipEl.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight;let a,l;switch(e){case"bottom":a=r.left+r.width/2-o.width/2,l=r.bottom+8;break;case"right":a=r.right+8,l=r.top+r.height/2-o.height/2;break;case"left":a=r.left-o.width-8,l=r.top+r.height/2-o.height/2;break;case"top":default:a=r.left+r.width/2-o.width/2,l=r.top-o.height-8;break}a<8&&(a=8),a+o.width>n&&(a=n-o.width-8),l<8&&(l=8),l+o.height>i&&(l=i-o.height-8),this.tooltipEl.style.left=`${a}px`,this.tooltipEl.style.top=`${l}px`,this.tooltipEl.style.position="fixed"}))},this._hideTooltip=()=>{this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null)},this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip),this.element.__kupolaInitialized=!0)}destroy(){this.element.__kupolaInitialized&&(this._showTooltip&&(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("focus",this._showTooltip)),this._hideTooltip&&(this.element.removeEventListener("mouseleave",this._hideTooltip),this.element.removeEventListener("blur",this._hideTooltip)),this._showTooltip&&this._hideTooltip&&this._hideTooltip(),this._showTooltip=null,this._hideTooltip=null,this.element.__kupolaInitialized=!1)}}function Si(s){const t=new Ci(s);t.init(),s._kupolaTooltip=t}function Li(s){s._kupolaTooltip&&(s._kupolaTooltip.destroy(),s._kupolaTooltip=null)}window.kupolaInitializer&&window.kupolaInitializer.register("tooltip",Si,Li);class Xt{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,e){this.customValidators[t]=e}addAsyncValidator(t,e){this.customAsyncValidators[t]=e}validate(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`,r={},o=t.querySelectorAll("[data-validate]");let n=!1;return o.forEach(i=>{const a=i.name||i.id,l=this.parseRules(i.getAttribute("data-validate")),c=this.getValue(i);for(const[h,u]of Object.entries(l))if((this.customValidators[h]||this.validators[h])?.(c,u))this.clearError(i);else{r[a]=this.getErrorMessage(h,u,i),this.showError(i,r[a]),n=!0;break}}),this.formStates[e]={valid:!n,errors:r,errorCount:Object.keys(r).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 e=t.closest(".ds-select"),r=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return r?r.textContent.trim():""}if(t.closest(".ds-fileupload")){const r=t.closest(".ds-fileupload").__fileUploadInstance;return r&&r.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const e=this.parseRules(t.getAttribute("data-validate")),r=this.getValue(t);for(const[o,n]of Object.entries(e))if(!(this.customValidators[o]||this.validators[o])?.(r,n))return this.showError(t,this.getErrorMessage(o,n,t)),!1;return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let e=!0;return t.forEach(r=>{this.validate(r)||(e=!1)}),e}async validateAsync(t,e={}){const r=t.id||`form-${Math.random().toString(36).substr(2,9)}`,o=e.group,n=o?t.querySelectorAll(`[data-validate][data-validate-group="${o}"]`):t.querySelectorAll("[data-validate]");let i=!1;for(const l of n)await this.validateInputAsync(l)||(i=!0);const a={};return n.forEach(l=>{const c=l.name||l.id,h=l.parentElement.querySelector(".ds-input__error");h&&(a[c]=h.textContent)}),this.formStates[r]={valid:!i,errors:a,errorCount:Object.keys(a).length},this.updateFormState(t),!i}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),r=this.parseRules(t.getAttribute("data-validate-async")||""),o=this.getValue(t);for(const[n,i]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(o,i))return this.showError(t,this.getErrorMessage(n,i,t)),!1;for(const[n,i]of Object.entries(r)){const a=this.customAsyncValidators[n]||this.asyncValidators[n];if(a)try{if(!await a(o,i,t))return this.showError(t,this.getErrorMessage(n,i,t)),!1}catch(l){return this.showError(t,l.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const r=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let o=!1;for(const n of r)await this.validateInputAsync(n)||(o=!0);return!o}getGroups(t){const e=new Set;return t.querySelectorAll("[data-validate-group]").forEach(r=>{e.add(r.getAttribute("data-validate-group"))}),Array.from(e)}getFormState(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[e]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const e=this.getFormState(t);e.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),e.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),e.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),e.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(o=>o.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(o=>{o.hasAttribute("data-permanent-disabled")||(o.disabled=!1)}));const r=t.querySelector(".ds-form__status");r&&(e.errorCount>0?(r.textContent=`${e.errorCount} ${e.errorCount===1?"error":"errors"} found`,r.classList.add("ds-form__status--error")):(r.textContent="All fields are valid",r.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const r=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[r]||(this.formStates[r]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[r].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const r=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[r]||(this.formStates[r]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[r].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const r=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[r]||(this.formStates[r]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[r].disabled=e,this.updateFormState(t)}resetForm(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[e]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(r=>{r.classList.remove("ds-input--error");const o=r.parentElement?.querySelector(".ds-input__error");o&&(o.textContent="")}),this.updateFormState(t)}parseRules(t){const e={};return t.split("|").forEach(o=>{const[n,i]=o.split(":");e[n]=i?i.split(","):[]}),e}validateRequired(t){return t!==""}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[e]){return t.length>=parseInt(e)}validateMaxLength(t,[e]){return t.length<=parseInt(e)}validatePattern(t,[e]){return new RegExp(e).test(t)}validateMin(t,[e]){return parseFloat(t)>=parseFloat(e)}validateMax(t,[e]){return parseFloat(t)<=parseFloat(e)}validateEqualTo(t,[e]){const r=document.getElementById(e);return r&&t===r.value}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,e){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let r=t.parentElement.querySelector(".ds-input__error");r||(r=document.createElement("span"),r.className="ds-input__error",r.setAttribute("role","alert"),r.setAttribute("aria-live","polite"),t.parentElement.appendChild(r)),r.textContent=e,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:e}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const e=t.parentElement.querySelector(".ds-input__error");e&&e.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const e=document.createElement("span");e.className="ds-input__status-icon ds-input__status-icon--success",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(e)}removeStatusIcon(t){const e=t.parentElement.querySelector(".ds-input__status-icon");e&&e.remove()}getErrorMessage(t,e,r){const o=r.getAttribute(`data-message-${t}`);return o||{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${e[0]} characters`,maxLength:`Maximum length is ${e[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${e[0]}`,max:`Maximum value is ${e[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const H=new Xt;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(s=>{s.addEventListener("submit",async t=>{const e=s.id||`form-${Math.random().toString(36).substr(2,9)}`;if(H.submitting.has(e)){t.preventDefault();return}t.preventDefault();const r=s.querySelector("[data-validate-async]")!==null;let o;if(r?o=await H.validateAsync(s):o=H.validate(s),o){H.submitting.add(e);const n=s.querySelector('button[type="submit"]');if(n){const i=n.textContent;n.setAttribute("data-original-text",i),n.textContent="Submitting...",n.disabled=!0}try{const i=s.getAttribute("data-on-submit");i&&window[i]?await window[i](s):s.submit()}finally{H.submitting.delete(e),n&&(n.textContent=n.getAttribute("data-original-text")||"Submit",n.disabled=!1)}}else{const n=s.querySelector(".ds-input--error");n&&n.focus()}}),s.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const o=document.activeElement;if(o&&o.closest(".ds-select"))return;H.validateInput(t)&&t.value.trim()&&H.showSuccess(t)},50)});const r=((o,n)=>{let i;return(...a)=>{clearTimeout(i),i=setTimeout(()=>o.apply(void 0,a),n)}})(()=>{const o=H.getValue(t);o.length>0||t.classList.contains("ds-input--error")?H.validateInput(t)&&o&&H.showSuccess(t):H.removeStatusIcon(t)},300);t.addEventListener("input",r),t.addEventListener("keyup",o=>{o.key==="Enter"&&H.validateInput(t)&&t.value.trim()&&H.showSuccess(t)})})})}));window.KupolaValidator=Xt;window.kupolaValidator=H;var et={exports:{}},Tt;function Hi(){return Tt||(Tt=1,function(s){class t{constructor(l,c={}){this.element=l,this.data=c.data||[],this.itemHeight=c.itemHeight||48,this.itemWidth=c.itemWidth||200,this.bufferSize=c.bufferSize||5,this.renderItem=c.renderItem||this.defaultRenderItem,this.onItemClick=c.onItemClick||null,this.onItemSelect=c.onItemSelect||null,this.onScroll=c.onScroll||null,this.onScrollEnd=c.onScrollEnd||null,this.selectedKey=c.selectedKey||null,this.keyField=c.keyField||"id",this.useDynamicHeight=c.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=c.estimatedHeight||48,this.container=null,this.scrollbarTrack=null,this.scrollbarThumb=null,this.totalHeight=0,this.startIndex=0,this.endIndex=0,this.isScrolling=!1,this.scrollTimeout=null,this.lastScrollTop=0,this.lastScrollLeft=0,this.init()}defaultRenderItem(l,c){return`
172
+ `,document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const t=this.overlay.querySelector(".ds-image-preview__close"),e=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),i=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this._prevHandler=()=>this.prev(),this._nextHandler=()=>this.next(),t.addEventListener("click",this.closeHandler),e.addEventListener("click",this._prevHandler),i.addEventListener("click",this._nextHandler),this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(a=>{a.addEventListener("click",o=>{const l=a.getAttribute("data-action");this.handleToolbarAction(l)})}),this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",a=>{a.preventDefault(),a.deltaY<0?this.zoomIn():this.zoomOut()},{passive:!1})}handleToolbarAction(t){switch(t){case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"zoom-reset":this.resetZoom();break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break}}zoomIn(){this.zoom=Math.min(this.maxZoom,this.zoom+this.zoomStep),this.updateTransform()}zoomOut(){this.zoom=Math.max(this.minZoom,this.zoom-this.zoomStep),this.updateTransform()}resetZoom(){this.zoom=1,this.rotation=0,this.updateTransform()}rotate(t){this.rotation+=t,this.updateTransform()}setRotation(t){this.rotation=t,this.updateTransform()}setZoom(t){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t)),this.updateTransform()}updateTransform(){const t=this.overlay.querySelector(".ds-image-preview__content img");t&&(t.style.transform=`scale(${this.zoom}) rotate(${this.rotation}deg)`)}handleKeydown(t){if(this.overlay.classList.contains("is-visible"))switch(t.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"+":case"=":t.preventDefault(),this.zoomIn();break;case"-":case"_":t.preventDefault(),this.zoomOut();break;case"0":t.preventDefault(),this.resetZoom();break;case"[":t.preventDefault(),this.rotate(-90);break;case"]":t.preventDefault(),this.rotate(90);break}}handleOverlayClick(t){t.target===this.overlay&&this.close()}show(t,e=0){this.images=t,this.currentIndex=Math.min(Math.max(e,0),t.length-1),this.resetZoom(),this.render(),this.overlay.classList.add("is-visible"),document.addEventListener("keydown",this.keyHandler),this.overlay.addEventListener("click",this.clickHandler),document.body.style.overflow="hidden"}close(){this.overlay.classList.remove("is-visible"),document.removeEventListener("keydown",this.keyHandler),this.overlay.removeEventListener("click",this.clickHandler),document.body.style.overflow=""}prev(){this.currentIndex>0&&(this.currentIndex--,this.resetZoom(),this.render())}next(){this.currentIndex<this.images.length-1&&(this.currentIndex++,this.resetZoom(),this.render())}goTo(t){t>=0&&t<this.images.length&&(this.currentIndex=t,this.resetZoom(),this.render())}render(){const t=this.overlay.querySelector(".ds-image-preview__content img"),e=this.overlay.querySelector(".ds-image-preview__title"),i=this.overlay.querySelector(".ds-image-preview__meta"),n=this.overlay.querySelector(".ds-image-preview__indicators"),r=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),o=this.images[this.currentIndex];t.src=o.src,t.alt=o.alt||"",e.textContent=o.title||"",i.textContent=o.meta||`${this.currentIndex+1} / ${this.images.length}`,r.disabled=this.currentIndex===0,a.disabled=this.currentIndex===this.images.length-1,n.innerHTML=this.images.map((l,c)=>`
173
+ <button class="ds-image-preview__indicator${c===this.currentIndex?" is-active":""}" type="button" data-index="${c}" aria-label="Go to image ${c+1}"></button>
174
+ `).join(""),n.querySelectorAll(".ds-image-preview__indicator").forEach(l=>{const c=()=>{this.goTo(parseInt(l.dataset.index))};l.addEventListener("click",c),l._clickHandler=c})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(r=>{r._clickHandler&&r.removeEventListener("click",r._clickHandler)});const e=this.overlay?.querySelector(".ds-image-preview__close"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),n=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),i&&this._prevHandler&&i.removeEventListener("click",this._prevHandler),n&&this._nextHandler&&n.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let N=null;function Ii(){N||(N=new St),document.querySelectorAll("[data-image-preview]").forEach(s=>{s.addEventListener("click",()=>{const t=JSON.parse(s.getAttribute("data-image-preview")),e=parseInt(s.getAttribute("data-image-index"))||0;N.show(t,e)})})}function Ti(s,t=0){N||(N=new St),N.show(s,t)}typeof window<"u"&&(window.ImagePreview=St,window.initImagePreview=Ii,window.showImagePreview=Ti);class fe{constructor(t,e={}){this.element=t,this.closeBtn=t.querySelector(".ds-tag__close"),this.checkbox=t.querySelector(".ds-tag__checkbox"),this.editInput=t.querySelector(".ds-tag__input"),this._listeners=[],this.color=e.color||t.getAttribute("data-tag-color")||"default",this.size=e.size||t.getAttribute("data-tag-size")||"default",this.checkable=e.checkable||t.hasAttribute("data-tag-checkable"),this.checked=e.checked||t.hasAttribute("data-tag-checked"),this.editable=e.editable||t.hasAttribute("data-tag-editable"),this.maxLength=e.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this._applyStyles(),this.closeBtn){const t=e=>{e.stopPropagation(),this.element.dispatchEvent(new CustomEvent("kupola:tag-remove",{detail:{tag:this.element,content:this.getContent()},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",t),this._listeners.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=e=>{e.target!==this.checkbox&&e.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this._listeners.push({el:this.element,event:"click",handler:t}),this.checkbox){const e=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",e),this._listeners.push({el:this.checkbox,event:"change",handler:e})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this._listeners.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const e=()=>{this.endEdit()},i=n=>{n.key==="Enter"?this.endEdit():n.key==="Escape"&&this.cancelEdit()};this.editInput.addEventListener("blur",e),this.editInput.addEventListener("keydown",i),this._listeners.push({el:this.editInput,event:"blur",handler:e}),this._listeners.push({el:this.editInput,event:"keydown",handler:i})}}}_applyStyles(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],e=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(i=>this.element.classList.remove(i)),e.forEach(i=>this.element.classList.remove(i)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),e.includes(`ds-tag--${this.size}`)&&this.element.classList.add(`ds-tag--${this.size}`),this.checkable&&this.element.classList.add("ds-tag--checkable"),this.checked&&this.element.classList.add("is-checked"),this.editable&&this.element.classList.add("ds-tag--editable")}setContent(t){this.editable&&this.editInput&&(this.editInput.value=t);const e=[];this.element.childNodes.forEach(o=>{o.nodeType===Node.TEXT_NODE&&e.push(o)}),e.forEach(o=>o.remove());const i=this.element.querySelector(".ds-tag__close"),n=this.element.querySelector(".ds-tag__checkbox"),r=this.element.querySelector(".ds-tag__input"),a=i||n||r||null;this.element.insertBefore(document.createTextNode(t),a),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:t},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-tag-color",t),this._applyStyles())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this._applyStyles())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=this.checked),this.element.dispatchEvent(new CustomEvent("kupola:tag-check",{detail:{tag:this.element,checked:this.checked,content:this.getContent()},bubbles:!0}))}setChecked(t){this.checked=t,this.element.setAttribute("data-tag-checked",t?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=t)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const t=this.getContent();if(this.editInput)this.editInput.value=t;else{const e=document.createElement("input");e.type="text",e.className="ds-tag__input",e.value=t,e.maxLength=this.maxLength,this.editInput=e;const i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,i);const n=()=>this.endEdit(),r=a=>{a.key==="Enter"?this.endEdit():a.key==="Escape"&&this.cancelEdit()};e.addEventListener("blur",n),e.addEventListener("keydown",r),this._listeners.push({el:e,event:"blur",handler:n}),this._listeners.push({el:e,event:"keydown",handler:r})}this.element.classList.add("is-editing"),setTimeout(()=>{this.editInput&&(this.editInput.focus(),this.editInput.select())},0)}endEdit(){if(!this.editable||!this.element.classList.contains("is-editing"))return;const t=this.editInput.value.trim();this.element.classList.remove("is-editing"),t&&t!==this.getContent()&&(this.setContent(t),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:t},bubbles:!0})))}cancelEdit(){!this.editable||!this.element.classList.contains("is-editing")||(this.element.classList.remove("is-editing"),this.editInput&&(this.editInput.value=this.getContent()))}setEditable(t){this.editable=t,t?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this._applyStyles()}isEditable(){return this.editable}setCheckable(t){this.checkable!==t&&(this.destroy(),this.checkable=t,t?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function ut(s,t){if(s.__kupolaInitialized)return;const e=new fe(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Ot(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Ai(){document.querySelectorAll(".ds-tag").forEach(s=>{ut(s)})}typeof window<"u"&&(window.Tag=fe,window.initTag=ut,window.cleanupTag=Ot,window.initTags=Ai,window.kupolaInitializer&&window.kupolaInitializer.register("tag",ut,Ot));class me{constructor(t){this.element=t,this.valueElement=t.querySelector(".ds-statcard__value"),this.progressFill=t.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(t=>{t.forEach(e=>{e.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this._observer.observe(this.element)}animateValue(){if(!this.valueElement)return;const t=this.valueElement.textContent,e=t.match(/[\d.,]+/);if(!e)return;const i=parseFloat(e[0].replace(",","")),n=t.substring(0,e.index),r=t.substring(e.index+e[0].length),a=1500,o=performance.now(),l=0,c=d=>{const h=d-o,u=Math.min(h/a,1),f=1-Math.pow(1-u,3),p=l+(i-l)*f;let m;i>=1e6?m=(p/1e6).toFixed(1)+"M":i>=1e3?m=(p/1e3).toFixed(1)+"K":Number.isInteger(i)?m=Math.floor(p).toLocaleString():m=p.toFixed(2),this.valueElement.textContent=n+m+r,u<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}animateProgress(){if(!this.progressFill)return;const t=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=t}updateValue(t,e={}){if(!this.valueElement)return;const i=e.duration||800,n=this.valueElement.textContent,r=n.match(/[\d.,]+/);if(!r){this.valueElement.textContent=t;return}const a=n.substring(0,r.index),o=n.substring(r.index+r[0].length),l=parseFloat(r[0].replace(",","")),c=parseFloat(t),d=performance.now(),h=u=>{const f=u-d,p=Math.min(f/i,1),m=1-Math.pow(1-p,3),y=l+(c-l)*m;let _;c>=1e6?_=(y/1e6).toFixed(1)+"M":c>=1e3?_=(y/1e3).toFixed(1)+"K":Number.isInteger(c)?_=Math.floor(y).toLocaleString():_=y.toFixed(2),this.valueElement.textContent=a+_+o,p<1&&requestAnimationFrame(h)};requestAnimationFrame(h)}updateProgress(t,e={}){if(!this.progressFill)return;const i=e.duration||600,n=parseFloat(this.progressFill.style.width||"0"),r=Math.min(Math.max(t,0),100),a=performance.now(),o=l=>{const c=l-a,d=Math.min(c/i,1),h=1-Math.pow(1-d,3),u=n+(r-n)*h;this.progressFill.style.width=u+"%",d<1&&requestAnimationFrame(o)};requestAnimationFrame(o)}setTrend(t,e){const i=this.element.querySelector(".ds-statcard__trend");if(!i)return;i.className=`ds-statcard__trend ds-statcard__trend--${t}`;const n=t==="up"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/></svg>':t==="down"?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 18 10.5 8.5 15.5 13.5 23 6"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="12 19 18 13 12 7 6 13"/></svg>';i.innerHTML=n+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function pt(s){if(s.__kupolaInitialized)return;const t=new me(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function Rt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function zi(){document.querySelectorAll(".ds-statcard").forEach(s=>{pt(s)})}function Es(s,t){const e=document.querySelector(s);e&&e.__kupolaInstance&&e.__kupolaInstance.updateValue(t)}typeof window<"u"&&(window.StatCard=me,window.initStatCard=pt,window.cleanupStatCard=Rt,window.initStatCards=zi,window.updateStatCard=Es,window.kupolaInitializer&&window.kupolaInitializer.register("statcard",pt,Rt));class Lt{constructor(t,e={}){this.element=t,this.data=e.data||[],this.startDate=e.startDate||this.getOneYearAgo(),this.endDate=e.endDate||new Date,this.cellSize=e.cellSize||14,this.onCellClick=e.onCellClick||null,this.tooltip=null,this.baseColor=e.color||t.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const t=new Date;return t.setFullYear(t.getFullYear()-1),t}init(){this.render(),this.createTooltip()}getDataByDate(t){const e=this.formatDate(t),i=this.data.find(n=>n.date===e);return i?i.value:0}formatDate(t){const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${i}-${n}`}getLevel(t,e){if(t===0)return 0;(!e||e===0)&&(e=Math.max(...this.data.map(n=>n.value),1));const i=t/e;return i<.2?1:i<.4?2:i<.6?3:i<.8?4:5}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:34,g:197,b:94}}getCellColor(t){const e=this.hexToRgb(this.baseColor);if(t===0)return"rgba(0, 0, 0, 0.1)";const i=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${i})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let i=-1;for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1)){const r=n.getMonth(),a=n.getDate();r!==i&&a===1&&(e.push({month:r,label:t[r],offset:Math.floor((n-this.startDate)/(1e3*60*60*24))}),i=r)}return e}getWeekCount(){let t=0;const i=new Date(this.startDate).getDay();for(let n=new Date(this.startDate);n<=this.endDate;n.setDate(n.getDate()+1))n.getDay()===0&&t++;return i!==0&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let i=[];const r=new Date(this.startDate).getDay();for(let _=1;_<r;_++)i.push(null);for(let _=new Date(this.startDate);_<=this.endDate;_.setDate(_.getDate()+1))i.push(new Date(_)),(_.getDay()===6||_.getTime()===this.endDate.getTime())&&(e.push(i),i=[]);const a=e.length,o=this.element.classList.contains("ds-heatmap--compact")?12:16,l=a*o,c=document.createElement("div");c.className="ds-heatmap__container";const d=document.createElement("div");d.className="ds-heatmap__labels-and-grid";const h=document.createElement("div");h.className="ds-heatmap__weekday-labels";const u=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(_=>{const b=document.createElement("div");b.className="ds-heatmap__weekday-label",b.textContent=_,b.style.height=u+"px",b.style.lineHeight=u+"px",h.appendChild(b)}),d.appendChild(h);const f=document.createElement("div");f.className="ds-heatmap__grid-container";const p=document.createElement("div");p.className="ds-heatmap__month-labels",p.style.width=l+"px";const m=this.getMonthLabels();m.forEach((_,b)=>{const v=document.createElement("div");v.className="ds-heatmap__month-label",v.textContent=_.label;const w=m[b+1];let k;w?k=Math.ceil((w.offset-_.offset)/7):k=a-Math.floor(_.offset/7),v.style.width=k*o+"px",p.appendChild(v)}),f.appendChild(p);const y=document.createElement("div");y.className="ds-heatmap__grid",e.forEach(_=>{const b=document.createElement("div");b.className="ds-heatmap__week-column",_.forEach(v=>{if(v===null){const w=document.createElement("div");w.className="ds-heatmap__cell",w.style.visibility="hidden",b.appendChild(w)}else{const w=this.getDataByDate(v),k=Math.max(...this.data.map(P=>P.value),1),E=this.getLevel(w,k),x=document.createElement("div");x.className="ds-heatmap__cell",x.dataset.date=this.formatDate(v),x.dataset.value=w,x.style.backgroundColor=this.getCellColor(E);const C=P=>this.showTooltip(P,v,w),M=()=>this.hideTooltip(),H=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(v),value:w})};x.addEventListener("mouseenter",C),x.addEventListener("mouseleave",M),x.addEventListener("click",H),this._listeners.push({el:x,event:"mouseenter",handler:C},{el:x,event:"mouseleave",handler:M},{el:x,event:"click",handler:H}),b.appendChild(x)}}),y.appendChild(b)}),f.appendChild(y),d.appendChild(f),c.appendChild(d),t.appendChild(c),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const i=document.createElement("span");i.className="ds-heatmap__legend-label",i.textContent="少";const n=document.createElement("div");n.className="ds-heatmap__legend-cells";for(let a=0;a<=5;a++){const o=document.createElement("div");o.className="ds-heatmap__legend-cell",o.style.backgroundColor=this.getCellColor(a),n.appendChild(o)}const r=document.createElement("span");r.className="ds-heatmap__legend-label",r.textContent="多",e.appendChild(i),e.appendChild(n),e.appendChild(r),t.appendChild(e)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(t,e,i){const n=t.target.getBoundingClientRect(),r=150;this.tooltip.innerHTML=`
175
+ <div class="ds-heatmap__tooltip-date">${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日</div>
176
+ <div class="ds-heatmap__tooltip-value">${i} contributions</div>
177
+ `,this.tooltip.style.left=Math.min(n.left+n.width/2-r/2,window.innerWidth-r-16)+"px",this.tooltip.style.top=n.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(t){this._listeners.forEach(({el:e,event:i,handler:n})=>{e.removeEventListener(i,n)}),this._listeners=[],this.data=t,this.render()}setDateRange(t,e){this.startDate=t,this.endDate=e,this.render()}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function ft(s){if(s.__kupolaInitialized)return;const t=s.getAttribute("data-heatmap-data");let e=[];if(t)try{e=JSON.parse(t)}catch{e=mt()}else e=mt();const i=new Lt(s,{data:e,onCellClick:n=>{}});s.__kupolaInstance=i,s.__kupolaInitialized=!0}function Vt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Pi(){document.querySelectorAll(".ds-heatmap").forEach(s=>{ft(s)})}function mt(){const s=[],t=new Date,e=new Date;e.setFullYear(e.getFullYear()-1);for(let i=new Date(e);i<=t;i.setDate(i.getDate()+1)){const n=i.getFullYear(),r=String(i.getMonth()+1).padStart(2,"0"),a=String(i.getDate()).padStart(2,"0"),l=i.getDay()===0||i.getDay()===6?Math.random()*20:Math.random()*50,c=Math.floor(l);s.push({date:`${n}-${r}-${a}`,value:c>0?c:Math.floor(Math.random()*30)+1})}return s}function Cs(s,t={}){const e=document.querySelector(s);if(e){const i=t.data||mt();return new Lt(e,{data:i,...t})}return null}typeof window<"u"&&(window.Heatmap=Lt,window.initHeatmap=ft,window.cleanupHeatmap=Vt,window.initHeatmaps=Pi,window.createHeatmap=Cs,window.generateMockHeatmapData=mt,window.kupolaInitializer&&window.kupolaInitializer.register("heatmap",ft,Vt));class ge{constructor(t,e={}){this.element=t,this.tooltipEl=null,this.options=e,this.delay=e.delay||parseInt(t.getAttribute("data-tooltip-delay"))||0,this.hideDelay=e.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=e.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=e.html||t.hasAttribute("data-tooltip-html"),this.theme=e.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=e.position||t.getAttribute("data-tooltip-position")||"top",this.animation=e.animation!==!1,this.mouseFollow=e.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this._showTooltip=null,this._hideTooltip=null,this._showTimer=null,this._hideTimer=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._mouseMoveHandler=null,this.isVisible=!1}init(){this.element.__kupolaInitialized||(this._showTooltip=()=>{this.delay>0?this._showTimer=setTimeout(()=>this.show(),this.delay):this.show()},this._hideTooltip=()=>{this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.hideDelay>0?this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this._clickHandler=()=>{this.isVisible?this.hide():this.show()},this._mouseMoveHandler=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const e=this.tooltipEl.getBoundingClientRect();let i=t.clientX+10,n=t.clientY+10;const r=window.innerWidth,a=window.innerHeight;i+e.width>r&&(i=t.clientX-e.width-10),n+e.height>a&&(n=t.clientY-e.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${n}px`},(this.trigger==="hover"||this.trigger==="focus")&&(this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.mouseFollow&&this.element.addEventListener("mousemove",this._mouseMoveHandler)),this.trigger==="click"&&(this.element.addEventListener("click",this._clickHandler),document.addEventListener("click",t=>{this.isVisible&&!this.element.contains(t.target)&&!this.tooltipEl?.contains(t.target)&&this.hide()})),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip)),this.element.__kupolaInitialized=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");t&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{this.tooltipEl.classList.add("is-visible"),this.mouseFollow||this._positionTooltip(),this.isVisible=!0,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-show",{detail:{tooltip:this.tooltipEl},bubbles:!0}))}))}hide(){if(!this.isVisible||!this.tooltipEl)return;this.tooltipEl.classList.remove("is-visible");const t=this.tooltipEl;setTimeout(()=>{t===this.tooltipEl&&(t.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:t},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}_positionTooltip(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),e=this.tooltipEl.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight;let r,a;switch(this.position){case"bottom":r=t.left+t.width/2-e.width/2,a=t.bottom+8;break;case"right":r=t.right+8,a=t.top+t.height/2-e.height/2;break;case"left":r=t.left-e.width-8,a=t.top+t.height/2-e.height/2;break;case"top":default:r=t.left+t.width/2-e.width/2,a=t.top-e.height-8;break}r<8&&(r=8),r+e.width>i&&(r=i-e.width-8),a<8&&(a=8),a+e.height>n&&(a=n-e.height-8),this.tooltipEl.style.left=`${r}px`,this.tooltipEl.style.top=`${a}px`,this.tooltipEl.style.position="fixed"}updateContent(t,e=!1){this.element.setAttribute("data-tooltip",t),e?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=e,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this._positionTooltip())}setPosition(t){["top","bottom","left","right"].includes(t)&&(this.position=t,this.element.setAttribute("data-tooltip-position",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this._positionTooltip()))}setTheme(t){this.theme=t,this.element.setAttribute("data-tooltip-theme",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(t){this.delay=t,this.element.setAttribute("data-tooltip-delay",t)}setHideDelay(t){this.hideDelay=t,this.element.setAttribute("data-tooltip-hide-delay",t)}setTrigger(t){["hover","click","focus","manual"].includes(t)&&(this.destroy(),this.trigger=t,this.element.setAttribute("data-tooltip-trigger",t),this.init())}enableMouseFollow(t){this.mouseFollow=t,t?(this.element.setAttribute("data-tooltip-mouse-follow",""),this.element.addEventListener("mousemove",this._mouseMoveHandler)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this._mouseMoveHandler))}destroy(){this.element.__kupolaInitialized&&(this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),(this.trigger==="hover"||this.trigger==="focus")&&(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("mouseleave",this._hideTooltip)),this.trigger==="click"&&this.element.removeEventListener("click",this._clickHandler),(this.trigger==="focus"||this.trigger==="hover")&&(this.element.removeEventListener("focus",this._showTooltip),this.element.removeEventListener("blur",this._hideTooltip)),this.mouseFollow&&this.element.removeEventListener("mousemove",this._mouseMoveHandler),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this._showTooltip=null,this._hideTooltip=null,this._clickHandler=null,this._mouseMoveHandler=null,this.element.__kupolaInitialized=!1)}}function gt(s,t){const e=new ge(s,t);e.init(),s._kupolaTooltip=e}function $i(s=document){s.querySelectorAll("[data-tooltip]").forEach(t=>{gt(t)})}function Kt(s){s._kupolaTooltip&&(s._kupolaTooltip.destroy(),s._kupolaTooltip=null)}typeof window<"u"&&(window.Tooltip=ge,window.initTooltip=gt,window.initTooltips=$i,window.cleanupTooltip=Kt,window.kupolaInitializer&&window.kupolaInitializer.register("tooltip",gt,Kt));class _e{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,e){this.customValidators[t]=e}addAsyncValidator(t,e){this.customAsyncValidators[t]=e}validate(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`,i={},n=t.querySelectorAll("[data-validate]");let r=!1;return n.forEach(a=>{const o=a.name||a.id,l=this.parseRules(a.getAttribute("data-validate")),c=this.getValue(a);for(const[d,h]of Object.entries(l))if((this.customValidators[d]||this.validators[d])?.(c,h))this.clearError(a);else{i[o]=this.getErrorMessage(d,h,a),this.showError(a,i[o]),r=!0;break}}),this.formStates[e]={valid:!r,errors:i,errorCount:Object.keys(i).length},this.updateFormState(t),!r}getValue(t){if(t.classList.contains("ds-datepicker__input")||t.classList.contains("ds-timepicker__input"))return t.value.trim();if(t.closest(".ds-select")){const e=t.closest(".ds-select"),i=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return i?i.textContent.trim():""}if(t.closest(".ds-fileupload")){const i=t.closest(".ds-fileupload").__fileUploadInstance;return i&&i.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const e=this.parseRules(t.getAttribute("data-validate")),i=this.getValue(t);for(const[n,r]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(i,r))return this.showError(t,this.getErrorMessage(n,r,t)),!1;return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let e=!0;return t.forEach(i=>{this.validate(i)||(e=!1)}),e}async validateAsync(t,e={}){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,n=e.group,r=n?t.querySelectorAll(`[data-validate][data-validate-group="${n}"]`):t.querySelectorAll("[data-validate]");let a=!1;for(const l of r)await this.validateInputAsync(l)||(a=!0);const o={};return r.forEach(l=>{const c=l.name||l.id,d=l.parentElement.querySelector(".ds-input__error");d&&(o[c]=d.textContent)}),this.formStates[i]={valid:!a,errors:o,errorCount:Object.keys(o).length},this.updateFormState(t),!a}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),i=this.parseRules(t.getAttribute("data-validate-async")||""),n=this.getValue(t);for(const[r,a]of Object.entries(e))if(!(this.customValidators[r]||this.validators[r])?.(n,a))return this.showError(t,this.getErrorMessage(r,a,t)),!1;for(const[r,a]of Object.entries(i)){const o=this.customAsyncValidators[r]||this.asyncValidators[r];if(o)try{if(!await o(n,a,t))return this.showError(t,this.getErrorMessage(r,a,t)),!1}catch(l){return this.showError(t,l.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const i=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let n=!1;for(const r of i)await this.validateInputAsync(r)||(n=!0);return!n}getGroups(t){const e=new Set;return t.querySelectorAll("[data-validate-group]").forEach(i=>{e.add(i.getAttribute("data-validate-group"))}),Array.from(e)}getFormState(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[e]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const e=this.getFormState(t);e.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),e.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),e.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),e.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>n.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(n=>{n.hasAttribute("data-permanent-disabled")||(n.disabled=!1)}));const i=t.querySelector(".ds-form__status");i&&(e.errorCount>0?(i.textContent=`${e.errorCount} ${e.errorCount===1?"error":"errors"} found`,i.classList.add("ds-form__status--error")):(i.textContent="All fields are valid",i.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].disabled=e,this.updateFormState(t)}resetForm(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[e]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(i=>{i.classList.remove("ds-input--error");const n=i.parentElement?.querySelector(".ds-input__error");n&&(n.textContent="")}),this.updateFormState(t)}parseRules(t){const e={};return t.split("|").forEach(n=>{const[r,a]=n.split(":");e[r]=a?a.split(","):[]}),e}validateRequired(t){return t!==""}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[e]){return t.length>=parseInt(e)}validateMaxLength(t,[e]){return t.length<=parseInt(e)}validatePattern(t,[e]){return new RegExp(e).test(t)}validateMin(t,[e]){return parseFloat(t)>=parseFloat(e)}validateMax(t,[e]){return parseFloat(t)<=parseFloat(e)}validateEqualTo(t,[e]){const i=document.getElementById(e);return i&&t===i.value}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,e){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let i=t.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),t.parentElement.appendChild(i)),i.textContent=e,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:e}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const e=t.parentElement.querySelector(".ds-input__error");e&&e.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const e=document.createElement("span");e.className="ds-input__status-icon ds-input__status-icon--success",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(e)}removeStatusIcon(t){const e=t.parentElement.querySelector(".ds-input__status-icon");e&&e.remove()}getErrorMessage(t,e,i){const n=i.getAttribute(`data-message-${t}`);return n||{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${e[0]} characters`,maxLength:`Maximum length is ${e[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${e[0]}`,max:`Maximum value is ${e[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const D=new _e;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(s=>{s.addEventListener("submit",async t=>{const e=s.id||`form-${Math.random().toString(36).substr(2,9)}`;if(D.submitting.has(e)){t.preventDefault();return}t.preventDefault();const i=s.querySelector("[data-validate-async]")!==null;let n;if(i?n=await D.validateAsync(s):n=D.validate(s),n){D.submitting.add(e);const r=s.querySelector('button[type="submit"]');if(r){const a=r.textContent;r.setAttribute("data-original-text",a),r.textContent="Submitting...",r.disabled=!0}try{const a=s.getAttribute("data-on-submit");a&&window[a]?await window[a](s):s.submit()}finally{D.submitting.delete(e),r&&(r.textContent=r.getAttribute("data-original-text")||"Submit",r.disabled=!1)}}else{const r=s.querySelector(".ds-input--error");r&&r.focus()}}),s.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const n=document.activeElement;if(n&&n.closest(".ds-select"))return;D.validateInput(t)&&t.value.trim()&&D.showSuccess(t)},50)});const i=((n,r)=>{let a;return(...o)=>{clearTimeout(a),a=setTimeout(()=>n.apply(void 0,o),r)}})(()=>{const n=D.getValue(t);n.length>0||t.classList.contains("ds-input--error")?D.validateInput(t)&&n&&D.showSuccess(t):D.removeStatusIcon(t)},300);t.addEventListener("input",i),t.addEventListener("keyup",n=>{n.key==="Enter"&&D.validateInput(t)&&t.value.trim()&&D.showSuccess(t)})})})}));typeof window<"u"&&(window.KupolaValidator=_e,window.kupolaValidator=D);class Dt{constructor(t,e={}){this.element=t,this.data=e.data||[],this.itemHeight=e.itemHeight||48,this.itemWidth=e.itemWidth||200,this.bufferSize=e.bufferSize||5,this.renderItem=e.renderItem||this.defaultRenderItem,this.onItemClick=e.onItemClick||null,this.onItemSelect=e.onItemSelect||null,this.onScroll=e.onScroll||null,this.onScrollEnd=e.onScrollEnd||null,this.selectedKey=e.selectedKey||null,this.keyField=e.keyField||"id",this.useDynamicHeight=e.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=e.estimatedHeight||48,this.container=null,this.scrollbarTrack=null,this.scrollbarThumb=null,this.totalHeight=0,this.startIndex=0,this.endIndex=0,this.isScrolling=!1,this.scrollTimeout=null,this.lastScrollTop=0,this.lastScrollLeft=0,this.init()}defaultRenderItem(t,e){return`
113
178
  <div class="ds-virtual-list__item-content">
114
179
  <div class="ds-virtual-list__item-icon">
115
180
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -121,8 +186,8 @@
121
186
  </svg>
122
187
  </div>
123
188
  <div>
124
- <div class="ds-virtual-list__item-title">${l.title||l.name||`Item ${c+1}`}</div>
125
- <div class="ds-virtual-list__item-subtitle">${l.subtitle||"Subtitle"}</div>
189
+ <div class="ds-virtual-list__item-title">${t.title||t.name||`Item ${e+1}`}</div>
190
+ <div class="ds-virtual-list__item-subtitle">${t.subtitle||"Subtitle"}</div>
126
191
  </div>
127
192
  </div>
128
193
  `}init(){this.createStructure(),this.update(),this.bindEvents()}createStructure(){this.element.innerHTML=`
@@ -132,127 +197,120 @@
132
197
  </div>
133
198
  </div>
134
199
  <div class="ds-virtual-list__container"></div>
135
- `,this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this._scrollHandler=l=>this.handleScroll(l),this._thumbDragStartHandler=l=>this.handleThumbDragStart(l),this._thumbDragMoveHandler=l=>this.handleThumbDragMove(l),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=l=>{l.preventDefault(),this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=l.deltaX+l.deltaY:this.element.scrollTop+=l.deltaY+l.deltaX},this.element.addEventListener("scroll",this._scrollHandler),this.scrollbarThumb.addEventListener("mousedown",this._thumbDragStartHandler),document.addEventListener("mousemove",this._thumbDragMoveHandler),document.addEventListener("mouseup",this._thumbDragEndHandler),this.element.addEventListener("wheel",this._wheelHandler,{passive:!1}),this._listeners=[{el:this.element,event:"scroll",handler:this._scrollHandler},{el:this.scrollbarThumb,event:"mousedown",handler:this._thumbDragStartHandler},{el:document,event:"mousemove",handler:this._thumbDragMoveHandler},{el:document,event:"mouseup",handler:this._thumbDragEndHandler},{el:this.element,event:"wheel",handler:this._wheelHandler}]}handleScroll(l){const c=this.element.classList.contains("ds-virtual-list--horizontal"),h=c?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:h,isHorizontal:c,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex}),this.updateScrollState(),this.renderVisibleItems(),this.updateScrollbar()}updateScrollState(){this.isScrolling=!0,this.element.classList.add("ds-virtual-list--scrolling"),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{if(this.isScrolling=!1,this.element.classList.remove("ds-virtual-list--scrolling"),this.onScrollEnd){const l=this.element.classList.contains("ds-virtual-list--horizontal"),c=l?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:c,isHorizontal:l,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(l){const c=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const h=this.data[l][this.keyField]||l;if(this.dynamicHeightCache.has(h))return this.dynamicHeightCache.get(h)}return c?this.itemWidth:this.itemHeight}getItemPositions(){const l=[];let c=0;return this.data.forEach((h,u)=>{const d=this.getItemSize(u);l.push({start:c,end:c+d,size:d}),c+=d}),l}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((h,u,d)=>h+this.getItemSize(d),0);const c=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*c}getIndexAtOffset(l){if(this.useDynamicHeight){const u=this.getItemPositions();for(let d=0;d<u.length;d++)if(l>=u[d].start&&l<u[d].end)return d;return this.data.length-1}const h=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(l/h)}renderVisibleItems(){const l=this.element.classList.contains("ds-virtual-list--horizontal"),c=l?this.element.scrollLeft:this.element.scrollTop,h=l?this.element.clientWidth:this.element.clientHeight,u=Math.max(0,this.getIndexAtOffset(c)-this.bufferSize);let d=Math.min(this.data.length-1,this.getIndexAtOffset(c+h)+this.bufferSize);d<u&&(d=u),this.startIndex=u,this.endIndex=d;const p=this.data.slice(u,d+1);let g="",f=0;if(this.useDynamicHeight)f=this.getItemPositions()[u]?.start||0;else{const m=l?this.itemWidth:this.itemHeight;f=u*m}p.forEach((m,v)=>{const y=u+v,w=m[this.keyField]||y,_=this.selectedKey===w,b=this.getItemSize(y),k=f;l?g+=`
200
+ `,this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this._scrollHandler=t=>this.handleScroll(t),this._thumbDragStartHandler=t=>this.handleThumbDragStart(t),this._thumbDragMoveHandler=t=>this.handleThumbDragMove(t),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=t=>{t.preventDefault(),this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=t.deltaX+t.deltaY:this.element.scrollTop+=t.deltaY+t.deltaX},this.element.addEventListener("scroll",this._scrollHandler),this.scrollbarThumb.addEventListener("mousedown",this._thumbDragStartHandler),document.addEventListener("mousemove",this._thumbDragMoveHandler),document.addEventListener("mouseup",this._thumbDragEndHandler),this.element.addEventListener("wheel",this._wheelHandler,{passive:!1}),this._listeners=[{el:this.element,event:"scroll",handler:this._scrollHandler},{el:this.scrollbarThumb,event:"mousedown",handler:this._thumbDragStartHandler},{el:document,event:"mousemove",handler:this._thumbDragMoveHandler},{el:document,event:"mouseup",handler:this._thumbDragEndHandler},{el:this.element,event:"wheel",handler:this._wheelHandler}]}handleScroll(t){const e=this.element.classList.contains("ds-virtual-list--horizontal"),i=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:i,isHorizontal:e,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex}),this.updateScrollState(),this.renderVisibleItems(),this.updateScrollbar()}updateScrollState(){this.isScrolling=!0,this.element.classList.add("ds-virtual-list--scrolling"),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{if(this.isScrolling=!1,this.element.classList.remove("ds-virtual-list--scrolling"),this.onScrollEnd){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:e,isHorizontal:t,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(t){const e=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const i=this.data[t][this.keyField]||t;if(this.dynamicHeightCache.has(i))return this.dynamicHeightCache.get(i)}return e?this.itemWidth:this.itemHeight}getItemPositions(){const t=[];let e=0;return this.data.forEach((i,n)=>{const r=this.getItemSize(n);t.push({start:e,end:e+r,size:r}),e+=r}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((i,n,r)=>i+this.getItemSize(r),0);const e=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*e}getIndexAtOffset(t){if(this.useDynamicHeight){const n=this.getItemPositions();for(let r=0;r<n.length;r++)if(t>=n[r].start&&t<n[r].end)return r;return this.data.length-1}const i=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(t/i)}renderVisibleItems(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop,i=t?this.element.clientWidth:this.element.clientHeight,n=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let r=Math.min(this.data.length-1,this.getIndexAtOffset(e+i)+this.bufferSize);r<n&&(r=n),this.startIndex=n,this.endIndex=r;const a=this.data.slice(n,r+1);let o="",l=0;if(this.useDynamicHeight)l=this.getItemPositions()[n]?.start||0;else{const c=t?this.itemWidth:this.itemHeight;l=n*c}a.forEach((c,d)=>{const h=n+d,u=c[this.keyField]||h,f=this.selectedKey===u,p=this.getItemSize(h),m=l;t?o+=`
136
201
  <div
137
- class="ds-virtual-list__item${_?" is-selected":""}"
138
- style="position: absolute; top: 0; left: ${k}px; width: ${b}px; height: 100%;"
139
- data-index="${y}"
140
- data-key="${w}"
202
+ class="ds-virtual-list__item${f?" is-selected":""}"
203
+ style="position: absolute; top: 0; left: ${m}px; width: ${p}px; height: 100%;"
204
+ data-index="${h}"
205
+ data-key="${u}"
141
206
  >
142
- ${this.renderItem(m,y)}
207
+ ${this.renderItem(c,h)}
143
208
  </div>
144
- `:g+=`
209
+ `:o+=`
145
210
  <div
146
- class="ds-virtual-list__item${_?" is-selected":""}"
147
- style="position: absolute; top: ${k}px; left: 0; right: 0; height: ${b}px;"
148
- data-index="${y}"
149
- data-key="${w}"
211
+ class="ds-virtual-list__item${f?" is-selected":""}"
212
+ style="position: absolute; top: ${m}px; left: 0; right: 0; height: ${p}px;"
213
+ data-index="${h}"
214
+ data-key="${u}"
150
215
  >
151
- ${this.renderItem(m,y)}
152
- </div>
153
- `,f+=b}),this.container.innerHTML=g,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(m=>{m.addEventListener("click",()=>this.handleItemClick(m))})}updateDynamicHeights(){if(this.isUpdating)return;let l=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(c=>{const h=parseInt(c.dataset.index),u=this.data[h][this.keyField]||h,d=c.offsetHeight;d!==this.getItemSize(h)&&(this.dynamicHeightCache.set(u,d),l=!0)}),l&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(l){const c=parseInt(l.dataset.index),h=l.dataset.key,u=this.data[c];this.onItemClick&&this.onItemClick({item:u,index:c,key:h}),this.onItemSelect&&this.select(h)}select(l){if(this.selectedKey=l,this.onItemSelect){const c=this.data.findIndex(h=>h[this.keyField]===l);c!==-1&&this.onItemSelect({item:this.data[c],index:c,key:l})}this.renderVisibleItems()}updateScrollbar(){const l=this.element.classList.contains("ds-virtual-list--horizontal"),c=this.getTotalSize(),h=l?this.element.clientWidth:this.element.clientHeight,u=l?this.element.scrollLeft:this.element.scrollTop;if(l){this.scrollbarThumb.style.display="none";return}const d=Math.max(20,h/c*h),p=h-d,g=u/(c-h||1)*p;this.scrollbarThumb.style.height=d+"px",this.scrollbarThumb.style.top=g+"px"}handleThumbDragStart(l){l.preventDefault(),this.isDragging=!0,this.dragStartY=l.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(l){if(!this.isDragging)return;const c=this.element.clientHeight,h=this.getTotalSize(),u=parseFloat(this.scrollbarThumb.style.height)||c,d=c-u,p=l.clientY-this.dragStartY;let g=this.dragStartTop+p;g=Math.max(0,Math.min(g,d)),this.scrollbarThumb.style.top=g+"px";const f=g/d*(h-c||0);this.element.scrollTop=f}handleThumbDragEnd(){this.isDragging=!1}update(){const l=this.element.classList.contains("ds-virtual-list--horizontal"),c=this.getTotalSize();l?(this.container.style.width=c+"px",this.container.style.height="100%"):(this.container.style.height=c+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(l){this.data=l,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(l){this.data.push(l),this.update()}removeItem(l){this.data.splice(l,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(l,c){this.data.splice(l,0,c),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(l,c="smooth"){const h=this.element.classList.contains("ds-virtual-list--horizontal");let u=0;if(this.useDynamicHeight)u=this.getItemPositions()[l]?.start||0;else{const d=h?this.itemWidth:this.itemHeight;u=l*d}h?this.element.scrollTo({left:u,behavior:c}):this.element.scrollTo({top:u,behavior:c})}scrollToKey(l,c="smooth"){const h=this.data.findIndex(u=>u[this.keyField]===l);h!==-1&&this.scrollTo(h,c)}scrollToTop(l="smooth"){const c=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[c?"left":"top"]:0,behavior:l})}scrollToBottom(l="smooth"){const c=this.element.classList.contains("ds-virtual-list--horizontal"),h=this.getTotalSize(),u=c?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[c?"left":"top"]:h-u,behavior:l})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((l,c)=>({item:l,index:this.startIndex+c,key:l[this.keyField]||this.startIndex+c}))}getItemIndex(l){return this.data.findIndex(c=>c[this.keyField]===l)}getItem(l){const c=this.getItemIndex(l);return c!==-1?this.data[c]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:l,event:c,handler:h})=>{l.removeEventListener(c,h)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this._listeners=null,this._scrollHandler=null,this._thumbDragStartHandler=null,this._thumbDragMoveHandler=null,this._thumbDragEndHandler=null,this._wheelHandler=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function e(a=1e3){const l=[],c=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let h=1;h<=a;h++){const u=Math.floor(Math.random()*c.length),d=Math.floor(Math.random()*1e4);l.push({id:h,title:`${c[u]} ${d}`,subtitle:`Last modified ${Math.floor(Math.random()*30)} days ago`,type:c[u].toLowerCase()})}return l}function r(a,l={}){const c=document.querySelector(a);if(c){const h=l.data||e(l.count||1e3);return new t(c,{data:h,...l})}return null}function o(a){if(a.__kupolaInitialized)return;const l=a.getAttribute("data-virtual-list");let c=[];if(l)try{c=JSON.parse(l)}catch{c=e(1e3)}else c=e(1e3);const h=new t(a,{data:c,onItemClick:u=>{},onItemSelect:u=>{}});a.__kupolaInstance=h,a.__kupolaInitialized=!0}function n(a){if(!a.__kupolaInitialized||!a.__kupolaInstance)return;a.__kupolaInstance.destroy(),a.__kupolaInstance=null,a.__kupolaInitialized=!1}function i(){document.querySelectorAll(".ds-virtual-list").forEach(a=>{o(a)})}s.exports?s.exports={VirtualList:t,initVirtualLists:i,initVirtualList:o,cleanupVirtualList:n,createVirtualList:r,generateMockVirtualListData:e}:(window.initVirtualList=o,window.cleanupVirtualList=n),window.kupolaInitializer&&window.kupolaInitializer.register("virtual-list",o,n)}(et)),et.exports}Hi();let Jt=class{constructor(t={}){this.enabled=t.enabled??!1,this.panel=null,this.isOpen=!1,this.activeTab="storage",this.activeStorageType="cookies",this.requestHistory=[],this.maxHistorySize=50}init(){if(this.enabled)try{this.createToggleButton(),this.createPanel(),this.setupNetworkInterceptor()}catch(t){console.error("Error in init:",t)}}createToggleButton(){const t=document.createElement("button");t.className="kupola-devtools__toggle",t.textContent="🛠️",t.style.cssText=`
154
- position: fixed;
155
- bottom: 28px;
156
- left: 50px;
157
- width: 48px;
158
- height: 48px;
159
- border-radius: 50%;
160
- background: #535164;
161
- color: white;
162
- border: none;
163
- cursor: pointer;
164
- z-index: 9999;
165
- font-size: 20px;
166
- box-shadow: 0 4px 12px rgba(0,0,0,0.3);
167
- transition: transform 0.2s;
168
- `,t.addEventListener("click",()=>this.togglePanel()),document.body.appendChild(t),this.toggleButton=t}createPanel(){const t=document.createElement("div");t.className="kupola-devtools__panel",t.style.cssText=`
169
- position: fixed;
170
- bottom: 80px;
171
- left: 28px;
172
- width: 550px;
173
- max-height: 650px;
174
- background: #1e1e1e;
175
- border-radius: 12px;
176
- box-shadow: 0 8px 32px rgba(0,0,0,0.4);
177
- z-index: 9998;
178
- display: none;
179
- flex-direction: column;
180
- overflow: hidden;
181
- border: 1px solid #333;
182
- `,t.innerHTML=`
183
- <div class="kupola-devtools__header">
184
- <span class="kupola-devtools__title">DevTools</span>
185
- <button class="kupola-devtools__close">✕</button>
186
- </div>
187
- <div class="kupola-devtools__tabs">
188
- <button data-tab="storage" class="kupola-devtools__tab active">Storage</button>
189
- <button data-tab="network" class="kupola-devtools__tab">Network</button>
190
- </div>
191
- <div class="kupola-devtools__sub-tabs" id="storage-sub-tabs">
192
- <button class="kupola-devtools__sub-tab active" data-storage="cookies">Cookies</button>
193
- <button class="kupola-devtools__sub-tab" data-storage="localStorage">LocalStorage</button>
194
- <button class="kupola-devtools__sub-tab" data-storage="sessionStorage">SessionStorage</button>
195
- </div>
196
- <div class="kupola-devtools__sub-tabs" id="network-sub-tabs" style="display:none;">
197
- <button class="kupola-devtools__network-action" data-action="clear">Clear</button>
198
- </div>
199
- <div class="kupola-devtools__content">
200
- ${this.getStorageContent("cookies")}
201
- </div>
202
- `,document.body.appendChild(t),this.panel=t,t.querySelector(".kupola-devtools__close").addEventListener("click",()=>this.togglePanel()),t.querySelectorAll(".kupola-devtools__tab").forEach(e=>{e.addEventListener("click",()=>this.switchTab(e.dataset.tab))}),this.setupStorageListener(),this.makeDraggable(),this.injectStyles()}switchTab(t){this.activeTab=t,this.panel.querySelectorAll(".kupola-devtools__tab").forEach(o=>{o.classList.toggle("active",o.dataset.tab===t)});const e=this.panel.querySelector("#storage-sub-tabs"),r=this.panel.querySelector("#network-sub-tabs");t==="storage"?(e.style.display="flex",r.style.display="none",this.renderStorageContent()):(e.style.display="none",r.style.display="flex",this.renderNetworkContent())}renderStorageContent(){const t=this.panel.querySelector(".kupola-devtools__content");t&&(t.innerHTML=this.getStorageContent(this.activeStorageType))}renderNetworkContent(){const t=this.panel.querySelector(".kupola-devtools__content");if(!t)return;if(this.requestHistory.length===0){t.innerHTML='<div class="kupola-devtools__loading">No network requests captured</div>';return}let e="";this.requestHistory.forEach((o,n)=>{const i=o.status>=200&&o.status<300?"success":o.status>=400?"error":"warning",a=o.duration?`${o.duration}ms`:"-";e+=`
203
- <div class="kupola-devtools__network-item" data-index="${n}">
204
- <div class="kupola-devtools__network-header">
205
- <span class="kupola-devtools__network-method">${o.method}</span>
206
- <span class="kupola-devtools__network-url">${o.url}</span>
207
- <span class="kupola-devtools__network-status ${i}">${o.status}</span>
208
- <span class="kupola-devtools__network-duration">${a}</span>
209
- </div>
210
- <div class="kupola-devtools__network-details" style="display:none;">
211
- ${o.params?`<div class="kupola-devtools__network-detail"><strong>Params:</strong><pre>${this.truncateContent(JSON.stringify(o.params,null,2),1e3)}</pre></div>`:""}
212
- ${o.requestBody?`<div class="kupola-devtools__network-detail"><strong>Request Body:</strong><pre>${this.truncateContent(o.requestBody,1e3)}</pre></div>`:""}
213
- ${o.response?`<div class="kupola-devtools__network-detail"><strong>Response:</strong><pre>${this.truncateContent(o.response,1500)}</pre></div>`:""}
216
+ ${this.renderItem(c,h)}
214
217
  </div>
218
+ `,l+=p}),this.container.innerHTML=o,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(c=>{c.addEventListener("click",()=>this.handleItemClick(c))})}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const i=parseInt(e.dataset.index),n=this.data[i][this.keyField]||i,r=e.offsetHeight;r!==this.getItemSize(i)&&(this.dynamicHeightCache.set(n,r),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),i=t.dataset.key,n=this.data[e];this.onItemClick&&this.onItemClick({item:n,index:e,key:i}),this.onItemSelect&&this.select(i)}select(t){if(this.selectedKey=t,this.onItemSelect){const e=this.data.findIndex(i=>i[this.keyField]===t);e!==-1&&this.onItemSelect({item:this.data[e],index:e,key:t})}this.renderVisibleItems()}updateScrollbar(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize(),i=t?this.element.clientWidth:this.element.clientHeight,n=t?this.element.scrollLeft:this.element.scrollTop;if(t){this.scrollbarThumb.style.display="none";return}const r=Math.max(20,i/e*i),a=i-r,o=n/(e-i||1)*a;this.scrollbarThumb.style.height=r+"px",this.scrollbarThumb.style.top=o+"px"}handleThumbDragStart(t){t.preventDefault(),this.isDragging=!0,this.dragStartY=t.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(t){if(!this.isDragging)return;const e=this.element.clientHeight,i=this.getTotalSize(),n=parseFloat(this.scrollbarThumb.style.height)||e,r=e-n,a=t.clientY-this.dragStartY;let o=this.dragStartTop+a;o=Math.max(0,Math.min(o,r)),this.scrollbarThumb.style.top=o+"px";const l=o/r*(i-e||0);this.element.scrollTop=l}handleThumbDragEnd(){this.isDragging=!1}update(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize();t?(this.container.style.width=e+"px",this.container.style.height="100%"):(this.container.style.height=e+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(t){this.data=t,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(t){this.data.push(t),this.update()}removeItem(t){this.data.splice(t,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(t,e){this.data.splice(t,0,e),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(t,e="smooth"){const i=this.element.classList.contains("ds-virtual-list--horizontal");let n=0;if(this.useDynamicHeight)n=this.getItemPositions()[t]?.start||0;else{const r=i?this.itemWidth:this.itemHeight;n=t*r}i?this.element.scrollTo({left:n,behavior:e}):this.element.scrollTo({top:n,behavior:e})}scrollToKey(t,e="smooth"){const i=this.data.findIndex(n=>n[this.keyField]===t);i!==-1&&this.scrollTo(i,e)}scrollToTop(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[e?"left":"top"]:0,behavior:t})}scrollToBottom(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal"),i=this.getTotalSize(),n=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:i-n,behavior:t})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((t,e)=>({item:t,index:this.startIndex+e,key:t[this.keyField]||this.startIndex+e}))}getItemIndex(t){return this.data.findIndex(e=>e[this.keyField]===t)}getItem(t){const e=this.getItemIndex(t);return e!==-1?this.data[e]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this._listeners=null,this._scrollHandler=null,this._thumbDragStartHandler=null,this._thumbDragMoveHandler=null,this._thumbDragEndHandler=null,this._wheelHandler=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function _t(s=1e3){const t=[],e=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let i=1;i<=s;i++){const n=Math.floor(Math.random()*e.length),r=Math.floor(Math.random()*1e4);t.push({id:i,title:`${e[n]} ${r}`,subtitle:`Last modified ${Math.floor(Math.random()*30)} days ago`,type:e[n].toLowerCase()})}return t}function Ss(s,t={}){const e=document.querySelector(s);if(e){const i=t.data||_t(t.count||1e3);return new Dt(e,{data:i,...t})}return null}function yt(s){if(s.__kupolaInitialized)return;const t=s.getAttribute("data-virtual-list");let e=[];if(t)try{e=JSON.parse(t)}catch{e=_t(1e3)}else e=_t(1e3);const i=new Dt(s,{data:e,onItemClick:n=>{},onItemSelect:n=>{}});s.__kupolaInstance=i,s.__kupolaInitialized=!0}function Wt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Ls(){document.querySelectorAll(".ds-virtual-list").forEach(s=>{yt(s)})}typeof window<"u"&&(window.VirtualList=Dt,window.initVirtualList=yt,window.cleanupVirtualList=Wt,window.initVirtualLists=Ls,window.createVirtualList=Ss,window.generateMockVirtualListData=_t,window.kupolaInitializer&&window.kupolaInitializer.register("virtual-list",yt,Wt));const Ds='xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter"',ye={globe:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 0 20"/><path d="M12 2a15.3 15.3 0 0 0 0 20"/>',dashboard:'<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>',mouse:'<rect x="6" y="2" width="12" height="20" rx="6"/><line x1="12" y1="6" x2="12" y2="11"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',square:'<rect x="3" y="3" width="18" height="18"/>',circle:'<circle cx="12" cy="12" r="9"/>',list:'<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',palette:'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',type:'<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',ruler:'<rect x="3" y="9" width="18" height="6" transform="rotate(-45 12 12)"/><line x1="7.5" y1="12.5" x2="9" y2="14"/><line x1="11" y1="9" x2="12.5" y2="10.5"/><line x1="14.5" y1="5.5" x2="16" y2="7"/>',sparkles:'<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',refresh:'<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',external:'<polyline points="14 4 20 4 20 10"/><line x1="20" y1="4" x2="11" y2="13"/><path d="M20 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5"/>',settings:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',sliders:'<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',minus:'<line x1="5" y1="12" x2="19" y2="12"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',github:'<path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/>',"message-circle":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/>',"message-plus":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/><line x1="12" y1="9" x2="12" y2="15"/><line x1="9" y1="12" x2="15" y2="12"/>',gear:'<path d="M9.3 5.7 6.375 5.025 5.025 6.375 5.7 9.3 3 11.1 3 12.9 5.7 14.7 5.025 17.625 6.375 18.975 9.3 18.3 11.1 21 12.9 21 14.7 18.3 17.625 18.975 18.975 17.625 18.3 14.7 21 12.9 21 11.1 18.3 9.3 18.975 6.375 17.625 5.025 14.7 5.7 12.9 3 11.1 3 9.3 5.7Z"/><circle cx="12" cy="12" r="3"/>',"user-circle":'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="2.5"/><path d="M7 17.5a5 5 0 0 1 10 0"/>',shield:'<path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/>',check:'<polyline points="4 12 10 18 20 6"/>',"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"alert-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',"alert-triangle":'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',"info-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"x-circle":'<circle cx="12" cy="12" r="9"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/>',alert:'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',info:'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>',user:'<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',users:'<path d="M2 21v-1a5 5 0 0 1 5-5h3a5 5 0 0 1 5 5v1"/><circle cx="8.5" cy="8" r="3.5"/><path d="M22 21v-1a5 5 0 0 0-4-4.9"/><path d="M16 3.1A4 4 0 0 1 16 11"/>',box:'<polyline points="3 7 12 2 21 7 21 17 12 22 3 17 3 7"/><line x1="3" y1="7" x2="12" y2="12"/><line x1="21" y1="7" x2="12" y2="12"/><line x1="12" y1="22" x2="12" y2="12"/>',zap:'<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',moon:'<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',sun:'<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',cmd:'<path d="M9 6h6v12H9z"/><rect x="3" y="3" width="6" height="6"/><rect x="15" y="3" width="6" height="6"/><rect x="3" y="15" width="6" height="6"/><rect x="15" y="15" width="6" height="6"/>',key:'<circle cx="7.5" cy="14.5" r="3.5"/><line x1="10" y1="12" x2="22" y2="12"/><line x1="22" y1="12" x2="22" y2="16"/><line x1="18" y1="12" x2="18" y2="15"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',mic:'<rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/>',at:'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',hash:'<line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/>',"sidebar-left":'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/>',"sidebar-right":'<rect x="3" y="3" width="18" height="18"/><line x1="15" y1="3" x2="15" y2="21"/>',"panel-bottom":'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="15" x2="21" y2="15"/>',git:'<circle cx="6" cy="5" r="3"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><line x1="6" y1="8" x2="6" y2="16"/><path d="M18 8v3a4 4 0 0 1-4 4h-4"/>',bug:'<rect x="8" y="6" width="8" height="14" rx="4"/><line x1="12" y1="11" x2="12" y2="20"/><line x1="3" y1="9" x2="8" y2="9"/><line x1="3" y1="14" x2="8" y2="14"/><line x1="3" y1="19" x2="8" y2="19"/><line x1="16" y1="9" x2="21" y2="9"/><line x1="16" y1="14" x2="21" y2="14"/><line x1="16" y1="19" x2="21" y2="19"/><line x1="9" y1="6" x2="9" y2="3"/><line x1="15" y1="6" x2="15" y2="3"/>',"search-menu":'<circle cx="11" cy="11" r="6"/><line x1="20" y1="20" x2="16" y2="16"/><line x1="3" y1="20" x2="13" y2="20"/>',extensions:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M17.5 14v3.5H21a2 2 0 0 1 0 4h-3.5V21a2 2 0 0 1-4 0v-3.5H14a2 2 0 0 1 0-4h3.5z"/>',wrench:'<path d="M14.7 6.3a4 4 0 0 0 5 5L21 12.5l-7.5 7.5a3 3 0 0 1-4.2-4.2L16.7 8 14.7 6.3z"/><path d="M14.7 6.3 12 9l-3-3 2.7-2.7a4 4 0 0 1 3 3z"/>',"message-square":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',"file-text":'<path d="M14 3H6v18h12V8z"/><polyline points="14 3 14 8 18 8"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="15" y2="17"/>',"scroll-text":'<path d="M5 4h11a3 3 0 0 1 3 3v10H8v3a1 1 0 0 1-1 1 3 3 0 0 1-3-3V7a3 3 0 0 1 1-3z"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/>',atom:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',"arrow-right-to-line":'<line x1="20" y1="4" x2="20" y2="20"/><line x1="3" y1="12" x2="17" y2="12"/><polyline points="11 6 17 12 11 18"/>',"info-square":'<rect x="3" y="3" width="18" height="18"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"arrow-minimize":'<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',"arrow-expand":'<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',logo:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',"more-h":'<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',edit:'<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',trash:'<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',file:'<path d="M14 3H6v18h12V7z"/><polyline points="14 3 14 7 18 7"/>',files:'<path d="M21 8v13H8V3h8z"/><polyline points="16 3 16 8 21 8"/><path d="M8 7H3v14h13v-3"/>',"grid-2x2":'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',layout:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',image:'<rect x="3" y="3" width="18" height="18"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><polyline points="3 18 9 12 13 16 17 12 21 16"/>',play:'<polygon points="6 4 20 12 6 20 6 4"/>',pause:'<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',help:'<rect x="3" y="3" width="18" height="18"/><path d="M9 9a3 3 0 0 1 6 0c0 2-3 2-3 4"/><line x1="12" y1="17" x2="12" y2="17.01"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',eye:'<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/>',star:'<polygon points="12 3 15 9 22 10 17 14 18 21 12 18 6 21 7 14 2 10 9 9 12 3"/>',heart:'<path d="M12 21s-7-5-7-11a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 6-7 11-7 11z"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',calendar:'<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',clock:'<circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 16 14"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',send:'<polygon points="3 12 21 4 17 21 12 13 3 12"/>',link:'<path d="M10 14a4 4 0 0 1 0-6l3-3a4 4 0 0 1 6 6l-1.5 1.5"/><path d="M14 10a4 4 0 0 1 0 6l-3 3a4 4 0 0 1-6-6l1.5-1.5"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',"log-out":'<path d="M14 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9"/><polyline points="16 16 21 12 16 8"/><line x1="9" y1="12" x2="21" y2="12"/>',menu:'<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',dollar:'<line x1="12" y1="2" x2="12" y2="22"/><path d="M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',bar:'<line x1="3" y1="21" x2="21" y2="21"/><rect x="5" y="11" width="3" height="8"/><rect x="10.5" y="6" width="3" height="13"/><rect x="16" y="14" width="3" height="5"/>',"trending-up":'<polyline points="3 17 9 11 13 15 21 7"/><polyline points="15 7 21 7 21 13"/>',"trending-down":'<polyline points="3 7 9 13 13 9 21 17"/><polyline points="15 17 21 17 21 11"/>',columns:'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M7 8h10v4a5 5 0 0 1-10 0V8z"/><path d="M12 17v5"/>',cpu:'<rect x="6" y="6" width="12" height="12"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="2" x2="9" y2="6"/><line x1="15" y1="2" x2="15" y2="6"/><line x1="9" y1="18" x2="9" y2="22"/><line x1="15" y1="18" x2="15" y2="22"/><line x1="2" y1="9" x2="6" y2="9"/><line x1="2" y1="15" x2="6" y2="15"/><line x1="18" y1="9" x2="22" y2="9"/><line x1="18" y1="15" x2="22" y2="15"/>',code:'<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',apple:'<path fill="currentColor" stroke="none" d="M17.05 12.04c-.03-3.04 2.49-4.5 2.6-4.57-1.42-2.07-3.62-2.36-4.4-2.39-1.87-.19-3.65 1.1-4.6 1.1-.96 0-2.42-1.08-3.98-1.05-2.05.03-3.94 1.19-4.99 3.02-2.13 3.69-.54 9.13 1.53 12.12 1.01 1.46 2.21 3.1 3.78 3.04 1.52-.06 2.09-.98 3.93-.98 1.83 0 2.36.98 3.97.95 1.64-.03 2.68-1.49 3.68-2.96 1.16-1.7 1.64-3.35 1.66-3.43-.04-.02-3.18-1.22-3.21-4.85zM14.06 4.34c.83-1.01 1.39-2.41 1.24-3.81-1.2.05-2.65.8-3.51 1.8-.77.89-1.45 2.31-1.27 3.68 1.34.1 2.71-.68 3.54-1.67z"/>'};function ve(s,t=16,e="0 0 24 24"){const i=ye[s];return i?`<svg ${Ds.replace('width="16"',`width="${t}"`).replace('height="16"',`height="${t}"`).replace('viewBox="0 0 24 24"',`viewBox="${e}"`)}>${i}</svg>`:""}function vt(s=document){s.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),i=+t.getAttribute("data-size")||16,n=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=ve(e,i,n),t.classList.add("icon")})}const qi={svg:ve,render:vt,PATHS:ye};typeof window<"u"&&(window.Icons=qi,document.readyState!=="loading"?vt():document.addEventListener("DOMContentLoaded",()=>vt()));class we{constructor(t){this.element=t,this.hoursEl=t.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=t.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=t.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const t=this.element.getAttribute("data-end-time");if(t)return new Date(t).getTime();const e=parseInt(this.element.getAttribute("data-hours"))||0,i=parseInt(this.element.getAttribute("data-minutes"))||0,n=parseInt(this.element.getAttribute("data-seconds"))||0;return new Date().getTime()+(e*3600+i*60+n)*1e3}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const t=new Date().getTime(),e=this.endTime-t;if(e<=0){this.stop(),this.displayTime(0,0,0),this.dispatchComplete();return}const i=Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),n=Math.floor(e%(1e3*60*60)/(1e3*60)),r=Math.floor(e%(1e3*60)/1e3);this.displayTime(i,n,r)}displayTime(t,e,i){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(e).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(i).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=t*1e3,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("kupola:countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function wt(s){if(s.__kupolaInitialized)return;const t=new we(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function Ut(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Bi(){document.querySelectorAll(".ds-countdown").forEach(t=>{wt(t)})}typeof window<"u"&&(window.Countdown=we,window.initCountdown=wt,window.cleanupCountdown=Ut,window.initCountdowns=Bi,window.kupolaInitializer&&window.kupolaInitializer.register("countdown",wt,Ut));class be{constructor(t){if(this.element=t,this.minusBtn=t.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=t.querySelector(".ds-number-input__btn--increase"),this.inputEl=t.querySelector(".ds-number-input__input"),this._listeners=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const t=()=>this.updateValue(-this.step),e=()=>this.updateValue(this.step),i=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",i),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:i})}updateValue(t){let e=parseInt(this.inputEl.value)||0;e+=t,e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let t=parseInt(this.inputEl.value);isNaN(t)&&(t=0),t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}updateState(){const t=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=t<=this.min,this.plusBtn.disabled=t>=this.max}setValue(t){t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(t,e){this.min=t,this.max=e,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function bt(s){if(!s.__kupolaInitialized)try{const t=new be(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function Yt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Fi(){document.querySelectorAll(".ds-number-input").forEach(s=>{bt(s)})}typeof window<"u"&&(window.NumberInput=be,window.initNumberInput=bt,window.cleanupNumberInput=Yt,window.initNumberInputs=Fi,window.kupolaInitializer&&window.kupolaInitializer.register("number-input",bt,Yt));class ke{constructor(t){this.container=t,this.track=t.querySelector(".ds-slider-captcha__track"),this.btn=t.querySelector(".ds-slider-captcha__btn"),this.text=t.querySelector(".ds-slider-captcha__text"),this.progress=t.querySelector(".ds-slider-captcha__progress"),this.statusEl=t.querySelector(".ds-slider-captcha__status"),this.refreshBtn=t.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=t.querySelector(".ds-slider-captcha__footer-refresh"),this.config={tolerance:6,minPoints:20,minDuration:300,maxDuration:1e4,minSpeedDelta:.3,maxAttempts:5},this.isDragging=!1,this.startX=0,this.startY=0,this.currentX=0,this.trackData=[],this.startTime=0,this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.targetX=0,this.distractorX=0,this.angle=0,this.distractorAngle=0,this.maxAngle=parseInt(t.getAttribute("data-angle"))||30,this.shape=t.getAttribute("data-shape")||"circle",this.hasDistractor=this.shape!=="circle",this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this._mouseDownHandler=null,this._mouseMoveHandler=null,this._mouseUpHandler=null,this._touchStartHandler=null,this._touchMoveHandler=null,this._touchEndHandler=null,this._mouseMoveListener=null,this._mouseUpListener=null,this._touchMoveListener=null,this._touchEndListener=null}init(){!this.track||!this.btn||this.container._initialized||(this._mouseDownHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.clientX,this.startY=t.clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._mouseMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,i=this.btn.offsetWidth,n=e-i-8;let r=t.clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.clientX,t.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._touchMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth,i=this.btn.offsetWidth,n=e-i-8;let r=t.touches[0].clientX-this.startX;r<0&&(r=0),r>n&&(r=n),this.currentX=r,this.btn.style.left=14+r+"px",this.progress&&(this.progress.style.width=r/n*100+"%"),this.collectTrack(t.touches[0].clientX,t.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),window.globalEvents?(this._mouseMoveListener=window.globalEvents.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=window.globalEvents.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=window.globalEvents.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=window.globalEvents.on(document,"touchend",this._touchEndHandler,{scope:this.scope})):(document.addEventListener("mousemove",this._mouseMoveHandler),document.addEventListener("mouseup",this._mouseUpHandler),document.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),document.addEventListener("touchend",this._touchEndHandler)),this.btn.addEventListener("touchstart",this._touchStartHandler,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container._initialized=!0,this.loadCaptcha())}generateTarget(){const t=this.track.offsetWidth,e=this.btn.offsetWidth,i=14,n=t*.35,r=t*.85-e,a=t*.6;if(this.angle=Math.floor(Math.random()*(this.maxAngle+1)),this.hasDistractor)do this.distractorAngle=Math.floor(Math.random()*(this.maxAngle+1));while(Math.abs(this.distractorAngle-this.angle)<5);this.hasDistractor?Math.random()>.5?(this.targetX=Math.floor(n+Math.random()*(a-n-e)),this.distractorX=Math.floor(a+Math.random()*(r-a))):(this.targetX=Math.floor(a+Math.random()*(r-a)),this.distractorX=Math.floor(n+Math.random()*(a-n-e))):this.targetX=Math.floor(n+Math.random()*(r-n));const o=this.container.querySelector(".ds-slider-captcha__target");if(o&&(o.style.left=this.targetX+i+e/2+"px",o.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",o.style.display="block"),this.hasDistractor){const l=this.container.querySelector(".ds-slider-captcha__target--distractor");l&&(l.style.left=this.distractorX+i+e/2+"px",l.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",l.style.display="block")}else{const l=this.container.querySelector(".ds-slider-captcha__target--distractor");l&&(l.style.display="none")}}resetSlider(){this.btn.className="ds-slider-captcha__btn",this.btn.style.transform="rotate("+this.angle+"deg)",this.btn.innerHTML="",this.btn.style.left="14px",this.btn.style.display="block",this.progress&&(this.progress.style.width="0%",this.progress.style.display="block"),this.text&&(this.text.textContent="按住滑块,拖动到缺口位置",this.text.style.color=""),this.refreshBtn&&(this.refreshBtn.style.display="none"),this.currentX=0,this.trackData=[],this.container.classList.remove("is-verified","is-error","is-disabled")}loadCaptcha(){this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.generateTarget(),this.resetSlider(),this.statusEl&&(this.statusEl.textContent="请完成验证",this.statusEl.className="ds-slider-captcha__status")}collectTrack(t,e){const n=Date.now()-this.startTime;let r=0,a=0;if(this.trackData.length>0){const l=this.trackData[this.trackData.length-1],c=this.currentX-l.x,d=n-l.t;if(d>0&&(r=c/d,this.trackData.length>1)){const h=this.trackData[this.trackData.length-2],u=l.t-h.t;if(u>0){const f=(l.x-h.x)/u;a=r-f}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:n,v:r,a});const o=this.container.querySelector(".ds-slider-captcha__point-count");o&&(o.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const t=this.trackData[this.trackData.length-1].x,e=this.hasDistractor?Math.abs(t-this.distractorX):1/0,i=Math.abs(t-this.targetX);if(this.hasDistractor&&e<i&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(i>this.config.tolerance)return{passed:!1,msg:"验证失败"};const n=[];for(let d=1;d<this.trackData.length;d++){const h=this.trackData[d].x-this.trackData[d-1].x,u=this.trackData[d].t-this.trackData[d-1].t;u>0&&u<500&&n.push(h/u)}if(n.length<3)return{passed:!1,msg:"验证失败"};const r=Math.max(...n),a=Math.min(...n);if(r-a<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let o=!1;for(const d of this.trackData)if(Math.abs(d.y)>2){o=!0;break}if(!o&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const l=this.trackData[this.trackData.length-1].t;if(l<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(l>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const c=[];for(let d=1;d<n.length;d++)c.push(Math.abs(n[d]-n[d-1]));return c.length>2&&c.reduce((h,u)=>h+u,0)/c.length<.05?{passed:!1,msg:"验证失败"}:{passed:!0,msg:"验证通过"}}verifyCaptcha(){this.isProcessing||this.isVerified||(this.isProcessing=!0,this.statusEl&&(this.statusEl.textContent="验证中...",this.statusEl.className="ds-slider-captcha__status is-loading"),this.btn.style.cursor="wait",this.container.classList.add("is-disabled"),setTimeout(()=>{const t=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",t.passed){this.isVerified=!0,this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const e=this.container.querySelector(".ds-slider-captcha__target");e&&(e.style.display="none");const i=this.container.querySelector(".ds-slider-captcha__target--distractor");i&&(i.style.display="none"),this.text&&(this.text.textContent="验证通过",this.text.style.color="var(--status-success-default)"),this.statusEl&&(this.statusEl.textContent="验证成功",this.statusEl.className="ds-slider-captcha__status is-success"),this.container.classList.add("is-verified"),this.container.classList.remove("is-disabled");const n=this.container.getAttribute("data-on-verified");n&&typeof window[n]=="function"&&window[n](this.container)}else if(this.attempts++,this.text&&(this.text.textContent=t.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=t.msg,this.statusEl.className="ds-slider-captcha__status is-error"),this.container.getAttribute("data-err-refresh")==="auto")setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const i=this.container.querySelector(".ds-slider-captcha__target");i&&(i.style.display="none");const n=this.container.querySelector(".ds-slider-captcha__target--distractor");n&&(n.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}},300))}destroy(){this.container._initialized&&(this.btn&&this._mouseDownHandler&&this.btn.removeEventListener("mousedown",this._mouseDownHandler),this.btn&&this._touchStartHandler&&this.btn.removeEventListener("touchstart",this._touchStartHandler),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this._mouseMoveListener&&this._mouseMoveListener.unsubscribe?this._mouseMoveListener.unsubscribe():this._mouseMoveHandler&&document.removeEventListener("mousemove",this._mouseMoveHandler),this._mouseUpListener&&this._mouseUpListener.unsubscribe?this._mouseUpListener.unsubscribe():this._mouseUpHandler&&document.removeEventListener("mouseup",this._mouseUpHandler),this._touchMoveListener&&this._touchMoveListener.unsubscribe?this._touchMoveListener.unsubscribe():this._touchMoveHandler&&document.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndListener&&this._touchEndListener.unsubscribe?this._touchEndListener.unsubscribe():this._touchEndHandler&&document.removeEventListener("touchend",this._touchEndHandler),this.container._initialized=!1)}}function Xt(){document.querySelectorAll(".ds-slider-captcha").forEach(s=>{const t=new ke(s);t.init(),s._kupolaSlideCaptcha=t})}function xe(s){s._kupolaSlideCaptcha&&(s._kupolaSlideCaptcha.destroy(),s._kupolaSlideCaptcha=null)}function Jt(){document.querySelectorAll(".ds-slider-captcha").forEach(s=>{xe(s)})}typeof window<"u"&&(window.SlideCaptcha=ke,window.initSlideCaptchas=Xt,window.cleanupSlideCaptcha=xe,window.cleanupAllSlideCaptchas=Jt,window.kupolaInitializer&&window.kupolaInitializer.register("slide-captcha",Xt,Jt));class Ee{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this._init()}_init(){this._setupValidators(),this._collectFields(),this._bindEvents()}_setupValidators(){this.validators={required:t=>typeof t=="string"?t.trim()!=="":Array.isArray(t)?t.length>0:t!=null,email:t=>t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t):!0,phone:t=>t?/^1[3-9]\d{9}$/.test(t):!0,url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>t?!isNaN(parseFloat(t))&&isFinite(t):!0,minlength:(t,e)=>t?t.length>=parseInt(e):!0,maxlength:(t,e)=>t?t.length<=parseInt(e):!0,min:(t,e)=>t?parseFloat(t)>=parseFloat(e):!0,max:(t,e)=>t?parseFloat(t)<=parseFloat(e):!0,pattern:(t,e)=>t?new RegExp(e).test(t):!0,equalTo:(t,e)=>{const i=document.getElementById(e);return i?t===i.value:!0}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}_collectFields(){this.form.querySelectorAll("input, select, textarea").forEach(e=>{e.hasAttribute("data-kupola-ignore")||this.fields.push(e)})}_bindEvents(){this.form.addEventListener("submit",t=>{this.validate()||t.preventDefault()}),this.fields.forEach(t=>{t.addEventListener("blur",()=>this.validateField(t)),t.addEventListener("input",()=>this.clearError(t))})}validate(){let t=!0;return this.fields.forEach(e=>{this.validateField(e)||(t=!1)}),t}validateField(t){const e=this._getFieldErrors(t);return e.length>0?(this.showError(t,e[0]),!1):(this.clearError(t),!0)}_getFieldErrors(t){const e=[],i=this._getFieldValue(t);for(const[n,r]of Object.entries(this.validators)){const a=t.getAttribute(`data-${n}`);if(a!==null&&!r(i,a)){let l=this.errorMessages[n];typeof l=="function"&&(l=l(a)),e.push(l)}}return e}_getFieldValue(t){const e=t.type;if(e==="checkbox")return t.checked;if(e==="radio"){const i=t.name,n=this.form.querySelector(`input[name="${i}"]:checked`);return n?n.value:null}return e==="select-multiple"?Array.from(t.selectedOptions).map(i=>i.value):t.value}showError(t,e){this.clearError(t);const i=document.createElement("span");i.className="ds-form-error",i.textContent=e,t.classList.add("ds-form-field--error");const n=t.parentElement;n.classList.contains("ds-form-field")?n.appendChild(i):t.parentNode.insertBefore(i,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const e=t.parentElement.querySelector(".ds-form-error");e&&e.remove()}addValidator(t,e,i){this.validators[t]=e,this.errorMessages[t]=i}getData(){const t={};return this.fields.forEach(e=>{const i=e.name;if(!i)return;const n=this._getFieldValue(e);e.type==="checkbox"?(t[i]||(t[i]=[]),e.checked&&t[i].push(e.value)):e.type==="radio"?!t[i]&&e.checked&&(t[i]=e.value):t[i]=n}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(n=>{const r=n.type;if(r==="checkbox"){const a=Array.isArray(t[e])?t[e]:[t[e]];n.checked=a.includes(n.value)}else if(r==="radio")n.checked=n.value===t[e];else if(r==="select-multiple"){const a=Array.isArray(t[e])?t[e]:[t[e]];Array.from(n.options).forEach(o=>{o.selected=a.includes(o.value)})}else n.value=t[e]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this.fields.forEach(t=>{t.removeEventListener("blur",()=>this.validateField(t)),t.removeEventListener("input",()=>this.clearError(t))}),this.form.removeEventListener("submit",()=>{}),this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function jt(s){const t=document.querySelectorAll(s||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const i=new Ee(e);e._kupolaForm=i}),t.length}function Ni(s){return s._kupolaForm}function Oi(s){const t=s._kupolaForm;return t?t.validate():!1}typeof window<"u"&&(window.KupolaForm=Ee,window.initFormValidation=jt,window.getFormInstance=Ni,window.validateForm=Oi,window.kupolaInitializer&&window.kupolaInitializer.register("form-validation",jt));class Ce{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,i,n={}){const{scope:r=null,once:a=!1,passive:o=!1,capture:l=!1}=n,c=this._generateId(),d={id:c,target:t,eventName:e,handler:i,scope:r,once:a,wrappedHandler:null};d.wrappedHandler=u=>{a&&this.offById(c),i.call(t,u)};const h=this._getEventKey(t,e);return this._listeners.has(h)||this._listeners.set(h,[]),this._listeners.get(h).push(d),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,d.wrappedHandler,{passive:o,capture:l}),{unsubscribe:()=>this.offById(c)}}once(t,e,i,n={}){return this.on(t,e,i,{...n,once:!0})}off(t,e,i){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(o=>o.handler!==i);r.forEach(o=>{o.handler===i&&(t.removeEventListener(e,o.wrappedHandler),this._removeFromScope(o))}),a.length===0?this._listeners.delete(n):this._listeners.set(n,a)}offById(t){for(const[e,i]of this._listeners){const n=i.findIndex(r=>r.id===t);if(n!==-1){const r=i[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),i.splice(n,1),i.length===0&&this._listeners.delete(e),this._removeFromScope(r),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(i=>{this.offById(i)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const i=this._getEventKey(t,e);if(!this._listeners.has(i))return;this._listeners.get(i).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(i)}else for(const[i,n]of this._listeners){const[r]=i.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(i))}}emit(t,e,i={}){const n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,i={}){if(!this._scopeListeners.has(t))return;const n=this._scopeListeners.get(t),r=new Set;for(const[a,o]of this._listeners)o.forEach(l=>{n.includes(l.id)&&r.add(l.target)});r.forEach(a=>{this.emit(a,e,i)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let i=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[o]=r.split(":");o===n&&(i+=a.length)}return i}getScopeListenerCount(t){return this._scopeListeners.has(t)?this._scopeListeners.get(t).length:0}hasListeners(t,e=null){return this.getListenerCount(t,e)>0}_getEventKey(t,e){return`${this._getTargetId(t)}:${e}`}_getTargetId(t){return t===document?"document":t===window?"window":t===document.body?"body":(t._kupolaId||(t._kupolaId=this._generateId()),t._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(t){if(!t.scope||!this._scopeListeners.has(t.scope))return;const e=this._scopeListeners.get(t.scope),i=e.indexOf(t.id);i!==-1&&(e.splice(i,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(i=>{i.target.removeEventListener(i.eventName,i.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const T=new Ce;function Ri(s,t,e,i){return T.on(s,t,e,i)}function Vi(s,t,e,i){return T.once(s,t,e,i)}function Ki(s,t,e){T.off(s,t,e)}function Wi(s,t,e){return T.emit(s,t,e)}function Ui(s,t){return T.emitGlobal(s,t)}function Yi(s){T.offByScope(s)}function Xi(s,t){T.offAll(s,t)}function Ji(s,t){return T.getListenerCount(s,t)}typeof window<"u"&&(window.GlobalEvents=Ce,window.globalEvents=T,window.kupolaOn=Ri,window.kupolaOnce=Vi,window.kupolaOff=Ki,window.kupolaEmit=Wi,window.kupolaEmitGlobal=Ui,window.kupolaOffByScope=Yi,window.kupolaOffAll=Xi,window.kupolaGetListenerCount=Ji);class Se{constructor(){this._queue=new Set,this._scheduled=!1}schedule(t){this._queue.add(t),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){const t=Array.from(this._queue);this._queue.clear(),this._scheduled=!1;const e=new Set;for(const i of t)if(!e.has(i)){e.add(i);try{i()}catch(n){console.error("[DependsScheduler]",n)}}}}const Ms=new Se;class ji{constructor(t,e){this.data=t,this.createdAt=Date.now(),this.ttl=e}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class Mt{constructor(){this._store=new Map}get(t){const e=this._store.get(t);return e||null}set(t,e,i=6e4){this._store.set(t,new ji(e,i))}has(t){return this._store.has(t)}delete(t){this._store.delete(t)}clear(){this._store.clear()}getStale(t){const e=this._store.get(t);return e?e.data:null}}class A extends Error{constructor(t,e,i){super(t),this.name="DependsError",this.code=e,this.cause=i,this.timestamp=Date.now()}}let Ht=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null;function Gi(s){if(!s||typeof s.fetch!="function")throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");Ht=s.fetch.bind(s)}function Zi(){return Ht}function Qi(){Ht=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null}class B{constructor(t,e){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=e,this.subscribers=[],this.pending=null,this.retryCount=t.retry??0,this.retryDelay=t.retryDelay??1e3,this.onError=t.onError||null}subscribe(t){return this.subscribers.push(t),()=>{const e=this.subscribers.indexOf(t);e>-1&&this.subscribers.splice(e,1)}}notify(){Ms.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(t){throw new A("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const e=this.cache.get(this.cacheKey);return e&&e.isFresh?e.data:e&&e.isStale?(this._revalidate(t),e.data):this._fetchWithRetry(t)}async _fetchWithRetry(t,e=0){try{const i=await this.fetch(t);return this.cache.set(this.cacheKey,i,this.staleTime),this.notify(),i}catch(i){if(e<this.retryCount){const r=this.retryDelay*Math.pow(2,e);return await new Promise(a=>setTimeout(a,r)),this._fetchWithRetry(t,e+1)}const n=i instanceof A?i:new A(i.message||"Fetch failed","FETCH_ERROR",i);if(this.onError)try{this.onError(n)}catch{}throw n}}async _revalidate(t){try{await this._fetchWithRetry(t)}catch{}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class ts extends B{constructor(t,e){super(t,e),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let e=this.config.source;for(const d in t)e=e.replace(`:${d}`,encodeURIComponent(t[d]));const i=[];for(const[d,h]of Object.entries(this.queryParams||{}))i.push(`${encodeURIComponent(d)}=${encodeURIComponent(h)}`);for(const d in t)this.config.source.includes(`:${d}`)||i.push(`${encodeURIComponent(d)}=${encodeURIComponent(t[d])}`);i.length>0&&(e+=(e.includes("?")?"&":"?")+i.join("&"));const n={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...this.headers}};["POST","PUT","PATCH"].includes(n.method)&&(n.body=JSON.stringify(t));const r=Ht;if(!r)throw new A("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const a=await r(e,n),o=typeof a.ok=="boolean"?a.ok:a.status>=200&&a.status<300,l=typeof a.status=="number"?a.status:0;if(!o)throw new A(`HTTP ${l}`,"HTTP_ERROR");return typeof a.json=="function"?await a.json():a.data!==void 0?a.data:a}}class Le extends B{constructor(t,e){super(t,e),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=t.sync!==!1,this.sync&&typeof window<"u"&&(this._storageHandler=i=>{i.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(t===null)return this.defaultValue;try{return JSON.parse(t)}catch{return t}}catch{return this.defaultValue}}setValue(t){const e=typeof t=="string"?t:JSON.stringify(t);localStorage.setItem(this.storageKey,e),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class es extends B{constructor(t,e){super(t,e),this.paramName=t.source.replace("route:","")}async fetch(){if(typeof window>"u")return"";const e=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));return e?decodeURIComponent(e[1]):new URLSearchParams(location.search).get(this.paramName)||""}}class is extends B{async fetch(t){return await this.config.source(t)}}class ss extends B{async fetch(){return this.config.source}}class De extends B{constructor(t,e){super(t,e),this.ws=null,this.reconnect=t.reconnect!==!1,this.reconnectDelay=t.reconnectDelay||3e3,this.messageHandler=null,this._connected=!1}async fetch(){return new Promise((t,e)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=i=>{let n;try{n=JSON.parse(i.data)}catch{n=i.data}this.cache.set(this.cacheKey,n,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=i=>{this._connected||e(new A("WebSocket connection failed","WS_ERROR",i))},this.ws.onclose=()=>{this._connected=!1,this.reconnect&&setTimeout(()=>{this.fetch().catch(()=>{})},this.reconnectDelay)}}catch(i){e(new A("WebSocket creation failed","WS_ERROR",i))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(typeof t=="string"?t:JSON.stringify(t))}destroy(){super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function Me(s,t){const e=s.source;return typeof e=="function"?new is(s,t):typeof e=="string"&&(e.startsWith("ws://")||e.startsWith("wss://"))?new De(s,t):typeof e=="string"&&(e.startsWith("/")||e.startsWith("http"))?new ts(s,t):typeof e=="string"&&e.startsWith("localStorage:")?new Le(s,t):typeof e=="string"&&e.startsWith("route:")?new es(s,t):new ss(s,t)}function ns(s,t){const e={},i=new Mt,n=[];for(const r in t){let p=function(){return Pe(s)},a=t[r];typeof a=="string"&&(a={source:a});const o={...a,cacheKey:a.cacheKey||`${r}-${JSON.stringify(Pe(s))}`},l=Me(o,i),c=L(null),d=L(!0),h=L(null),u=L(null);let f=0;async function m(){const b=++f;d.value=!0,h.value=null;try{const v=await l.getValue(p());if(b!==f)return;c.value=v,u.value=Date.now()}catch(v){if(b!==f)return;h.value=v.message||"Unknown error"}finally{b===f&&(d.value=!1)}}m();const y=l.subscribe(()=>{const b=i.getStale(l.cacheKey);b!=null&&(c.value=b,u.value=Date.now())});n.push(y);const _=Object.keys(s);_.length>0&&_.forEach(b=>{const v=s[b];if(v&&typeof v=="object"&&"value"in v&&v._subscribers){const w=()=>{l.invalidate(),m()};v._subscribers.add(w),n.push(()=>v._subscribers.delete(w))}}),e[r]={data:c,loading:d,error:h,lastUpdated:u,refresh(){return l.invalidate(),m()},setValue(b){l instanceof Le&&(l.setValue(b),c.value=b)},send(b){l instanceof De&&l.send(b)},_source:l}}return e._dispose=()=>{if(n.forEach(r=>r()),window.__kupolaDepInstances){const r=window.__kupolaDepInstances.indexOf(e);r!==-1&&window.__kupolaDepInstances.splice(r,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(e),e}function rs(s){const t=new Mt,e=Me(s,t),i=L(null),n=L(!0),r=L(null);let a=0;async function o(){const l=++a;n.value=!0,r.value=null;try{const c=await e.getValue(s.params||{});if(l!==a)return;i.value=c}catch(c){if(l!==a)return;r.value=c.message||"Unknown error"}finally{l===a&&(n.value=!1)}}return o(),e.subscribe(()=>{const l=t.getStale(e.cacheKey);l!=null&&(i.value=l)}),{data:i,loading:n,error:r,refresh(){return e.invalidate(),o()}}}function Pe(s){const t={};for(const e in s){const i=s[e];i&&typeof i=="object"&&"value"in i?t[e]=i.value:t[e]=i}return t}function as(){}typeof window<"u"&&(window.useDeps=ns,window.useQuery=rs,window.clearCache=as,window.DependsError=A,window.CacheManager=Mt,window.Scheduler=Se,window.configureHttpClient=Gi,window.getHttpClient=Zi,window.resetHttpClient=Qi);class He{constructor(t,e={}){this.element=typeof t=="string"?document.querySelector(t):t,this.options=e,this.columns=(e.columns||[]).map((i,n)=>({...i,_index:n})),this.rowKey=e.rowKey||"id",this._data=[],this._loading=!1,this.striped=e.striped!==!1,this.bordered=e.bordered||!1,this.hoverable=e.hoverable!==!1,this.compact=e.compact||!1,this.emptyText=e.emptyText||"暂无数据",this.loadingText=e.loadingText||"加载中...",this.multiSort=e.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=e.pagination!==!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._pageSize=e.pageSize||10,this._currentPage=1,this._total=0,this.selection=e.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=e.selectionColumnTitle||"",this.expandable=e.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=e.expandColumnTitle||"",this.editable=e.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=e.resizable||!1,this.draggable=e.draggable||!1,this._dragState=null,this.tree=e.tree||null,this._treeExpandedKeys=new Set,e.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=e.virtualScroll||null,this._scrollContainer=null,this.mergeCells=e.mergeCells||null,this.onSort=e.onSort||null,this.onPageChange=e.onPageChange||null,this.onRowClick=e.onRowClick||null,this.onFilter=e.onFilter||null,this.onSelect=e.onSelect||null,this.onExpand=e.onExpand||null,this.onEditSave=e.onEditSave||null,this.onEditCancel=e.onEditCancel||null,this.onRowDragEnd=e.onRowDragEnd||null,this.onColumnResize=e.onColumnResize||null,this.sortKey=L(null),this.sortOrder=L(null),this.currentPage=L(1),this.filterText=L(""),this.selectedKeys=L([]),this._init()}_init(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&typeof t=="object"&&"value"in t?(this._data=Array.isArray(t.value)?t.value:[],t._subscribers?.add(e=>{this._data=Array.isArray(e)?e:[],this._total=this._data.length,this.render()})):Array.isArray(t)?this._data=t:this._data=[],this.tree&&this._treeExpandAll&&this._flattenForExpand(this._data),this._total=this._getFlatData(this._data).length,this.render()}setLoading(t){t&&typeof t=="object"&&"value"in t?(this._loading=t.value,t._subscribers?.add(e=>{this._loading=e,this.render()})):this._loading=!!t,this.render()}_flattenForExpand(t,e=0,i=null){const n=this.tree?.childrenKey||"children",r=[];for(const a of t){const o=a[this.rowKey];r.push({...a,_level:e,_parentKey:i,_hasChildren:!!(a[n]&&a[n].length)}),a[n]&&a[n].length&&r.push(...this._flattenForExpand(a[n],e+1,o))}return r}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const i=this.tree?.childrenKey||"children",n=[];for(const r of t){const a=r[this.rowKey];n.push({...r,_level:e,_hasChildren:!!(r[i]&&r[i].length)}),r[i]&&r[i].length&&this._treeExpandedKeys.has(a)&&n.push(...this._flattenVisible(r[i],e+1))}return n}getProcessedData(){let t=this.tree?[...this._data]:[...this._data];if(this._filterText){const n=this._filterText.toLowerCase();this.tree?t=this._filterTree(t,n):t=t.filter(r=>this.columns.some(a=>{const o=r[a.key];return o!=null&&String(o).toLowerCase().includes(n)}))}this._sorts.length>0&&(this.tree?t=this._sortTree(t):t=this._sortFlat(t));const e=this.tree?this._flattenVisible(t):t;this._total=e.length;let i=e;if(this._showPagination&&this._pageSize>0){const n=(this._currentPage-1)*this._pageSize;i=e.slice(n,n+this._pageSize)}return i}_filterTree(t,e){const i=this.tree?.childrenKey||"children";return t.reduce((n,r)=>{const a=r[i]?this._filterTree(r[i],e):[];return(this.columns.some(l=>{const c=r[l.key];return c!=null&&String(c).toLowerCase().includes(e)})||a.length>0)&&(n.push({...r,[i]:a}),a.length>0&&this._treeExpandedKeys.add(r[this.rowKey])),n},[])}_sortFlat(t){return[...t].sort((e,i)=>{for(const n of this._sorts){const r=this.columns.find(c=>c.key===n.key);let a=e[n.key],o=i[n.key],l=0;if(r?.sorter?l=r.sorter(a,o,n.order):a==null?l=1:o==null?l=-1:typeof a=="number"&&typeof o=="number"?l=n.order==="asc"?a-o:o-a:l=n.order==="asc"?String(a).localeCompare(String(o)):String(o).localeCompare(String(a)),l!==0)return l}return 0})}_sortTree(t){const e=this._sortFlat(t),i=this.tree?.childrenKey||"children";return e.map(n=>n[i]?.length?{...n,[i]:this._sortTree(n[i])}:n)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const i=document.createElement("div");i.className="kupola-table-container";const n=document.createElement("table");n.className=this._getTableClass(),n.appendChild(this._renderThead()),this.virtualScroll?n.appendChild(this._renderVirtualTbody(t)):n.appendChild(this._renderTbody(t)),i.appendChild(n),e.appendChild(i),this._showPagination&&this._total>0&&e.appendChild(this._renderPagination()),this.resizable&&this._initColumnResize(),this.draggable&&this._initRowDrag(),this._applyStickyColumns()}_renderThead(){const t=document.createElement("thead"),e=document.createElement("tr");if(this.selection){const i=document.createElement("th");if(i.className="kupola-table-col-selection",this.selection==="checkbox"){const n=document.createElement("input");n.type="checkbox";const a=this.getProcessedData().map(o=>o[this.rowKey]);n.checked=a.length>0&&a.every(o=>this._selectedKeys.has(o)),n.addEventListener("change",()=>n.checked?this.selectAll():this.deselectAll()),i.appendChild(n)}e.appendChild(i)}if(this.expandable){const i=document.createElement("th");i.className="kupola-table-col-expand",e.appendChild(i)}return this.columns.forEach(i=>{const n=document.createElement("th");if(n.textContent=i.title||i.key,i.width&&(n.style.width=typeof i.width=="number"?i.width+"px":i.width),i.minWidth&&(n.style.minWidth=typeof i.minWidth=="number"?i.minWidth+"px":i.minWidth),i.align&&(n.style.textAlign=i.align),i.fixed&&n.setAttribute("data-fixed",i.fixed),i.sortable){n.classList.add("kupola-table-sortable");const r=this._sorts.find(o=>o.key===i.key);r&&n.classList.add(`kupola-table-sort-${r.order}`),n.addEventListener("click",o=>{this.resizable&&o.target.classList.contains("kupola-table-resize-handle")||this._handleSort(i.key)});const a=document.createElement("span");a.className="kupola-table-sort-icon",r?a.textContent=this.multiSort?` ${this._sorts.indexOf(r)+1}${r.order==="asc"?"▲":"▼"}`:r.order==="asc"?" ▲":" ▼":a.textContent=" ⇅",n.appendChild(a)}if(this.resizable&&i.key!==this.columns[this.columns.length-1]?.key){const r=document.createElement("span");r.className="kupola-table-resize-handle",r.setAttribute("data-col-key",i.key),n.appendChild(r)}e.appendChild(n)}),t.appendChild(e),t}_renderTbody(t){const e=document.createElement("tbody");if(this._loading)e.appendChild(this._renderStatusRow(this.loadingText,"kupola-table-loading"));else if(t.length===0)e.appendChild(this._renderStatusRow(this.emptyText,"kupola-table-empty"));else{const i=this.mergeCells?this.mergeCells(t):[],n=new Map;i.forEach(a=>n.set(`${a.row}-${a.col}`,a));const r=new Set;t.forEach((a,o)=>{const l=a[this.rowKey]??o,c=this._selectedKeys.has(l),d=this._expandedKeys.has(l),h=this._renderDataRow(a,o,l,c,r,n);if(e.appendChild(h),this.expandable&&d){const u=document.createElement("tr");u.className="kupola-table-expand-row";const f=document.createElement("td"),p=this.columns.length+(this.selection?1:0)+1;f.colSpan=p,f.className="kupola-table-expand-content";const m=this.expandable(a);typeof m=="string"?f.innerHTML=m:m instanceof HTMLElement&&f.appendChild(m),u.appendChild(f),e.appendChild(u)}})}return e}_renderDataRow(t,e,i,n,r,a){const o=document.createElement("tr");if(o.setAttribute("data-row-key",i),n&&o.classList.add("kupola-table-row-selected"),this.draggable&&(o.draggable=!0,o.classList.add("kupola-table-draggable")),this.selection){const l=document.createElement("td");l.className="kupola-table-col-selection";const c=document.createElement("input");c.type=this.selection,c.checked=n,c.addEventListener("change",()=>{this.selection==="radio"?(this._selectedKeys.clear(),this._selectedKeys.add(i)):n?this._selectedKeys.delete(i):this._selectedKeys.add(i),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),l.appendChild(c),o.appendChild(l)}if(this.expandable){const l=document.createElement("td");l.className="kupola-table-col-expand";const c=document.createElement("button");c.className="kupola-table-expand-btn";const d=this._expandedKeys.has(i);c.textContent=d?"▼":"▶",c.type="button",c.addEventListener("click",()=>this._toggleExpand(i)),l.appendChild(c),o.appendChild(l)}return this.columns.forEach((l,c)=>{if(r.has(`${e}-${c}`))return;const d=document.createElement("td");l.align&&(d.style.textAlign=l.align),l.fixed&&(d.setAttribute("data-fixed",l.fixed),d.classList.add(`kupola-table-fixed-${l.fixed}`));const h=a.get(`${e}-${c}`);if(h){h.rowSpan>1&&(d.rowSpan=h.rowSpan),h.colSpan>1&&(d.colSpan=h.colSpan);for(let f=0;f<(h.rowSpan||1);f++)for(let p=0;p<(h.colSpan||1);p++)f===0&&p===0||r.add(`${e+f}-${c+p}`)}if(this.tree&&c===0&&t._level>0){const f=document.createElement("span");if(f.className="kupola-table-tree-indent",f.style.paddingLeft=t._level*20+"px",d.appendChild(f),t._hasChildren){const p=document.createElement("button");p.className="kupola-table-tree-toggle",p.textContent=this._treeExpandedKeys.has(t[this.rowKey])?"▼":"▶",p.type="button",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleTreeExpand(t[this.rowKey])}),d.appendChild(p)}else{const p=document.createElement("span");p.className="kupola-table-tree-toggle-placeholder",d.appendChild(p)}}const u=this._editingCell&&this._editingCell.rowKey===i&&this._editingCell.colKey===l.key;if(u)d.appendChild(this._renderEditCell(l,t));else if(l.render){const f=l.render(t[l.key],t,e);typeof f=="string"?d.innerHTML=f:f instanceof HTMLElement&&d.appendChild(f)}else d.textContent=t[l.key]??"";this.editable&&!u&&l.editable!==!1&&(d.classList.add("kupola-table-editable-cell"),d.addEventListener("dblclick",()=>this._startEdit(i,l.key,t[l.key]))),o.appendChild(d)}),this.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",l=>{l.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,l)})),o}_renderStatusRow(t,e){const i=document.createElement("tr"),n=document.createElement("td");return n.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),n.className=e,n.textContent=t,i.appendChild(n),i}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:i=40,overscan:n=5}=this.virtualScroll,r=t.length*i;if(this._loading)return this._renderTbody(t);if(t.length===0)return this._renderTbody(t);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",e.appendChild(a),this._virtualData={data:t,rowHeight:i,overscan:n,totalHeight:r,tbody:e,topSpacer:a},this._updateVirtualScroll();const o=document.createElement("tr");o.className="kupola-table-virtual-spacer-bottom",o.style.height="0px",e.appendChild(o);const l=this.element.querySelector(".kupola-table-container");return l&&(l.style.maxHeight=this.virtualScroll.maxHeight||"400px",l.style.overflowY="auto",l.addEventListener("scroll",()=>this._updateVirtualScroll())),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:i,tbody:n,topSpacer:r}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const o=a.scrollTop,l=a.clientHeight,c=Math.max(0,Math.floor(o/e)-i),d=Math.min(t.length,Math.ceil((o+l)/e)+i);n.querySelectorAll(".kupola-table-virtual-row").forEach(p=>p.remove());const u=document.createDocumentFragment();for(let p=c;p<d;p++){const m=t[p],y=m[this.rowKey]??p,_=this._renderDataRow(m,p,y,this._selectedKeys.has(y),new Set,new Map);_.classList.add("kupola-table-virtual-row"),_.style.height=e+"px",u.appendChild(_)}r.style.height=c*e+"px";const f=n.querySelector(".kupola-table-virtual-spacer-bottom");f&&(f.style.height=(t.length-d)*e+"px"),r.after(u)}_renderEditCell(t,e){const i=document.createElement("div");i.className="kupola-table-edit-cell";const n=document.createElement("input");if(n.type=t.editType||"text",n.className="ds-input kupola-table-edit-input",n.value=this._editBuffer[t.key]??e[t.key]??"",t.editOptions){const l=document.createElement("select");l.className="ds-input kupola-table-edit-input",t.editOptions.forEach(c=>{const d=document.createElement("option");d.value=typeof c=="object"?c.value:c,d.textContent=typeof c=="object"?c.label:c,String(d.value)===String(n.value)&&(d.selected=!0),l.appendChild(d)}),l.addEventListener("change",()=>{this._editBuffer[t.key]=l.value}),i.appendChild(l)}else n.addEventListener("input",()=>{this._editBuffer[t.key]=n.value}),i.appendChild(n);const r=document.createElement("div");r.className="kupola-table-edit-actions";const a=document.createElement("button");a.className="kupola-table-edit-save",a.textContent="✓",a.type="button",a.addEventListener("click",()=>this._saveEdit(e,t));const o=document.createElement("button");return o.className="kupola-table-edit-cancel",o.textContent="✗",o.type="button",o.addEventListener("click",()=>this._cancelEdit()),r.appendChild(a),r.appendChild(o),i.appendChild(r),n.addEventListener("keydown",l=>{l.key==="Enter"&&this._saveEdit(e,t),l.key==="Escape"&&this._cancelEdit()}),setTimeout(()=>n.focus?.(),0),i}_startEdit(t,e,i){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:i},this.render()}_saveEdit(t,e){const i=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,i,this._data):t[e.key]=i,this._editingCell=null,this._editBuffer={},this.render()}_cancelEdit(){this.onEditCancel&&this.onEditCancel(this._editingCell),this._editingCell=null,this._editBuffer={},this.render()}_handleSort(t){if(this.multiSort){const e=this._sorts.findIndex(i=>i.key===t);if(e>=0){const i=this._sorts[e];i.order==="asc"?i.order="desc":this._sorts.splice(e,1)}else this._sorts.push({key:t,order:"asc"})}else{const e=this._sorts.find(i=>i.key===t);e?e.order==="asc"?e.order="desc":this._sorts=[]:this._sorts=[{key:t,order:"asc"}]}this.sortKey.value=this._sorts.map(e=>e.key).join(","),this.sortOrder.value=this._sorts.map(e=>e.order).join(","),this._currentPage=1,this.onSort&&this.onSort(this._sorts),this.render()}_toggleExpand(t){this._expandedKeys.has(t)?this._expandedKeys.delete(t):this._expandedKeys.add(t),this.onExpand&&this.onExpand(t,this._expandedKeys.has(t)),this.render()}_toggleTreeExpand(t){this._treeExpandedKeys.has(t)?this._treeExpandedKeys.delete(t):this._treeExpandedKeys.add(t),this.render()}selectRow(t){this._selectedKeys.add(t),this._syncSelected(),this.render()}deselectRow(t){this._selectedKeys.delete(t),this._syncSelected(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this._selectedKeys.add(t[this.rowKey])),this._syncSelected(),this.render()}deselectAll(){this._selectedKeys.clear(),this._syncSelected(),this.render()}invertSelection(){this.getProcessedData().forEach(e=>{const i=e[this.rowKey];this._selectedKeys.has(i)?this._selectedKeys.delete(i):this._selectedKeys.add(i)}),this._syncSelected(),this.render()}getSelectedKeys(){return[...this._selectedKeys]}getSelectedRows(){return(this.tree?this._flattenForExpand(this._data):this._data).filter(e=>this._selectedKeys.has(e[this.rowKey]))}_syncSelected(){this.selectedKeys.value=[...this._selectedKeys]}_initColumnResize(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(e=>{e.addEventListener("mousedown",i=>{i.preventDefault();const n=e.getAttribute("data-col-key"),r=e.parentElement,a=i.clientX,o=r.offsetWidth,l=d=>{const h=Math.max(50,o+(d.clientX-a));r.style.width=h+"px";const u=this.columns.find(f=>f.key===n);u&&(u.width=h),this.onColumnResize&&this.onColumnResize(n,h)},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)})})}_initRowDrag(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(e=>{e.addEventListener("dragstart",i=>{this._dragState={fromKey:e.getAttribute("data-row-key")},e.classList.add("kupola-table-dragging"),i.dataTransfer.effectAllowed="move"}),e.addEventListener("dragover",i=>{i.preventDefault(),i.dataTransfer.dropEffect="move",e.classList.add("kupola-table-drag-over")}),e.addEventListener("dragleave",()=>e.classList.remove("kupola-table-drag-over")),e.addEventListener("drop",i=>{if(i.preventDefault(),e.classList.remove("kupola-table-drag-over"),!this._dragState)return;const n=e.getAttribute("data-row-key");if(this._dragState.fromKey===n)return;const r=this._data.findIndex(o=>String(o[this.rowKey])===this._dragState.fromKey),a=this._data.findIndex(o=>String(o[this.rowKey])===n);if(r>=0&&a>=0){const[o]=this._data.splice(r,1);this._data.splice(a,0,o),this.onRowDragEnd&&this.onRowDragEnd(o,r,a,this._data),this.render()}}),e.addEventListener("dragend",()=>{e.classList.remove("kupola-table-dragging"),this._dragState=null})})}_applyStickyColumns(){const t=this.columns.filter(n=>n.fixed==="left");this.selection,this.expandable,t.forEach(n=>{const r=this.element.querySelectorAll('th[data-fixed="left"]'),a=this.element.querySelectorAll('td[data-fixed="left"]'),o=this.columns.indexOf(n);let l=(this.selection?40:0)+(this.expandable?40:0);for(let c=0;c<o;c++)this.columns[c].fixed==="left"&&(l+=this.columns[c]._resolvedWidth||120);r.forEach(c=>{c.textContent.startsWith(n.title||n.key)&&(c.style.position="sticky",c.style.left=l+"px",c.style.zIndex="2",n._resolvedWidth=c.offsetWidth)}),a.forEach(c=>{c.style.position="sticky",c.style.left=l+"px",c.style.zIndex="1",c.style.background="inherit"})});let e=0;[...this.columns].filter(n=>n.fixed==="right").reverse().forEach(n=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(a=>{a.style.position="sticky",a.style.right=e+"px",a.style.zIndex="1"}),e+=n._resolvedWidth||n.width||120})}_renderToolbar(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const n=document.createElement("input");n.type="text",n.className="ds-input kupola-table-filter-input",n.placeholder=this.options.filterPlaceholder||"搜索...",n.value=this._filterText;let r;n.addEventListener("input",()=>{clearTimeout(r),r=setTimeout(()=>{this._filterText=n.value,this._currentPage=1,this.filterText.value=this._filterText,this.onFilter&&this.onFilter(this._filterText),this.render()},300)}),t.appendChild(n)}const e=document.createElement("div");if(e.className="kupola-table-toolbar-right",this.selection&&this._selectedKeys.size>0){const n=document.createElement("span");n.className="kupola-table-selection-info",n.textContent=`已选 ${this._selectedKeys.size} 项`,e.appendChild(n);const r=document.createElement("button");r.className="ds-btn ds-btn--sm",r.textContent="反选",r.type="button",r.addEventListener("click",()=>this.invertSelection()),e.appendChild(r)}if(this.options.showExport){const n=document.createElement("button");n.className="ds-btn ds-btn--sm ds-btn--secondary",n.textContent="导出 CSV",n.type="button",n.addEventListener("click",()=>this.exportCSV()),e.appendChild(n)}const i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this._total} 条`,e.appendChild(i),t.appendChild(e),t}_renderPagination(){const t=Math.ceil(this._total/this._pageSize);if(t<=1)return document.createElement("div");const e=document.createElement("div");if(e.className="kupola-table-pagination",this.options.showPageSize){const o=document.createElement("select");o.className="kupola-table-page-size",this._pageSizes.forEach(l=>{const c=document.createElement("option");c.value=l,c.textContent=`${l} 条/页`,l===this._pageSize&&(c.selected=!0),o.appendChild(c)}),o.addEventListener("change",()=>{this._pageSize=parseInt(o.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(o)}const i=document.createElement("div");i.className="kupola-table-pages";const n=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));n.disabled=this._currentPage<=1,i.appendChild(n),this._getPageRange(this._currentPage,t).forEach(o=>{if(o==="..."){const l=document.createElement("span");l.className="kupola-table-page-ellipsis",l.textContent="...",i.appendChild(l)}else{const l=this._createPageBtn(o,()=>this._goToPage(o));o===this._currentPage&&l.classList.add("active"),i.appendChild(l)}});const r=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));r.disabled=this._currentPage>=t,i.appendChild(r),e.appendChild(i);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${t}`,e.appendChild(a),e}_createPageBtn(t,e){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_goToPage(t){const e=Math.ceil(this._total/this._pageSize);t<1||t>e||(this._currentPage=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this._pageSize),this.render())}_getPageRange(t,e){if(e<=7)return Array.from({length:e},(n,r)=>r+1);const i=[];if(t<=3){for(let n=1;n<=5;n++)i.push(n);i.push("...",e)}else if(t>=e-2){i.push(1,"...");for(let n=e-4;n<=e;n++)i.push(n)}else{i.push(1,"...");for(let n=t-1;n<=t+1;n++)i.push(n);i.push("...",e)}return i}exportCSV(t="export.csv"){const e=this.getProcessedData(),i=this.columns.map(c=>c.title||c.key),n=e.map(c=>this.columns.map(d=>{let h=c[d.key];return h==null&&(h=""),h=String(h).replace(/"/g,'""'),`"${h}"`}).join(",")),r="\uFEFF"+[i.join(","),...n].join(`
219
+ `),a=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=t,l.click(),URL.revokeObjectURL(o)}_getTableClass(){const t=["kupola-table"];return this.striped&&t.push("kupola-table-striped"),this.bordered&&t.push("kupola-table-bordered"),this.hoverable&&t.push("kupola-table-hover"),this.compact&&t.push("kupola-table-compact"),t.join(" ")}refresh(){this.render()}getPage(){return{current:this._currentPage,pageSize:this._pageSize,total:this._total}}setColumns(t){this.columns=t.map((e,i)=>({...e,_index:i})),this.render()}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper")}}let $e=!1;function Hs(){if($e||typeof document>"u")return;const s=document.createElement("style");s.textContent=`
220
+ .kupola-table-wrapper { width: 100%; }
221
+ .kupola-table-container { overflow-x: auto; }
222
+ .kupola-table { width: 100%; border-collapse: collapse; font-size: 14px; }
223
+ .kupola-table th, .kupola-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #e8e8e8; }
224
+ .kupola-table th { background: #fafafa; font-weight: 600; color: #333; white-space: nowrap; }
225
+ .kupola-table-striped tbody tr:nth-child(even) { background: #fafafa; }
226
+ .kupola-table-hover tbody tr:hover { background: #f0f7ff; }
227
+ .kupola-table-bordered { border: 1px solid #e8e8e8; }
228
+ .kupola-table-bordered th, .kupola-table-bordered td { border: 1px solid #e8e8e8; }
229
+ .kupola-table-compact th, .kupola-table-compact td { padding: 8px 12px; }
230
+ .kupola-table-sortable { cursor: pointer; user-select: none; position: relative; }
231
+ .kupola-table-sortable:hover { background: #f0f0f0; }
232
+ .kupola-table-sort-icon { font-size: 12px; opacity: 0.5; margin-left: 4px; }
233
+ .kupola-table-sort-asc .kupola-table-sort-icon,
234
+ .kupola-table-sort-desc .kupola-table-sort-icon { opacity: 1; color: #1890ff; }
235
+ .kupola-table-empty, .kupola-table-loading { text-align: center; padding: 40px 16px !important; color: #999; }
236
+ .kupola-table-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
237
+ .kupola-table-toolbar-right { display: flex; align-items: center; gap: 8px; }
238
+ .kupola-table-filter-input { padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; width: 240px; }
239
+ .kupola-table-filter-input:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.1); }
240
+ .kupola-table-info { color: #999; font-size: 13px; }
241
+ .kupola-table-selection-info { color: #1890ff; font-size: 13px; font-weight: 500; }
242
+ .kupola-table-col-selection { width: 40px; text-align: center; }
243
+ .kupola-table-col-expand { width: 40px; text-align: center; }
244
+ .kupola-table-expand-btn { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 6px; color: #666; }
245
+ .kupola-table-expand-btn:hover { color: #1890ff; }
246
+ .kupola-table-expand-row td { background: #fafafa; padding: 16px; }
247
+ .kupola-table-row-selected { background: #e6f7ff !important; }
248
+ .kupola-table-row-selected:hover { background: #bae7ff !important; }
249
+ /* Resize */
250
+ .kupola-table-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; background: transparent; }
251
+ .kupola-table-resize-handle:hover { background: #1890ff; opacity: 0.3; }
252
+ /* Drag */
253
+ .kupola-table-draggable { transition: opacity 0.2s; }
254
+ .kupola-table-dragging { opacity: 0.4; }
255
+ .kupola-table-drag-over { border-top: 2px solid #1890ff !important; }
256
+ /* Edit */
257
+ .kupola-table-editable-cell { cursor: text; }
258
+ .kupola-table-editable-cell:hover { background: #e6f7ff; }
259
+ .kupola-table-edit-cell { display: flex; gap: 4px; align-items: center; }
260
+ .kupola-table-edit-input { flex: 1; padding: 2px 6px; font-size: 13px; }
261
+ .kupola-table-edit-actions { display: flex; gap: 2px; }
262
+ .kupola-table-edit-save, .kupola-table-edit-cancel { background: none; border: 1px solid #d9d9d9; border-radius: 3px; cursor: pointer; padding: 2px 6px; font-size: 12px; }
263
+ .kupola-table-edit-save { color: #52c41a; border-color: #52c41a; }
264
+ .kupola-table-edit-cancel { color: #ff4d4f; border-color: #ff4d4f; }
265
+ .kupola-table-edit-save:hover { background: #f6ffed; }
266
+ .kupola-table-edit-cancel:hover { background: #fff2f0; }
267
+ /* Tree */
268
+ .kupola-table-tree-indent { display: inline-block; }
269
+ .kupola-table-tree-toggle { background: none; border: none; cursor: pointer; font-size: 10px; padding: 0 4px; color: #666; }
270
+ .kupola-table-tree-toggle:hover { color: #1890ff; }
271
+ .kupola-table-tree-toggle-placeholder { display: inline-block; width: 18px; }
272
+ /* Virtual */
273
+ .kupola-table-virtual-wrapper .kupola-table-container { overflow-y: auto; }
274
+ /* Pagination */
275
+ .kupola-table-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; padding: 8px 0; }
276
+ .kupola-table-pages { display: flex; gap: 4px; align-items: center; }
277
+ .kupola-table-page-btn { min-width: 32px; height: 32px; border: 1px solid #d9d9d9; border-radius: 4px; background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
278
+ .kupola-table-page-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }
279
+ .kupola-table-page-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }
280
+ .kupola-table-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
281
+ .kupola-table-page-ellipsis { padding: 0 4px; color: #999; }
282
+ .kupola-table-page-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }
283
+ .kupola-table-page-info { color: #999; font-size: 13px; }
284
+ `,document.head.appendChild(s),$e=!0}function Ie(s,t){return Hs(),new He(s,t)}function Is(){document.querySelectorAll("[data-kupola-table]").forEach(s=>{const t=s.getAttribute("data-kupola-table");let e={};if(t)try{e=JSON.parse(t)}catch{}Ie(s,e)})}typeof window<"u"&&(window.KupolaTable=He,window.initTable=Ie);class Te{constructor(t,e={}){this.element=typeof t=="string"?document.querySelector(t):t,this.options=e,this._current=e.current||1,this._total=e.total||0,this._pageSize=e.pageSize||10,this._maxPages=e.maxPages||7,this._showTotal=e.showTotal!==!1,this._showSizeChanger=e.showSizeChanger||!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._simple=e.simple||!1,this.current=L(this._current),this.total=L(this._total),this.onChange=e.onChange||null,this.onPageSizeChange=e.onPageSizeChange||null,this._init()}_init(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this._total/this._pageSize))}setCurrent(t){t=Math.max(1,Math.min(t,this.totalPages)),t!==this._current&&(this._current=t,this.current.value=t,this.onChange&&this.onChange(t,this._pageSize),this.render())}setTotal(t){t&&typeof t=="object"&&"value"in t?(this._total=t.value||0,t._subscribers?.add(e=>{this._total=e||0,this._current>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this._total=t,this.total.value=this._total,this.render()}setPageSize(t){this._pageSize=t,this._current=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this._current),this.render()}render(){const t=this.element;t.innerHTML="",!(this._total<=0)&&(this._simple?this._renderSimple(t):this._renderFull(t))}_renderSimple(t){const e=this.totalPages,i=this._btn("‹",()=>this.setCurrent(this._current-1));i.disabled=this._current<=1,t.appendChild(i);const n=document.createElement("span");n.className="kupola-pagination-simple-info",n.textContent=`${this._current} / ${e}`,t.appendChild(n);const r=this._btn("›",()=>this.setCurrent(this._current+1));r.disabled=this._current>=e,t.appendChild(r)}_renderFull(t){const e=this.totalPages;if(this._showTotal){const a=document.createElement("span");a.className="kupola-pagination-total",a.textContent=`共 ${this._total} 条`,t.appendChild(a)}if(this._showSizeChanger){const a=document.createElement("select");a.className="kupola-pagination-size",this._pageSizes.forEach(o=>{const l=document.createElement("option");l.value=o,l.textContent=`${o} 条/页`,o===this._pageSize&&(l.selected=!0),a.appendChild(l)}),a.addEventListener("change",()=>this.setPageSize(parseInt(a.value))),t.appendChild(a)}const i=document.createElement("div");i.className="kupola-pagination-pages";const n=this._btn("‹",()=>this.setCurrent(this._current-1));n.disabled=this._current<=1,i.appendChild(n),this._getPageRange().forEach(a=>{if(a==="..."){const o=document.createElement("span");o.className="kupola-pagination-ellipsis",o.textContent="···",i.appendChild(o)}else{const o=this._btn(a,()=>this.setCurrent(a));a===this._current&&o.classList.add("active"),i.appendChild(o)}});const r=this._btn("›",()=>this.setCurrent(this._current+1));if(r.disabled=this._current>=e,i.appendChild(r),t.appendChild(i),e>10){const a=document.createElement("span");a.className="kupola-pagination-jumper",a.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const o=a.querySelector("input");o.addEventListener("change",()=>{const l=parseInt(o.value);l>=1&&l<=e&&this.setCurrent(l)}),o.addEventListener("keydown",l=>{if(l.key==="Enter"){const c=parseInt(o.value);c>=1&&c<=e&&this.setCurrent(c)}}),t.appendChild(a)}}_btn(t,e){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_getPageRange(){const t=this.totalPages,e=this._maxPages;if(t<=e)return Array.from({length:t},(r,a)=>a+1);const i=[],n=Math.floor(e/2);if(this._current<=n+1){for(let r=1;r<=e-2;r++)i.push(r);i.push("...",t)}else if(this._current>=t-n){i.push(1,"...");for(let r=t-e+3;r<=t;r++)i.push(r)}else{i.push(1,"...");for(let r=this._current-n+2;r<=this._current+n-2;r++)i.push(r);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let qe=!1;function Ts(){if(qe||typeof document>"u")return;const s=document.createElement("style");s.textContent=`
285
+ .kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
286
+ .kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }
287
+ .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; }
288
+ .kupola-pagination-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }
289
+ .kupola-pagination-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }
290
+ .kupola-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
291
+ .kupola-pagination-ellipsis { padding: 0 4px; color: #999; user-select: none; }
292
+ .kupola-pagination-total { color: #666; font-size: 14px; }
293
+ .kupola-pagination-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }
294
+ .kupola-pagination-simple-info { padding: 0 8px; font-size: 14px; color: #333; }
295
+ .kupola-pagination-jumper { font-size: 14px; color: #666; }
296
+ .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; }
297
+ .kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }
298
+ `,document.head.appendChild(s),qe=!0}function os(s,t){return Ts(),new Te(s,t)}typeof window<"u"&&(window.KupolaPagination=Te,window.initPagination=os);let Be=!1;class ls extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const t=this.querySelector('[slot="trigger"]'),e=this.querySelectorAll('[slot="item"]'),i=document.createElement("div");i.className="ds-dropdown",i.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),i.appendChild(t));const n=document.createElement("div");n.className="ds-dropdown__menu",e.forEach(r=>{r.className="ds-dropdown__item",n.appendChild(r)}),i.appendChild(n),this.innerHTML="",this.appendChild(i)}attributeChangedCallback(t,e,i){if(t==="open"){const n=this.querySelector(".ds-dropdown__menu");n&&(n.style.display=i!==null?"block":"")}}}class cs extends HTMLElement{static get observedAttributes(){return["title","position"]}connectedCallback(){const t=this.firstElementChild;t&&(t.setAttribute("data-title",this.getAttribute("title")||""),this.getAttribute("position")&&t.setAttribute("data-tooltip-position",this.getAttribute("position")))}attributeChangedCallback(t,e,i){if(t==="title"){const n=this.firstElementChild;n&&n.setAttribute("data-title",i||"")}}}class ds extends HTMLElement{connectedCallback(){this._render()}_render(){const t=document.createElement("div");t.className="ds-collapse",t.setAttribute("data-collapse",""),this.querySelectorAll("k-collapse-item").forEach(i=>{const n=i.getAttribute("title")||"",r=i.innerHTML,a=document.createElement("div");a.className="ds-collapse__item",a.innerHTML=`
299
+ <button class="ds-collapse__header">
300
+ <span>${n}</span>
301
+ <svg class="icon ds-collapse__chevron" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
302
+ </button>
303
+ <div class="ds-collapse__body"><div class="ds-collapse__content">${r}</div></div>
304
+ `,t.appendChild(a)}),this.innerHTML="",this.appendChild(t)}}class As extends HTMLElement{static get observedAttributes(){return["title"]}}class hs extends HTMLElement{static get observedAttributes(){return["position","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("position")||"left",e=document.createElement("div");e.className=`ds-drawer ds-drawer--${t}`,e.setAttribute("data-drawer",""),e.innerHTML=this.innerHTML,this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,i){if(t==="open"){const n=this.querySelector(".ds-drawer");n&&n.classList.toggle("is-open",i!==null)}}}class us extends HTMLElement{static get observedAttributes(){return["title","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("title")||"",e=document.createElement("div");e.className="ds-backdrop",e.style.display="none",e.innerHTML=`
305
+ <div class="ds-dialog">
306
+ <div class="ds-dialog__head">
307
+ <span class="ds-dialog__title">${t}</span>
308
+ <button class="ds-dialog__close" aria-label="Close">
309
+ <svg class="icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
310
+ </button>
215
311
  </div>
216
- `}),t.innerHTML=e,t.querySelectorAll(".kupola-devtools__network-item").forEach(o=>{o.addEventListener("click",()=>{const n=o.querySelector(".kupola-devtools__network-details");n.style.display=n.style.display==="none"?"block":"none"})});const r=this.panel.querySelector('[data-action="clear"]');r&&r.addEventListener("click",o=>{o.stopPropagation(),this.clearNetworkHistory()})}clearNetworkHistory(){this.requestHistory=[],this.renderNetworkContent()}truncateContent(t,e){if(!t)return"-";const r=typeof t=="string"?t:JSON.stringify(t);return r.length<=e?r:r.substring(0,e)+`... (truncated, ${r.length} chars)`}setupNetworkInterceptor(){const t=this,e=window.fetch;window.fetch=async function(i,a={}){const l=Date.now(),c=Date.now()+Math.random();let h=null;if(a.body)if(typeof a.body=="string")h=a.body;else if(a.body instanceof FormData)try{h=JSON.stringify(Object.fromEntries(a.body))}catch{}else try{h=JSON.stringify(a.body)}catch{}let u=null;try{const p=new URL(typeof i=="string"?i:i.href);p.search&&(u=Object.fromEntries(p.searchParams))}catch{}const d={id:c,method:a.method||"GET",url:typeof i=="string"?i:i.href,params:u,requestBody:h,status:0,response:null,duration:null};t.addRequest(d);try{const p=await e.apply(this,arguments);d.status=p.status,d.duration=Date.now()-l;try{const f=await p.clone().text();try{d.response=JSON.parse(f)}catch{d.response=f}}catch{}return t.updateRequest(d),p}catch(p){throw d.status=-1,d.response=p.message,d.duration=Date.now()-l,t.updateRequest(d),p}};const r=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(i,a){this.__kupolaRequest={method:i,url:a,params:null,requestBody:null,status:0,response:null,startTime:Date.now()};try{const l=new URL(a);l.search&&(this.__kupolaRequest.params=Object.fromEntries(l.searchParams))}catch{}r.apply(this,arguments)};const o=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(i){if(this.__kupolaRequest){if(i){if(typeof i=="string")this.__kupolaRequest.requestBody=i;else if(i instanceof FormData)try{this.__kupolaRequest.requestBody=JSON.stringify(Object.fromEntries(i))}catch{}}const a={...this.__kupolaRequest};t.addRequest(a),this.__kupolaEntry=a}o.apply(this,arguments)};const n=XMLHttpRequest.prototype.onreadystatechange;XMLHttpRequest.prototype.onreadystatechange=function(){if(this.__kupolaEntry&&this.readyState===4){this.__kupolaEntry.status=this.status,this.__kupolaEntry.duration=Date.now()-this.__kupolaRequest.startTime;try{const i=this.responseText;try{this.__kupolaEntry.response=JSON.parse(i)}catch{this.__kupolaEntry.response=i}}catch{}t.updateRequest(this.__kupolaEntry)}typeof n=="function"&&n.apply(this,arguments)}}addRequest(t){this.requestHistory.unshift(t),this.requestHistory.length>this.maxHistorySize&&this.requestHistory.pop(),this.isOpen&&this.activeTab==="network"&&this.renderNetworkContent()}updateRequest(t){const e=this.requestHistory.findIndex(r=>r.id===t.id||r.url===t.url&&r.method===t.method&&!r.status);e!==-1&&(this.requestHistory[e]=t,this.isOpen&&this.activeTab==="network"&&this.renderNetworkContent())}setupStorageListener(){const t=this;window.addEventListener("storage",o=>{if(t.isOpen&&t.activeTab==="storage"){const n=t.panel?.querySelector(".kupola-devtools__content");if(n){const i=o.storageArea===localStorage?"localStorage":"sessionStorage";t.activeStorageType=i,t.updateStorageTabs(),n.innerHTML=t.getStorageContent(i)}}});const e=Storage.prototype.setItem;Storage.prototype.setItem=function(o,n){const i=this.getItem(o);e.call(this,o,n);const a=new StorageEvent("storage",{key:o,oldValue:i,newValue:n,url:window.location.href,storageArea:this});window.dispatchEvent(a)};const r=Storage.prototype.removeItem;Storage.prototype.removeItem=function(o){const n=this.getItem(o);r.call(this,o);const i=new StorageEvent("storage",{key:o,oldValue:n,newValue:null,url:window.location.href,storageArea:this});window.dispatchEvent(i)}}injectStyles(){const t=document.createElement("style");t.textContent=`
217
- .kupola-devtools__header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #2d2d2d; border-bottom: 1px solid #333; }
218
- .kupola-devtools__title { color: #535164; font-weight: 600; font-size: 14px; }
219
- .kupola-devtools__close { background: none; border: none; color: #888; cursor: pointer; font-size: 14px; padding: 4px; }
220
- .kupola-devtools__close:hover { color: #fff; }
221
- .kupola-devtools__tabs { display: flex; background: #252525; border-bottom: 1px solid #333; }
222
- .kupola-devtools__tab { flex: 1; padding: 10px 8px; background: none; border: none; color: #888; cursor: pointer; font-size: 11px; border-bottom: 2px solid transparent; transition: all 0.2s; }
223
- .kupola-devtools__tab:hover { color: #fff; }
224
- .kupola-devtools__tab.active { color: #535164; border-bottom-color: #535164; }
225
- .kupola-devtools__sub-tabs { display: flex; gap: 4px; padding: 8px 12px; background: #1e1e1e; border-bottom: 1px solid #333; }
226
- .kupola-devtools__sub-tab { padding: 4px 8px; background: #333; border: none; color: #888; cursor: pointer; font-size: 11px; border-radius: 4px; }
227
- .kupola-devtools__sub-tab:hover { color: #fff; }
228
- .kupola-devtools__sub-tab.active { background: #535164; color: white; }
229
- .kupola-devtools__network-action { padding: 4px 8px; background: #333; border: none; color: #888; cursor: pointer; font-size: 11px; border-radius: 4px; }
230
- .kupola-devtools__network-action:hover { color: #fff; background: #444; }
231
- .kupola-devtools__content { flex: 1; overflow-y: auto; padding: 12px; font-family: 'Consolas', monospace; font-size: 12px; }
232
- .kupola-devtools__list-item { padding: 6px 8px; border-radius: 4px; margin-bottom: 4px; background: #2a2a2a; }
233
- .kupola-devtools__list-item:hover { background: #333; }
234
- .kupola-devtools__loading { display: flex; justify-content: center; align-items: center; height: 100px; color: #666; }
235
- .kupola-devtools__storage-key { color: #9cdcfe; margin-right: 8px; }
236
- .kupola-devtools__storage-value { color: #ce9178; word-break: break-all; }
237
- .kupola-devtools__network-item { padding: 6px 8px; border-radius: 4px; margin-bottom: 4px; background: #2a2a2a; cursor: pointer; }
238
- .kupola-devtools__network-item:hover { background: #333; }
239
- .kupola-devtools__network-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
240
- .kupola-devtools__network-method { padding: 2px 6px; border-radius: 3px; font-weight: 600; font-size: 11px; color: white; }
241
- .kupola-devtools__network-method.GET { background: #4CAF50; }
242
- .kupola-devtools__network-method.POST { background: #2196F3; }
243
- .kupola-devtools__network-method.PUT { background: #FF9800; }
244
- .kupola-devtools__network-method.DELETE { background: #F44336; }
245
- .kupola-devtools__network-method.PATCH { background: #9C27B0; }
246
- .kupola-devtools__network-url { flex: 1; color: #9cdcfe; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
247
- .kupola-devtools__network-status { padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600; }
248
- .kupola-devtools__network-status.success { background: #4CAF50; color: white; }
249
- .kupola-devtools__network-status.error { background: #F44336; color: white; }
250
- .kupola-devtools__network-status.warning { background: #FF9800; color: white; }
251
- .kupola-devtools__network-duration { color: #888; font-size: 11px; }
252
- .kupola-devtools__network-details { margin-top: 8px; padding-top: 8px; border-top: 1px solid #333; }
253
- .kupola-devtools__network-detail { margin-bottom: 8px; }
254
- .kupola-devtools__network-detail strong { color: #535164; display: block; margin-bottom: 4px; }
255
- .kupola-devtools__network-detail pre { margin: 0; color: #ce9178; white-space: pre-wrap; word-break: break-all; }
256
- `,document.head.appendChild(t)}makeDraggable(){const t=this.panel.querySelector(".kupola-devtools__header");let e=!1,r,o,n,i;this._dragMouseDownHandler=a=>{a.target.closest(".kupola-devtools__close")||(e=!0,r=a.clientX,o=a.clientY,n=this.panel.offsetLeft,i=this.panel.offsetTop)},this._dragMouseMoveHandler=a=>{if(!e)return;const l=a.clientX-r,c=a.clientY-o;this.panel.style.left=`${n+l}px`,this.panel.style.right="auto",this.panel.style.top=`${Math.max(0,i+c)}px`},this._dragMouseUpHandler=()=>{e=!1},t.addEventListener("mousedown",this._dragMouseDownHandler),document.addEventListener("mousemove",this._dragMouseMoveHandler),document.addEventListener("mouseup",this._dragMouseUpHandler)}destroy(){const t=this.panel.querySelector(".kupola-devtools__header");t&&this._dragMouseDownHandler&&t.removeEventListener("mousedown",this._dragMouseDownHandler),this._dragMouseMoveHandler&&document.removeEventListener("mousemove",this._dragMouseMoveHandler),this._dragMouseUpHandler&&document.removeEventListener("mouseup",this._dragMouseUpHandler),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this._dragMouseDownHandler=null,this._dragMouseMoveHandler=null,this._dragMouseUpHandler=null,this.panel=null}togglePanel(){this.isOpen=!this.isOpen,this.panel.style.display=this.isOpen?"flex":"none",this.isOpen&&this.activeTab==="network"&&this.renderNetworkContent()}updateStorageTabs(){this.panel.querySelectorAll(".kupola-devtools__sub-tab").forEach(t=>{t.classList.toggle("active",t.dataset.storage===this.activeStorageType)})}getStorageContent(t){let e=[];try{if(t==="cookies")e=document.cookie.split(";").map(o=>o.trim()).filter(o=>o).map(o=>{const[n,...i]=o.split("=");return{key:n,value:i.join("=")}});else if(t==="localStorage")for(let o=0;o<localStorage.length;o++)e.push({key:localStorage.key(o),value:localStorage.getItem(localStorage.key(o))});else if(t==="sessionStorage")for(let o=0;o<sessionStorage.length;o++)e.push({key:sessionStorage.key(o),value:sessionStorage.getItem(sessionStorage.key(o))})}catch(o){return console.error("Error reading storage:",o),'<div class="kupola-devtools__loading">Error reading storage</div>'}if(e.length===0)return'<div class="kupola-devtools__loading">No data</div>';let r="";return e.forEach(o=>{let n=o.value;if(n&&n.length>0&&n.length<2e3)try{const i=JSON.parse(n);n=JSON.stringify(i,null,2)}catch{}else n&&n.length>=2e3&&(n=n.substring(0,500)+"... (truncated, "+n.length+" chars)");r+=`<div class="kupola-devtools__list-item"><div><span class="kupola-devtools__storage-key">${o.key}</span></div><div class="kupola-devtools__storage-value">${n}</div></div>`}),r}handleStorageClick(t){const e=t.target;if(e.classList.contains("kupola-devtools__sub-tab")){t.stopPropagation();const r=e.dataset.storage;if(r){this.activeStorageType=r,this.updateStorageTabs();const o=this.panel.querySelector(".kupola-devtools__content");o&&(o.innerHTML=this.getStorageContent(r))}}}};function At(){try{const s=new URLSearchParams(window.location.search);(s.has("dev")||s.has("debug"))&&(window.kupolaDevTools=new Jt({enabled:!0}),window.kupolaDevTools.init(),window.addEventListener("click",e=>{window.kupolaDevTools&&window.kupolaDevTools.handleStorageClick&&window.kupolaDevTools.handleStorageClick(e)}))}catch(s){console.error("Error initializing Kupola DevTools:",s)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",At):At();window.KupolaDevTools=Jt;var qt={},zt;function Di(){return zt||(zt=1,function(s){const t='xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter"',e={globe:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 0 20"/><path d="M12 2a15.3 15.3 0 0 0 0 20"/>',dashboard:'<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>',mouse:'<rect x="6" y="2" width="12" height="20" rx="6"/><line x1="12" y1="6" x2="12" y2="11"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',square:'<rect x="3" y="3" width="18" height="18"/>',circle:'<circle cx="12" cy="12" r="9"/>',list:'<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',palette:'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',type:'<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',ruler:'<rect x="3" y="9" width="18" height="6" transform="rotate(-45 12 12)"/><line x1="7.5" y1="12.5" x2="9" y2="14"/><line x1="11" y1="9" x2="12.5" y2="10.5"/><line x1="14.5" y1="5.5" x2="16" y2="7"/>',sparkles:'<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',refresh:'<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',external:'<polyline points="14 4 20 4 20 10"/><line x1="20" y1="4" x2="11" y2="13"/><path d="M20 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5"/>',settings:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',sliders:'<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',minus:'<line x1="5" y1="12" x2="19" y2="12"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',github:'<path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/>',"message-circle":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/>',"message-plus":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/><line x1="12" y1="9" x2="12" y2="15"/><line x1="9" y1="12" x2="15" y2="12"/>',gear:'<path d="M9.3 5.7 6.375 5.025 5.025 6.375 5.7 9.3 3 11.1 3 12.9 5.7 14.7 5.025 17.625 6.375 18.975 9.3 18.3 11.1 21 12.9 21 14.7 18.3 17.625 18.975 18.975 17.625 18.3 14.7 21 12.9 21 11.1 18.3 9.3 18.975 6.375 17.625 5.025 14.7 5.7 12.9 3 11.1 3 9.3 5.7Z"/><circle cx="12" cy="12" r="3"/>',"user-circle":'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="2.5"/><path d="M7 17.5a5 5 0 0 1 10 0"/>',shield:'<path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/>',check:'<polyline points="4 12 10 18 20 6"/>',"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"alert-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',"alert-triangle":'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',"info-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"x-circle":'<circle cx="12" cy="12" r="9"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/>',alert:'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',info:'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>',user:'<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',users:'<path d="M2 21v-1a5 5 0 0 1 5-5h3a5 5 0 0 1 5 5v1"/><circle cx="8.5" cy="8" r="3.5"/><path d="M22 21v-1a5 5 0 0 0-4-4.9"/><path d="M16 3.1A4 4 0 0 1 16 11"/>',box:'<polyline points="3 7 12 2 21 7 21 17 12 22 3 17 3 7"/><line x1="3" y1="7" x2="12" y2="12"/><line x1="21" y1="7" x2="12" y2="12"/><line x1="12" y1="22" x2="12" y2="12"/>',zap:'<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',moon:'<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',sun:'<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',cmd:'<path d="M9 6h6v12H9z"/><rect x="3" y="3" width="6" height="6"/><rect x="15" y="3" width="6" height="6"/><rect x="3" y="15" width="6" height="6"/><rect x="15" y="15" width="6" height="6"/>',key:'<circle cx="7.5" cy="14.5" r="3.5"/><line x1="10" y1="12" x2="22" y2="12"/><line x1="22" y1="12" x2="22" y2="16"/><line x1="18" y1="12" x2="18" y2="15"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',mic:'<rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/>',at:'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',hash:'<line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/>',"sidebar-left":'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/>',"sidebar-right":'<rect x="3" y="3" width="18" height="18"/><line x1="15" y1="3" x2="15" y2="21"/>',"panel-bottom":'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="15" x2="21" y2="15"/>',git:'<circle cx="6" cy="5" r="3"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><line x1="6" y1="8" x2="6" y2="16"/><path d="M18 8v3a4 4 0 0 1-4 4h-4"/>',bug:'<rect x="8" y="6" width="8" height="14" rx="4"/><line x1="12" y1="11" x2="12" y2="20"/><line x1="3" y1="9" x2="8" y2="9"/><line x1="3" y1="14" x2="8" y2="14"/><line x1="3" y1="19" x2="8" y2="19"/><line x1="16" y1="9" x2="21" y2="9"/><line x1="16" y1="14" x2="21" y2="14"/><line x1="16" y1="19" x2="21" y2="19"/><line x1="9" y1="6" x2="9" y2="3"/><line x1="15" y1="6" x2="15" y2="3"/>',"search-menu":'<circle cx="11" cy="11" r="6"/><line x1="20" y1="20" x2="16" y2="16"/><line x1="3" y1="20" x2="13" y2="20"/>',extensions:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M17.5 14v3.5H21a2 2 0 0 1 0 4h-3.5V21a2 2 0 0 1-4 0v-3.5H14a2 2 0 0 1 0-4h3.5z"/>',wrench:'<path d="M14.7 6.3a4 4 0 0 0 5 5L21 12.5l-7.5 7.5a3 3 0 0 1-4.2-4.2L16.7 8 14.7 6.3z"/><path d="M14.7 6.3 12 9l-3-3 2.7-2.7a4 4 0 0 1 3 3z"/>',"message-square":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',"file-text":'<path d="M14 3H6v18h12V8z"/><polyline points="14 3 14 8 18 8"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="15" y2="17"/>',"scroll-text":'<path d="M5 4h11a3 3 0 0 1 3 3v10H8v3a1 1 0 0 1-1 1 3 3 0 0 1-3-3V7a3 3 0 0 1 1-3z"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/>',atom:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',"arrow-right-to-line":'<line x1="20" y1="4" x2="20" y2="20"/><line x1="3" y1="12" x2="17" y2="12"/><polyline points="11 6 17 12 11 18"/>',"info-square":'<rect x="3" y="3" width="18" height="18"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"arrow-minimize":'<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',"arrow-expand":'<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',logo:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',"more-h":'<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',edit:'<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',trash:'<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',file:'<path d="M14 3H6v18h12V7z"/><polyline points="14 3 14 7 18 7"/>',files:'<path d="M21 8v13H8V3h8z"/><polyline points="16 3 16 8 21 8"/><path d="M8 7H3v14h13v-3"/>',"grid-2x2":'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',layout:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',image:'<rect x="3" y="3" width="18" height="18"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><polyline points="3 18 9 12 13 16 17 12 21 16"/>',play:'<polygon points="6 4 20 12 6 20 6 4"/>',pause:'<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',help:'<rect x="3" y="3" width="18" height="18"/><path d="M9 9a3 3 0 0 1 6 0c0 2-3 2-3 4"/><line x1="12" y1="17" x2="12" y2="17.01"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',eye:'<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/>',star:'<polygon points="12 3 15 9 22 10 17 14 18 21 12 18 6 21 7 14 2 10 9 9 12 3"/>',heart:'<path d="M12 21s-7-5-7-11a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 6-7 11-7 11z"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',calendar:'<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',clock:'<circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 16 14"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',send:'<polygon points="3 12 21 4 17 21 12 13 3 12"/>',link:'<path d="M10 14a4 4 0 0 1 0-6l3-3a4 4 0 0 1 6 6l-1.5 1.5"/><path d="M14 10a4 4 0 0 1 0 6l-3 3a4 4 0 0 1-6-6l1.5-1.5"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',"log-out":'<path d="M14 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9"/><polyline points="16 16 21 12 16 8"/><line x1="9" y1="12" x2="21" y2="12"/>',menu:'<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',dollar:'<line x1="12" y1="2" x2="12" y2="22"/><path d="M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',bar:'<line x1="3" y1="21" x2="21" y2="21"/><rect x="5" y="11" width="3" height="8"/><rect x="10.5" y="6" width="3" height="13"/><rect x="16" y="14" width="3" height="5"/>',"trending-up":'<polyline points="3 17 9 11 13 15 21 7"/><polyline points="15 7 21 7 21 13"/>',"trending-down":'<polyline points="3 7 9 13 13 9 21 17"/><polyline points="15 17 21 17 21 11"/>',columns:'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M7 8h10v4a5 5 0 0 1-10 0V8z"/><path d="M12 17v5"/>',cpu:'<rect x="6" y="6" width="12" height="12"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="2" x2="9" y2="6"/><line x1="15" y1="2" x2="15" y2="6"/><line x1="9" y1="18" x2="9" y2="22"/><line x1="15" y1="18" x2="15" y2="22"/><line x1="2" y1="9" x2="6" y2="9"/><line x1="2" y1="15" x2="6" y2="15"/><line x1="18" y1="9" x2="22" y2="9"/><line x1="18" y1="15" x2="22" y2="15"/>',code:'<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',apple:'<path fill="currentColor" stroke="none" d="M17.05 12.04c-.03-3.04 2.49-4.5 2.6-4.57-1.42-2.07-3.62-2.36-4.4-2.39-1.87-.19-3.65 1.1-4.6 1.1-.96 0-2.42-1.08-3.98-1.05-2.05.03-3.94 1.19-4.99 3.02-2.13 3.69-.54 9.13 1.53 12.12 1.01 1.46 2.21 3.1 3.78 3.04 1.52-.06 2.09-.98 3.93-.98 1.83 0 2.36.98 3.97.95 1.64-.03 2.68-1.49 3.68-2.96 1.16-1.7 1.64-3.35 1.66-3.43-.04-.02-3.18-1.22-3.21-4.85zM14.06 4.34c.83-1.01 1.39-2.41 1.24-3.81-1.2.05-2.65.8-3.51 1.8-.77.89-1.45 2.31-1.27 3.68 1.34.1 2.71-.68 3.54-1.67z"/>'};function r(n,i=16,a="0 0 24 24"){const l=e[n];return l?`<svg ${t.replace('width="16"',`width="${i}"`).replace('height="16"',`height="${i}"`).replace('viewBox="0 0 24 24"',`viewBox="${a}"`)}>${l}</svg>`:""}function o(n=document){n.querySelectorAll("[data-icon]").forEach(i=>{const a=i.getAttribute("data-icon"),l=+i.getAttribute("data-size")||16,c=i.getAttribute("data-viewbox")||"0 0 24 24";i.innerHTML=r(a,l,c),i.classList.add("icon")})}s.Icons={svg:r,render:o,PATHS:e},document.readyState!=="loading"?o():document.addEventListener("DOMContentLoaded",()=>o())}(typeof window<"u"?window:globalThis)),qt}Di();var st={exports:{}},Pt;function Mi(){return Pt||(Pt=1,function(s){class t{constructor(i){this.element=i,this.hoursEl=i.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=i.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=i.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const i=this.element.getAttribute("data-end-time");if(i)return new Date(i).getTime();const a=parseInt(this.element.getAttribute("data-hours"))||0,l=parseInt(this.element.getAttribute("data-minutes"))||0,c=parseInt(this.element.getAttribute("data-seconds"))||0;return new Date().getTime()+(a*3600+l*60+c)*1e3}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const i=new Date().getTime(),a=this.endTime-i;if(a<=0){this.stop(),this.displayTime(0,0,0),this.dispatchComplete();return}const l=Math.floor(a%(1e3*60*60*24)/(1e3*60*60)),c=Math.floor(a%(1e3*60*60)/(1e3*60)),h=Math.floor(a%(1e3*60)/1e3);this.displayTime(l,c,h)}displayTime(i,a,l){this.hoursEl&&(this.hoursEl.textContent=String(i).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(a).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(l).padStart(2,"0"))}setEndTime(i){this.endTime=i.getTime(),this.update()}addTime(i){this.endTime+=i*1e3,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("ds-countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-countdown").forEach(i=>{e(i)})}s.exports?s.exports={Countdown:t,initCountdowns:o,initCountdown:e,cleanupCountdown:r}:(window.Countdown=t,window.initCountdown=e,window.cleanupCountdown=r),window.kupolaInitializer&&window.kupolaInitializer.register("countdown",e,r)}(st)),st.exports}Mi();var it={exports:{}},$t;function Ii(){return $t||($t=1,function(s){class t{constructor(i){if(this.element=i,this.minusBtn=i.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=i.querySelector(".ds-number-input__btn--increase"),this.inputEl=i.querySelector(".ds-number-input__input"),this._listeners=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const i=()=>this.updateValue(-this.step),a=()=>this.updateValue(this.step),l=()=>this.handleInput();this.minusBtn.addEventListener("click",i),this.plusBtn.addEventListener("click",a),this.inputEl.addEventListener("input",l),this._listeners.push({el:this.minusBtn,event:"click",handler:i},{el:this.plusBtn,event:"click",handler:a},{el:this.inputEl,event:"input",handler:l})}updateValue(i){let a=parseInt(this.inputEl.value)||0;a+=i,a<this.min&&(a=this.min),a>this.max&&(a=this.max),this.inputEl.value=a,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let i=parseInt(this.inputEl.value);isNaN(i)&&(i=0),i<this.min&&(i=this.min),i>this.max&&(i=this.max),this.inputEl.value=i,this.updateState(),this.dispatchChange()}updateState(){const i=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=i<=this.min,this.plusBtn.disabled=i>=this.max}setValue(i){i<this.min&&(i=this.min),i>this.max&&(i=this.max),this.inputEl.value=i,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(i,a){this.min=i,this.max=a,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("ds-number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:i,event:a,handler:l})=>{i.removeEventListener(a,l)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function e(n){if(!n.__kupolaInitialized)try{const i=new t(n);n.__kupolaInstance=i,n.__kupolaInitialized=!0}catch(i){console.error("[NumberInput] Error initializing:",i)}}function r(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-number-input").forEach(n=>{e(n)})}s.exports?s.exports={NumberInput:t,initNumberInputs:o,initNumberInput:e,cleanupNumberInput:r}:(window.NumberInput=t,window.initNumberInput=e,window.cleanupNumberInput=r),window.kupolaInitializer&&window.kupolaInitializer.register("number-input",e,r)}(it)),it.exports}Ii();var nt={exports:{}},Rt;function Ti(){return Rt||(Rt=1,function(s){class t{constructor(i){this.container=i,this.track=i.querySelector(".ds-slider-captcha__track"),this.btn=i.querySelector(".ds-slider-captcha__btn"),this.text=i.querySelector(".ds-slider-captcha__text"),this.progress=i.querySelector(".ds-slider-captcha__progress"),this.statusEl=i.querySelector(".ds-slider-captcha__status"),this.refreshBtn=i.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=i.querySelector(".ds-slider-captcha__footer-refresh"),this.config={tolerance:6,minPoints:20,minDuration:300,maxDuration:1e4,minSpeedDelta:.3,maxAttempts:5},this.isDragging=!1,this.startX=0,this.startY=0,this.currentX=0,this.trackData=[],this.startTime=0,this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.targetX=0,this.distractorX=0,this.angle=0,this.distractorAngle=0,this.maxAngle=parseInt(i.getAttribute("data-angle"))||30,this.shape=i.getAttribute("data-shape")||"circle",this.hasDistractor=this.shape!=="circle",this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this._mouseDownHandler=null,this._mouseMoveHandler=null,this._mouseUpHandler=null,this._touchStartHandler=null,this._touchMoveHandler=null,this._touchEndHandler=null,this._mouseMoveListener=null,this._mouseUpListener=null,this._touchMoveListener=null,this._touchEndListener=null}init(){!this.track||!this.btn||this.container._initialized||(this._mouseDownHandler=i=>{this.isVerified||this.isProcessing||(i.preventDefault(),this.isDragging=!0,this.startX=i.clientX,this.startY=i.clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._mouseMoveHandler=i=>{if(!this.isDragging)return;i.preventDefault();const a=this.track.offsetWidth,l=this.btn.offsetWidth,c=a-l-8;let h=i.clientX-this.startX;h<0&&(h=0),h>c&&(h=c),this.currentX=h,this.btn.style.left=14+h+"px",this.progress&&(this.progress.style.width=h/c*100+"%"),this.collectTrack(i.clientX,i.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=i=>{this.isVerified||this.isProcessing||(i.preventDefault(),this.isDragging=!0,this.startX=i.touches[0].clientX,this.startY=i.touches[0].clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._touchMoveHandler=i=>{if(!this.isDragging)return;i.preventDefault();const a=this.track.offsetWidth,l=this.btn.offsetWidth,c=a-l-8;let h=i.touches[0].clientX-this.startX;h<0&&(h=0),h>c&&(h=c),this.currentX=h,this.btn.style.left=14+h+"px",this.progress&&(this.progress.style.width=h/c*100+"%"),this.collectTrack(i.touches[0].clientX,i.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),window.globalEvents?(this._mouseMoveListener=window.globalEvents.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=window.globalEvents.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=window.globalEvents.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=window.globalEvents.on(document,"touchend",this._touchEndHandler,{scope:this.scope})):(document.addEventListener("mousemove",this._mouseMoveHandler),document.addEventListener("mouseup",this._mouseUpHandler),document.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),document.addEventListener("touchend",this._touchEndHandler)),this.btn.addEventListener("touchstart",this._touchStartHandler,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container._initialized=!0,this.loadCaptcha())}generateTarget(){const i=this.track.offsetWidth,a=this.btn.offsetWidth,l=14,c=i*.35,h=i*.85-a,u=i*.6;if(this.angle=Math.floor(Math.random()*(this.maxAngle+1)),this.hasDistractor)do this.distractorAngle=Math.floor(Math.random()*(this.maxAngle+1));while(Math.abs(this.distractorAngle-this.angle)<5);this.hasDistractor?Math.random()>.5?(this.targetX=Math.floor(c+Math.random()*(u-c-a)),this.distractorX=Math.floor(u+Math.random()*(h-u))):(this.targetX=Math.floor(u+Math.random()*(h-u)),this.distractorX=Math.floor(c+Math.random()*(u-c-a))):this.targetX=Math.floor(c+Math.random()*(h-c));const d=this.container.querySelector(".ds-slider-captcha__target");if(d&&(d.style.left=this.targetX+l+a/2+"px",d.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",d.style.display="block"),this.hasDistractor){const p=this.container.querySelector(".ds-slider-captcha__target--distractor");p&&(p.style.left=this.distractorX+l+a/2+"px",p.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",p.style.display="block")}else{const p=this.container.querySelector(".ds-slider-captcha__target--distractor");p&&(p.style.display="none")}}resetSlider(){this.btn.className="ds-slider-captcha__btn",this.btn.style.transform="rotate("+this.angle+"deg)",this.btn.innerHTML="",this.btn.style.left="14px",this.btn.style.display="block",this.progress&&(this.progress.style.width="0%",this.progress.style.display="block"),this.text&&(this.text.textContent="按住滑块,拖动到缺口位置",this.text.style.color=""),this.refreshBtn&&(this.refreshBtn.style.display="none"),this.currentX=0,this.trackData=[],this.container.classList.remove("is-verified","is-error","is-disabled")}loadCaptcha(){this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.generateTarget(),this.resetSlider(),this.statusEl&&(this.statusEl.textContent="请完成验证",this.statusEl.className="ds-slider-captcha__status")}collectTrack(i,a){const c=Date.now()-this.startTime;let h=0,u=0;if(this.trackData.length>0){const p=this.trackData[this.trackData.length-1],g=this.currentX-p.x,f=c-p.t;if(f>0&&(h=g/f,this.trackData.length>1)){const m=this.trackData[this.trackData.length-2],v=p.t-m.t;if(v>0){const y=(p.x-m.x)/v;u=h-y}}}this.trackData.push({x:this.currentX,y:a-this.startY,t:c,v:h,a:u});const d=this.container.querySelector(".ds-slider-captcha__point-count");d&&(d.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const i=this.trackData[this.trackData.length-1].x,a=this.hasDistractor?Math.abs(i-this.distractorX):1/0,l=Math.abs(i-this.targetX);if(this.hasDistractor&&a<l&&a<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(l>this.config.tolerance)return{passed:!1,msg:"验证失败"};const c=[];for(let f=1;f<this.trackData.length;f++){const m=this.trackData[f].x-this.trackData[f-1].x,v=this.trackData[f].t-this.trackData[f-1].t;v>0&&v<500&&c.push(m/v)}if(c.length<3)return{passed:!1,msg:"验证失败"};const h=Math.max(...c),u=Math.min(...c);if(h-u<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let d=!1;for(const f of this.trackData)if(Math.abs(f.y)>2){d=!0;break}if(!d&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const p=this.trackData[this.trackData.length-1].t;if(p<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(p>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const g=[];for(let f=1;f<c.length;f++)g.push(Math.abs(c[f]-c[f-1]));return g.length>2&&g.reduce((m,v)=>m+v,0)/g.length<.05?{passed:!1,msg:"验证失败"}:{passed:!0,msg:"验证通过"}}verifyCaptcha(){this.isProcessing||this.isVerified||(this.isProcessing=!0,this.statusEl&&(this.statusEl.textContent="验证中...",this.statusEl.className="ds-slider-captcha__status is-loading"),this.btn.style.cursor="wait",this.container.classList.add("is-disabled"),setTimeout(()=>{const i=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",i.passed){this.isVerified=!0,this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const a=this.container.querySelector(".ds-slider-captcha__target");a&&(a.style.display="none");const l=this.container.querySelector(".ds-slider-captcha__target--distractor");l&&(l.style.display="none"),this.text&&(this.text.textContent="验证通过",this.text.style.color="var(--status-success-default)"),this.statusEl&&(this.statusEl.textContent="验证成功",this.statusEl.className="ds-slider-captcha__status is-success"),this.container.classList.add("is-verified"),this.container.classList.remove("is-disabled");const c=this.container.getAttribute("data-on-verified");c&&typeof window[c]=="function"&&window[c](this.container)}else if(this.attempts++,this.text&&(this.text.textContent=i.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=i.msg,this.statusEl.className="ds-slider-captcha__status is-error"),this.container.getAttribute("data-err-refresh")==="auto")setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const l=this.container.querySelector(".ds-slider-captcha__target");l&&(l.style.display="none");const c=this.container.querySelector(".ds-slider-captcha__target--distractor");c&&(c.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}},300))}destroy(){this.container._initialized&&(this.btn&&this._mouseDownHandler&&this.btn.removeEventListener("mousedown",this._mouseDownHandler),this.btn&&this._touchStartHandler&&this.btn.removeEventListener("touchstart",this._touchStartHandler),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this._mouseMoveListener&&this._mouseMoveListener.unsubscribe?this._mouseMoveListener.unsubscribe():this._mouseMoveHandler&&document.removeEventListener("mousemove",this._mouseMoveHandler),this._mouseUpListener&&this._mouseUpListener.unsubscribe?this._mouseUpListener.unsubscribe():this._mouseUpHandler&&document.removeEventListener("mouseup",this._mouseUpHandler),this._touchMoveListener&&this._touchMoveListener.unsubscribe?this._touchMoveListener.unsubscribe():this._touchMoveHandler&&document.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndListener&&this._touchEndListener.unsubscribe?this._touchEndListener.unsubscribe():this._touchEndHandler&&document.removeEventListener("touchend",this._touchEndHandler),this.container._initialized=!1)}}function e(){document.querySelectorAll(".ds-slider-captcha").forEach(n=>{const i=new t(n);i.init(),n._kupolaSlideCaptcha=i})}function r(n){n._kupolaSlideCaptcha&&(n._kupolaSlideCaptcha.destroy(),n._kupolaSlideCaptcha=null)}function o(){document.querySelectorAll(".ds-slider-captcha").forEach(n=>{r(n)})}s.exports&&(s.exports={initSlideCaptchas:e,cleanupSlideCaptcha:r,cleanupAllSlideCaptchas:o})}(nt)),nt.exports}Ti();(function(s){let t=null;class e{constructor(d){this.component=d,this.lifecycle=d&&d.lifecycle||null,this._onMountedHandlers=[],this._onUnmountedHandlers=[],this._onUpdatedHandlers=[],this._watches=[],this._refs=new Map,this._computedDeps=new Map}ref(d=null){if(s.kupolaData){const g=`__ref_${Math.random().toString(36).slice(2,11)}__`;return s.kupolaData.set(g,d),{get value(){return s.kupolaData.get(g)},set value(f){s.kupolaData.set(g,f)},_key:g}}const p={_value:d,_subscribers:new Set};return Object.defineProperty(p,"value",{get(){return p._value},set(g){g!==p._value&&(p._value=g,p._subscribers.forEach(f=>f(g)))}}),p}reactive(d){if(s.kupolaData)return s.kupolaData.createReactive(d);const p=this,g={get(m,v){if(v==="__isReactive")return!0;if(v==="__raw")return m;const y=m[v];return typeof y=="object"&&y!==null&&!y.__isReactive&&(m[v]=p.reactive(y)),m[v]},set(m,v,y){return m[v]===y||(m[v]=y,p._notifyWatchers(v,y)),!0},deleteProperty(m,v){return delete m[v],p._notifyWatchers(v,void 0),!0}},f=new Proxy(d,g);return f.__isReactive=!0,f}onMounted(d){this.lifecycle?this.lifecycle.on("mount",d,{name:"onMounted"}):this._onMountedHandlers.push(d)}onUnmounted(d){this.lifecycle?this.lifecycle.on("unmount",d,{name:"onUnmounted"}):this._onUnmountedHandlers.push(d)}onUpdated(d){this.lifecycle?this.lifecycle.on("update",d,{name:"onUpdated"}):this._onUpdatedHandlers.push(d)}watch(d,p,g={}){if(typeof d=="function"){const f=()=>{const m=d();m!==f._oldValue&&(p(m,f._oldValue),f._oldValue=m)};if(f._oldValue=void 0,this._watches.push(f),f(),s.kupolaData){const m=[],v=s.kupolaData.get;s.kupolaData.get=function(y){return m.push(y),v.call(this,y)},d(),s.kupolaData.get=v,m.forEach(y=>{s.kupolaData.observe(y,f)})}}else typeof d=="object"&&d!==null&&(d._subscribers?d._subscribers.add(p):d._key&&s.kupolaData&&s.kupolaData.observe(d._key,()=>{p(d.value)}))}computed(d){const p=this.ref();let g=()=>{try{p.value=d()}catch(v){console.error("Computed property error:",v)}};const f=[];if(s.kupolaData){const v=s.kupolaData.get;s.kupolaData.get=function(y){return f.push(y),v.call(this,y)},g(),s.kupolaData.get=v,f.forEach(y=>{s.kupolaData.observe(y,g)}),this._computedDeps.set(p,f)}else g();let m=p._value;return Object.defineProperty(p,"value",{get:()=>m,set:v=>{console.warn("Cannot assign to a computed property")}}),g=()=>{try{m=d()}catch(v){console.error("Computed property error:",v)}},p}emit(d,p){this.component&&this.component.$emit(d,p)}_notifyWatchers(d,p){this._watches.forEach(g=>{try{g()}catch(f){console.error(f)}})}_executeMounted(){this._onMountedHandlers.forEach(d=>{try{d()}catch(p){console.error(p)}})}_executeUnmounted(){this._onUnmountedHandlers.forEach(d=>{try{d()}catch(p){console.error(p)}})}_executeUpdated(){this._onUpdatedHandlers.forEach(d=>{try{d()}catch(p){console.error(p)}})}destroy(){this._watches.forEach(d=>{d._subscribers&&d._subscribers.clear()}),this._watches=[],this._computedDeps.forEach((d,p)=>{d.forEach(g=>{s.kupolaData&&s.kupolaData.unobserve(g)})}),this._computedDeps.clear(),this._refs.clear(),this._onMountedHandlers=[],this._onUnmountedHandlers=[],this._onUpdatedHandlers=[],this.component=null,this.lifecycle=null}}function r(u=null){if(t)return t.ref(u);if(s.kupolaData){const p=`__ref_${Math.random().toString(36).slice(2,11)}__`;return s.kupolaData.set(p,u),{get value(){return s.kupolaData.get(p)},set value(g){s.kupolaData.set(p,g)},_key:p}}const d={_value:u,_subscribers:new Set};return Object.defineProperty(d,"value",{get(){return d._value},set(p){p!==d._value&&(d._value=p,d._subscribers.forEach(g=>g(p)))}}),d}function o(u){if(t)return t.reactive(u);if(s.kupolaData)return s.kupolaData.createReactive(u);const d={get(g,f){if(f==="__isReactive")return!0;if(f==="__raw")return g;const m=g[f];return typeof m=="object"&&m!==null&&!m.__isReactive&&(g[f]=new Proxy(m,d),g[f].__isReactive=!0),g[f]},set(g,f,m){return g[f]===m||(g[f]=m,t&&t._notifyWatchers(f,m)),!0},deleteProperty(g,f){return delete g[f],t&&t._notifyWatchers(f,void 0),!0}},p=new Proxy(u,d);return p.__isReactive=!0,p}function n(u){t?t.onMounted(u):console.warn("onMounted called outside of setup()")}function i(u){t?t.onUnmounted(u):console.warn("onUnmounted called outside of setup()")}function a(u){t?t.onUpdated(u):console.warn("onUpdated called outside of setup()")}function l(u,d,p={}){t&&t.watch(u,d,p)}function c(u){if(t)return t.computed(u);const d=r();let p=()=>{try{d.value=u()}catch(f){console.error("Computed property error:",f)}};if(s.kupolaData){const f=[],m=s.kupolaData.get;s.kupolaData.get=function(v){return f.push(v),m.call(this,v)},p(),s.kupolaData.get=m,f.forEach(v=>{s.kupolaData.observe(v,p)})}else p();let g=d._value;return Object.defineProperty(d,"value",{get:()=>g,set:f=>{console.warn("Cannot assign to a computed property")}}),p=()=>{try{g=u()}catch(f){console.error("Computed property error:",f)}},d}function h(u){if(typeof u!="function"){console.error("setup() requires a function argument");return}const d=new e,p=t;t=d;let g;try{g=u(d)}finally{t=p}return g}s.SetupContext=e,s.ref=r,s.reactive=o,s.onMounted=n,s.onUnmounted=i,s.onUpdated=a,s.watch=l,s.computed=c,s.setup=h,s._getCurrentSetupContext=()=>t,s._setCurrentSetupContext=u=>{t=u},s._clearSetupContext=()=>{t=null}})(window);(function(s){class t{constructor(n,i={}){if(this.form=typeof n=="string"?document.querySelector(n):n,this.options={validateOnSubmit:!0,validateOnChange:!1,validateOnBlur:!1,preventDefault:!0,...i},this.submitHandlers=[],this.isSubmitting=!1,this.errors={},this.rules={},this.validator=s.kupolaValidator||new s.KupolaValidator,!this.form||!(this.form instanceof HTMLFormElement)){console.warn("[KupolaForm] Invalid form element");return}this._init()}_init(){this.options.validateOnChange&&this.form.addEventListener("input",n=>{this._validateField(n.target)}),this.options.validateOnBlur&&this.form.addEventListener("blur",n=>{n.target.form===this.form&&this._validateField(n.target)},!0)}submit(n){const i=async a=>{if(this.options.preventDefault&&a.preventDefault(),!this.isSubmitting){this.isSubmitting=!0;try{if(this.options.validateOnSubmit){const c=await this.validate();if(!c.valid){this._showErrors(c.errors);return}}const l=n(a);l instanceof Promise&&await l}finally{this.isSubmitting=!1}}};return this.submitHandlers.push(i),this.form.addEventListener("submit",i),()=>{const a=this.submitHandlers.indexOf(i);a>-1&&(this.submitHandlers.splice(a,1),this.form.removeEventListener("submit",i))}}setRules(n){return this.rules={...this.rules,...n},this._applyRulesToDOM(),this}_applyRulesToDOM(){Object.keys(this.rules).forEach(n=>{const i=this.form.querySelector(`[name="${n}"]`);if(!i)return;const a=this.rules[n],l=this._rulesToString(a);i.setAttribute("data-validate",l)})}_rulesToString(n){if(typeof n=="function")return"custom";const i=[];return Object.keys(n).forEach(a=>{const l=n[a];typeof l=="object"&&l!==null?a==="pattern"?i.push(`pattern:${l.source?.replace(/\//g,"")}`):a==="equalTo"?i.push(`equalTo:${l}`):i.push(a):typeof l=="number"||typeof l=="string"?i.push(`${a}:${l}`):l===!0&&i.push(a)}),i.join("|")}async validate(n=null){this.errors={};const i=[],a=n?Array.isArray(n)?n:[n]:this.form.querySelectorAll("input, select, textarea");for(const l of a){const c=l.name;if(!c)continue;const h=await this._validateField(l);h.length>0&&(this.errors[c]=h,i.push(...h))}return{valid:i.length===0,errors:i,fieldErrors:this.errors}}async _validateField(n){const i=n.name,a=this.rules[i];if(typeof a=="function"){const c=a(n.value.trim(),n);if(c instanceof Promise){const h=await c;if(h!==!0){const u=n.getAttribute("data-label")||n.getAttribute("placeholder")||i,d=typeof h=="string"?h:`${u} 验证失败`;return this.validator.showError(n,d),[d]}}else if(c!==!0){const h=n.getAttribute("data-label")||n.getAttribute("placeholder")||i,u=typeof c=="string"?c:`${h} 验证失败`;return this.validator.showError(n,u),[u]}return this.validator.clearError(n),[]}if(!await this.validator.validateInputAsync(n)){const c=n.parentElement?.querySelector(".ds-input__error");return c?[c.textContent]:["Validation failed"]}return[]}_showErrors(n){typeof Message<"u"?Message.error(n.join(`
257
- `)):typeof console<"u"&&console.error("Form validation errors:",n)}getValues(){const n={};return this.form.querySelectorAll("input, select, textarea").forEach(a=>{const l=a.name;l&&(a.type==="checkbox"?(n[l]||(n[l]=[]),a.checked&&n[l].push(a.value)):a.type==="radio"?a.checked&&(n[l]=a.value):a.type==="file"?n[l]=a.files:n[l]=a.value)}),n}setValues(n){return Object.keys(n).forEach(i=>{const a=this.form.querySelector(`[name="${i}"]`);if(a)if(a.type==="checkbox"){const l=Array.isArray(n[i])?n[i]:[n[i]];a.checked=l.includes(a.value)}else if(a.type==="radio"){const l=this.form.querySelector(`[name="${i}"][value="${n[i]}"]`);l&&(l.checked=!0)}else if(a.type==="file"){const l=new DataTransfer;n[i]instanceof FileList&&Array.from(n[i]).forEach(c=>{l.items.add(c)}),a.files=l.files}else a.value=n[i]}),this}reset(){return this.form.reset(),this.errors={},this.validator.resetForm(this.form),this}clearErrors(){return this.errors={},this.form.querySelectorAll(".ds-input--error").forEach(n=>{this.validator.clearError(n)}),this}getError(n){return this.errors[n]||[]}hasError(n){return this.errors[n]&&this.errors[n].length>0}destroy(){this.submitHandlers.forEach(n=>{this.form.removeEventListener("submit",n)}),this.submitHandlers=[],this.errors={},this.rules={}}}function e(o,n={}){return new t(o,n)}function r(o,n={}){return new t(o,n)}s.KupolaForm=t,s.useForm=e,s.createForm=r})(window);let jt=class{static createElement(t){const e=document.createElement("div");return e.innerHTML=t,e.firstElementChild}static mountComponent(t,e={},r=""){const o=this.createElement(r),n=new t(o);return Object.assign(n.props,e),{component:n,element:o}}static async waitFor(t,e=1e3){const r=Date.now();return new Promise((o,n)=>{const i=async()=>{try{const a=await t();a?o(a):Date.now()-r<e?requestAnimationFrame(i):n(new Error("waitFor timeout"))}catch{Date.now()-r<e?requestAnimationFrame(i):n(new Error("waitFor timeout"))}};requestAnimationFrame(i)})}static async waitForElement(t,e=document,r=1e3){return this.waitFor(()=>e.querySelector(t),r)}static async waitForText(t,e=document,r=1e3){return this.waitFor(()=>e.textContent.includes(t),r)}static fireEvent(t,e,r={}){const o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});t.dispatchEvent(o)}static fireInput(t,e){t.value=e,this.fireEvent(t,"input"),this.fireEvent(t,"change")}static fireClick(t){this.fireEvent(t,"click")}static fireKeyDown(t,e){const r=new KeyboardEvent("keydown",{key:e,bubbles:!0});t.dispatchEvent(r)}static async nextTick(){return new Promise(t=>requestAnimationFrame(t))}static mockDate(t){const e=Date.now,r=Date;return Date.now=()=>t.getTime(),globalThis.Date=class extends Date{constructor(...o){return super(...o),o.length===0?new Date(t):new r(...o)}},()=>{Date.now=e,globalThis.Date=r}}static mockFetch(t){const e=fetch;return globalThis.fetch=jest.fn(async(r,o)=>{for(const n of t)if(typeof n.url=="string"&&r===n.url||n.url instanceof RegExp&&n.url.test(r)||n.method&&o&&o.method===n.method)return n.response();return e(r,o)}),()=>{globalThis.fetch=e}}static async mountAndWait(t,e={},r=""){const{component:o,element:n}=this.mountComponent(t,e,r);return await o.mount(),await this.nextTick(),{component:o,element:n}}static async unmountAndWait(t){await t.unmount(),await this.nextTick()}static getByText(t,e){const r=t.querySelectorAll("*");for(const o of r)if(o.textContent.trim()===e)return o;throw new Error(`Element with text "${e}" not found`)}static queryByText(t,e){const r=t.querySelectorAll("*");for(const o of r)if(o.textContent.trim()===e)return o;return null}static getByTestId(t,e){const r=t.querySelector(`[data-testid="${e}"]`);if(!r)throw new Error(`Element with data-testid="${e}" not found`);return r}static queryByTestId(t,e){return t.querySelector(`[data-testid="${e}"]`)}static getByRole(t,e){const r=t.querySelector(`[role="${e}"]`);if(!r)throw new Error(`Element with role="${e}" not found`);return r}static queryByRole(t,e){return t.querySelector(`[role="${e}"]`)}static async simulateDrag(t,e,r,o,n){this.fireEvent(t,"dragstart",{clientX:e,clientY:r}),this.fireEvent(t,"drag",{clientX:(e+o)/2,clientY:(r+n)/2}),this.fireEvent(t,"dragend",{clientX:o,clientY:n})}static async simulateTouch(t,e,r,o,n){const i=new TouchEvent("touchstart",{touches:[{clientX:e,clientY:r}],bubbles:!0});t.dispatchEvent(i);const a=new TouchEvent("touchmove",{touches:[{clientX:(e+o)/2,clientY:(r+n)/2}],bubbles:!0});t.dispatchEvent(a);const l=new TouchEvent("touchend",{touches:[{clientX:o,clientY:n}],bubbles:!0});t.dispatchEvent(l)}static async waitForState(t,e,r){return this.waitFor(()=>t.state[e]===r)}static async waitForProps(t,e,r){return this.waitFor(()=>t.props[e]===r)}static async waitForEmitted(t,e){return this.waitFor(()=>t._emitted&&t._emitted[e])}static spyOn(t,e){const r=t[e],o=function(...n){return o.called=!0,o.callCount=(o.callCount||0)+1,o.args=(o.args||[]).concat([n]),r.apply(this,n)};return t[e]=o,()=>{t[e]=r}}static async flushPromises(){return new Promise(t=>setImmediate(t))}};window.KupolaTestUtils=jt;window.testUtils=jt;let ct=class{constructor(t={}){this.locales=t.locales||{},this.currentLocale=t.defaultLocale||"zh-CN",this.fallbackLocale=t.fallbackLocale||"zh-CN",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(e=>(console.warn(`Missing translation: ${e}`),e)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(r=>{const o=r.dataset.kupolaI18n;if(o)try{const n=JSON.parse(r.textContent);this.addLocale(o,n)}catch(n){console.error("Failed to parse i18n data:",n)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const r of Object.keys(e))e[r]instanceof Object&&r in t?this._mergeDeep(t[r],e[r]):t[r]=e[r]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let r=this._getTranslation(t,this.currentLocale);return r||(r=this._getTranslation(t,this.fallbackLocale)),r?this._interpolate(r,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const r=t.split(this.delimiter);let o=this.locales[e];for(const n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return null;return typeof o=="string"?o:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>e[o]!==void 0?e[o]:r)}n(t,e,r={}){const o=this.t(t,{...r,count:e});if(!o)return o;const n=o.split("|");return n.length===1?o.replace("{count}",e):n.length===2?e===1?n[0]:n[1]:n.length>=3?e===0?n[0]:e===1?n[1]:n[2]:o}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const o=await(await fetch(e)).json();return this.addLocale(t,o),!0}catch(r){return console.error("Failed to load locale:",r),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const r=e.locale||this.currentLocale,o=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(r,e).format(o)}formatNumber(t,e={}){const r=e.locale||this.currentLocale;return new Intl.NumberFormat(r,e).format(t)}formatCurrency(t,e,r={}){const o=r.locale||this.currentLocale;return new Intl.NumberFormat(o,{style:"currency",currency:e,...r}).format(t)}formatRelativeTime(t,e,r={}){const o=r.locale||this.currentLocale;return new Intl.RelativeTimeFormat(o,r).format(t,e)}};const I=new ct;function Ai(s){return new ct(s)}function qi(s,t={}){return I.t(s,t)}function zi(s,t,e={}){return I.n(s,t,e)}function Pi(s){return I.setLocale(s)}function $i(){return I.getLocale()}function Ri(s,t={}){return I.formatDate(s,t)}function Fi(s,t={}){return I.formatNumber(s,t)}function Oi(s,t,e={}){return I.formatCurrency(s,t,e)}window.KupolaI18n=ct;window.kupolaI18n=I;window.createI18n=Ai;window.t=qi;window.n=zi;window.setLocale=Pi;window.getLocale=$i;window.formatDate=Ri;window.formatNumber=Fi;window.formatCurrency=Oi;let Gt=class{constructor(){this.listeners=new Map,this.scopes=new Map}on(t,e,r,o={}){const n=this._getKey(t,e);this.listeners.has(n)||this.listeners.set(n,[]);const i=c=>{r.before&&typeof r.before=="function"&&r.before(c);const h=r(c);return r.after&&typeof r.after=="function"&&r.after(c,h),h},a={handler:r,wrapper:i,options:o,active:!0};this.listeners.get(n).push(a),o.scope&&(this.scopes.has(o.scope)||this.scopes.set(o.scope,[]),this.scopes.get(o.scope).push({target:t,eventType:e,handler:r,wrapper:i})),t.addEventListener(e,i,o);const l=()=>{if(t.removeEventListener(e,i,o),this.listeners.has(n)){const c=this.listeners.get(n),h=c.indexOf(a);h!==-1&&c.splice(h,1)}if(o.scope&&this.scopes.has(o.scope)){const c=this.scopes.get(o.scope),h=c.findIndex(u=>u.target===t&&u.eventType===e&&u.handler===r);h!==-1&&c.splice(h,1)}a.active=!1};return a.unsubscribe=l,a}off(t,e,r){const o=this._getKey(t,e);if(!this.listeners.has(o))return;const n=this.listeners.get(o),i=n.findIndex(a=>a.handler===r);if(i!==-1){const a=n[i];t.removeEventListener(e,a.wrapper,a.options),a.active=!1,n.splice(i,1),a.options.scope&&this._removeFromScope(a.options.scope,t,e,r)}}once(t,e,r,o={}){const n=i=>(this.off(t,e,n),r(i));return this.on(t,e,n,o)}clearScope(t){if(!this.scopes.has(t))return;this.scopes.get(t).forEach(({target:r,eventType:o,handler:n,wrapper:i})=>{r.removeEventListener(o,i);const a=this._getKey(r,o);if(this.listeners.has(a)){const l=this.listeners.get(a),c=l.findIndex(h=>h.handler===n);c!==-1&&(l[c].active=!1,l.splice(c,1))}}),this.scopes.delete(t)}_removeFromScope(t,e,r,o){if(!this.scopes.has(t))return;const n=this.scopes.get(t),i=n.findIndex(a=>a.target===e&&a.eventType===r&&a.handler===o);i!==-1&&n.splice(i,1)}_getKey(t,e){return`${t===document?"document":t===window?"window":t===document.body?"body":t.nodeName?t.nodeName:"unknown"}:${e}`}getListenerCount(t,e){const r=this._getKey(t,e);return this.listeners.has(r)?this.listeners.get(r).length:0}getAllListenerCounts(){const t={};return this.listeners.forEach((e,r)=>{t[r]=e.filter(o=>o.active).length}),t}cleanup(){this.listeners.forEach((t,e)=>{const[r,o]=e.split(":");let n;r==="document"?n=document:r==="window"?n=window:r==="body"&&(n=document.body),n&&t.forEach(i=>{n.removeEventListener(o,i.wrapper,i.options)})}),this.listeners.clear(),this.scopes.clear()}};const A=new Gt;function Ni(s,t,e,r){return A.on(s,t,e,r)}function Bi(s,t,e){A.off(s,t,e)}function Ki(s,t,e,r){return A.once(s,t,e,r)}function Ui(s){A.clearScope(s)}window.GlobalEventManager=Gt;window.globalEvents=A;window.on=Ni;window.off=Bi;window.once=Ki;window.clearScope=Ui;let Qt=class{constructor(){this.csrfToken=null,this.cspEnabled=!1}init(){this._initCSRF(),this._initCSP()}_initCSRF(){const t=document.querySelector('meta[name="csrf-token"]');t&&(this.csrfToken=t.getAttribute("content"))}_initCSP(){document.querySelector('meta[http-equiv="Content-Security-Policy"]')&&(this.cspEnabled=!0)}getCSRFToken(){return this.csrfToken}setCSRFToken(t){this.csrfToken=t;const e=document.querySelector('meta[name="csrf-token"]');e&&e.setAttribute("content",t)}addCSRFHeader(t){return this.csrfToken&&(t.headers=t.headers||{},t.headers["X-CSRF-Token"]=this.csrfToken),t}escapeHtml(t){if(!t||typeof t!="string")return t;const e=document.createElement("div");return e.textContent=t,e.innerHTML}sanitize(t){if(!t||typeof t!="string")return t;const e=["b","strong","i","em","u","s","strike","sub","sup","a","br","p","span","div","h1","h2","h3","h4","h5","h6","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","iframe"],r=["href","src","alt","title","class","id","data-*","width","height","frameborder","allowfullscreen"],o=document.createElement("div");o.innerHTML=t;const n=i=>{if(i.nodeType===Node.ELEMENT_NODE){const a=i.tagName.toLowerCase();if(!e.includes(a)){i.parentNode.replaceChild(document.createTextNode(i.textContent),i);return}Array.from(i.attributes).forEach(l=>{const c=l.name.toLowerCase();r.includes(c)||c.startsWith("data-")?(c==="href"||c==="src")&&(this._isSafeUrl(l.value)||i.removeAttribute(l.name)):i.removeAttribute(l.name)})}for(let a=i.childNodes.length-1;a>=0;a--)n(i.childNodes[a])};return n(o),o.innerHTML}_isSafeUrl(t){try{const e=new URL(t);return["http:","https:","data:","mailto:","tel:"].includes(e.protocol)}catch{return!1}}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateURL(t){try{return new URL(t),!0}catch{return!1}}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t.replace(/\s/g,""))}generateSecureHash(t){if(!t||typeof t!="string")return"";let e=0;for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);e=(e<<5)-e+o,e=e&e}return Math.abs(e).toString(36)}isXSSAttack(t){return!t||typeof t!="string"?!1:[/<script[^>]*>.*?<\/script>/gi,/<img[^>]*onerror[^>]*>/gi,/javascript:/gi,/vbscript:/gi,/onload[^>]*=/gi,/onclick[^>]*=/gi,/onmouseover[^>]*=/gi,/<iframe[^>]*>/gi].some(r=>r.test(t))}protectForm(t){t instanceof HTMLFormElement&&t.addEventListener("submit",e=>{const r=t.querySelectorAll("input, textarea");let o=!1;r.forEach(n=>{this.isXSSAttack(n.value)?(o=!0,n.classList.add("ds-input--error")):n.classList.remove("ds-input--error")}),o&&(e.preventDefault(),console.error("[KupolaSecurity] XSS attack detected in form"))})}};const Vi=new Qt;window.kupolaSecurity=Vi;window.KupolaSecurity=Qt;let Zt=class{constructor(){this.handlers=new Map,this.errorLog=[],this.maxLogs=100,this.globalHandler=null}init(){this._installGlobalHandlers()}_installGlobalHandlers(){window.addEventListener("error",t=>{this.handleError(t.error||t.message,{source:t.filename,line:t.lineno,column:t.colno,type:"global"})}),window.addEventListener("unhandledrejection",t=>{this.handleError(t.reason,{type:"promise",rejection:!0})})}setGlobalHandler(t){typeof t=="function"&&(this.globalHandler=t)}handleError(t,e={}){const r=this._normalizeError(t,e);if(this._logError(r),this._notifyHandlers(r),this.globalHandler)try{this.globalHandler(r)}catch(o){console.error("[KupolaErrorHandler] Error in global handler:",o)}return r}_normalizeError(t,e){const r={id:this._generateId(),timestamp:Date.now(),message:"",stack:"",type:e.type||"unknown",source:e.source||"",line:e.line||0,column:e.column||0,component:e.component||"",hook:e.hook||"",args:e.args||[],...e};return t instanceof Error?(r.message=t.message,r.stack=t.stack||"",r.name=t.name):typeof t=="string"?r.message=t:t&&typeof t=="object"&&(r.message=t.message||JSON.stringify(t),r.stack=t.stack||"",r.name=t.name||""),r}_generateId(){return`err-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_logError(t){this.errorLog.unshift(t),this.errorLog.length>this.maxLogs&&this.errorLog.pop(),console.error(`[KupolaError] [${t.type}] ${t.message}`,t)}_notifyHandlers(t){this.handlers.forEach((e,r)=>{try{e(t)}catch(o){console.error(`[KupolaErrorHandler] Error in handler "${r}":`,o)}})}on(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)}off(t,e){if(!this.handlers.has(t))return;const r=this.handlers.get(t),o=r.indexOf(e);o>-1&&r.splice(o,1)}getErrorLog(){return[...this.errorLog]}clearErrorLog(){this.errorLog=[]}getErrorCount(){return this.errorLog.length}getErrorByType(t){return this.errorLog.filter(e=>e.type===t)}captureErrors(t,e){!t||!e||!Array.isArray(e)||e.forEach(r=>{if(typeof t[r]=="function"){const o=t[r];t[r]=function(...n){try{const i=o.apply(this,n);return i instanceof Promise?i.catch(a=>{throw at.handleError(a,{type:"method",component:t.constructor?.name||"",hook:r,args:n}),a}):i}catch(i){throw at.handleError(i,{type:"method",component:t.constructor?.name||"",hook:r,args:n}),i}}}})}};const at=new Zt;window.kupolaErrorHandler=at;window.KupolaErrorHandler=Zt;let te=class{constructor(){this.metrics=new Map,this.timers=new Map,this.observers=[],this.enabled=!1,this.thresholds={render:16,mount:100,update:50,http:3e3}}init(){this.enabled=!0,this._setupObservers(),this._measureNavigation()}_setupObservers(){if("PerformanceObserver"in window){const t=new PerformanceObserver(o=>{o.getEntries().forEach(n=>{this._recordMetric("paint",{name:n.name,startTime:n.startTime,duration:n.duration})})});t.observe({type:"paint",buffered:!0}),this.observers.push(t);const e=new PerformanceObserver(o=>{o.getEntries().forEach(n=>{this._recordMetric("resource",{name:n.name,type:n.initiatorType,duration:n.duration,size:n.transferSize,startTime:n.startTime})})});e.observe({type:"resource",buffered:!0}),this.observers.push(e);const r=new PerformanceObserver(o=>{o.getEntries().forEach(n=>{this._recordMetric("longtask",{duration:n.duration,startTime:n.startTime})})});r.observe({type:"longtask",buffered:!0}),this.observers.push(r)}}_measureNavigation(){if("performance"in window){const t=performance.getEntriesByType("navigation")[0];t&&this._recordMetric("navigation",{domContentLoaded:t.domContentLoadedEventEnd-t.fetchStart,load:t.loadEventEnd-t.fetchStart,firstByte:t.responseStart-t.requestStart,redirectCount:t.redirectCount})}}startTimer(t,e={}){this.enabled&&this.timers.set(t,{startTime:performance.now(),context:e})}stopTimer(t){if(!this.enabled)return null;const e=this.timers.get(t);if(!e)return null;const r=performance.now()-e.startTime;return this.timers.delete(t),this._recordMetric("timer",{name:t,duration:r,...e.context}),r}_recordMetric(t,e){if(!this.enabled)return;const r={type:t,timestamp:Date.now(),...e};this.metrics.has(t)||this.metrics.set(t,[]),this.metrics.get(t).push(r)}measure(t,e,r={}){if(!this.enabled)return t();this.startTimer(e,r);let o,n;try{o=t()}catch(i){n=i}if(this.stopTimer(e),n)throw n;return o}measureAsync(t,e,r={}){return this.enabled?(this.startTimer(e,r),t().then(o=>(this.stopTimer(e),o)).catch(o=>{throw this.stopTimer(e),o})):t()}getMetrics(t){return t?this.metrics.get(t)||[]:Array.from(this.metrics.entries())}getSummary(){const t={navigation:null,paint:null,timers:[],resources:[],longTasks:[]};return this.metrics.has("navigation")&&(t.navigation=this.metrics.get("navigation")[0]),this.metrics.has("paint")&&(t.paint=this.metrics.get("paint")),this.metrics.has("timer")&&(t.timers=this.metrics.get("timer")),this.metrics.has("resource")&&(t.resources=this.metrics.get("resource")),this.metrics.has("longtask")&&(t.longTasks=this.metrics.get("longtask")),t}getPerformanceScore(){const t=this.getSummary();let e=100;if(t.navigation&&(t.navigation.load>3e3?e-=20:t.navigation.load>2e3&&(e-=10),t.navigation.domContentLoaded>1500?e-=15:t.navigation.domContentLoaded>1e3&&(e-=5)),t.paint){const r=t.paint.find(o=>o.name==="first-contentful-paint");r&&r.startTime>2e3?e-=20:r&&r.startTime>1e3&&(e-=10)}return t.longTasks.length>0&&(e-=t.longTasks.length*10),Math.max(0,e)}logSummary(){const t=this.getSummary(),e=this.getPerformanceScore();console.group("[KupolaPerformance] Summary"),console.log("Score:",e),console.log("Navigation:",t.navigation),console.log("Paint:",t.paint),console.log("Long Tasks:",t.longTasks.length),console.groupEnd()}clear(){this.metrics.clear(),this.timers.clear()}destroy(){this.observers.forEach(t=>{t.disconnect()}),this.observers=[],this.clear(),this.enabled=!1}};const Wi=new te;window.kupolaPerformance=Wi;window.KupolaPerformance=te;const ee=window.KupolaComponent,se=window.KupolaComponentRegistry,ie=window.KupolaRouter,ne=window.KupolaHttp,re=window.KupolaStatePersist,oe=window.KupolaLifecycle,ae=window.KupolaPluginManager,le=window.KupolaDevTools,ce=window.kupolaRegistry,de=window.kupolaPersist,he=window.kupolaLifecycle,ue=window.kupolaPluginManager,pe=window.KupolaUtils,fe=window.createRouter,me=window.createHttp,ge=window.createLifecycle,ye=window.createStore,ve=window.getStore,_e=window.registerComponent,we=window.registerLazyComponent,xe=window.bootstrapComponents,be=window.defineMixin,ke=window.useMixin,Ee=window.initTheme,Ce=window.setTheme,Se=window.getTheme,Le=window.setBrand,He=window.getBrand,De=window.initDropdowns,Me=window.initSelects,Ie=window.initDatePickers,Te=window.initTimePickers,Ae=window.initSliders,qe=window.initCarousels,ze=window.initDrawers,Pe=window.initModals,$e=window.initDialogs,Re=window.initNotifications,Fe=window.initMessages,Oe=window.initFileUploads,Ne=window.initCollapses,Be=window.initColorPickers,Ke=window.initCalendars,Ue=window.initDynamicTags,Ve=window.initImagePreviews,We=window.initTags,Ye=window.initStatCards,Xe=window.initHeatmaps,Je=window.initTooltips,je=window.initValidation,Ge=window.initVirtualLists,Qe=window.initIcons,Ze=window.initCountdowns,ts=window.initNumberInputs,es=window.initSlideCaptchas,ss=window.setup,is=window.ref,ns=window.reactive,rs=window.onMounted,os=window.onUnmounted,as=window.onUpdated,ls=window.watch,cs=window.computed,ds=window.KupolaForm,hs=window.useForm,us=window.createForm,ps=window.KupolaTestUtils,fs=window.testUtils,ms=window.KupolaI18n,gs=window.kupolaI18n,ys=window.createI18n,vs=window.t,_s=window.n,ws=window.setLocale,xs=window.getLocale,bs=window.formatDate,ks=window.formatNumber,Es=window.formatCurrency,Cs=window.GlobalEventManager,Ss=window.globalEvents,Ls=window.on,Hs=window.off,Ds=window.once,Ms=window.clearScope,Is=window.KupolaSecurity,Ts=window.kupolaSecurity,As=window.KupolaErrorHandler,qs=window.kupolaErrorHandler,zs=window.KupolaPerformance,Ps=window.kupolaPerformance,Yi={KupolaComponent:ee,KupolaComponentRegistry:se,KupolaRouter:ie,KupolaHttp:ne,KupolaStatePersist:re,KupolaLifecycle:oe,KupolaPluginManager:ae,KupolaDevTools:le,KupolaSecurity:Is,KupolaErrorHandler:As,KupolaPerformance:zs,kupolaRegistry:ce,kupolaPersist:de,kupolaLifecycle:he,kupolaPluginManager:ue,kupolaSecurity:Ts,kupolaErrorHandler:qs,kupolaPerformance:Ps,KupolaUtils:pe,createRouter:fe,createHttp:me,createLifecycle:ge,createStore:ye,getStore:ve,registerComponent:_e,registerLazyComponent:we,bootstrapComponents:xe,defineMixin:be,useMixin:ke,initTheme:Ee,setTheme:Ce,getTheme:Se,setBrand:Le,getBrand:He,initDropdowns:De,initSelects:Me,initDatePickers:Ie,initTimePickers:Te,initSliders:Ae,initCarousels:qe,initDrawers:ze,initModals:Pe,initDialogs:$e,initNotifications:Re,initMessages:Fe,initFileUploads:Oe,initCollapses:Ne,initColorPickers:Be,initCalendars:Ke,initDynamicTags:Ue,initImagePreviews:Ve,initTags:We,initStatCards:Ye,initHeatmaps:Xe,initTooltips:Je,initValidation:je,initVirtualLists:Ge,initIcons:Qe,initCountdowns:Ze,initNumberInputs:ts,initSlideCaptchas:es,setup:ss,ref:is,reactive:ns,onMounted:rs,onUnmounted:os,onUpdated:as,watch:ls,computed:cs,KupolaForm:ds,useForm:hs,createForm:us,KupolaTestUtils:ps,testUtils:fs,KupolaI18n:ms,kupolaI18n:gs,createI18n:ys,t:vs,n:_s,setLocale:ws,getLocale:xs,formatDate:bs,formatNumber:ks,formatCurrency:Es,GlobalEventManager:Cs,globalEvents:Ss,on:Ls,off:Hs,once:Ds,clearScope:Ms};exports.GlobalEventManager=Cs;exports.KupolaComponent=ee;exports.KupolaComponentRegistry=se;exports.KupolaDevTools=le;exports.KupolaErrorHandler=As;exports.KupolaForm=ds;exports.KupolaHttp=ne;exports.KupolaI18n=ms;exports.KupolaLifecycle=oe;exports.KupolaPerformance=zs;exports.KupolaPluginManager=ae;exports.KupolaRouter=ie;exports.KupolaSecurity=Is;exports.KupolaStatePersist=re;exports.KupolaTestUtils=ps;exports.KupolaUtils=pe;exports.bootstrapComponents=xe;exports.clearScope=Ms;exports.computed=cs;exports.createForm=us;exports.createHttp=me;exports.createI18n=ys;exports.createLifecycle=ge;exports.createRouter=fe;exports.createStore=ye;exports.default=Yi;exports.defineMixin=be;exports.formatCurrency=Es;exports.formatDate=bs;exports.formatNumber=ks;exports.getBrand=He;exports.getLocale=xs;exports.getStore=ve;exports.getTheme=Se;exports.globalEvents=Ss;exports.initCalendars=Ke;exports.initCarousels=qe;exports.initCollapses=Ne;exports.initColorPickers=Be;exports.initCountdowns=Ze;exports.initDatePickers=Ie;exports.initDialogs=$e;exports.initDrawers=ze;exports.initDropdowns=De;exports.initDynamicTags=Ue;exports.initFileUploads=Oe;exports.initHeatmaps=Xe;exports.initIcons=Qe;exports.initImagePreviews=Ve;exports.initMessages=Fe;exports.initModals=Pe;exports.initNotifications=Re;exports.initNumberInputs=ts;exports.initSelects=Me;exports.initSlideCaptchas=es;exports.initSliders=Ae;exports.initStatCards=Ye;exports.initTags=We;exports.initTheme=Ee;exports.initTimePickers=Te;exports.initTooltips=Je;exports.initValidation=je;exports.initVirtualLists=Ge;exports.kupolaErrorHandler=qs;exports.kupolaI18n=gs;exports.kupolaLifecycle=he;exports.kupolaPerformance=Ps;exports.kupolaPersist=de;exports.kupolaPluginManager=ue;exports.kupolaRegistry=ce;exports.kupolaSecurity=Ts;exports.n=_s;exports.off=Hs;exports.on=Ls;exports.onMounted=rs;exports.onUnmounted=os;exports.onUpdated=as;exports.once=Ds;exports.reactive=ns;exports.ref=is;exports.registerComponent=_e;exports.registerLazyComponent=we;exports.setBrand=Le;exports.setLocale=ws;exports.setTheme=Ce;exports.setup=ss;exports.t=vs;exports.testUtils=fs;exports.useForm=hs;exports.useMixin=ke;exports.watch=ls;
312
+ <div class="ds-dialog__body"></div>
313
+ <div class="ds-dialog__foot"></div>
314
+ </div>
315
+ `;const i=e.querySelector(".ds-dialog__body"),n=this.querySelector('[slot="body"]');n&&i.appendChild(n);const r=e.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&r.appendChild(a);const o=e.querySelector(".ds-dialog__close");o&&o.addEventListener("click",()=>this.close()),e.addEventListener("click",l=>{l.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,i){if(t==="open"){const n=this.querySelector(".ds-backdrop");n&&(n.style.display=i!==null?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}function ps(){if(Be||typeof customElements>"u")return;Be=!0;const s=[["k-dropdown",ls],["k-tooltip",cs],["k-collapse",ds],["k-collapse-item",As],["k-drawer",hs],["k-modal",us]];for(const[t,e]of s)customElements.get(t)||customElements.define(t,e)}typeof window<"u"&&(window.registerWebComponents=ps,window.KupolaDropdownElement=ls,window.KupolaTooltipElement=cs,window.KupolaCollapseElement=ds,window.KupolaDrawerElement=hs,window.KupolaModalElement=us);exports.BRAND_OPTIONS=$;exports.CacheEntry=ji;exports.CacheManager=Mt;exports.Calendar=ue;exports.Carousel=le;exports.Collapse=de;exports.ColorPicker=he;exports.ComponentInitializerRegistry=ee;exports.Countdown=we;exports.Datepicker=re;exports.DependsError=A;exports.DependsSource=B;exports.Dialog=bi;exports.Drawer=Et;exports.Dropdown=se;exports.DynamicTags=pe;exports.FetchedSource=ts;exports.FileUpload=ce;exports.FunctionSource=is;exports.GlobalEvents=Ce;exports.Heatmap=Lt;exports.Icons=qi;exports.ImagePreview=St;exports.KupolaComponent=O;exports.KupolaComponentRegistry=ie;exports.KupolaDataBind=Gt;exports.KupolaEventBus=Qt;exports.KupolaForm=Ee;exports.KupolaI18n=xt;exports.KupolaLifecycle=R;exports.KupolaPagination=Te;exports.KupolaStore=U;exports.KupolaStoreManager=Zt;exports.KupolaTable=He;exports.KupolaUtils=Tt;exports.KupolaValidator=_e;exports.Message=Ei;exports.Modal=I;exports.Notification=ki;exports.NumberInput=be;exports.PATHS=ye;exports.RouteSource=es;exports.Scheduler=Se;exports.Select=ne;exports.SlideCaptcha=ke;exports.Slider=oe;exports.StatCard=me;exports.StaticSource=ss;exports.StorageSource=Le;exports.Tag=fe;exports.Timepicker=ae;exports.Tooltip=ge;exports.VirtualList=Dt;exports.WebSocketSource=De;exports.alertModal=vi;exports.applyMixin=X;exports.bootstrapComponents=Ge;exports.cleanupAllDropdowns=di;exports.cleanupAllSlideCaptchas=Jt;exports.cleanupCalendar=Ft;exports.cleanupCarousel=gi;exports.cleanupCollapse=Bt;exports.cleanupColorPicker=ct;exports.cleanupCountdown=Ut;exports.cleanupDatepicker=et;exports.cleanupDrawer=Pt;exports.cleanupDropdown=G;exports.cleanupDynamicTags=Nt;exports.cleanupFileUpload=qt;exports.cleanupHeatmap=Vt;exports.cleanupModal=$t;exports.cleanupNumberInput=Yt;exports.cleanupSelect=Q;exports.cleanupSlideCaptcha=xe;exports.cleanupSlider=zt;exports.cleanupStatCard=Rt;exports.cleanupTag=Ot;exports.cleanupTimepicker=At;exports.cleanupTooltip=Kt;exports.cleanupVirtualList=Wt;exports.clearCache=as;exports.configureHttpClient=Gi;exports.confirmModal=yi;exports.createBrandPicker=Xe;exports.createI18n=ei;exports.createLifecycle=Oe;exports.createModal=Ct;exports.createSource=Me;exports.createStore=Ve;exports.createThemeToggle=Ye;exports.defineComponent=ti;exports.defineMixin=Ze;exports.emit=Wi;exports.emitGlobal=Ui;exports.formatCurrency=li;exports.formatDate=ai;exports.formatNumber=oi;exports.getBrand=F;exports.getFormInstance=Ni;exports.getHttpClient=Zi;exports.getListenerCount=Ji;exports.getLocale=ri;exports.getStore=Ke;exports.getTheme=q;exports.globalEvents=T;exports.initAllTables=Is;exports.initCalendar=dt;exports.initCalendars=Mi;exports.initCarousel=nt;exports.initCarousels=mi;exports.initCollapse=ot;exports.initCollapses=Li;exports.initColorPicker=lt;exports.initColorPickers=Di;exports.initCountdown=wt;exports.initCountdowns=Bi;exports.initDatepicker=tt;exports.initDatepickers=ui;exports.initDrawer=W;exports.initDrawers=_i;exports.initDropdown=j;exports.initDropdowns=ci;exports.initDynamicTags=ht;exports.initDynamicTagsAll=Hi;exports.initFileUpload=at;exports.initFileUploads=Si;exports.initFormValidation=jt;exports.initHeatmap=ft;exports.initHeatmaps=Pi;exports.initImagePreview=Ii;exports.initMessages=Ci;exports.initModal=rt;exports.initModals=wi;exports.initNotifications=xi;exports.initNumberInput=bt;exports.initNumberInputs=Fi;exports.initPagination=os;exports.initSelect=Z;exports.initSelects=hi;exports.initSlideCaptchas=Xt;exports.initSlider=st;exports.initSliders=fi;exports.initStatCard=pt;exports.initStatCards=zi;exports.initTable=Ie;exports.initTag=ut;exports.initTags=Ai;exports.initTheme=te;exports.initTimepicker=it;exports.initTimepickers=pi;exports.initTooltip=gt;exports.initTooltips=$i;exports.initVirtualList=yt;exports.kupolaBootstrap=J;exports.kupolaData=Y;exports.kupolaEvents=Re;exports.kupolaI18n=z;exports.kupolaInitializer=S;exports.kupolaLifecycle=Ne;exports.kupolaStoreManager=kt;exports.n=si;exports.off=Ki;exports.offAll=Xi;exports.offByScope=Yi;exports.on=Ri;exports.once=Vi;exports.ref=L;exports.registerComponent=Je;exports.registerLazyComponent=je;exports.registerWebComponents=ps;exports.renderIcon=vt;exports.resetHttpClient=Qi;exports.setBrand=K;exports.setLocale=ni;exports.setTheme=V;exports.showImagePreview=Ti;exports.svg=ve;exports.t=ii;exports.useDeps=ns;exports.useMixin=Qe;exports.useQuery=rs;exports.validateForm=Oi;exports.validator=D;
258
316
  //# sourceMappingURL=kupola.cjs.js.map