@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
- (function(y,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(y=typeof globalThis<"u"?globalThis:y||self,A(y.Kupola={}))})(this,function(y){"use strict";var A={exports:{}},ht;function ut(){return ht||(ht=1,function(i){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 s=n.name.replace("data-prop-","");let a=n.value;try{a=JSON.parse(a)}catch{}o[s]=a}return o}_parseSlots(){const o={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const a=s.getAttribute("data-slot")||"default";o[a]=s.innerHTML.trim(),s.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(s=>s!==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
+ (function(d,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(d=typeof globalThis<"u"?globalThis:d||self,A(d.Kupola={}))})(this,function(d){"use strict";class A{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((a,r)=>r.priority-a.priority),()=>{const a=n.findIndex(r=>r.handler===e);a>-1&&n.splice(a,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const i of t){const a=this.hooks.get(e).find(r=>r.name===i);a&&!a.resolved&&(await a.handler(),a.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 a=performance.now();try{for(const l of i){await this._resolveDepends(l.depends,t);const o=performance.now();let c,h;try{c=l.handler(...e),c instanceof Promise&&await c,l.resolved=!0}catch(p){h=p,console.error(`[KupolaLifecycle] Error in ${t} hook "${l.name}":`,p),t!=="error"&&await this._handleError({phase:t,hook:l.name,error:p,args:e})}const u=performance.now()-o;this.trace.push({emitId:n,phase:t,hookName:l.name,duration:u,status:h?"error":"success",error:h?h.message:null,timestamp:Date.now()})}const r=performance.now()-a;console.debug(`[KupolaLifecycle] ${t} completed in ${r.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)}`,a=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(a),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),i&&this._updateState(i.to),this.allPhases.includes(a)&&await this.emit(a,...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 ze{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 A(`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 a=typeof window<"u"&&window.kupolaLifecycle?.on(n,e[n],{name:`${t}:${n}`});a&&i.push({phase:n,unsubscribe:a})})}_unregisterPluginHooks(t){const e=this.pluginHooks.get(t);e&&(e.forEach(({unsubscribe:i})=>{i&&i()}),this.pluginHooks.delete(t))}}const Pe=new A("app"),ms=new ze;function $e(s="app"){return new A(s)}typeof window<"u"&&(window.KupolaLifecycle=A,window.KupolaPluginManager=ze,window.kupolaLifecycle=Pe,window.kupolaPluginManager=ms,window.createLifecycle=$e);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 a=typeof i=="object"?i[t]:i,r=typeof n=="object"?n[t]:n;return a<r?e==="asc"?-1:1:a>r?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,a)=>n&&n[a],s)||e},set(s,t,e){if(!s||typeof s!="object")return s;const i=t.split("."),n=i.pop();let a=s;return i.forEach(r=>{a[r]||(a[r]={}),a=a[r]}),a[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,a)=>i.set(a,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 a=typeof n=="object"?n[t]:n,r=e?n[e]:n;return a!==void 0&&(i[a]=r),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"),a=String(s.getHours()).padStart(2,"0"),r=String(s.getMinutes()).padStart(2,"0"),l=String(s.getSeconds()).padStart(2,"0"),o=String(s.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][s.getDay()];return t.replace("YYYY",e).replace("MM",i).replace("DD",n).replace("HH",a).replace("mm",r).replace("ss",l).replace("SSS",o).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(),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,a=24*n,r=7*a,l=30*a,o=365*a;return e<i?"刚刚":e<n?`${Math.floor(e/i)}分钟前`:e<a?`${Math.floor(e/n)}小时前`:e<r?`${Math.floor(e/a)}天前`:e<l?`${Math.floor(e/r)}周前`:e<o?`${Math.floor(e/l)}个月前`:`${Math.floor(e/o)}年前`}},debounce(s,t,e={}){let i=null,n=null,a=null,r=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){s.apply(a,n)}function h(){r=Date.now(),l?(i=setTimeout(u,t),c()):i=setTimeout(u,t)}function u(){i=null,o&&n&&c(),n=null,a=null}function p(){const m=Date.now()-r;return Math.max(0,t-m)}return function(...m){n=m,a=this,r=Date.now(),i?(clearTimeout(i),i=setTimeout(u,p())):h()}},throttle(s,t,e={}){let i=!1;const n=e.trailing||!1;let a=null,r=null;function l(){s.apply(r,a),a=null,r=null}return function(...o){i?n&&(a=o,r=this):(i=!0,a=o,r=this,l(),setTimeout(()=>{i=!1,n&&a&&l()},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 a=e.length-1;a>=0;a--){let r=parseInt(e[a],10);n&&(r*=2,r>9&&(r-=9)),i+=r,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,a,r]=e;return parseInt(i)>=0&&parseInt(i)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseInt(a)>=0&&parseInt(a)<=255&&parseFloat(r)>=0&&parseFloat(r)<=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],a=t[i],r=[];a.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");this[o](n,...c)||r.push(o)}else if(typeof l=="function"){const o=l(n,s);o!==!0&&r.push(o||"validation_failed")}}),r.length>0&&(e[i]=r)}),{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 a(u,p){return u<<p|u>>>32-p}function r(u){const p=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const m=p&4294967295,f=p>>>32&4294967295;for(let g=0;g<4;g++)u+=String.fromCharCode(m>>>8*g&255);for(let g=0;g<4;g++)u+=String.fromCharCode(f>>>8*g&255);return u}function l(u,p){const[m,f,g,v]=p,y=[];for(let C=0;C<16;C++)y[C]=u.charCodeAt(C*4)&255|(u.charCodeAt(C*4+1)&255)<<8|(u.charCodeAt(C*4+2)&255)<<16|(u.charCodeAt(C*4+3)&255)<<24;let k=m,w=f,b=g,E=v;for(let C=0;C<64;C++){let x,S;const H=Math.floor(C/16),I=C%16;H===0?(x=w&b|~w&E,S=I):H===1?(x=E&w|~E&b,S=(5*I+1)%16):H===2?(x=w^b^E,S=(3*I+5)%16):(x=b^(w|~E),S=7*I%16);const q=E;E=b,b=w,w=w+a(k+x+i[C]+y[S]&4294967295,n[H][C%4]),k=q}return[m+k&4294967295,f+w&4294967295,g+b&4294967295,v+E&4294967295]}const o=r(t);let c=[...e];for(let u=0;u<o.length;u+=64)c=l(o.substring(u,u+64),c);let h="";return c.forEach(u=>{for(let p=0;p<4;p++)h+=(u>>>8*p&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 i(c,h){return c>>>h|c<<32-h}function n(c){const h=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=h&4294967295,p=h>>>32&4294967295;for(let m=0;m<4;m++)c+=String.fromCharCode(p>>>8*m&255);for(let m=0;m<4;m++)c+=String.fromCharCode(u>>>8*m&255);return c}function a(c,h){const u=[];for(let b=0;b<16;b++)u[b]=c.charCodeAt(b*4)&255|(c.charCodeAt(b*4+1)&255)<<8|(c.charCodeAt(b*4+2)&255)<<16|(c.charCodeAt(b*4+3)&255)<<24;for(let b=16;b<64;b++){const E=i(u[b-15],7)^i(u[b-15],18)^u[b-15]>>>3,C=i(u[b-2],17)^i(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+E+u[b-7]+C&4294967295}let[p,m,f,g,v,y,k,w]=h;for(let b=0;b<64;b++){const E=i(v,6)^i(v,11)^i(v,25),C=v&y^~v&k,x=w+E+C+e[b]+u[b]&4294967295,S=i(p,2)^i(p,13)^i(p,22),H=p&m^p&f^m&f,I=S+H&4294967295;w=k,k=y,y=v,v=g+x&4294967295,g=f,f=m,m=p,p=x+I&4294967295}return[h[0]+p&4294967295,h[1]+m&4294967295,h[2]+f&4294967295,h[3]+g&4294967295,h[4]+v&4294967295,h[5]+y&4294967295,h[6]+k&4294967295,h[7]+w&4294967295]}const r=n(t);let l=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<r.length;c+=64)l=a(r.substring(c,c+64),l);let o="";return l.forEach(c=>{for(let h=3;h>=0;h--)o+=(c>>>8*h&255).toString(16).padStart(2,"0")}),o},base64Encode(s){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",i=0;const n=s?s.split("").map(a=>a.charCodeAt(0)):[];for(;i<n.length;){const a=n[i++],r=n[i++]||0,l=n[i++]||0,o=a>>2,c=(a&3)<<4|r>>4,h=(r&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(i>n.length+1?"=":t[h])+(i>n.length?"=":t[u])}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++)),a=t.indexOf(s.charAt(i++)),r=t.indexOf(s.charAt(i++)),l=t.indexOf(s.charAt(i++)),o=n<<2|a>>4,c=(a&15)<<4|r>>2,h=(r&3)<<6|l;e+=String.fromCharCode(o),r!==64&&(e+=String.fromCharCode(c)),l!==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((i,n)=>{const a=new Image;a.crossOrigin=e,a.onload=()=>{this.cache.set(s,a),i(a)},a.onerror=()=>{n(new Error(`Failed to load image: ${s}`))},a.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((a,r)=>{const l=document.createElement("script");l.type=e,l.async=i,l.defer=n,l.onload=()=>{this.cache.set(s,l),a(l)},l.onerror=()=>{l.remove(),r(new Error(`Failed to load script: ${s}`))},l.src=s,document.head.appendChild(l)})},async loadStylesheet(s,t={}){const{media:e="all"}=t;return this.cache.has(s)?this.cache.get(s):new Promise((i,n)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=s,a.media=e,a.onload=()=>{this.cache.set(s,a),i(a)},a.onerror=()=>{a.remove(),n(new Error(`Failed to load stylesheet: ${s}`))},document.head.appendChild(a)})},async loadFont(s,t,e={}){const{weight:i="normal",style:n="normal"}=e,a=new FontFace(s,`url(${t})`,{weight:i,style:n});try{return await a.load(),document.fonts.add(a),a}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 gs(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 qe{constructor(){this.children={},this.keys=[]}}class At{constructor(){this.root=new qe}insert(t){let e=this.root;const i=t.split(".");i.forEach((n,a)=>{e.children[n]||(e.children[n]=new qe),e=e.children[n],a===i.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const i=t.split("."),n=[];for(let a=0;a<i.length;a++){const r=i[a];if(!e.children[r])break;e=e.children[r];const l=o=>{o.keys.length>0&&n.push(...o.keys),Object.values(o.children).forEach(c=>l(c))};l(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),i=[];for(let n=1;n<=e.length;n++){const a=e.slice(0,n).join(".");i.push(a)}return i}}const _={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class zt{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new At,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 a=Reflect.get(e,i,n);return a&&typeof a=="object"&&!Array.isArray(a)?this.wrapReactive(a,i):a},set:(e,i,n,a)=>{const r=Reflect.get(e,i,a),l=Reflect.set(e,i,n,a),o=this.resolvePath(e,i);return this.notify(o,n,r),this.queueUpdate(o,n),l},deleteProperty:(e,i)=>{const n=Reflect.get(e,i,receiver),a=Reflect.deleteProperty(e,i),r=this.resolvePath(e,i);return this.notify(r,void 0,n),this.queueUpdate(r,void 0),a}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(a,r,l)=>{if(r==="__raw__")return a;if(r===_.parent||r==="__parent__")return a[_.parent];if(r===_.path||r==="__path__")return a[_.path];if(r===_.isReactive||r==="__isReactive__")return!0;const o=Reflect.get(a,r,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${a[_.path]}${a[_.path]?".":""}${r}`):o},set:(a,r,l,o)=>{if(r===_.parent||r===_.path||r===_.isReactive||r==="__parent__"||r==="__path__"||r==="__isReactive__")return!0;const c=Reflect.get(a,r,o),h=Reflect.set(a,r,l,o),u=`${a[_.path]}${a[_.path]?".":""}${r}`;return this.notify(u,l,c),this.queueUpdate(u,l),h},deleteProperty:(a,r)=>{if(r===_.parent||r===_.path||r===_.isReactive)return!1;const l=Reflect.get(a,r),o=Reflect.deleteProperty(a,r),c=`${a[_.path]}${a[_.path]?".":""}${r}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(a,r)=>r==="__raw__"||r===_.parent||r===_.path||r===_.isReactive||r==="__parent__"||r==="__path__"||r==="__isReactive__"?!0:r in a,ownKeys:a=>Reflect.ownKeys(a).filter(r=>r!==_.parent&&r!==_.path&&r!==_.isReactive),getOwnPropertyDescriptor:(a,r)=>r===_.parent||r===_.path||r===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:a[r]}:Reflect.getOwnPropertyDescriptor(a,r)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(a=>{t[a]&&typeof t[a]=="object"&&!Array.isArray(t[a])&&(t[a]=this.wrapReactive(t[a],`${e}${e?".":""}${a}`))}),n}resolvePath(t,e){return t[_.path]?`${t[_.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(a=>{if(!t.has(a)){const r=this.get(a);this.updateElementsDirect(a,r),t.add(a)}})}),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(a=>this.updateQueue.has(a)||this.pathTrie.getSubKeys(a).some(r=>this.updateQueue.has(r)))&&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(a=>{i||(this.notify(a,t[a],n?.[a]),this.queueUpdate(a,t[a]))})):(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(),a=i.reduce((l,o)=>(l[o]||(l[o]={}),l[o]),this.rawData),r=a[n];a[n]=e,this.notify(t,e,r),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(a){console.error(`Observer error for ${t}:`,a)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,i)}catch(a){console.error("Wildcard observer error:",a)}})}updateElement(t,e){const i=t.getAttribute("data-bind");if(!i)return;i.split("|").forEach(a=>{const r=a.split(":"),l=r[0].trim(),o=r[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=gs(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 h=e?"none":"";t.style.display!==h&&(t.style.display=h);break;case"class":o&&(e?t.classList.add(o):t.classList.remove(o));break;case"style":o&&t.style[o]!==String(e??"")&&(t.style[o]=e??"");break;case"attr":o&&t.getAttribute(o)!==String(e??"")&&t.setAttribute(o,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(a=>this.get(a)),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 At,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:i="local",debounce:n=0,version:a=1,encrypt:r=!1,encryptionKey:l=null}=e,o=i==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:n,timeout:null,version:a,encrypt:r,encryptionKey:l});const c=this.get(t);c!==void 0&&this._persistSave(t,c,o,{version:a,encrypt:r,encryptionKey:l}),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,i,n={}){try{const{version:a=1,encrypt:r=!1,encryptionKey:l=null}=n,o={value:e,version:a,timestamp:Date.now()};let c=JSON.stringify(o);r&&l&&(c=this._encrypt(c,l)),this._ensureStorageCapacity(i),i.setItem(`kupola:${t}`,c)}catch(a){if(console.warn(`Failed to persist key ${t}:`,a),a.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(r){console.warn(`sessionStorage also failed for key ${t}:`,r)}}}}_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 a=t.key(n);if(a?.startsWith("kupola:"))try{const r=JSON.parse(t.getItem(a));r.timestamp&&e-r.timestamp>i&&t.removeItem(a)}catch{t.removeItem(a)}}}_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 a=localStorage.key(n);if(a?.startsWith("kupola:")){const r=a.replace("kupola:","");try{const l=localStorage.getItem(a);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${r} (version ${o.version})`);continue}e[r]=o.value!==void 0?o.value:o}catch(l){console.warn(`Failed to load persisted key ${r}:`,l)}}}for(let n=0;n<sessionStorage.length;n++){const a=sessionStorage.key(n);if(a?.startsWith("kupola:")){const r=a.replace("kupola:","");try{const l=sessionStorage.getItem(a);let o;if(i){const c=this._decrypt(l,i);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${r} (version ${o.version})`);continue}e[r]=o.value!==void 0?o.value:o}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 r=n.split(":")[1]?.trim();r&&(i.type==="checkbox"?(e[r]||(e[r]=[]),i.checked&&e[r].push(i.value)):i.type==="radio"?i.checked&&(e[r]=i.value):e[r]=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[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const i={get:(a,r,l)=>{if(r==="__raw__")return a;if(r===_.parent||r==="__parent__")return a[_.parent];if(r===_.path||r==="__path__")return a[_.path];if(r===_.isReactive||r==="__isReactive__")return!0;const o=Reflect.get(a,r,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${a[_.path]}${a[_.path]?".":""}${r}`):o},set:(a,r,l,o)=>{if(r===_.parent||r===_.path||r===_.isReactive||r==="__parent__"||r==="__path__"||r==="__isReactive__")return!0;const c=Reflect.get(a,r,o),h=Reflect.set(a,r,l,o),u=`${a[_.path]}${a[_.path]?".":""}${r}`;return this.notify(u,l,c),this.queueUpdate(u,l),h},deleteProperty:(a,r)=>{if(r===_.parent||r===_.path||r===_.isReactive)return!1;const l=Reflect.get(a,r),o=Reflect.deleteProperty(a,r),c=`${a[_.path]}${a[_.path]?".":""}${r}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(a,r)=>r==="__raw__"||r===_.parent||r===_.path||r===_.isReactive||r==="__parent__"||r==="__path__"||r==="__isReactive__"?!0:r in a,ownKeys:a=>Reflect.ownKeys(a).filter(r=>r!==_.parent&&r!==_.path&&r!==_.isReactive),getOwnPropertyDescriptor:(a,r)=>r===_.parent||r===_.path||r===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:a[r]}:Reflect.getOwnPropertyDescriptor(a,r)},n=new Proxy(t,i);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(a=>{t[a]&&typeof t[a]=="object"&&!Array.isArray(t[a])&&(t[a]=this.wrapReactive(t[a],`${e}${e?".":""}${a}`))}),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(a=>this._bindElement(a)),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 a=t.__kupolaBindHandler;a&&t.removeEventListener("input",a);const r=()=>{const l=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,l):this.set(n,l)};t.__kupolaBindHandler=r,t.addEventListener("input",r)}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 At,this.updateQueue.clear(),this.snapshots=[]}}class Y{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 Pt{constructor(){this.stores=new Map}createStore(t,e){const i=new Y(t,e);return this.stores.set(t,i),i}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof Y&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class $t{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=a=>{this.delegatedEvents[e].forEach(({selector:r,cb:l})=>{(a.target.matches(r)||a.target.closest(r))&&l(a)})};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 X=new zt,Be=new $t,J=new Pt;function Fe(s,t){return J.createStore(s,t)}function Ne(s){return J.getStore(s)}typeof window<"u"&&(window.KupolaDataBind=zt,window.KupolaEventBus=$t,window.KupolaStore=Y,window.KupolaStoreManager=Pt,window.kupolaData=X,window.kupolaEvents=Be,window.kupolaStoreManager=J,window.createStore=Fe,window.getStore=Ne,window.kupolaRef=L);const Oe="kupola-theme",Re="kupola-brand",B=[{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 F(){return localStorage.getItem(Oe)||"dark"}function K(s){if(s!=="dark"&&s!=="light")return;document.documentElement.setAttribute("data-theme",s),localStorage.setItem(Oe,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 O(){return localStorage.getItem(Re)||"zengqing"}function W(s){const t=B.find(n=>n.id===s);if(!t)return;document.documentElement.setAttribute("data-brand",s),localStorage.setItem(Re,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 a=e.querySelector(".brand-name");a&&(a.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 qt(){const s=F();K(s);const t=O();W(t);const e=document.querySelector("[data-theme-toggle]");e&&e.addEventListener("click",()=>{const o=F()==="dark"?"light":"dark";K(o)});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",B.forEach(l=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",l.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=l.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(l.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=l.name,i.appendChild(o)}),document.body.appendChild(i));const n=document.querySelector("[data-brand-toggle]");n&&i&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",a,!0)},0):document.removeEventListener("click",a,!0)},i.onclick=function(l){l.stopPropagation()});function a(l){i&&n&&!i.contains(l.target)&&!n.contains(l.target)&&(i.style.display="none",document.removeEventListener("click",a,!0))}document.querySelectorAll("[data-brand-btn]").forEach(l=>{l.addEventListener("click",o=>{o.stopPropagation();const c=l.getAttribute("data-brand-btn");W(c),i&&(i.style.display="none")})})}function Ve(){const s=document.createElement("button");s.setAttribute("data-theme-toggle",""),s.setAttribute("data-current-theme",F()),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=F()==="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 r=F()==="dark"?"light":"dark";K(r)}),s}function Ke(){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",B.forEach(r=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",r.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=r.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(r.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=r.name,s.appendChild(l)}),document.body.appendChild(s);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",O()),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=B.find(r=>r.id===O()).color;const i=document.createElement("span");i.className="brand-name",i.style.fontSize="11px",i.textContent=B.find(r=>r.id===O()).name,t.appendChild(e),t.appendChild(i),document.body.appendChild(t),t.onclick=function(r){r.stopPropagation(),r.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},s.onclick=function(r){r.stopPropagation()};function n(r){!s.contains(r.target)&&!t.contains(r.target)&&(s.style.display="none",document.removeEventListener("click",n,!0))}return s.querySelectorAll("[data-brand-btn]").forEach(r=>{r.addEventListener("click",l=>{l.stopPropagation();const o=r.getAttribute("data-brand-btn");W(o),s.style.display="none"})}),{toggleBtn:t,container:s}}typeof window<"u"&&(window.getTheme=F,window.setTheme=K,window.initTheme=qt,window.createThemeToggle=Ve,window.getBrand=O,window.setBrand=W,window.BRAND_OPTIONS=B,window.createBrandPicker=Ke);class Bt{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 a=n||i.replace("data-",""),r=this.initializers.get(a)||this.initializers.get(i.replace("data-",""));if(r){try{await r(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${a}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const i of this._cssClasses)if(e.includes(i)){const n=i.replace("ds-",""),a=this.initializers.get(n)||this.initializers.get(i);if(a){try{await a(t),this.processedElements.add(t)}catch(r){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,r)}return}}}}cleanup(t){for(const i of this._dataAttrs){const n=t.getAttribute(i);if(n!==null){const a=n||i.replace("data-",""),r=this.cleanupFunctions.get(a)||this.cleanupFunctions.get(i.replace("data-",""));if(r){try{r(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${a}":`,l)}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-",""),a=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(i);if(a){try{a(t)}catch(r){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,r)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const i=t.querySelectorAll(e),n=[];i.forEach(a=>{this.processedElements.has(a)||n.push(this.initialize(a))}),await Promise.all(n)}}const D=new Bt,_s=[{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 _s)s.attr&&!D._dataAttrs.includes(s.attr)&&D._dataAttrs.push(s.attr),s.cls&&!D._cssClasses.includes(s.cls)&&D._cssClasses.push(s.cls);typeof window<"u"&&(window.ComponentInitializerRegistry=Bt,window.kupolaInitializer=D);class R{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 A,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(a){console.error(`Error in event handler for ${t}:`,a)}}),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 s=new Set;for(;n&&n.constructor!==Object&&n.constructor!==t;){for(const[a,l]of Object.entries(o))s.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]?.()),s.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 s=r.prototype[n];s?r.prototype[n]=function(...a){return o[n].apply(this,a),s.apply(this,a)}:r.prototype[n]=o[n]}else r.prototype[n]=o[n]})}i.exports?i.exports={KupolaComponent:t,applyMixin:e}:(window.KupolaComponent=t,window.applyMixin=e)}(A)),A.exports}ut();var $={exports:{}},pt;function ft(){return pt||(pt=1,function(i){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 s=(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,s),s}defineMixin(r,o){this.mixins.set(r,o)}useMixin(r,...o){o.forEach(n=>{const s=this.mixins.get(n);s&&window.applyMixin&&window.applyMixin(r,s)})}async bootstrap(r=document){await this._upgradeElements(r),this._startObserver(r)}async _upgradeElements(r){const o=r.querySelectorAll("[data-component]"),n=[];o.forEach(s=>{n.push(this._upgradeElement(s))}),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 s=r.getAttribute("data-mixins"),a=n;s&&window.applyMixin&&s.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(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.hasAttribute("data-component")&&this._upgradeElement(s).catch(a=>console.error(a)),this._upgradeElements(s).catch(a=>console.error(a)))}),n.removedNodes.forEach(s=>{if(s.nodeType===Node.ELEMENT_NODE){const a=this.instances.get(s);a&&(a.unmount(),this.instances.delete(s)),s.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()}}i.exports?i.exports={KupolaComponentRegistry:t}:window.KupolaComponentRegistry=t}($)),$.exports}ft();var R={exports:{}},mt;function gt(){return mt||(mt=1,function(i){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(s=>{const a=s.path.startsWith("/")?s.path:n+(n&&!s.path.startsWith("/")?"/":"")+s.path,l=this._pathToRegex(a);this.routeMap.set(a,{...s,regex:l,parentPath:n}),s.children&&s.children.length>0&&this._registerRoutes(s.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 s=this._matchRoute(o);if(!s)return;const a=this.currentRoute;for(const l of this.beforeEachHandlers)if(await l(s,a)===!1)return;this.currentRoute=s,this._updateURL(o,n),await this._renderRoute(s);for(const l of this.afterEachHandlers)l(s)}_matchRoute(o){for(const[,n]of this.routeMap){const s=o.match(n.regex);if(s){const a={};(n.path.match(/:(\w+)/g)||[]).forEach((h,u)=>{a[h.slice(1)]=s[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(s=>{const[a,l]=s.split("=");n[a]=decodeURIComponent(l||"")}),n}_updateURL(o,n){if(this.mode==="hash"){const s=`#${o}`;n?location.replace(s):location.hash=o}else{const s=this.base+o+location.search;n?history.replaceState({},"",s):history.pushState({},"",s)}}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 s=await this._resolveComponent(o.component);if(!s)return;const a=document.createElement("div");a.setAttribute("data-component",s),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 s=document.querySelector("[data-router-view]");if(!s)return;if(document.querySelector(`[data-component="${n.component}"]`))await this._renderChildComponent(o);else{this._cleanupContainerComponents(s),s.classList.add("router-view-leave"),s.classList.remove("router-view-enter"),await this._waitForAnimation(s);const l=await this._resolveComponent(n.component);if(!l)return;const c=document.createElement("div");c.setAttribute("data-component",l),s.innerHTML="",s.appendChild(c),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap(s),setTimeout(()=>{s.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 s=n.querySelector("[data-router-view]");if(!s||!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])}),s.innerHTML="",s.appendChild(l),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap(s),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 s=await o(),a=s.default||s,l=`lazy-${Math.random().toString(36).substr(2,9)}`;return window.kupolaRegistry&&window.kupolaRegistry.register(l,a),this.componentCache.set(n,l),l}catch(s){return console.error("Failed to load lazy component:",s),null}}if(typeof o=="string"&&o.startsWith("lazy:")){const n=o.slice(5);if(window.kupolaRegistry)try{await window.kupolaRegistry.getAsync(n)}catch(s){return console.error(`Failed to load lazy component ${n}:`,s),null}return n}return o}_getParentComponent(o){for(const[n,s]of this.routeMap)if(n===o)return s.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 s=this._getTransitionDuration(o);if(s>0){const a=()=>{o.removeEventListener("transitionend",a),o.removeEventListener("animationend",a),n()};o.addEventListener("transitionend",a),o.addEventListener("animationend",a),setTimeout(a,s+100)}else n()})}_getTransitionDuration(o){const n=window.getComputedStyle(o),s=parseFloat(n.transitionDuration)||0,a=parseFloat(n.animationDuration)||0;return Math.max(s,a)*1e3}_cleanupContainerComponents(o){o.querySelectorAll("[data-component]").forEach(s=>{const a=s.__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)}i.exports?i.exports={KupolaRouter:t,createRouter:e}:(window.KupolaRouter=t,window.createRouter=e)}(R)),R.exports}gt();var F={exports:{}},yt;function vt(){return yt||(yt=1,function(i){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:s="GET",params:a={},data:l=null}=o,c=a?new URLSearchParams(a).toString():"",h=l?JSON.stringify(l):"";return`${s}:${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(s){if(n<this.maxRetries)return await new Promise(a=>setTimeout(a,this.retryDelay*Math.pow(2,n))),this._requestWithRetry(o,n+1);throw s}}async _request(o){const{url:n,method:s="GET",headers:a={},params:l={},data:c=null,timeout:h=this.timeout,cache:u=!1}=o,d=this._generateCacheKey({url:n,method:s,params:l,data:c});if(u&&s==="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:s,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(_=>{m.searchParams.append(_,l[_])}),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 v={url:f.url.replace(this.baseURL,""),method:f.method,headers:f.headers,signal:f.signal,timeout:h};c!==null&&(v.data=c),l&&Object.keys(l).length>0&&(v.params=l),m=await this.axios(v)}else if(m=await this._fetchWithTimeout(f,h),!m.ok){const v=new Error(`HTTP error! status: ${m.status}`);throw v.status=m.status,v.statusText=m.statusText,v}const _={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(_):(u&&s==="GET"&&this._setCache(d,_),_)}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 s=new AbortController,a=s.signal,l=new Promise((h,u)=>{const d=setTimeout(()=>{s.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((s,a)=>{n[a]=s}),n}cancelRequest(o,n={},s="GET",a=null){const l=this._generateCacheKey({url:o,method:s,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,s)=>{s.startsWith(`GET:${o}`)&&this.cache.delete(s)})}get(o,n={}){const s=n.cache??!0,a=n.retry??this.maxRetries>0,l={...n,url:o,method:"GET",cache:s};return a?this._requestWithRetry(l):this._request(l)}post(o,n=null,s={}){const a=s.retry??this.maxRetries>0,l={...s,url:o,method:"POST",data:n,cache:!1};return a?this._requestWithRetry(l):this._request(l)}async uploadFile(o,n,s={}){const{chunkSize:a=2*1024*1024,onProgress:l,headers:c={},parallel:h=!1}=s,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 _=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(_)}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,s,a,l,c,h){const u=s*l,d=Math.min(u+l,n.size),p=n.slice(u,d),g=new FormData;return g.append("chunk",p),g.append("chunkIndex",s),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,s,a){return this.post(`${o}/complete`,{fileId:n,totalChunks:s,fileName:a})}_generateFileId(o){const n=`${o.name}-${o.size}-${o.lastModified}`;let s=0;for(let a=0;a<n.length;a++)s=(s<<5)-s+n.charCodeAt(a),s|=0;return Math.abs(s).toString(36)+Date.now().toString(36)}put(o,n=null,s={}){const a=s.retry??this.maxRetries>0,l={...s,url:o,method:"PUT",data:n,cache:!1};return a?this._requestWithRetry(l):this._request(l)}delete(o,n={}){const s=n.retry??this.maxRetries>0,a={...n,url:o,method:"DELETE",cache:!1};return s?this._requestWithRetry(a):this._request(a)}patch(o,n=null,s={}){const a=s.retry??this.maxRetries>0,l={...s,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)}i.exports?i.exports={KupolaHttp:t,createHttp:e}:(window.KupolaHttp=t,window.createHttp=e)}(F)),F.exports}vt();var O={exports:{}},_t;function Ri(){return _t||(_t=1,function(i){class t{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet}register(o,n,s=null){this.initializers.set(o,n),s&&this.cleanupFunctions.set(o,s)}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 s=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(s.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 s=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(s.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"),s=[];n.forEach(a=>{this.processedElements.has(a)||s.push(this.initialize(a))}),await Promise.all(s)}}const e=new t;i.exports?i.exports={ComponentInitializerRegistry:t,kupolaInitializer:e}:(window.ComponentInitializerRegistry=t,window.kupolaInitializer=e)}(O)),O.exports}Ri();var N={exports:{}},wt;function Fi(){if(wt)return N.exports;if(wt=1,typeof window>"u"){const{KupolaComponent:t,applyMixin:e}=ut(),{KupolaComponentRegistry:r}=ft(),{KupolaRouter:o,createRouter:n}=gt(),{KupolaHttp:s,createHttp:a}=vt();N.exports={KupolaComponent:t,applyMixin:e,KupolaComponentRegistry:r,KupolaRouter:o,KupolaHttp:s,createRouter:n,createHttp:a}}window.KupolaComponentRegistry&&(window.kupolaRegistry=new window.KupolaComponentRegistry);async function i(){window.kupolaData&&window.kupolaData.loadPersisted(),window.kupolaRegistry&&await window.kupolaRegistry.bootstrap()}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):setTimeout(i,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}Fi();let P=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,s)=>s.priority-n.priority),()=>{const n=o.findIndex(s=>s.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(s=>s.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 s=performance.now()-n;console.debug(`[KupolaLifecycle] ${t} completed in ${s.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)}},xt=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 P(`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 Oi=new P("app"),Ni=new xt;function Bi(i="app"){return new P(i)}window.KupolaLifecycle=P,window.KupolaPluginManager=xt,window.kupolaLifecycle=Oi,window.kupolaPluginManager=Ni,window.createLifecycle=Bi;const bt={string:{trim(i){return i?i.trim():""},trimLeft(i){return i?i.replace(/^\s+/,""):""},trimRight(i){return i?i.replace(/\s+$/,""):""},toUpperCase(i){return i?i.toUpperCase():""},toLowerCase(i){return i?i.toLowerCase():""},capitalize(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""},camelize(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""},hyphenate(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart(i,t,e=" "){return(String(i)||"").padStart(t,e)},padEnd(i,t,e=" "){return(String(i)||"").padEnd(t,e)},truncate(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e},replaceAll(i,t,e){return i?i.split(t).join(e):""},format(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,r)=>t[r]!==void 0?t[r]:`{{${r}}}`):""},startsWith(i,t){return(i||"").startsWith(t)},endsWith(i,t){return(i||"").endsWith(t)},includes(i,t){return(i||"").includes(t)},repeat(i,t){return(i||"").repeat(t)},reverse(i){return(i||"").split("").reverse().join("")},countOccurrences(i,t){return!i||!t?0:i.split(t).length-1},escapeHtml(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML},unescapeHtml(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent},generateRandom(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let r=0;r<i;r++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}},array:{isArray(i){return Array.isArray(i)},isEmpty(i){return!i||i.length===0},size(i){return i?i.length:0},first(i,t){return i&&i.length>0?i[0]:t},last(i,t){return i&&i.length>0?i[i.length-1]:t},get(i,t,e){return i&&i[t]!==void 0?i[t]:e},slice(i,t,e){return i?i.slice(t,e):[]},concat(...i){return i.reduce((t,e)=>t.concat(e||[]),[])},join(i,t=","){return i?i.join(t):""},indexOf(i,t,e=0){return i?i.indexOf(t,e):-1},lastIndexOf(i,t,e){return i?i.lastIndexOf(t,e):-1},includes(i,t){return i?i.includes(t):!1},push(i,...t){return i&&i.push(...t),i},pop(i){return i?i.pop():void 0},shift(i){return i?i.shift():void 0},unshift(i,...t){return i&&i.unshift(...t),i},remove(i,t){if(!i)return i;const e=i.indexOf(t);return e>-1&&i.splice(e,1),i},removeAt(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i},insert(i,t,e){return i&&(i.splice(t,0,e),i)},reverse(i){return i?i.slice().reverse():[]},sort(i,t){return i?i.slice().sort(t):[]},sortBy(i,t,e="asc"){return i?i.slice().sort((r,o)=>{const n=typeof r=="object"?r[t]:r,s=typeof o=="object"?o[t]:o;return n<s?e==="asc"?-1:1:n>s?e==="asc"?1:-1:0}):[]},filter(i,t){return i?i.filter(t):[]},map(i,t){return i?i.map(t):[]},reduce(i,t,e){return i?i.reduce(t,e):e},forEach(i,t){i&&i.forEach(t)},every(i,t){return i?i.every(t):!0},some(i,t){return i?i.some(t):!1},find(i,t){return i?i.find(t):void 0},findIndex(i,t){return i?i.findIndex(t):-1},flat(i,t=1){return i?i.flat(t):[]},flattenDeep(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(this.flattenDeep(e)):t.concat(e),[]):[]},unique(i){return i?[...new Set(i)]:[]},uniqueBy(i,t){if(!i)return[];const e=new Set;return i.filter(r=>{const o=typeof r=="object"?r[t]:r;return e.has(o)?!1:(e.add(o),!0)})},chunk(i,t){if(!i||t<=0)return[];const e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e},shuffle(i){if(!i)return[];const t=i.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(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0},average(i){return!i||i.length===0?0:this.sum(i)/i.length},max(i){return i&&i.length>0?Math.max(...i):-1/0},min(i){return i&&i.length>0?Math.min(...i):1/0},intersection(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(r=>e&&e.includes(r)))},union(...i){return[...new Set(i.flat().filter(Boolean))]},difference(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]},zip(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,r)=>i.map(o=>o&&o[r]))}},object:{isObject(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)},isEmpty(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0},keys(i){return i?Object.keys(i):[]},values(i){return i?Object.values(i):[]},entries(i){return i?Object.entries(i):[]},has(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1},get(i,t,e){return i&&t.split(".").reduce((o,n)=>o&&o[n],i)||e},set(i,t,e){if(!i||typeof i!="object")return i;const r=t.split("."),o=r.pop();let n=i;return r.forEach(s=>{n[s]||(n[s]={}),n=n[s]}),n[o]=e,i},pick(i,t){return i?t.reduce((e,r)=>(i[r]!==void 0&&(e[r]=i[r]),e),{}):{}},omit(i,t){return i?Object.keys(i).reduce((e,r)=>(t.includes(r)||(e[r]=i[r]),e),{}):{}},merge(...i){return i.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(i){return i&&JSON.parse(JSON.stringify(i))},deepClone(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const r=new Map;return t.set(i,r),i.forEach((o,n)=>r.set(n,this.deepClone(o,t))),r}if(i instanceof Set){const r=new Set;return t.set(i,r),i.forEach(o=>r.add(this.deepClone(o,t))),r}if(Array.isArray(i)){const r=[];return t.set(i,r),i.forEach(o=>r.push(this.deepClone(o,t))),r}const e={};return t.set(i,e),Object.keys(i).forEach(r=>{e[r]=this.deepClone(i[r],t)}),e},forEach(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))},map(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(r=>{e[r]=t(i[r],r,i)}),e},filter(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(r=>{t(i[r],r,i)&&(e[r]=i[r])}),e},reduce(i,t,e){return i?Object.keys(i).reduce((r,o)=>t(r,i[o],o,i),e):e},toArray(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]},fromArray(i,t,e){return i?i.reduce((r,o)=>{const n=typeof o=="object"?o[t]:o,s=e?o[e]:o;return n!==void 0&&(r[n]=s),r},{}):{}},size(i){return i?Object.keys(i).length:0},invert(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t},isEqual(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),r=Object.keys(t);return e.length!==r.length?!1:e.every(o=>this.isEqual(i[o],t[o]))},freeze(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&this.freeze(i[t])}),i)},seal(i){return i&&Object.seal(i)}},number:{isNumber(i){return typeof i=="number"&&!isNaN(i)},isInteger(i){return Number.isInteger(i)},isFloat(i){return this.isNumber(i)&&!Number.isInteger(i)},isPositive(i){return this.isNumber(i)&&i>0},isNegative(i){return this.isNumber(i)&&i<0},isZero(i){return this.isNumber(i)&&i===0},clamp(i,t,e){return this.isNumber(i)?Math.min(Math.max(i,t),e):i},round(i,t=0){if(!this.isNumber(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e},floor(i){return this.isNumber(i)?Math.floor(i):i},ceil(i){return this.isNumber(i)?Math.ceil(i):i},abs(i){return this.isNumber(i)?Math.abs(i):i},min(...i){const t=i.filter(this.isNumber);return t.length>0?Math.min(...t):void 0},max(...i){const t=i.filter(this.isNumber);return t.length>0?Math.max(...t):void 0},sum(...i){return i.flat().filter(this.isNumber).reduce((e,r)=>e+r,0)},average(...i){const t=i.flat().filter(this.isNumber);return t.length>0?this.sum(t)/t.length:0},random(i=0,t=1){return Math.random()*(t-i)+i},randomInt(i,t){return Math.floor(this.random(i,t+1))},format(i,t=2){return this.isNumber(i)?i.toFixed(t):String(i)},formatCurrency(i,t="CNY",e=2){return this.isNumber(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)},formatPercent(i,t=0){return this.isNumber(i)?`${(i*100).toFixed(t)}%`:String(i)},toFixed(i,t=0){return this.isNumber(i)?i.toFixed(t):String(i)},toPrecision(i,t=6){return this.isNumber(i)?i.toPrecision(t):String(i)},isNaN(i){return Number.isNaN(i)},isFinite(i){return Number.isFinite(i)},parseInt(i,t=10){return Number.parseInt(i,t)},parseFloat(i){return Number.parseFloat(i)},toNumber(i,t=0){const e=Number(i);return isNaN(e)?t:e},safeDivide(i,t,e=0){return!this.isNumber(i)||!this.isNumber(t)||t===0?e:i/t},safeMultiply(...i){return i.reduce((t,e)=>!this.isNumber(t)||!this.isNumber(e)?0:t*e,1)}},date:{now(){return Date.now()},today(){const i=new Date;return i.setHours(0,0,0,0),i},tomorrow(){const i=this.today();return i.setDate(i.getDate()+1),i},yesterday(){const i=this.today();return i.setDate(i.getDate()-1),i},isDate(i){return i instanceof Date&&!isNaN(i.getTime())},isValid(i){return this.isDate(i)},parse(i){const t=new Date(i);return this.isValid(t)?t:null},format(i,t="YYYY-MM-DD HH:mm:ss"){if(!this.isDate(i))return"";const e=i.getFullYear(),r=String(i.getMonth()+1).padStart(2,"0"),o=String(i.getDate()).padStart(2,"0"),n=String(i.getHours()).padStart(2,"0"),s=String(i.getMinutes()).padStart(2,"0"),a=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",r).replace("DD",o).replace("HH",n).replace("mm",s).replace("ss",a).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",h)},toISO(i){return this.isDate(i)?i.toISOString():""},toUTC(i){return this.isDate(i)?new Date(i.toUTCString()):null},addDays(i,t){if(!this.isDate(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e},addHours(i,t){if(!this.isDate(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e},addMinutes(i,t){if(!this.isDate(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e},addSeconds(i,t){if(!this.isDate(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e},diffDays(i,t){if(!this.isDate(i)||!this.isDate(t))return 0;const e=this.today(),r=this.today();return e.setTime(i.getTime()),r.setTime(t.getTime()),Math.floor((e.getTime()-r.getTime())/(1e3*60*60*24))},diffHours(i,t){return!this.isDate(i)||!this.isDate(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))},diffMinutes(i,t){return!this.isDate(i)||!this.isDate(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))},diffSeconds(i,t){return!this.isDate(i)||!this.isDate(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)},isToday(i){return this.isDate(i)?this.diffDays(i,this.today())===0:!1},isYesterday(i){return this.isDate(i)?this.diffDays(i,this.today())===-1:!1},isTomorrow(i){return this.isDate(i)?this.diffDays(i,this.today())===1:!1},isFuture(i){return this.isDate(i)?i.getTime()>this.now():!1},isPast(i){return this.isDate(i)?i.getTime()<this.now():!1},isLeapYear(i){if(!this.isDate(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)},getDaysInMonth(i){if(!this.isDate(i))return 0;const t=i.getFullYear(),e=i.getMonth();return new Date(t,e+1,0).getDate()},getWeekOfYear(i){if(!this.isDate(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))},getQuarter(i){return this.isDate(i)?Math.ceil((i.getMonth()+1)/3):0},startOfDay(i){if(!this.isDate(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t},endOfDay(i){if(!this.isDate(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t},startOfMonth(i){return this.isDate(i)?new Date(i.getFullYear(),i.getMonth(),1):i},endOfMonth(i){return this.isDate(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i},startOfWeek(i,t=1){if(!this.isDate(i))return i;const e=new Date(i),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(i,t=1){if(!this.isDate(i))return i;const e=this.startOfWeek(i,t),r=new Date(e);return r.setDate(r.getDate()+6),r.setHours(23,59,59,999),r},getAge(i){if(!this.isDate(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)},fromNow(i){if(!this.isDate(i))return"";const e=this.now()-i.getTime(),r=60*1e3,o=60*r,n=24*o,s=7*n,a=30*n,l=365*n;return e<r?"刚刚":e<o?`${Math.floor(e/r)}分钟前`:e<n?`${Math.floor(e/o)}小时前`:e<s?`${Math.floor(e/n)}天前`:e<a?`${Math.floor(e/s)}周前`:e<l?`${Math.floor(e/a)}个月前`:`${Math.floor(e/l)}年前`}},debounce(i,t,e={}){let r=null,o=null,n=null,s=0;const a=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(n,o)}function h(){s=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()-s;return Math.max(0,t-p)}return function(...p){o=p,n=this,s=Date.now(),r?(clearTimeout(r),r=setTimeout(u,d())):h()}},throttle(i,t,e={}){let r=!1;const o=e.trailing||!1;let n=null,s=null;function a(){i.apply(s,n),n=null,s=null}return function(...l){r?o&&(n=l,s=this):(r=!0,n=l,s=this,a(),setTimeout(()=>{r=!1,o&&n&&a()},t))}},validator:{isEmail(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")},isPhone(i){return/^1[3-9]\d{9}$/.test(i||"")},isURL(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")},isIPv4(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")},isIPv6(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")},isIP(i){return this.isIPv4(i)||this.isIPv6(i)},isIDCard(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")},isPassport(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")},isCreditCard(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let r=0,o=!1;for(let n=e.length-1;n>=0;n--){let s=parseInt(e[n],10);o&&(s*=2,s>9&&(s-=9)),r+=s,o=!o}return r%10===0},isHexColor(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")},isRGB(i){const e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return e?e.slice(1).every(r=>parseInt(r)>=0&&parseInt(r)<=255):!1},isRGBA(i){const e=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!e)return!1;const[,r,o,n,s]=e;return parseInt(r)>=0&&parseInt(r)<=255&&parseInt(o)>=0&&parseInt(o)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(s)>=0&&parseFloat(s)<=1},isColor(i){return this.isHexColor(i)||this.isRGB(i)||this.isRGBA(i)},isDate(i){return!isNaN(new Date(i).getTime())},isJSON(i){try{return JSON.parse(i),!0}catch{return!1}},isEmpty(i){return!i||i.trim()===""},isWhitespace(i){return/^\s+$/.test(i||"")},isNumber(i){return!isNaN(parseFloat(i))&&isFinite(i)},isInteger(i){return/^-?\d+$/.test(i||"")},isFloat(i){return/^-?\d+\.\d+$/.test(i||"")},isPositive(i){const t=parseFloat(i);return!isNaN(t)&&t>0},isNegative(i){const t=parseFloat(i);return!isNaN(t)&&t<0},isAlpha(i){return/^[a-zA-Z]+$/.test(i||"")},isAlphaNumeric(i){return/^[a-zA-Z0-9]+$/.test(i||"")},isChinese(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")},isLength(i,t,e){const r=(i||"").length;return r>=t&&(e===void 0||r<=e)},minLength(i,t){return(i||"").length>=t},maxLength(i,t){return(i||"").length<=t},matches(i,t){return t instanceof RegExp?t.test(i||""):!1},equals(i,t){return String(i)===String(t)},contains(i,t){return(i||"").includes(t)},notContains(i,t){return!this.contains(i,t)},isArray(i){return Array.isArray(i)},arrayLength(i,t,e){const r=i?i.length:0;return r>=t&&(e===void 0||r<=e)},arrayMinLength(i,t){return i?i.length>=t:!1},arrayMaxLength(i,t){return i?i.length<=t:!1},isObject(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)},hasKeys(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))},validate(i,t){const e={};return Object.keys(t).forEach(r=>{const o=i[r],n=t[r],s=[];n.forEach(a=>{if(typeof a=="string"){const[l,...c]=a.split(":");this[l](o,...c)||s.push(l)}else if(typeof a=="function"){const l=a(o,i);l!==!0&&s.push(l||"validation_failed")}}),s.length>0&&(e[r]=s)}),{valid:Object.keys(e).length===0,errors:e}}},crypto:{md5(i){const t=i?String(i):"",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 s(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,_=[];for(let E=0;E<16;E++)_[E]=u.charCodeAt(E*4)&255|(u.charCodeAt(E*4+1)&255)<<8|(u.charCodeAt(E*4+2)&255)<<16|(u.charCodeAt(E*4+3)&255)<<24;let v=p,x=g,w=f,k=m;for(let E=0;E<64;E++){let L,C;const S=Math.floor(E/16),H=E%16;S===0?(L=x&w|~x&k,C=H):S===1?(L=k&x|~k&w,C=(5*H+1)%16):S===2?(L=x^w^k,C=(3*H+5)%16):(L=w^(x|~k),C=7*H%16);const M=k;k=w,w=x,x=x+n(v+L+r[E]+_[C]&4294967295,o[S][E%4]),v=M}return[p+v&4294967295,g+x&4294967295,f+w&4294967295,m+k&4294967295]}const l=s(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(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function 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 w=0;w<16;w++)u[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=r(u[w-15],7)^r(u[w-15],18)^u[w-15]>>>3,E=r(u[w-2],17)^r(u[w-2],19)^u[w-2]>>>10;u[w]=u[w-16]+k+u[w-7]+E&4294967295}let[d,p,g,f,m,_,v,x]=h;for(let w=0;w<64;w++){const k=r(m,6)^r(m,11)^r(m,25),E=m&_^~m&v,L=x+k+E+e[w]+u[w]&4294967295,C=r(d,2)^r(d,13)^r(d,22),S=d&p^d&g^p&g,H=C+S&4294967295;x=v,v=_,_=m,m=f+L&4294967295,f=g,g=p,p=d,d=L+H&4294967295}return[h[0]+d&4294967295,h[1]+p&4294967295,h[2]+g&4294967295,h[3]+f&4294967295,h[4]+m&4294967295,h[5]+_&4294967295,h[6]+v&4294967295,h[7]+x&4294967295]}const s=o(t);let a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<s.length;c+=64)a=n(s.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(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",r=0;const o=i?i.split("").map(n=>n.charCodeAt(0)):[];for(;r<o.length;){const n=o[r++],s=o[r++]||0,a=o[r++]||0,l=n>>2,c=(n&3)<<4|s>>4,h=(s&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(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",r=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");r<i.length;){const o=t.indexOf(i.charAt(r++)),n=t.indexOf(i.charAt(r++)),s=t.indexOf(i.charAt(r++)),a=t.indexOf(i.charAt(r++)),l=o<<2|n>>4,c=(n&15)<<4|s>>2,h=(s&3)<<6|a;e+=String.fromCharCode(l),s!==64&&(e+=String.fromCharCode(c)),a!==64&&(e+=String.fromCharCode(h))}return e},uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}},preload:{cache:new Map,async loadImage(i,t={}){const{crossOrigin:e="anonymous"}=t;return this.cache.has(i)?this.cache.get(i):new Promise((r,o)=>{const n=new Image;n.crossOrigin=e,n.onload=()=>{this.cache.set(i,n),r(n)},n.onerror=()=>{o(new Error(`Failed to load image: ${i}`))},n.src=i})},async loadImages(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(o=>this.loadImage(o,t)));const r=[];for(const o of i)r.push(await this.loadImage(o,t));return r},async loadScript(i,t={}){const{type:e="text/javascript",async:r=!0,defer:o=!1}=t;return this.cache.has(i)?this.cache.get(i):new Promise((n,s)=>{const a=document.createElement("script");a.type=e,a.async=r,a.defer=o,a.onload=()=>{this.cache.set(i,a),n(a)},a.onerror=()=>{a.remove(),s(new Error(`Failed to load script: ${i}`))},a.src=i,document.head.appendChild(a)})},async loadStylesheet(i,t={}){const{media:e="all"}=t;return this.cache.has(i)?this.cache.get(i):new Promise((r,o)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=i,n.media=e,n.onload=()=>{this.cache.set(i,n),r(n)},n.onerror=()=>{n.remove(),o(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(n)})},async loadFont(i,t,e={}){const{weight:r="normal",style:o="normal"}=e,n=new FontFace(i,`url(${t})`,{weight:r,style:o});try{return await n.load(),document.fonts.add(n),n}catch{throw new Error(`Failed to load font: ${i}`)}},async preload(i,t="image"){switch(t){case"image":return this.loadImage(i);case"script":return this.loadScript(i);case"stylesheet":case"style":return this.loadStylesheet(i);default:throw new Error(`Unsupported preload type: ${t}`)}},isLoaded(i){return this.cache.has(i)},clearCache(){this.cache.clear()},clearCacheByUrl(i){this.cache.delete(i)}}};window.KupolaUtils=bt,window.kupolaUtils=bt;class kt{constructor(){this.children={},this.keys=[]}}class B{constructor(){this.root=new kt}insert(t){let e=this.root;const r=t.split(".");r.forEach((o,n)=>{e.children[o]||(e.children[o]=new kt),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 s=r[n];if(!e.children[s])break;e=e.children[s];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 b={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class Et{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 s=Reflect.get(e,r,n),a=Reflect.set(e,r,o,n),l=this.resolvePath(e,r);return this.notify(l,o,s),this.queueUpdate(l,o),a},deleteProperty:(e,r)=>{const o=Reflect.get(e,r,receiver),n=Reflect.deleteProperty(e,r),s=this.resolvePath(e,r);return this.notify(s,void 0,o),this.queueUpdate(s,void 0),n}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[b.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const r={get:(n,s,a)=>{if(s==="__raw__")return n;if(s===b.parent||s==="__parent__")return n[b.parent];if(s===b.path||s==="__path__")return n[b.path];if(s===b.isReactive||s==="__isReactive__")return!0;const l=Reflect.get(n,s,a);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${n[b.path]}${n[b.path]?".":""}${s}`):l},set:(n,s,a,l)=>{if(s===b.parent||s===b.path||s===b.isReactive||s==="__parent__"||s==="__path__"||s==="__isReactive__")return!0;const c=Reflect.get(n,s,l),h=Reflect.set(n,s,a,l),u=`${n[b.path]}${n[b.path]?".":""}${s}`;return this.notify(u,a,c),this.queueUpdate(u,a),h},deleteProperty:(n,s)=>{if(s===b.parent||s===b.path||s===b.isReactive)return!1;const a=Reflect.get(n,s),l=Reflect.deleteProperty(n,s),c=`${n[b.path]}${n[b.path]?".":""}${s}`;return this.notify(c,void 0,a),this.queueUpdate(c,void 0),l},has:(n,s)=>s==="__raw__"||s===b.parent||s===b.path||s===b.isReactive||s==="__parent__"||s==="__path__"||s==="__isReactive__"?!0:s in n,ownKeys:n=>Reflect.ownKeys(n).filter(s=>s!==b.parent&&s!==b.path&&s!==b.isReactive),getOwnPropertyDescriptor:(n,s)=>s===b.parent||s===b.path||s===b.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:n[s]}:Reflect.getOwnPropertyDescriptor(n,s)},o=new Proxy(t,r);return t[b.parent]=t,t[b.path]=e,t[b.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[b.path]?`${t[b.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 s=this.get(n);this.updateElementsDirect(n,s),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(s=>this.updateQueue.has(s)))&&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),s=n[o];n[o]=e,this.notify(t,e,s),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 s=n.split(":"),a=s[0].trim(),l=s[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:s=!1,encryptionKey:a=null}=e,l=r==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:o,timeout:null,version:n,encrypt:s,encryptionKey:a});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:n,encrypt:s,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:s=!1,encryptionKey:a=null}=o,l={value:e,version:n,timestamp:Date.now()};let c=JSON.stringify(l);s&&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(s){console.warn(`sessionStorage also failed for key ${t}:`,s)}}}}_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 s=JSON.parse(t.getItem(n));s.timestamp&&e-s.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 s=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 ${s} (version ${l.version})`);continue}e[s]=l.value!==void 0?l.value:l}catch(a){console.warn(`Failed to load persisted key ${s}:`,a)}}}for(let o=0;o<sessionStorage.length;o++){const n=sessionStorage.key(o);if(n?.startsWith("kupola:")){const s=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 ${s} (version ${l.version})`);continue}e[s]=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 s=o.split(":")[1]?.trim();s&&(r.type==="checkbox"?(e[s]||(e[s]=[]),r.checked&&e[s].push(r.value)):r.type==="radio"?r.checked&&(e[s]=r.value):e[s]=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[b.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const r={get:(n,s,a)=>{if(s==="__raw__")return n;if(s===b.parent||s==="__parent__")return n[b.parent];if(s===b.path||s==="__path__")return n[b.path];if(s===b.isReactive||s==="__isReactive__")return!0;const l=Reflect.get(n,s,a);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${n[b.path]}${n[b.path]?".":""}${s}`):l},set:(n,s,a,l)=>{if(s===b.parent||s===b.path||s===b.isReactive||s==="__parent__"||s==="__path__"||s==="__isReactive__")return!0;const c=Reflect.get(n,s,l),h=Reflect.set(n,s,a,l),u=`${n[b.path]}${n[b.path]?".":""}${s}`;return this.notify(u,a,c),this.queueUpdate(u,a),h},deleteProperty:(n,s)=>{if(s===b.parent||s===b.path||s===b.isReactive)return!1;const a=Reflect.get(n,s),l=Reflect.deleteProperty(n,s),c=`${n[b.path]}${n[b.path]?".":""}${s}`;return this.notify(c,void 0,a),this.queueUpdate(c,void 0),l},has:(n,s)=>s==="__raw__"||s===b.parent||s===b.path||s===b.isReactive||s==="__parent__"||s==="__path__"||s==="__isReactive__"?!0:s in n,ownKeys:n=>Reflect.ownKeys(n).filter(s=>s!==b.parent&&s!==b.path&&s!==b.isReactive),getOwnPropertyDescriptor:(n,s)=>s===b.parent||s===b.path||s===b.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:n[s]}:Reflect.getOwnPropertyDescriptor(n,s)},o=new Proxy(t,r);return t[b.parent]=t,t[b.path]=e,t[b.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 s=()=>{const a=t.type==="checkbox"?t.checked:t.value;o.includes(".")?this.setNested(o,a):this.set(o,a)};t.__kupolaBindHandler=s,t.addEventListener("input",s)}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 K{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 Ct{constructor(){this.stores=new Map}createStore(t,e){const r=new K(t,e);return this.stores.set(t,r),r}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof K&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class St{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:s,cb:a})=>{(n.target.matches(s)||n.target.closest(s))&&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 U=new Et,Ki=new St,V=new Ct;function Ui(i,t){return V.createStore(i,t)}function Vi(i){return V.getStore(i)}document.addEventListener("DOMContentLoaded",()=>{U.loadPersisted(),U.bind()}),window.KupolaDataBind=Et,window.KupolaEventBus=St,window.KupolaStore=K,window.KupolaStoreManager=Ct,window.kupolaData=U,window.kupolaEvents=Ki,window.kupolaStoreManager=V,window.createStore=Ui,window.getStore=Vi;var W={exports:{}},Lt;function Wi(){return Lt||(Lt=1,function(i){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 s(){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 _=g.querySelector(".brand-name");_&&(_.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=s();a(p);const g=document.querySelector("[data-theme-toggle]");g&&g.addEventListener("click",()=>{const w=o()==="dark"?"light":"dark";n(w)});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(x=>{const w=document.createElement("button");w.setAttribute("data-brand-btn",x.id),w.style.display="flex",w.style.justifyContent="center",w.style.alignItems="center",w.style.height="60px",w.style.backgroundColor=x.color,w.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(x.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=x.name,f.appendChild(w)}),document.body.appendChild(f));const m=document.querySelector("[data-brand-toggle]");m&&f&&(m.onclick=function(x){x.stopPropagation(),x.preventDefault();const w=f.style.display==="none";f.style.display=w?"grid":"none",w?setTimeout(()=>{document.addEventListener("click",_,!0)},0):document.removeEventListener("click",_,!0)},f.onclick=function(x){x.stopPropagation()});function _(x){f&&m&&!f.contains(x.target)&&!m.contains(x.target)&&(f.style.display="none",document.removeEventListener("click",_,!0))}document.querySelectorAll("[data-brand-btn]").forEach(x=>{x.addEventListener("click",w=>{w.stopPropagation();const k=x.getAttribute("data-brand-btn");a(k),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 v=o()==="dark"?"light":"dark";n(v)}),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(v=>{const x=document.createElement("button");x.setAttribute("data-brand-btn",v.id),x.style.display="flex",x.style.justifyContent="center",x.style.alignItems="center",x.style.height="60px",x.style.backgroundColor=v.color,x.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(v.color)?"#0C0C0D":"#FFFFFF",x.style.fontWeight="500",x.style.borderRadius="4px",x.style.border="none",x.style.cursor="pointer",x.style.margin="0",x.style.padding="0",x.textContent=v.name,d.appendChild(x)}),document.body.appendChild(d);const p=document.createElement("button");p.setAttribute("data-brand-toggle",""),p.setAttribute("data-current-brand",s()),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(v=>v.id===s()).color;const f=document.createElement("span");f.className="brand-name",f.style.fontSize="11px",f.textContent=r.find(v=>v.id===s()).name,p.appendChild(g),p.appendChild(f),document.body.appendChild(p),p.onclick=function(v){v.stopPropagation(),v.preventDefault();const x=d.style.display==="none";d.style.display=x?"grid":"none",x?setTimeout(()=>{document.addEventListener("click",m,!0)},0):document.removeEventListener("click",m,!0)},d.onclick=function(v){v.stopPropagation()};function m(v){!d.contains(v.target)&&!p.contains(v.target)&&(d.style.display="none",document.removeEventListener("click",m,!0))}return d.querySelectorAll("[data-brand-btn]").forEach(v=>{v.addEventListener("click",x=>{x.stopPropagation();const w=v.getAttribute("data-brand-btn");a(w),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(i.exports)i.exports={getTheme:o,setTheme:n,initTheme:l,createThemeToggle:c,getBrand:s,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)}}(W)),W.exports}Wi();class Yi{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 Xi(i){const t=new Yi(i);t.init(),i._kupolaDropdown=t}function Ji(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}window.kupolaInitializer&&window.kupolaInitializer.register("dropdown",Xi,Ji);class ji{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 Gi(i){const t=new ji(i);t.init(),i._kupolaSelect=t}function Qi(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}window.kupolaInitializer&&window.kupolaInitializer.register("select",Gi,Qi);class Zi{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,s=e.height||280;o>=s?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):n>=s?(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"),s=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 _=`${u}-${String(d+1).padStart(2,"0")}-${String(f).padStart(2,"0")}`;e.value===_&&m.classList.add("is-selected");const v=new Date,x=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`;_===x&&m.classList.add("is-today");const w=()=>{e.value=_,t.style.display="none",t.setAttribute("hidden",""),e.dispatchEvent(new Event("change"))};m.addEventListener("click",w),m._dayClickHandler=w,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),s&&(s.addEventListener("click",h),s._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 ts(i){const t=new Zi(i);t.init(),i._kupolaDatepicker=t}function es(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("datepicker",ts,es);class is{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,s=e.height||320;o>=s?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):n>=s?(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!==R;){for(const[n,a]of Object.entries(t))i.has(n)||e.hasOwnProperty(n)&&(Array.isArray(a)?a.forEach(r=>{n==="render"&&this.lifecycle.on(r,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(a,r=>(this.renderError(r.error),"handled")):this.lifecycle.on(a,()=>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 j(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=R,window.applyMixin=j);class Ft{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 R))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 a=await i(),r=a.default||a;if(!(r.prototype instanceof R))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,r),r}catch(a){throw this.loadingPromises.delete(t),a}})();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&&j(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 l=D.get(e);if(l)try{await l(t);return}catch(o){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,o)}}let i=this.components.get(e);if(!i){try{i=await this.getAsync(e)}catch(l){console.error(`Failed to load component ${e}:`,l);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),a=i;n&&n.split(",").forEach(l=>{const o=this.mixins.get(l.trim());o&&j(a,o)});const r=new a(t);t.__kupolaInstance=r,this.instances.set(t,r),r.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(r=>console.error(r)),this._upgradeElements(n).catch(r=>console.error(r)),D.initialize(n).catch(()=>{});const a=D._buildSelector();a&&n.querySelectorAll?.(a).forEach(r=>{D.initialize(r).catch(()=>{})})}}),i.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const a=this.instances.get(n);a&&(a.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(r=>{const l=this.instances.get(r);l&&(l.unmount(),this.instances.delete(r))}),D.cleanup(n),n.querySelectorAll?.("*").forEach(r=>{D.cleanup(r)})}})})}),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=Ft),d.kupolaRegistry=null,typeof window<"u"&&(d.kupolaRegistry=new Ft);async function G(){typeof window<"u"&&(X.loadPersisted(),X.bind(),qt(),await D.initializeAll(),d.kupolaRegistry&&await d.kupolaRegistry.bootstrap())}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",G):typeof window<"u"&&setTimeout(G,0);function We(s,t){d.kupolaRegistry&&d.kupolaRegistry.register(s,t)}function Ue(s,t){d.kupolaRegistry&&d.kupolaRegistry.registerLazy(s,t)}function Ye(s){return d.kupolaRegistry?d.kupolaRegistry.bootstrap(s):Promise.resolve()}function Xe(s,t){d.kupolaRegistry&&d.kupolaRegistry.defineMixin(s,t)}function Je(s,...t){d.kupolaRegistry&&d.kupolaRegistry.useMixin(s,...t)}function je(s,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${s}"): options must be an object`);t.componentClass?d.kupolaRegistry&&d.kupolaRegistry.register(s,t.componentClass):t.lazy&&d.kupolaRegistry&&d.kupolaRegistry.registerLazy(s,t.lazy),t.init?D.register(s,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&D.register(s,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}typeof window<"u"&&(window.kupolaRegistry=d.kupolaRegistry,window.kupolaInitializer=D,window.kupolaBootstrap=G,window.registerComponent=We,window.registerLazyComponent=Ue,window.bootstrapComponents=Ye,window.defineMixin=Xe,window.useMixin=Je,window.defineComponent=je);class Z{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 a=JSON.parse(i.textContent);this.addLocale(n,a)}catch(a){console.error("Failed to parse i18n data:",a)}});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 a of i)if(n&&typeof n=="object"&&a in n)n=n[a];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 a=n.split("|");return a.length===1?n.replace("{count}",e):a.length===2?e===1?a[0]:a[1]:a.length>=3?e===0?a[0]:e===1?a[1]:a[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 P=new Z;function Ge(s){return new Z(s)}function Ze(s,t={}){return P.t(s,t)}function Qe(s,t,e={}){return P.n(s,t,e)}function ti(s){return P.setLocale(s)}function ei(){return P.getLocale()}function ii(s,t={}){return P.formatDate(s,t)}function si(s,t={}){return P.formatNumber(s,t)}function ni(s,t,e={}){return P.formatCurrency(s,t,e)}typeof window<"u"&&(window.KupolaI18n=Z,window.kupolaI18n=P,window.createI18n=Ge,window.t=Ze,window.n=Qe,window.setLocale=ti,window.getLocale=ei,window.formatDate=ii,window.formatNumber=si,window.formatCurrency=ni);class Nt{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 a=i-t.bottom,r=t.top;a<e.height&&r>a?(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 Q(s,t){const e=new Nt(s,t);e.init(),s._kupolaDropdown=e}function ai(s=document){s.querySelectorAll(".ds-dropdown").forEach(t=>{Q(t)})}function tt(s){s._kupolaDropdown&&(s._kupolaDropdown.destroy(),s._kupolaDropdown=null)}function ri(){document.querySelectorAll(".ds-dropdown").forEach(s=>{tt(s)})}typeof window<"u"&&(window.Dropdown=Nt,window.initDropdown=Q,window.initDropdowns=ai,window.cleanupDropdown=tt,window.cleanupAllDropdowns=ri,window.kupolaInitializer&&window.kupolaInitializer.register("dropdown",Q,tt));class Ot{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(a=>a.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(a=>a.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",a=>{a.stopPropagation(),this.selectedValues.delete(t);const r=this.optionsEl.querySelector(`[data-value="${t}"]`);r&&r.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 et(s,t){const e=new Ot(s,t);e.init(),s._kupolaSelect=e}function li(s=document){s.querySelectorAll(".ds-select").forEach(t=>{et(t)})}function it(s){s._kupolaSelect&&(s._kupolaSelect.destroy(),s._kupolaSelect=null)}function ys(){document.querySelectorAll(".ds-select").forEach(s=>{it(s)})}typeof window<"u"&&(window.Select=Ot,window.initSelect=et,window.initSelects=li,window.cleanupSelect=it,window.cleanupAllSelects=ys,window.kupolaInitializer&&window.kupolaInitializer.register("select",et,it));class Rt{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,a=t.top,r=e.height||320;n>=r?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):a>=r?(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(f=>{f._dayClickHandler&&f.removeEventListener("click",f._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 a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--prev",a.type="button",a.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>',a.addEventListener("click",f=>{f.stopPropagation(),this._prevMonth()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=`${e} ${this.months[i]}`,r.addEventListener("click",f=>{f.stopPropagation(),this.viewMode="months",this._renderCalendar()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",f=>{f.stopPropagation(),this._nextMonth()}),n.appendChild(a),n.appendChild(r),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(f=>{const g=document.createElement("span");g.className="ds-datepicker__weekday",g.textContent=f,o.appendChild(g)}),t.appendChild(o);const h=document.createElement("div");h.className="ds-datepicker__days";const u=new Date(e,i,1).getDay(),p=new Date(e,i+1,0).getDate(),m=(u-this.weekStart+7)%7;for(let f=0;f<m;f++){const g=document.createElement("span");g.className="ds-datepicker__day ds-datepicker__day--empty",h.appendChild(g)}for(let f=1;f<=p;f++){const g=new Date(e,i,f),v=document.createElement("button");v.className="ds-datepicker__day",v.type="button",v.textContent=f,this._formatDate(g),this._isToday(g)&&v.classList.add("is-today"),this.range?((this._isSameDay(g,this.rangeStart)||this._isSameDay(g,this.rangeEnd))&&v.classList.add("is-selected"),this._isInRange(g)&&v.classList.add("is-in-range")):this._isSameDay(g,this.selectedDate)&&v.classList.add("is-selected"),this._isDateDisabled(g)&&(v.classList.add("is-disabled"),v.disabled=!0);const y=()=>this._selectDate(g);v.addEventListener("click",y),v._dayClickHandler=y,h.appendChild(v)}if(t.appendChild(h),this.showToday){const f=document.createElement("div");f.className="ds-datepicker__footer";const g=document.createElement("button");g.className="ds-datepicker__today-btn",g.type="button",g.textContent=this.todayText,g.addEventListener("click",y=>{y.stopPropagation(),this._goToToday()});const v=document.createElement("button");v.className="ds-datepicker__clear-btn",v.type="button",v.textContent=this.clearText,v.addEventListener("click",y=>{y.stopPropagation(),this._clearDate()}),f.appendChild(g),f.appendChild(v),t.appendChild(f)}}_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 a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--prev",a.type="button",a.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>',a.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=`${i} - ${i+11}`,r.addEventListener("click",c=>{c.stopPropagation()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(a),n.appendChild(r),n.appendChild(l),t.appendChild(n);const o=document.createElement("div");o.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const h=i+c,u=document.createElement("button");u.className="ds-datepicker__year-cell",u.type="button",u.textContent=h,h===e&&u.classList.add("is-selected"),u.addEventListener("click",p=>{p.stopPropagation(),this.currentDate.setFullYear(h),this.viewMode="months",this._renderCalendar()}),o.appendChild(u)}t.appendChild(o)}_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",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=e,a.addEventListener("click",o=>{o.stopPropagation(),this.viewMode="years",this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--next",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',r.addEventListener("click",o=>{o.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),i.appendChild(n),i.appendChild(a),i.appendChild(r),t.appendChild(i);const l=document.createElement("div");l.className="ds-datepicker__months-grid",this.months.forEach((o,c)=>{const h=document.createElement("button");h.className="ds-datepicker__month-cell",h.type="button",h.textContent=o,c===this.currentDate.getMonth()&&h.classList.add("is-selected"),h.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),l.appendChild(h)}),t.appendChild(l)}_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 st(s,t){const e=new Rt(s,t);e.init(),s._kupolaDatepicker=e}function oi(s=document){s.querySelectorAll(".ds-datepicker").forEach(t=>{st(t)})}function nt(s){s._kupolaDatepicker&&(s._kupolaDatepicker.destroy(),s._kupolaDatepicker=null)}function vs(){document.querySelectorAll(".ds-datepicker").forEach(s=>{nt(s)})}typeof window<"u"&&(window.Datepicker=Rt,window.initDatepicker=st,window.initDatepickers=oi,window.cleanupDatepicker=nt,window.cleanupAllDatepickers=vs,window.kupolaInitializer&&window.kupolaInitializer.register("datepicker",st,nt));class Vt{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 a=this.minTime.split(":"),r=parseInt(a[0])*3600+parseInt(a[1])*60+(parseInt(a[2])||0);if(n<r)return!0}if(this.maxTime){const a=this.maxTime.split(":"),r=parseInt(a[0])*3600+parseInt(a[1])*60+(parseInt(a[2])||0);if(n>r)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,a=t.top,r=e.height||320;n>=r?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):a>=r?(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 a=i;this.use12Hour&&(i===12?a=this.isPM?12:0:a=this.isPM?i+12:i),this.selectedHour=a,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 a=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(a).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 at(s,t){const e=new Vt(s,t);e.init(),s._kupolaTimepicker=e}function ci(s=document){s.querySelectorAll(".ds-timepicker").forEach(t=>{at(t)})}function Kt(s){s._kupolaTimepicker&&(s._kupolaTimepicker.destroy(),s._kupolaTimepicker=null)}typeof window<"u"&&(window.Timepicker=Vt,window.initTimepicker=at,window.initTimepickers=ci,window.cleanupTimepicker=Kt,window.kupolaInitializer&&window.kupolaInitializer.register("timepicker",at,Kt));class Wt{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 a=(i-t)/(e-t)*100;this.vertical?n.style.bottom=a+"%":n.style.left=a+"%";const r=document.createElement("span");r.className="ds-slider__mark-label",r.textContent=i,n.appendChild(r),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=r=>{this.disabled||(r.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",n),document.addEventListener("mouseup",a),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",a))},n=r=>{if(!this._isDragging)return;r.preventDefault();const l=r.touches?r.touches[0].clientX:r.clientX,o=r.touches?r.touches[0].clientY:r.clientY,c=this.track.getBoundingClientRect();let h;this.vertical?h=1-(o-c.top)/c.height:h=(l-c.left)/c.width,h=Math.max(0,Math.min(1,h));const u=parseFloat(this.input?.min||0),p=parseFloat(this.input?.max||100),m=parseFloat(this.input?.step||1);let f=u+h*(p-u);if(f=Math.round(f/m)*m,f=Math.max(u,Math.min(p,f)),e==="start"&&this.range&&this.inputEnd){const g=parseFloat(this.inputEnd.value);f>g&&(f=g)}if(e==="end"&&this.range&&this.input){const g=parseFloat(this.input.value);f<g&&(f=g)}e==="start"&&this.input?this.input.value=f:e==="end"&&this.inputEnd&&(this.inputEnd.value=f),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:h})},a=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",a),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 a;this.vertical?a=1-(n-e.top)/e.height:a=(i-e.left)/e.width,a=Math.max(0,Math.min(1,a));const r=parseFloat(this.input?.min||0),l=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let c=r+a*(l-r);if(c=Math.round(c/o)*o,this.range){const h=parseFloat(this.input?.value||0),u=parseFloat(this.inputEnd?.value||0),p=Math.abs(c-h),m=Math.abs(c-u);p<=m?this.input&&(this.input.value=Math.min(c,u)):this.inputEnd&&(this.inputEnd.value=Math.max(c,h))}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),a=parseFloat(i.min||0),r=parseFloat(i.max||100);let l=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),l=Math.min(r,l+n);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),l=Math.max(a,l-n);break;case"Home":t.preventDefault(),l=a;break;case"End":t.preventDefault(),l=r;break;default:return}i.value=l,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),a=(i-t)/(e-t)*100,r=(n-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=a+"%",this.fill.style.height=r-a+"%"):(this.fill.style.left=a+"%",this.fill.style.width=r-a+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=a+"%":this.thumbStart.style.left=a+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=r+"%":this.thumbEnd.style.left=r+"%"),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 rt(s,t){if(!s.__kupolaInitialized)try{const e=new Wt(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}catch(e){console.error("[Slider] Error initializing:",e)}}function Ut(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function di(){document.querySelectorAll(".ds-slider").forEach(s=>{rt(s)})}typeof window<"u"&&(window.Slider=Wt,window.initSlider=rt,window.initSliders=di,window.cleanupSlider=Ut,window.kupolaInitializer&&window.kupolaInitializer.register("slider",rt,Ut));class Yt{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 lt(s,t){if(s.__kupolaInitialized)return;const e=new Yt(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function hi(s=document){s.querySelectorAll(".ds-carousel").forEach(t=>{lt(t)})}function ui(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}typeof window<"u"&&(window.Carousel=Yt,window.initCarousel=lt,window.initCarousels=hi,window.kupolaInitializer&&window.kupolaInitializer.register("carousel",lt,ui));class ot{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 ws(s={}){const{title:t="",content:e="",html:i=!1,placement:n="right",width:a="400px",height:r="400px",closable:l=!0,showMask:o=!0,footer:c=null,onClose:h,onOpen:u}=s,p=document.createElement("div");p.className="ds-drawer-container";let m="";c!==null&&(typeof c=="string"?m=`<div class="ds-drawer__footer">${c}</div>`:m=`<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>`),p.innerHTML=`
33
+ <div class="ds-drawer-mask">
34
+ <div class="ds-drawer ds-drawer--${n}" style="${n==="left"||n==="right"?"width:"+a:"height:"+r}">
35
+ <div class="ds-drawer__header">
36
+ <span class="ds-drawer__title"></span>
37
+ ${l?`<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
+ ${m}
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 s=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",()=>{s.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)}),s.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 ss(i){const t=new is(i);t.init(),i._kupolaTimepicker=t}function ns(i){i._kupolaTimepicker&&(i._kupolaTimepicker.destroy(),i._kupolaTimepicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("timepicker",ss,ns);class rs{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 os(i){if(!i.__kupolaInitialized)try{const t=new rs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}catch(t){console.error("[Slider] Error initializing:",t)}}function as(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}window.kupolaInitializer&&window.kupolaInitializer.register("slider",os,as);var Y={exports:{}},Ht;function ls(){return Ht||(Ht=1,function(i){class t{constructor(s){this.element=s,this.track=s.querySelector(".ds-carousel__track"),this.items=s.querySelectorAll(".ds-carousel__item"),this.prevBtn=s.querySelector(".ds-carousel__prev"),this.nextBtn=s.querySelector(".ds-carousel__next"),this.indicators=s.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=s.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((s,a)=>{const l=()=>this.goTo(a);this._indicatorClickHandlers.push(l),s.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(s){if(s<0||s>=this.totalItems)return;this.currentIndex=s;const a=-s*100;this.track.style.transform=`translateX(${a}%)`,this.updateIndicators()}prev(){const s=this.currentIndex>0?this.currentIndex-1:this.totalItems-1;this.goTo(s)}next(){const s=this.currentIndex<this.totalItems-1?this.currentIndex+1:0;this.goTo(s)}updateIndicators(){this.indicators.forEach((s,a)=>{a===this.currentIndex?s.classList.add("is-active"):s.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((s,a)=>{const l=this._indicatorClickHandlers[a];l&&s.removeEventListener("click",l)}),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function e(n){if(n.__kupolaInitialized)return;const s=new t(n);n.__kupolaInstance=s,n.__kupolaInitialized=!0}function r(n=document){n.querySelectorAll(".ds-carousel").forEach(s=>{e(s)})}function o(n){if(!n.__kupolaInitialized||!n.__kupolaInstance)return;n.__kupolaInstance.destroy(),n.__kupolaInstance=null,n.__kupolaInitialized=!1}i.exports?i.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))}(Y)),Y.exports}ls();class cs{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 ds(i){if(i.__kupolaInitialized)return;const t=new cs(i);i.__kupolaInstance=t,i.__kupolaInitialized=!0}function hs(i){if(!i.__kupolaInitialized||!i.__kupolaInstance)return;i.__kupolaInstance.destroy(),i.__kupolaInstance=null,i.__kupolaInitialized=!1}window.kupolaInitializer&&window.kupolaInitializer.register("drawer",ds,hs);var X={exports:{}},Dt;function us(){return Dt||(Dt=1,function(i){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(s={}){const{title:a="",content:l="",width:c="480px",onConfirm:h,onCancel:u}=s,d=document.createElement("div");d.className="ds-modal-container",d.innerHTML=`
47
+ `,document.body.appendChild(p);const f=new ot(p,{placement:n,width:a,height:r,showMask:o,onClose:h,onOpen:u}),g=p.querySelector(".ds-drawer__title");g&&(g.textContent=t);const v=p.querySelector(".ds-drawer__body");v&&(i?v.innerHTML=e:v.textContent=e);const y=p.querySelector("[data-drawer-confirm]"),k=p.querySelector("[data-drawer-cancel]");k&&k.addEventListener("click",()=>f.close()),y&&y.addEventListener("click",()=>{s.onConfirm&&s.onConfirm(),f.close()});const w=f.closeDrawer;return f.closeDrawer=()=>{w(),setTimeout(()=>{f.destroy(),p.remove()},300)},f.open(),f}function U(s,t){if(s.__kupolaInitialized)return;const e=new ot(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Xt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function pi(){document.querySelectorAll("[data-drawer]").forEach(s=>{s.addEventListener("click",()=>{const t=s.getAttribute("data-drawer"),e=document.getElementById(t);e&&(U(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&&U(t)})}typeof window<"u"&&(window.Drawer=ot,window.initDrawer=U,window.initDrawers=pi,window.cleanupDrawer=Xt,window.createDrawer=ws,window.kupolaInitializer&&window.kupolaInitializer.register("drawer",U,Xt));class T{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")})),T._openCount=(T._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),T._openCount=Math.max(0,(T._openCount||0)-1),T._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()}}T._openCount=0;function ct(s={}){const{title:t="",content:e="",html:i=!1,width:n="480px",fullscreen:a=!1,showCancel:r=!0,showConfirm:l=!0,confirmText:o="OK",cancelText:c="Cancel",confirmClass:h="ds-btn--brand",cancelClass:u="ds-btn--ghost",closable:p=!0,maskClosable:m=!0,onConfirm:f,onCancel:g,onOpen:v,onClose:y,footer:k=null}=s,w=document.createElement("div");w.className="ds-modal-container";let b="";k!==null&&(typeof k=="string"?b=`<div class="ds-modal__footer">${k}</div>`:(l||r)&&(b=`<div class="ds-modal__footer">
48
+ ${r?`<button class="ds-btn ${u}" data-modal-cancel>${c}</button>`:""}
49
+ ${l?`<button class="ds-btn ${h}" data-modal-confirm>${o}</button>`:""}
50
+ </div>`)),w.innerHTML=`
25
51
  <div class="ds-modal-mask">
26
- <div class="ds-modal" style="max-width: ${c}">
52
+ <div class="ds-modal${a?" ds-modal--fullscreen":""}" style="${a?"":"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
+ ${p?`<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
+ ${b}
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]"),_=d.querySelector("[data-modal-cancel]"),v=()=>{h&&h(),p.close()},x=()=>{u&&u(),p.close()};m&&m.addEventListener("click",v),_&&_.addEventListener("click",x);const w=()=>{setTimeout(()=>{m&&m.removeEventListener("click",v),_&&_.removeEventListener("click",x),p.destroy(),d.remove()},300)},k=p.close.bind(p);return p.close=()=>{k(),w()},p.open(),p}function r(s){if(s.__kupolaInitialized)return;const a=new t(s);s.__kupolaInstance=a,s.__kupolaInitialized=!0}function o(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function n(){document.querySelectorAll(".ds-modal-container").forEach(s=>{r(s)})}i.exports?i.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)}(X)),X.exports}us();var J={exports:{}},Mt;function ps(){return Mt||(Mt=1,function(i){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:s="",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(w);const E=new T(w,{fullscreen:a,closableOnMask:m}),C=w.querySelector(".ds-modal__title");C&&(C.textContent=t);const x=w.querySelector(".ds-modal__body");x&&(i?x.innerHTML=e:x.textContent=e);const S=w.querySelector("[data-modal-confirm]"),H=w.querySelector("[data-modal-cancel]");let I=!1;const q=async()=>{if(f){S.disabled=!0,S.classList.add("is-loading");try{if(await f()===!1){S.disabled=!1,S.classList.remove("is-loading");return}}catch{S.disabled=!1,S.classList.remove("is-loading");return}}I=!0,E.close()},fs=()=>{g&&g(),E.close()};S&&S.addEventListener("click",q),H&&H.addEventListener("click",fs);const Ts=()=>{setTimeout(()=>{S&&S.removeEventListener("click",q),H&&H.removeEventListener("click",fs),E.destroy(),w.remove(),y&&y(I)},300)},As=E.close.bind(E);return E.close=()=>{As(),Ts()},E.open(),v&&setTimeout(()=>v(),50),E}function fi(s){return typeof s=="string"&&(s={content:s}),ct({...s,showCancel:!0,showConfirm:!0})}function mi(s){return typeof s=="string"&&(s={content:s}),ct({...s,showCancel:!1,showConfirm:!0})}function dt(s){if(s.__kupolaInitialized)return;const t=new T(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function Jt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function gi(){document.querySelectorAll(".ds-modal-container").forEach(s=>{dt(s)})}typeof window<"u"&&(window.Modal=T,window.initModal=dt,window.cleanupModal=Jt,window.initModals=gi,window.createModal=ct,window.confirmModal=fi,window.alertModal=mi,window.kupolaInitializer&&window.kupolaInitializer.register("modal",dt,Jt));class _i{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:a,onCancel:r}=t,l={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},o=document.createElement("div");o.className="ds-modal-container",o.innerHTML=`
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}">${l[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"||r?'<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=s;const u=h.querySelector(".ds-modal-mask"),d=h.querySelector("[data-dialog-confirm]"),p=h.querySelector("[data-dialog-cancel]"),g=function(x){x.key==="Escape"&&(l&&l(),v())},f=function(x){x.target===u&&(l&&l(),v())},m=function(){a&&a(),v()},_=function(){l&&l(),v()},v=()=>{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",_),setTimeout(()=>h.remove(),300)};return u.classList.add("is-visible"),document.body.style.overflow="hidden",d&&d.addEventListener("click",m),p&&p.addEventListener("click",_),u.addEventListener("click",f),document.addEventListener("keydown",g),{close:v}}}i.exports&&(i.exports=t)}(J)),J.exports}ps();var j={exports:{}},Tt;function fs(){return Tt||(Tt=1,function(i){class t{constructor(s){this.element=s,this.dropzone=s.querySelector(".ds-fileupload__dropzone"),this.input=s.querySelector(".ds-fileupload__input"),this.list=s.querySelector(".ds-fileupload__list"),this.progress=s.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(s.getAttribute("data-max-size"))||0,this.maxCount=parseInt(s.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const s=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",s),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:s},{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(s){s.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(s){const a=this.input.getAttribute("accept");if(a&&a!==""){const l=a.split(",").map(d=>d.trim()),c=s.type,h=s.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: ${s.type}`),!1}return this.maxSize>0&&s.size>this.maxSize?(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1):!0}renderFileItem(s){const a=document.createElement("div");a.className="ds-fileupload__item",a.dataset.filename=s.name;const l=this.getFileIcon(s.type);a.innerHTML=`
81
+ `,document.body.appendChild(o),i&&(o.querySelector(".ds-dialog__title").textContent=i),o.querySelector(".ds-dialog__content").textContent=n;const c=o.querySelector(".ds-modal-mask"),h=o.querySelector("[data-dialog-confirm]"),u=o.querySelector("[data-dialog-cancel]"),p=function(y){y.key==="Escape"&&(r&&r(),v())},m=function(y){y.target===c&&(r&&r(),v())},f=function(){a&&a(),v()},g=function(){r&&r(),v()},v=()=>{c.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",p),c.removeEventListener("click",m),h&&h.removeEventListener("click",f),u&&u.removeEventListener("click",g),setTimeout(()=>o.remove(),300)};return c.classList.add("is-visible"),document.body.style.overflow="hidden",h&&h.addEventListener("click",f),u&&u.addEventListener("click",g),c.addEventListener("click",m),document.addEventListener("keydown",p),{close:v}}}typeof window<"u"&&(window.Dialog=_i);const yi={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,a=document.createElement("div");a.className=`ds-notification__item ds-notification__item--${i}`;const r={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>'};a.innerHTML=`
82
+ <div class="ds-notification__icon ds-notification__icon--${i}">${r[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&&(a.querySelector(".ds-notification__title").textContent=t),e&&(a.querySelector(".ds-notification__message").textContent=e);let l=document.querySelector(".ds-notification");l||(l=document.createElement("div"),l.className="ds-notification",document.body.appendChild(l)),l.appendChild(a),setTimeout(()=>{a.classList.add("is-visible")},10),a.querySelector(".ds-notification__close").addEventListener("click",()=>{a.classList.remove("is-visible"),a.classList.add("is-exiting"),setTimeout(()=>a.remove(),300)}),n>0&&setTimeout(()=>{a.classList.remove("is-visible"),a.classList.add("is-exiting"),setTimeout(()=>a.remove(),300)},n)}};function vi(){}typeof window<"u"&&(window.Notification=yi,window.initNotifications=vi);const wi={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 a={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}">${a[t]}</div>
92
+ <div class="ds-message__content"></div>
93
+ `,n.querySelector(".ds-message__content").textContent=s;let r=document.querySelector(".ds-message");r||(r=document.createElement("div"),r.className="ds-message",document.body.appendChild(r)),r.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 bi(){}typeof window<"u"&&(window.Message=wi,window.initMessages=bi);class jt{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=r=>{r.target===this.input||this.input.contains(r.target)||this.input.click()},e=r=>{const l=Array.from(r.target.files);this.addFiles(l),r.target.value=""},i=r=>{r.preventDefault(),r.stopPropagation(),this.dropzone.classList.add("is-dragging")},n=r=>{r.preventDefault(),r.stopPropagation(),this.dropzone.classList.remove("is-dragging")},a=r=>{r.preventDefault(),r.stopPropagation(),this.dropzone.classList.remove("is-dragging");const l=Array.from(r.dataTransfer.files);this.addFiles(l)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",e),this.dropzone.addEventListener("dragover",i),this.dropzone.addEventListener("dragleave",n),this.dropzone.addEventListener("drop",a),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:a})}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(l=>l.trim()),n=t.type,a=t.name.toLowerCase();if(!i.some(l=>l.startsWith(".")?a.endsWith(l):l.includes("/")?l.endsWith("/*")?n.startsWith(l.replace("/*","")):n===l:!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(s.name)}</span>
65
- <span class="ds-fileupload__size">${this.formatSize(s.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(s,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(s){return s.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>':s.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>':s.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>':s.includes("pdf")||s.includes("document")||s.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>':s.includes("zip")||s.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(s,a=20){if(s.length<=a)return s;const l=s.substring(s.lastIndexOf("."));return s.substring(0,s.lastIndexOf(".")).substring(0,a-l.length-3)+"..."+l}formatSize(s){if(s===0)return"0 B";const a=1024,l=["B","KB","MB","GB"],c=Math.floor(Math.log(s)/Math.log(a));return parseFloat((s/Math.pow(a,c)).toFixed(1))+" "+l[c]}removeFile(s,a){this.files=this.files.filter(l=>l!==s),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(s){this.clearError(),this.dropzone.classList.add("is-error");const a=document.createElement("div");a.className="ds-fileupload__error",a.textContent=s,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 s=this.dropzone.querySelector(".ds-fileupload__error");s&&s.remove()}showPreview(s){if(!s.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="${s.name}">
105
+ `;const n=e.querySelector(".ds-fileupload__remove"),a=()=>{this.removeFile(t,e)};n.addEventListener("click",a),this._listeners.push({el:n,event:"click",handler:a}),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(s,this.list?.querySelector(`[data-filename="${s.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(s)}updateProgress(s){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=`${s}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(a),s>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(s){this.updateProgress(0);const a=100;let l=0;Math.max(1,Math.floor(s.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:s,event:a,handler:l})=>{s.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 s=new t(n);n.__kupolaInstance=s,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)})}i.exports?i.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)}(j)),j.exports}fs();var G={exports:{}},It;function ms(){return It||(It=1,function(i){class t{constructor(s){this.element=s,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:s,event:a,handler:l})=>{s.removeEventListener(a,l)}),this._listeners=null,this.headers=null,this.element=null}toggle(s){const a=this.headers[s];a&&a.clickHandler()}expand(s){const a=this.headers[s];a&&!a.item.classList.contains("is-active")&&a.clickHandler()}collapse(s){const a=this.headers[s];a&&a.item.classList.contains("is-active")&&a.clickHandler()}expandAll(){this.headers.forEach((s,a)=>{s.item.classList.contains("is-active")||this.toggle(a)})}collapseAll(){this.headers.forEach((s,a)=>{s.item.classList.contains("is-active")&&this.toggle(a)})}}function e(n){if(n.__kupolaInitialized)return;const s=new t(n);n.__kupolaInstance=s,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)})}i.exports?i.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)}(G)),G.exports}ms();class gs{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 ys(i){const t=new gs(i);t.init(),i._kupolaColorPicker=t}function vs(i){i._kupolaColorPicker&&(i._kupolaColorPicker.destroy(),i._kupolaColorPicker=null)}window.kupolaInitializer&&window.kupolaInitializer.register("color-picker",ys,vs);var Q={exports:{}},At;function _s(){return At||(At=1,function(i){class t{constructor(s){if(this.element=s,this.titleEl=s.querySelector(".ds-calendar__title"),this.daysEl=s.querySelector(".ds-calendar__days"),this.prevBtn=s.querySelector(".ds-calendar__nav--prev"),this.nextBtn=s.querySelector(".ds-calendar__nav--next"),this.todayBtn=s.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 s=()=>{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",s),this._listeners.push({el:this.prevBtn,event:"click",handler:s})),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 s=this.currentDate.getFullYear(),a=this.currentDate.getMonth();this.titleEl.textContent=`${s} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a]}`;const l=new Date(s,a,1).getDay(),c=new Date(s,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=`${s}-${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(s,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:s,event:a,handler:l})=>{s.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(s){this.currentDate=new Date(s),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(s,a){if(this.element){const l=new CustomEvent(`kupola:calendar:${s}`,{detail:a,bubbles:!0,cancelable:!0});this.element.dispatchEvent(l)}}}function e(n){if(!n.__kupolaInitialized)try{const s=new t(n);n.__kupolaInstance=s,n.__kupolaInitialized=!0}catch(s){console.error("[Calendar] Error initializing:",s)}}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)})}i.exports?i.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)}(Q)),Q.exports}_s();var Z={exports:{}},qt;function ws(){return qt||(qt=1,function(i){class t{constructor(s){this.element=s,this.input=s.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__remove").forEach(s=>{const a=l=>{l.stopPropagation();const c=s.closest(".ds-dynamic-tags__tag");c&&(c.remove(),this.dispatchChange())};s.addEventListener("click",a),this._listeners.push({el:s,event:"click",handler:a})}),this.input){const s=()=>{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(),s())};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(s){!s||!this.input||(this.input.value=s,this.input.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})))}removeTag(s){const l=this.element.querySelectorAll(".ds-dynamic-tags__tag")[s];l&&(l.remove(),this.dispatchChange())}getTags(){const s=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(a=>{s.push(a.textContent)}),s}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(s=>{s.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:s,event:a,handler:l})=>{s.removeEventListener(a,l)}),this._listeners=null,this.input=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const s=new t(n);n.__kupolaInstance=s,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)})}i.exports?i.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)}(Z)),Z.exports}ws();var tt={exports:{}},zt;function xs(){return zt||(zt=1,function(i){class t{constructor(s={}){this.images=s.images||[],this.currentIndex=s.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 a=n.querySelector(".ds-fileupload__preview-remove"),r=()=>{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)};a.addEventListener("click",r),this._listeners.push({el:a,event:"click",handler:r}),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 a=Math.min(100,Math.floor(i/e*100));this.updateProgress(a),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 ht(s){if(s.__kupolaInitialized)return;const t=new jt(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function Gt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function ki(){document.querySelectorAll(".ds-fileupload").forEach(s=>{ht(s)})}typeof window<"u"&&(window.FileUpload=jt,window.initFileUpload=ht,window.cleanupFileUpload=Gt,window.initFileUploads=ki,window.kupolaInitializer&&window.kupolaInitializer.register("fileupload",ht,Gt));class Zt{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"),a=e.nextElementSibling;if(!n||!a||!a.classList.contains("ds-collapse__content"))return;const r=n.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(i);r&&n.classList.add("is-disabled");let l=n.classList.contains("is-active");(this.defaultExpanded==="all"||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(i))&&(l=!0),l?(n.classList.add("is-active"),a.style.height=a.scrollHeight+"px",a.style.overflow="hidden",setTimeout(()=>{n.classList.contains("is-active")&&(a.style.height="auto",a.style.overflow="visible")},this.animationDuration)):(n.classList.remove("is-active"),a.style.height="0",a.style.overflow="hidden");const o=()=>{if(r)return;const c=n.classList.contains("is-active");this.accordion&&!c&&this.headers.forEach((h,u)=>{u!==i&&h.item.classList.contains("is-active")&&this._collapseItem(h)}),c?this._collapseItem({item:n,content:a}):this._expandItem({item:n,content:a}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:i,expanded:!c,item:n},bubbles:!0}))};e.addEventListener("click",o),this.headers.push({header:e,item:n,content:a,clickHandler:o,isDisabled:r}),this._listeners.push({el:e,event:"click",handler:o})})}_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 ut(s,t){if(s.__kupolaInitialized)return;const e=new Zt(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function Qt(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Ei(){document.querySelectorAll(".ds-collapse").forEach(s=>{ut(s)})}typeof window<"u"&&(window.Collapse=Zt,window.initCollapse=ut,window.cleanupCollapse=Qt,window.initCollapses=Ei,window.kupolaInitializer&&window.kupolaInitializer.register("collapse",ut,Qt));class te{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,a=parseInt(e.substring(4,6),16)/255,r=e.length===8?parseInt(e.substring(6,8),16)/255:1,l=Math.max(i,n,a),o=Math.min(i,n,a);let c=0,h=0,u=l;const p=l-o;if(h=l===0?0:p/l,l!==o)switch(l){case i:c=((n-a)/p+(n<a?6:0))/6;break;case n:c=((a-i)/p+2)/6;break;case a:c=((i-n)/p+4)/6;break}this.hue=Math.round(c*360),this.saturation=Math.round(h*100),this.brightness=Math.round(u*100),this.alpha=Math.round(r*100)}_HSBToColorString(t,e,i,n=1){e/=100,i/=100,n/=100;const a=u=>(u+t/60)%6,r=u=>i*(1-e*Math.max(0,Math.min(a(u),4-a(u),1))),l=Math.round(r(5)*255),o=Math.round(r(3)*255),c=Math.round(r(1)*255);if(this.mode==="rgb")return n<1?`rgba(${l}, ${o}, ${c}, ${n.toFixed(2)})`:`rgb(${l}, ${o}, ${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 h=`#${l.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`;return n<1?h+Math.round(n*255).toString(16).padStart(2,"0"):h}_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 r=n.currentTarget.getAttribute("data-color");this.updateColor(r),this.hidePanel()},this._inputInputHandler=n=>{const a=n.target.value;this._isValidColor(a)&&this.updateColor(a)},this._alphaChangeHandler=n=>{this.alpha=parseInt(n.target.value),this._updateFromHSB()},this._modeChangeHandler=n=>{const a=n.currentTarget;this.mode=a.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(r=>r.classList.remove("is-active")),a.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=n=>{this.hue=parseInt(n.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=n=>{const a=n.currentTarget.getBoundingClientRect(),r=n.clientX-a.left,l=n.clientY-a.top;this.saturation=Math.round(r/a.width*100),this.brightness=Math.round((1-l/a.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 pt(s,t){const e=new te(s,t);e.init(),s._kupolaColorPicker=e}function xi(s=document){s.querySelectorAll(".ds-color-picker").forEach(t=>{pt(t)})}function ft(s){s._kupolaColorPicker&&(s._kupolaColorPicker.destroy(),s._kupolaColorPicker=null)}function bs(){document.querySelectorAll(".ds-color-picker").forEach(s=>{ft(s)})}typeof window<"u"&&(window.ColorPicker=te,window.initColorPicker=pt,window.initColorPickers=xi,window.cleanupColorPicker=ft,window.cleanupAllColorPickers=bs,window.kupolaInitializer&&window.kupolaInitializer.register("color-picker",pt,ft));class ee{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,a=i.end;if(!n)return!1;const r=typeof n=="string"?n:this._formatDate(n);if(!a)return r===e;const l=typeof a=="string"?a:this._formatDate(a);return e>=r&&e<=l})}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 l=0;l<i;l++){const o=document.createElement("span");o.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(o)}const a=new Date,r=this._formatDate(a);for(let l=1;l<=n;l++){const o=new Date(t,e,l),c=document.createElement("button");c.className="ds-calendar__day",c.textContent=l;const h=this._formatDate(o);h===r&&c.classList.add("is-today"),this._isSameDay(o,this.selectedDate)&&c.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(o)&&c.classList.add("is-range-start"),this._isRangeEnd(o)&&c.classList.add("is-range-end"),this._isDateInRange(o)&&c.classList.add("is-in-range"));const u=this._getEventsForDate(o);if(u.length>0){c.classList.add("has-events");const m=document.createElement("span");m.className="ds-calendar__day-event",m.style.backgroundColor=u[0].color||"#007bff",c.appendChild(m)}const p=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(m=>m.classList.remove("is-selected")),c.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(o,this.rangeEnd)?(this.rangeStart=o,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(o<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=o):this.rangeEnd=o,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=o,this.onSelect&&this.onSelect({date:o,dateStr:h}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:o,dateStr:h},bubbles:!0}))),u.forEach(m=>{this.onEventClick&&this.onEventClick(m,o)}),this.render()};c.addEventListener("click",p),this._listeners.push({el:c,event:"click",handler:p}),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)),a=n,r=new Date(n);r.setDate(n.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} - ${this.i18n.shortMonths[r.getMonth()]} ${r.getDate()} ${t}`,this.daysEl.innerHTML="";const l=new Date,o=this._formatDate(l);for(let c=0;c<7;c++){const h=new Date(n);h.setDate(n.getDate()+c);const u=document.createElement("button");u.className="ds-calendar__day ds-calendar__day--week";const p=document.createElement("span");p.className="ds-calendar__day-header",p.textContent=this.i18n.shortWeekdays[h.getDay()],u.appendChild(p);const m=document.createElement("span");m.className="ds-calendar__day-number",m.textContent=h.getDate(),u.appendChild(m);const f=this._formatDate(h);f===o&&u.classList.add("is-today"),this._isSameDay(h,this.selectedDate)&&u.classList.add("is-selected");const g=this._getEventsForDate(h);if(g.length>0){const y=document.createElement("span");y.className="ds-calendar__day-events",g.slice(0,3).forEach(k=>{const w=document.createElement("span");w.className="ds-calendar__day-event",w.style.backgroundColor=k.color||"#007bff",y.appendChild(w)}),u.appendChild(y)}const v=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(y=>y.classList.remove("is-selected")),u.classList.add("is-selected"),this.selectedDate=h,this.onSelect&&this.onSelect({date:h,dateStr:f}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:h,dateStr:f},bubbles:!0})),this.render()};u.addEventListener("click",v),this._listeners.push({el:u,event:"click",handler:v}),this.daysEl.appendChild(u)}}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 mt(s,t){if(!s.__kupolaInitialized)try{const e=new ee(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}catch(e){console.error("[Calendar] Error initializing:",e)}}function ie(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Ci(){document.querySelectorAll(".ds-calendar").forEach(s=>{mt(s)})}typeof window<"u"&&(window.Calendar=ee,window.initCalendar=mt,window.cleanupCalendar=ie,window.initCalendars=Ci,window.kupolaInitializer&&window.kupolaInitializer.register("calendar",mt,ie));class se{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 a=this.createTag(n);this.element.insertBefore(a,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 a=r=>{r.stopPropagation(),e.remove(),this.dispatchChange()};return n.addEventListener("click",a),this._listeners.push({el:n,event:"click",handler:a}),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(a=>i.classList.remove(a)),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 gt(s,t){if(s.__kupolaInitialized)return;const e=new se(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function ne(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Si(){document.querySelectorAll(".ds-dynamic-tags").forEach(s=>{gt(s)})}typeof window<"u"&&(window.DynamicTags=se,window.initDynamicTags=gt,window.cleanupDynamicTags=ne,window.initDynamicTagsAll=Si,window.kupolaInitializer&&window.kupolaInitializer.register("dynamic-tags",gt,ne));class _t{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 s=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(),s.addEventListener("click",this.closeHandler),a.addEventListener("click",this._prevHandler),l.addEventListener("click",this._nextHandler)}handleKeydown(s){if(this.overlay.classList.contains("is-visible"))switch(s.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break}}handleOverlayClick(s){s.target===this.overlay&&this.close()}show(s,a=0){this.images=s,this.currentIndex=Math.min(Math.max(a,0),s.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(s){s>=0&&s<this.images.length&&(this.currentIndex=s,this.render())}render(){const s=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];s.src=d.src,s.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 s=this.overlay?.querySelector(".ds-image-preview__indicators");s&&s.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 s=JSON.parse(n.getAttribute("data-image-preview")),a=parseInt(n.getAttribute("data-image-index"))||0;e.show(s,a)})})}function o(n,s=0){e||(e=new t),e.show(n,s)}i.exports&&(i.exports={ImagePreview:t,initImagePreview:r,showImagePreview:o})}(tt)),tt.exports}xs();var et={exports:{}},Pt;function bs(){return Pt||(Pt=1,function(i){class t{constructor(s){this.element=s,this.closeBtn=s.querySelector(".ds-tag__close"),this._listeners=[],this.init()}init(){if(this.closeBtn){const s=a=>{a.stopPropagation(),this.element.dispatchEvent(new CustomEvent("ds-tag-remove",{detail:{tag:this.element},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",s),this._listeners.push({el:this.closeBtn,event:"click",handler:s})}}setContent(s){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(s),this.closeBtn||null)}getContent(){return this.element.textContent.trim()}destroy(){this._listeners.forEach(({el:s,event:a,handler:l})=>{s.removeEventListener(a,l)}),this._listeners=null,this.closeBtn=null,this.element=null}}function e(n){if(n.__kupolaInitialized)return;const s=new t(n);n.__kupolaInstance=s,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)})}i.exports?i.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)}(et)),et.exports}bs();var it={exports:{}},$t;function ks(){return $t||($t=1,function(i){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 _=m-p,v=Math.min(_/d,1),x=1-Math.pow(1-v,3),w=g+(c-g)*x;let k;c>=1e6?k=(w/1e6).toFixed(1)+"M":c>=1e3?k=(w/1e3).toFixed(1)+"K":Number.isInteger(c)?k=Math.floor(w).toLocaleString():k=w.toFixed(2),this.valueElement.textContent=h+k+u,v<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=>{const x=v-m,w=Math.min(x/c,1),k=1-Math.pow(1-w,3),E=g+(f-g)*k;let L;f>=1e6?L=(E/1e6).toFixed(1)+"M":f>=1e3?L=(E/1e3).toFixed(1)+"K":Number.isInteger(f)?L=Math.floor(E).toLocaleString():L=E.toFixed(2),this.valueElement.textContent=d+L+p,w<1&&requestAnimationFrame(_)};requestAnimationFrame(_)}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),_=1-Math.pow(1-m,3),v=h+(u-h)*_;this.progressFill.style.width=v+"%",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(s){if(s.__kupolaInitialized)return;const a=new t(s);s.__kupolaInstance=a,s.__kupolaInitialized=!0}function r(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function o(){document.querySelectorAll(".ds-statcard").forEach(s=>{e(s)})}function n(s,a){const l=document.querySelector(s);l&&l.__kupolaInstance&&l.__kupolaInstance.updateValue(a)}i.exports?i.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)}(it)),it.exports}ks();var st={exports:{}},Rt;function Es(){return Rt||(Rt=1,function(i){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 C=1;C<d;C++)h.push(null);for(let C=new Date(this.startDate);C<=this.endDate;C.setDate(C.getDate()+1))h.push(new Date(C)),(C.getDay()===6||C.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 _=document.createElement("div");_.className="ds-heatmap__labels-and-grid";const v=document.createElement("div");v.className="ds-heatmap__weekday-labels";const x=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(C=>{const S=document.createElement("div");S.className="ds-heatmap__weekday-label",S.textContent=C,S.style.height=x+"px",S.style.lineHeight=x+"px",v.appendChild(S)}),_.appendChild(v);const w=document.createElement("div");w.className="ds-heatmap__grid-container";const k=document.createElement("div");k.className="ds-heatmap__month-labels",k.style.width=f+"px";const E=this.getMonthLabels();E.forEach((C,S)=>{const H=document.createElement("div");H.className="ds-heatmap__month-label",H.textContent=C.label;const M=E[S+1];let z;M?z=Math.ceil((M.offset-C.offset)/7):z=p-Math.floor(C.offset/7),H.style.width=z*g+"px",k.appendChild(H)}),w.appendChild(k);const L=document.createElement("div");L.className="ds-heatmap__grid",c.forEach(C=>{const S=document.createElement("div");S.className="ds-heatmap__week-column",C.forEach(H=>{if(H===null){const M=document.createElement("div");M.className="ds-heatmap__cell",M.style.visibility="hidden",S.appendChild(M)}else{const M=this.getDataByDate(H),z=Math.max(...this.data.map(dt=>dt.value),1),Xs=this.getLevel(M,z),T=document.createElement("div");T.className="ds-heatmap__cell",T.dataset.date=this.formatDate(H),T.dataset.value=M,T.style.backgroundColor=this.getCellColor(Xs);const zi=dt=>this.showTooltip(dt,H,M),Pi=()=>this.hideTooltip(),$i=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(H),value:M})};T.addEventListener("mouseenter",zi),T.addEventListener("mouseleave",Pi),T.addEventListener("click",$i),this._listeners.push({el:T,event:"mouseenter",handler:zi},{el:T,event:"mouseleave",handler:Pi},{el:T,event:"click",handler:$i}),S.appendChild(T)}}),L.appendChild(S)}),w.appendChild(L),_.appendChild(w),m.appendChild(_),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 s(a,l={}){const c=document.querySelector(a);if(c){const h=l.data||n();return new t(c,{data:h,...l})}return null}i.exports?i.exports={Heatmap:t,initHeatmaps:o,initHeatmap:e,cleanupHeatmap:r,createHeatmap:s,generateMockHeatmapData:n}:(window.Heatmap=t,window.initHeatmap=e,window.cleanupHeatmap=r),window.kupolaInitializer&&window.kupolaInitializer.register("heatmap",e,r)}(st)),st.exports}Es();class Cs{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,s=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>s&&(l=s-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 Ss(i){const t=new Cs(i);t.init(),i._kupolaTooltip=t}function Ls(i){i._kupolaTooltip&&(i._kupolaTooltip.destroy(),i._kupolaTooltip=null)}window.kupolaInitializer&&window.kupolaInitializer.register("tooltip",Ss,Ls);class Ft{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(s=>{const a=s.name||s.id,l=this.parseRules(s.getAttribute("data-validate")),c=this.getValue(s);for(const[h,u]of Object.entries(l))if((this.customValidators[h]||this.validators[h])?.(c,u))this.clearError(s);else{r[a]=this.getErrorMessage(h,u,s),this.showError(s,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 s=!1;for(const l of n)await this.validateInputAsync(l)||(s=!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:!s,errors:a,errorCount:Object.keys(a).length},this.updateFormState(t),!s}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,s]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(o,s))return this.showError(t,this.getErrorMessage(n,s,t)),!1;for(const[n,s]of Object.entries(r)){const a=this.customAsyncValidators[n]||this.asyncValidators[n];if(a)try{if(!await a(o,s,t))return this.showError(t,this.getErrorMessage(n,s,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,s]=o.split(":");e[n]=s?s.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 D=new Ft;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(i=>{i.addEventListener("submit",async t=>{const e=i.id||`form-${Math.random().toString(36).substr(2,9)}`;if(D.submitting.has(e)){t.preventDefault();return}t.preventDefault();const r=i.querySelector("[data-validate-async]")!==null;let o;if(r?o=await D.validateAsync(i):o=D.validate(i),o){D.submitting.add(e);const n=i.querySelector('button[type="submit"]');if(n){const s=n.textContent;n.setAttribute("data-original-text",s),n.textContent="Submitting...",n.disabled=!0}try{const s=i.getAttribute("data-on-submit");s&&window[s]?await window[s](i):i.submit()}finally{D.submitting.delete(e),n&&(n.textContent=n.getAttribute("data-original-text")||"Submit",n.disabled=!1)}}else{const n=i.querySelector(".ds-input--error");n&&n.focus()}}),i.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const o=document.activeElement;if(o&&o.closest(".ds-select"))return;D.validateInput(t)&&t.value.trim()&&D.showSuccess(t)},50)});const r=((o,n)=>{let s;return(...a)=>{clearTimeout(s),s=setTimeout(()=>o.apply(void 0,a),n)}})(()=>{const o=D.getValue(t);o.length>0||t.classList.contains("ds-input--error")?D.validateInput(t)&&o&&D.showSuccess(t):D.removeStatusIcon(t)},300);t.addEventListener("input",r),t.addEventListener("keyup",o=>{o.key==="Enter"&&D.validateInput(t)&&t.value.trim()&&D.showSuccess(t)})})})})),window.KupolaValidator=Ft,window.kupolaValidator=D;var nt={exports:{}},Ot;function Hs(){return Ot||(Ot=1,function(i){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(r=>{r.addEventListener("click",l=>{const o=r.getAttribute("data-action");this.handleToolbarAction(o)})}),this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",r=>{r.preventDefault(),r.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"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),r=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),l=this.images[this.currentIndex];t.src=l.src,t.alt=l.alt||"",e.textContent=l.title||"",i.textContent=l.meta||`${this.currentIndex+1} / ${this.images.length}`,a.disabled=this.currentIndex===0,r.disabled=this.currentIndex===this.images.length-1,n.innerHTML=this.images.map((o,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(o=>{const c=()=>{this.goTo(parseInt(o.dataset.index))};o.addEventListener("click",c),o._clickHandler=c})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(a=>{a._clickHandler&&a.removeEventListener("click",a._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 V=null;function Li(){V||(V=new _t),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;V.show(t,e)})})}function Di(s,t=0){V||(V=new _t),V.show(s,t)}typeof window<"u"&&(window.ImagePreview=_t,window.initImagePreview=Li,window.showImagePreview=Di);class ae{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(l=>{l.nodeType===Node.TEXT_NODE&&e.push(l)}),e.forEach(l=>l.remove());const i=this.element.querySelector(".ds-tag__close"),n=this.element.querySelector(".ds-tag__checkbox"),a=this.element.querySelector(".ds-tag__input"),r=i||n||a||null;this.element.insertBefore(document.createTextNode(t),r),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(),a=r=>{r.key==="Enter"?this.endEdit():r.key==="Escape"&&this.cancelEdit()};e.addEventListener("blur",n),e.addEventListener("keydown",a),this._listeners.push({el:e,event:"blur",handler:n}),this._listeners.push({el:e,event:"keydown",handler:a})}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 yt(s,t){if(s.__kupolaInitialized)return;const e=new ae(s,t);s.__kupolaInstance=e,s.__kupolaInitialized=!0}function re(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Mi(){document.querySelectorAll(".ds-tag").forEach(s=>{yt(s)})}typeof window<"u"&&(window.Tag=ae,window.initTag=yt,window.cleanupTag=re,window.initTags=Mi,window.kupolaInitializer&&window.kupolaInitializer.register("tag",yt,re));class le{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),a=t.substring(e.index+e[0].length),r=1500,l=performance.now(),o=0,c=h=>{const u=h-l,p=Math.min(u/r,1),m=1-Math.pow(1-p,3),f=o+(i-o)*m;let g;i>=1e6?g=(f/1e6).toFixed(1)+"M":i>=1e3?g=(f/1e3).toFixed(1)+"K":Number.isInteger(i)?g=Math.floor(f).toLocaleString():g=f.toFixed(2),this.valueElement.textContent=n+g+a,p<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,a=n.match(/[\d.,]+/);if(!a){this.valueElement.textContent=t;return}const r=n.substring(0,a.index),l=n.substring(a.index+a[0].length),o=parseFloat(a[0].replace(",","")),c=parseFloat(t),h=performance.now(),u=p=>{const m=p-h,f=Math.min(m/i,1),g=1-Math.pow(1-f,3),v=o+(c-o)*g;let y;c>=1e6?y=(v/1e6).toFixed(1)+"M":c>=1e3?y=(v/1e3).toFixed(1)+"K":Number.isInteger(c)?y=Math.floor(v).toLocaleString():y=v.toFixed(2),this.valueElement.textContent=r+y+l,f<1&&requestAnimationFrame(u)};requestAnimationFrame(u)}updateProgress(t,e={}){if(!this.progressFill)return;const i=e.duration||600,n=parseFloat(this.progressFill.style.width||"0"),a=Math.min(Math.max(t,0),100),r=performance.now(),l=o=>{const c=o-r,h=Math.min(c/i,1),u=1-Math.pow(1-h,3),p=n+(a-n)*u;this.progressFill.style.width=p+"%",h<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}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 vt(s){if(s.__kupolaInitialized)return;const t=new le(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function oe(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Hi(){document.querySelectorAll(".ds-statcard").forEach(s=>{vt(s)})}function ks(s,t){const e=document.querySelector(s);e&&e.__kupolaInstance&&e.__kupolaInstance.updateValue(t)}typeof window<"u"&&(window.StatCard=le,window.initStatCard=vt,window.cleanupStatCard=oe,window.initStatCards=Hi,window.updateStatCard=ks,window.kupolaInitializer&&window.kupolaInitializer.register("statcard",vt,oe));class wt{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 a=n.getMonth(),r=n.getDate();a!==i&&r===1&&(e.push({month:a,label:t[a],offset:Math.floor((n-this.startDate)/(1e3*60*60*24))}),i=a)}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 a=new Date(this.startDate).getDay();for(let y=1;y<a;y++)i.push(null);for(let y=new Date(this.startDate);y<=this.endDate;y.setDate(y.getDate()+1))i.push(new Date(y)),(y.getDay()===6||y.getTime()===this.endDate.getTime())&&(e.push(i),i=[]);const r=e.length,l=this.element.classList.contains("ds-heatmap--compact")?12:16,o=r*l,c=document.createElement("div");c.className="ds-heatmap__container";const h=document.createElement("div");h.className="ds-heatmap__labels-and-grid";const u=document.createElement("div");u.className="ds-heatmap__weekday-labels";const p=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__weekday-label",k.textContent=y,k.style.height=p+"px",k.style.lineHeight=p+"px",u.appendChild(k)}),h.appendChild(u);const m=document.createElement("div");m.className="ds-heatmap__grid-container";const f=document.createElement("div");f.className="ds-heatmap__month-labels",f.style.width=o+"px";const g=this.getMonthLabels();g.forEach((y,k)=>{const w=document.createElement("div");w.className="ds-heatmap__month-label",w.textContent=y.label;const b=g[k+1];let E;b?E=Math.ceil((b.offset-y.offset)/7):E=r-Math.floor(y.offset/7),w.style.width=E*l+"px",f.appendChild(w)}),m.appendChild(f);const v=document.createElement("div");v.className="ds-heatmap__grid",e.forEach(y=>{const k=document.createElement("div");k.className="ds-heatmap__week-column",y.forEach(w=>{if(w===null){const b=document.createElement("div");b.className="ds-heatmap__cell",b.style.visibility="hidden",k.appendChild(b)}else{const b=this.getDataByDate(w),E=Math.max(...this.data.map(q=>q.value),1),C=this.getLevel(b,E),x=document.createElement("div");x.className="ds-heatmap__cell",x.dataset.date=this.formatDate(w),x.dataset.value=b,x.style.backgroundColor=this.getCellColor(C);const S=q=>this.showTooltip(q,w,b),H=()=>this.hideTooltip(),I=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(w),value:b})};x.addEventListener("mouseenter",S),x.addEventListener("mouseleave",H),x.addEventListener("click",I),this._listeners.push({el:x,event:"mouseenter",handler:S},{el:x,event:"mouseleave",handler:H},{el:x,event:"click",handler:I}),k.appendChild(x)}}),v.appendChild(k)}),m.appendChild(v),h.appendChild(m),c.appendChild(h),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 r=0;r<=5;r++){const l=document.createElement("div");l.className="ds-heatmap__legend-cell",l.style.backgroundColor=this.getCellColor(r),n.appendChild(l)}const a=document.createElement("span");a.className="ds-heatmap__legend-label",a.textContent="多",e.appendChild(i),e.appendChild(n),e.appendChild(a),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(),a=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-a/2,window.innerWidth-a-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 bt(s){if(s.__kupolaInitialized)return;const t=s.getAttribute("data-heatmap-data");let e=[];if(t)try{e=JSON.parse(t)}catch{e=kt()}else e=kt();const i=new wt(s,{data:e,onCellClick:n=>{}});s.__kupolaInstance=i,s.__kupolaInitialized=!0}function ce(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Ii(){document.querySelectorAll(".ds-heatmap").forEach(s=>{bt(s)})}function kt(){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(),a=String(i.getMonth()+1).padStart(2,"0"),r=String(i.getDate()).padStart(2,"0"),o=i.getDay()===0||i.getDay()===6?Math.random()*20:Math.random()*50,c=Math.floor(o);s.push({date:`${n}-${a}-${r}`,value:c>0?c:Math.floor(Math.random()*30)+1})}return s}function Es(s,t={}){const e=document.querySelector(s);if(e){const i=t.data||kt();return new wt(e,{data:i,...t})}return null}typeof window<"u"&&(window.Heatmap=wt,window.initHeatmap=bt,window.cleanupHeatmap=ce,window.initHeatmaps=Ii,window.createHeatmap=Es,window.generateMockHeatmapData=kt,window.kupolaInitializer&&window.kupolaInitializer.register("heatmap",bt,ce));class de{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 a=window.innerWidth,r=window.innerHeight;i+e.width>a&&(i=t.clientX-e.width-10),n+e.height>r&&(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 a,r;switch(this.position){case"bottom":a=t.left+t.width/2-e.width/2,r=t.bottom+8;break;case"right":a=t.right+8,r=t.top+t.height/2-e.height/2;break;case"left":a=t.left-e.width-8,r=t.top+t.height/2-e.height/2;break;case"top":default:a=t.left+t.width/2-e.width/2,r=t.top-e.height-8;break}a<8&&(a=8),a+e.width>i&&(a=i-e.width-8),r<8&&(r=8),r+e.height>n&&(r=n-e.height-8),this.tooltipEl.style.left=`${a}px`,this.tooltipEl.style.top=`${r}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 Et(s,t){const e=new de(s,t);e.init(),s._kupolaTooltip=e}function Ti(s=document){s.querySelectorAll("[data-tooltip]").forEach(t=>{Et(t)})}function he(s){s._kupolaTooltip&&(s._kupolaTooltip.destroy(),s._kupolaTooltip=null)}typeof window<"u"&&(window.Tooltip=de,window.initTooltip=Et,window.initTooltips=Ti,window.cleanupTooltip=he,window.kupolaInitializer&&window.kupolaInitializer.register("tooltip",Et,he));class ue{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 a=!1;return n.forEach(r=>{const l=r.name||r.id,o=this.parseRules(r.getAttribute("data-validate")),c=this.getValue(r);for(const[h,u]of Object.entries(o))if((this.customValidators[h]||this.validators[h])?.(c,u))this.clearError(r);else{i[l]=this.getErrorMessage(h,u,r),this.showError(r,i[l]),a=!0;break}}),this.formStates[e]={valid:!a,errors:i,errorCount:Object.keys(i).length},this.updateFormState(t),!a}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,a]of Object.entries(e))if(!(this.customValidators[n]||this.validators[n])?.(i,a))return this.showError(t,this.getErrorMessage(n,a,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,a=n?t.querySelectorAll(`[data-validate][data-validate-group="${n}"]`):t.querySelectorAll("[data-validate]");let r=!1;for(const o of a)await this.validateInputAsync(o)||(r=!0);const l={};return a.forEach(o=>{const c=o.name||o.id,h=o.parentElement.querySelector(".ds-input__error");h&&(l[c]=h.textContent)}),this.formStates[i]={valid:!r,errors:l,errorCount:Object.keys(l).length},this.updateFormState(t),!r}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[a,r]of Object.entries(e))if(!(this.customValidators[a]||this.validators[a])?.(n,r))return this.showError(t,this.getErrorMessage(a,r,t)),!1;for(const[a,r]of Object.entries(i)){const l=this.customAsyncValidators[a]||this.asyncValidators[a];if(l)try{if(!await l(n,r,t))return this.showError(t,this.getErrorMessage(a,r,t)),!1}catch(o){return this.showError(t,o.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 a of i)await this.validateInputAsync(a)||(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[a,r]=n.split(":");e[a]=r?r.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 M=new ue;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(M.submitting.has(e)){t.preventDefault();return}t.preventDefault();const i=s.querySelector("[data-validate-async]")!==null;let n;if(i?n=await M.validateAsync(s):n=M.validate(s),n){M.submitting.add(e);const a=s.querySelector('button[type="submit"]');if(a){const r=a.textContent;a.setAttribute("data-original-text",r),a.textContent="Submitting...",a.disabled=!0}try{const r=s.getAttribute("data-on-submit");r&&window[r]?await window[r](s):s.submit()}finally{M.submitting.delete(e),a&&(a.textContent=a.getAttribute("data-original-text")||"Submit",a.disabled=!1)}}else{const a=s.querySelector(".ds-input--error");a&&a.focus()}}),s.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const n=document.activeElement;if(n&&n.closest(".ds-select"))return;M.validateInput(t)&&t.value.trim()&&M.showSuccess(t)},50)});const i=((n,a)=>{let r;return(...l)=>{clearTimeout(r),r=setTimeout(()=>n.apply(void 0,l),a)}})(()=>{const n=M.getValue(t);n.length>0||t.classList.contains("ds-input--error")?M.validateInput(t)&&n&&M.showSuccess(t):M.removeStatusIcon(t)},300);t.addEventListener("input",i),t.addEventListener("keyup",n=>{n.key==="Enter"&&M.validateInput(t)&&t.value.trim()&&M.showSuccess(t)})})})})),typeof window<"u"&&(window.KupolaValidator=ue,window.kupolaValidator=M);class xt{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,_)=>{const v=u+_,x=m[this.keyField]||v,w=this.selectedKey===x,k=this.getItemSize(v),E=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 a=this.getItemSize(n);t.push({start:e,end:e+a,size:a}),e+=a}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((i,n,a)=>i+this.getItemSize(a),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 a=0;a<n.length;a++)if(t>=n[a].start&&t<n[a].end)return a;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 a=Math.min(this.data.length-1,this.getIndexAtOffset(e+i)+this.bufferSize);a<n&&(a=n),this.startIndex=n,this.endIndex=a;const r=this.data.slice(n,a+1);let l="",o=0;if(this.useDynamicHeight)o=this.getItemPositions()[n]?.start||0;else{const c=t?this.itemWidth:this.itemHeight;o=n*c}r.forEach((c,h)=>{const u=n+h,p=c[this.keyField]||u,m=this.selectedKey===p,f=this.getItemSize(u),g=o;t?l+=`
136
201
  <div
137
- class="ds-virtual-list__item${w?" is-selected":""}"
138
- style="position: absolute; top: 0; left: ${E}px; width: ${k}px; height: 100%;"
139
- data-index="${v}"
140
- data-key="${x}"
202
+ class="ds-virtual-list__item${m?" is-selected":""}"
203
+ style="position: absolute; top: 0; left: ${g}px; width: ${f}px; height: 100%;"
204
+ data-index="${u}"
205
+ data-key="${p}"
141
206
  >
142
- ${this.renderItem(m,v)}
207
+ ${this.renderItem(c,u)}
143
208
  </div>
144
- `:g+=`
209
+ `:l+=`
145
210
  <div
146
- class="ds-virtual-list__item${w?" is-selected":""}"
147
- style="position: absolute; top: ${E}px; left: 0; right: 0; height: ${k}px;"
148
- data-index="${v}"
149
- data-key="${x}"
211
+ class="ds-virtual-list__item${m?" is-selected":""}"
212
+ style="position: absolute; top: ${g}px; left: 0; right: 0; height: ${f}px;"
213
+ data-index="${u}"
214
+ data-key="${p}"
150
215
  >
151
- ${this.renderItem(m,v)}
152
- </div>
153
- `,f+=k}),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 s(){document.querySelectorAll(".ds-virtual-list").forEach(a=>{o(a)})}i.exports?i.exports={VirtualList:t,initVirtualLists:s,initVirtualList:o,cleanupVirtualList:n,createVirtualList:r,generateMockVirtualListData:e}:(window.initVirtualList=o,window.cleanupVirtualList=n),window.kupolaInitializer&&window.kupolaInitializer.register("virtual-list",o,n)}(nt)),nt.exports}Hs();let Nt=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 s=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 ${s}">${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,u)}
214
217
  </div>
218
+ `,o+=f}),this.container.innerHTML=l,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,a=e.offsetHeight;a!==this.getItemSize(i)&&(this.dynamicHeightCache.set(n,a),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 a=Math.max(20,i/e*i),r=i-a,l=n/(e-i||1)*r;this.scrollbarThumb.style.height=a+"px",this.scrollbarThumb.style.top=l+"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,a=e-n,r=t.clientY-this.dragStartY;let l=this.dragStartTop+r;l=Math.max(0,Math.min(l,a)),this.scrollbarThumb.style.top=l+"px";const o=l/a*(i-e||0);this.element.scrollTop=o}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 a=i?this.itemWidth:this.itemHeight;n=t*a}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 Ct(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),a=Math.floor(Math.random()*1e4);t.push({id:i,title:`${e[n]} ${a}`,subtitle:`Last modified ${Math.floor(Math.random()*30)} days ago`,type:e[n].toLowerCase()})}return t}function xs(s,t={}){const e=document.querySelector(s);if(e){const i=t.data||Ct(t.count||1e3);return new xt(e,{data:i,...t})}return null}function St(s){if(s.__kupolaInitialized)return;const t=s.getAttribute("data-virtual-list");let e=[];if(t)try{e=JSON.parse(t)}catch{e=Ct(1e3)}else e=Ct(1e3);const i=new xt(s,{data:e,onItemClick:n=>{},onItemSelect:n=>{}});s.__kupolaInstance=i,s.__kupolaInitialized=!0}function pe(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Cs(){document.querySelectorAll(".ds-virtual-list").forEach(s=>{St(s)})}typeof window<"u"&&(window.VirtualList=xt,window.initVirtualList=St,window.cleanupVirtualList=pe,window.initVirtualLists=Cs,window.createVirtualList=xs,window.generateMockVirtualListData=Ct,window.kupolaInitializer&&window.kupolaInitializer.register("virtual-list",St,pe));const Ss='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"',fe={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 me(s,t=16,e="0 0 24 24"){const i=fe[s];return i?`<svg ${Ss.replace('width="16"',`width="${t}"`).replace('height="16"',`height="${t}"`).replace('viewBox="0 0 24 24"',`viewBox="${e}"`)}>${i}</svg>`:""}function Lt(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=me(e,i,n),t.classList.add("icon")})}const Ai={svg:me,render:Lt,PATHS:fe};typeof window<"u"&&(window.Icons=Ai,document.readyState!=="loading"?Lt():document.addEventListener("DOMContentLoaded",()=>Lt()));class ge{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)),a=Math.floor(e%(1e3*60)/1e3);this.displayTime(i,n,a)}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 Dt(s){if(s.__kupolaInitialized)return;const t=new ge(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}function _e(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function zi(){document.querySelectorAll(".ds-countdown").forEach(t=>{Dt(t)})}typeof window<"u"&&(window.Countdown=ge,window.initCountdown=Dt,window.cleanupCountdown=_e,window.initCountdowns=zi,window.kupolaInitializer&&window.kupolaInitializer.register("countdown",Dt,_e));class ye{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 Mt(s){if(!s.__kupolaInitialized)try{const t=new ye(s);s.__kupolaInstance=t,s.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function ve(s){if(!s.__kupolaInitialized||!s.__kupolaInstance)return;s.__kupolaInstance.destroy(),s.__kupolaInstance=null,s.__kupolaInitialized=!1}function Pi(){document.querySelectorAll(".ds-number-input").forEach(s=>{Mt(s)})}typeof window<"u"&&(window.NumberInput=ye,window.initNumberInput=Mt,window.cleanupNumberInput=ve,window.initNumberInputs=Pi,window.kupolaInitializer&&window.kupolaInitializer.register("number-input",Mt,ve));class we{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 a=t.clientX-this.startX;a<0&&(a=0),a>n&&(a=n),this.currentX=a,this.btn.style.left=14+a+"px",this.progress&&(this.progress.style.width=a/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 a=t.touches[0].clientX-this.startX;a<0&&(a=0),a>n&&(a=n),this.currentX=a,this.btn.style.left=14+a+"px",this.progress&&(this.progress.style.width=a/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,a=t*.85-e,r=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()*(r-n-e)),this.distractorX=Math.floor(r+Math.random()*(a-r))):(this.targetX=Math.floor(r+Math.random()*(a-r)),this.distractorX=Math.floor(n+Math.random()*(r-n-e))):this.targetX=Math.floor(n+Math.random()*(a-n));const l=this.container.querySelector(".ds-slider-captcha__target");if(l&&(l.style.left=this.targetX+i+e/2+"px",l.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",l.style.display="block"),this.hasDistractor){const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.style.left=this.distractorX+i+e/2+"px",o.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",o.style.display="block")}else{const o=this.container.querySelector(".ds-slider-captcha__target--distractor");o&&(o.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 a=0,r=0;if(this.trackData.length>0){const o=this.trackData[this.trackData.length-1],c=this.currentX-o.x,h=n-o.t;if(h>0&&(a=c/h,this.trackData.length>1)){const u=this.trackData[this.trackData.length-2],p=o.t-u.t;if(p>0){const m=(o.x-u.x)/p;r=a-m}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:n,v:a,a:r});const l=this.container.querySelector(".ds-slider-captcha__point-count");l&&(l.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 h=1;h<this.trackData.length;h++){const u=this.trackData[h].x-this.trackData[h-1].x,p=this.trackData[h].t-this.trackData[h-1].t;p>0&&p<500&&n.push(u/p)}if(n.length<3)return{passed:!1,msg:"验证失败"};const a=Math.max(...n),r=Math.min(...n);if(a-r<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let l=!1;for(const h of this.trackData)if(Math.abs(h.y)>2){l=!0;break}if(!l&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const o=this.trackData[this.trackData.length-1].t;if(o<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(o>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const c=[];for(let h=1;h<n.length;h++)c.push(Math.abs(n[h]-n[h-1]));return c.length>2&&c.reduce((u,p)=>u+p,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 be(){document.querySelectorAll(".ds-slider-captcha").forEach(s=>{const t=new we(s);t.init(),s._kupolaSlideCaptcha=t})}function ke(s){s._kupolaSlideCaptcha&&(s._kupolaSlideCaptcha.destroy(),s._kupolaSlideCaptcha=null)}function Ee(){document.querySelectorAll(".ds-slider-captcha").forEach(s=>{ke(s)})}typeof window<"u"&&(window.SlideCaptcha=we,window.initSlideCaptchas=be,window.cleanupSlideCaptcha=ke,window.cleanupAllSlideCaptchas=Ee,window.kupolaInitializer&&window.kupolaInitializer.register("slide-captcha",be,Ee));class xe{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,a]of Object.entries(this.validators)){const r=t.getAttribute(`data-${n}`);if(r!==null&&!a(i,r)){let o=this.errorMessages[n];typeof o=="function"&&(o=o(r)),e.push(o)}}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 a=n.type;if(a==="checkbox"){const r=Array.isArray(t[e])?t[e]:[t[e]];n.checked=r.includes(n.value)}else if(a==="radio")n.checked=n.value===t[e];else if(a==="select-multiple"){const r=Array.isArray(t[e])?t[e]:[t[e]];Array.from(n.options).forEach(l=>{l.selected=r.includes(l.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 Ce(s){const t=document.querySelectorAll(s||".ds-form");return t.forEach(e=>{if(e._kupolaForm)return;const i=new xe(e);e._kupolaForm=i}),t.length}function $i(s){return s._kupolaForm}function qi(s){const t=s._kupolaForm;return t?t.validate():!1}typeof window<"u"&&(window.KupolaForm=xe,window.initFormValidation=Ce,window.getFormInstance=$i,window.validateForm=qi,window.kupolaInitializer&&window.kupolaInitializer.register("form-validation",Ce));class Se{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,i,n={}){const{scope:a=null,once:r=!1,passive:l=!1,capture:o=!1}=n,c=this._generateId(),h={id:c,target:t,eventName:e,handler:i,scope:a,once:r,wrappedHandler:null};h.wrappedHandler=p=>{r&&this.offById(c),i.call(t,p)};const u=this._getEventKey(t,e);return this._listeners.has(u)||this._listeners.set(u,[]),this._listeners.get(u).push(h),a&&(this._scopeListeners.has(a)||this._scopeListeners.set(a,[]),this._scopeListeners.get(a).push(c)),t.addEventListener(e,h.wrappedHandler,{passive:l,capture:o}),{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 a=this._listeners.get(n),r=a.filter(l=>l.handler!==i);a.forEach(l=>{l.handler===i&&(t.removeEventListener(e,l.wrappedHandler),this._removeFromScope(l))}),r.length===0?this._listeners.delete(n):this._listeners.set(n,r)}offById(t){for(const[e,i]of this._listeners){const n=i.findIndex(a=>a.id===t);if(n!==-1){const a=i[n];return a.target.removeEventListener(a.eventName,a.wrappedHandler),i.splice(n,1),i.length===0&&this._listeners.delete(e),this._removeFromScope(a),!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(a=>{t.removeEventListener(e,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(i)}else for(const[i,n]of this._listeners){const[a]=i.split(":");this._getTargetId(t)===a&&(n.forEach(r=>{t.removeEventListener(r.eventName,r.wrappedHandler),this._removeFromScope(r)}),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),a=new Set;for(const[r,l]of this._listeners)l.forEach(o=>{n.includes(o.id)&&a.add(o.target)});a.forEach(r=>{this.emit(r,e,i)})}getListenerCount(t,e=null){if(e){const a=this._getEventKey(t,e);return this._listeners.has(a)?this._listeners.get(a).length:0}let i=0;const n=this._getTargetId(t);for(const[a,r]of this._listeners){const[l]=a.split(":");l===n&&(i+=r.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 z=new Se;function Bi(s,t,e,i){return z.on(s,t,e,i)}function Fi(s,t,e,i){return z.once(s,t,e,i)}function Ni(s,t,e){z.off(s,t,e)}function Oi(s,t,e){return z.emit(s,t,e)}function Ri(s,t){return z.emitGlobal(s,t)}function Vi(s){z.offByScope(s)}function Ki(s,t){z.offAll(s,t)}function Wi(s,t){return z.getListenerCount(s,t)}typeof window<"u"&&(window.GlobalEvents=Se,window.globalEvents=z,window.kupolaOn=Bi,window.kupolaOnce=Fi,window.kupolaOff=Ni,window.kupolaEmit=Oi,window.kupolaEmitGlobal=Ri,window.kupolaOffByScope=Vi,window.kupolaOffAll=Ki,window.kupolaGetListenerCount=Wi);class Le{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 Ls=new Le;class Ui{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 Ht{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 Ui(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 $ extends Error{constructor(t,e,i){super(t),this.name="DependsError",this.code=e,this.cause=i,this.timestamp=Date.now()}}let It=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null;function Yi(s){if(!s||typeof s.fetch!="function")throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");It=s.fetch.bind(s)}function Xi(){return It}function Ji(){It=typeof globalThis<"u"&&globalThis.fetch?globalThis.fetch.bind(globalThis):typeof window<"u"&&window.fetch?window.fetch.bind(window):null}class N{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(){Ls.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(e){console.error("[DependsSource.notify]",e)}})})}async fetch(t){throw new $("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 a=this.retryDelay*Math.pow(2,e);return await new Promise(r=>setTimeout(r,a)),this._fetchWithRetry(t,e+1)}const n=i instanceof $?i:new $(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 ji extends N{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 h in t)e=e.replace(`:${h}`,encodeURIComponent(t[h]));const i=[];for(const[h,u]of Object.entries(this.queryParams||{}))i.push(`${encodeURIComponent(h)}=${encodeURIComponent(u)}`);for(const h in t)this.config.source.includes(`:${h}`)||i.push(`${encodeURIComponent(h)}=${encodeURIComponent(t[h])}`);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 a=It;if(!a)throw new $("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const r=await a(e,n),l=typeof r.ok=="boolean"?r.ok:r.status>=200&&r.status<300,o=typeof r.status=="number"?r.status:0;if(!l)throw new $(`HTTP ${o}`,"HTTP_ERROR");return typeof r.json=="function"?await r.json():r.data!==void 0?r.data:r}}class De extends N{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 Gi extends N{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 Zi extends N{async fetch(t){return await this.config.source(t)}}class Qi extends N{async fetch(){return this.config.source}}class Me extends N{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 $("WebSocket connection failed","WS_ERROR",i))},this.ws.onclose=()=>{this._connected=!1,this.reconnect&&setTimeout(()=>{this.fetch().catch(()=>{})},this.reconnectDelay)}}catch(i){e(new $("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 He(s,t){const e=s.source;return typeof e=="function"?new Zi(s,t):typeof e=="string"&&(e.startsWith("ws://")||e.startsWith("wss://"))?new Me(s,t):typeof e=="string"&&(e.startsWith("/")||e.startsWith("http"))?new ji(s,t):typeof e=="string"&&e.startsWith("localStorage:")?new De(s,t):typeof e=="string"&&e.startsWith("route:")?new Gi(s,t):new Qi(s,t)}function ts(s,t){const e={},i=new Ht,n=[];for(const a in t){let f=function(){return is(s)},r=t[a];typeof r=="string"&&(r={source:r});const l={...r,cacheKey:r.cacheKey||`${a}-${JSON.stringify(is(s))}`},o=He(l,i),c=L(null),h=L(!0),u=L(null),p=L(null);let m=0;async function g(){const k=++m;h.value=!0,u.value=null;try{const w=await o.getValue(f());if(k!==m)return;c.value=w,p.value=Date.now()}catch(w){if(k!==m)return;u.value=w.message||"Unknown error"}finally{k===m&&(h.value=!1)}}g();const v=o.subscribe(()=>{const k=i.getStale(o.cacheKey);k!=null&&(c.value=k,p.value=Date.now())});n.push(v);const y=Object.keys(s);y.length>0&&y.forEach(k=>{const w=s[k];if(w&&typeof w=="object"&&"value"in w&&w._subscribers){const b=()=>{o.invalidate(),g()};w._subscribers.add(b),n.push(()=>w._subscribers.delete(b))}}),e[a]={data:c,loading:h,error:u,lastUpdated:p,refresh(){return o.invalidate(),g()},setValue(k){o instanceof De&&(o.setValue(k),c.value=k)},send(k){o instanceof Me&&o.send(k)},_source:o}}return e._dispose=()=>{if(n.forEach(a=>a()),window.__kupolaDepInstances){const a=window.__kupolaDepInstances.indexOf(e);a!==-1&&window.__kupolaDepInstances.splice(a,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(e),e}function es(s){const t=new Ht,e=He(s,t),i=L(null),n=L(!0),a=L(null);let r=0;async function l(){const o=++r;n.value=!0,a.value=null;try{const c=await e.getValue(s.params||{});if(o!==r)return;i.value=c}catch(c){if(o!==r)return;a.value=c.message||"Unknown error"}finally{o===r&&(n.value=!1)}}return l(),e.subscribe(()=>{const o=t.getStale(e.cacheKey);o!=null&&(i.value=o)}),{data:i,loading:n,error:a,refresh(){return e.invalidate(),l()}}}function is(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 ss(){}typeof window<"u"&&(window.useDeps=ts,window.useQuery=es,window.clearCache=ss,window.DependsError=$,window.CacheManager=Ht,window.Scheduler=Le,window.configureHttpClient=Yi,window.getHttpClient=Xi,window.resetHttpClient=Ji);class Ie{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",a=[];for(const r of t){const l=r[this.rowKey];a.push({...r,_level:e,_parentKey:i,_hasChildren:!!(r[n]&&r[n].length)}),r[n]&&r[n].length&&a.push(...this._flattenForExpand(r[n],e+1,l))}return a}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const i=this.tree?.childrenKey||"children",n=[];for(const a of t){const r=a[this.rowKey];n.push({...a,_level:e,_hasChildren:!!(a[i]&&a[i].length)}),a[i]&&a[i].length&&this._treeExpandedKeys.has(r)&&n.push(...this._flattenVisible(a[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(a=>this.columns.some(r=>{const l=a[r.key];return l!=null&&String(l).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,a)=>{const r=a[i]?this._filterTree(a[i],e):[];return(this.columns.some(o=>{const c=a[o.key];return c!=null&&String(c).toLowerCase().includes(e)})||r.length>0)&&(n.push({...a,[i]:r}),r.length>0&&this._treeExpandedKeys.add(a[this.rowKey])),n},[])}_sortFlat(t){return[...t].sort((e,i)=>{for(const n of this._sorts){const a=this.columns.find(c=>c.key===n.key);let r=e[n.key],l=i[n.key],o=0;if(a?.sorter?o=a.sorter(r,l,n.order):r==null?o=1:l==null?o=-1:typeof r=="number"&&typeof l=="number"?o=n.order==="asc"?r-l:l-r:o=n.order==="asc"?String(r).localeCompare(String(l)):String(l).localeCompare(String(r)),o!==0)return o}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 r=this.getProcessedData().map(l=>l[this.rowKey]);n.checked=r.length>0&&r.every(l=>this._selectedKeys.has(l)),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 a=this._sorts.find(l=>l.key===i.key);a&&n.classList.add(`kupola-table-sort-${a.order}`),n.addEventListener("click",l=>{this.resizable&&l.target.classList.contains("kupola-table-resize-handle")||this._handleSort(i.key)});const r=document.createElement("span");r.className="kupola-table-sort-icon",a?r.textContent=this.multiSort?` ${this._sorts.indexOf(a)+1}${a.order==="asc"?"▲":"▼"}`:a.order==="asc"?" ▲":" ▼":r.textContent=" ⇅",n.appendChild(r)}if(this.resizable&&i.key!==this.columns[this.columns.length-1]?.key){const a=document.createElement("span");a.className="kupola-table-resize-handle",a.setAttribute("data-col-key",i.key),n.appendChild(a)}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(r=>n.set(`${r.row}-${r.col}`,r));const a=new Set;t.forEach((r,l)=>{const o=r[this.rowKey]??l,c=this._selectedKeys.has(o),h=this._expandedKeys.has(o),u=this._renderDataRow(r,l,o,c,a,n);if(e.appendChild(u),this.expandable&&h){const p=document.createElement("tr");p.className="kupola-table-expand-row";const m=document.createElement("td"),f=this.columns.length+(this.selection?1:0)+1;m.colSpan=f,m.className="kupola-table-expand-content";const g=this.expandable(r);typeof g=="string"?m.innerHTML=g:g instanceof HTMLElement&&m.appendChild(g),p.appendChild(m),e.appendChild(p)}})}return e}_renderDataRow(t,e,i,n,a,r){const l=document.createElement("tr");if(l.setAttribute("data-row-key",i),n&&l.classList.add("kupola-table-row-selected"),this.draggable&&(l.draggable=!0,l.classList.add("kupola-table-draggable")),this.selection){const o=document.createElement("td");o.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()}),o.appendChild(c),l.appendChild(o)}if(this.expandable){const o=document.createElement("td");o.className="kupola-table-col-expand";const c=document.createElement("button");c.className="kupola-table-expand-btn";const h=this._expandedKeys.has(i);c.textContent=h?"▼":"▶",c.type="button",c.addEventListener("click",()=>this._toggleExpand(i)),o.appendChild(c),l.appendChild(o)}return this.columns.forEach((o,c)=>{if(a.has(`${e}-${c}`))return;const h=document.createElement("td");o.align&&(h.style.textAlign=o.align),o.fixed&&(h.setAttribute("data-fixed",o.fixed),h.classList.add(`kupola-table-fixed-${o.fixed}`));const u=r.get(`${e}-${c}`);if(u){u.rowSpan>1&&(h.rowSpan=u.rowSpan),u.colSpan>1&&(h.colSpan=u.colSpan);for(let m=0;m<(u.rowSpan||1);m++)for(let f=0;f<(u.colSpan||1);f++)m===0&&f===0||a.add(`${e+m}-${c+f}`)}if(this.tree&&c===0&&t._level>0){const m=document.createElement("span");if(m.className="kupola-table-tree-indent",m.style.paddingLeft=t._level*20+"px",h.appendChild(m),t._hasChildren){const f=document.createElement("button");f.className="kupola-table-tree-toggle",f.textContent=this._treeExpandedKeys.has(t[this.rowKey])?"▼":"▶",f.type="button",f.addEventListener("click",g=>{g.stopPropagation(),this._toggleTreeExpand(t[this.rowKey])}),h.appendChild(f)}else{const f=document.createElement("span");f.className="kupola-table-tree-toggle-placeholder",h.appendChild(f)}}const p=this._editingCell&&this._editingCell.rowKey===i&&this._editingCell.colKey===o.key;if(p)h.appendChild(this._renderEditCell(o,t));else if(o.render){const m=o.render(t[o.key],t,e);typeof m=="string"?h.innerHTML=m:m instanceof HTMLElement&&h.appendChild(m)}else h.textContent=t[o.key]??"";this.editable&&!p&&o.editable!==!1&&(h.classList.add("kupola-table-editable-cell"),h.addEventListener("dblclick",()=>this._startEdit(i,o.key,t[o.key]))),l.appendChild(h)}),this.onRowClick&&(l.style.cursor="pointer",l.addEventListener("click",o=>{o.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,o)})),l}_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,a=t.length*i;if(this._loading)return this._renderTbody(t);if(t.length===0)return this._renderTbody(t);const r=document.createElement("tr");r.className="kupola-table-virtual-spacer-top",r.style.height="0px",e.appendChild(r),this._virtualData={data:t,rowHeight:i,overscan:n,totalHeight:a,tbody:e,topSpacer:r},this._updateVirtualScroll();const l=document.createElement("tr");l.className="kupola-table-virtual-spacer-bottom",l.style.height="0px",e.appendChild(l);const o=this.element.querySelector(".kupola-table-container");return o&&(o.style.maxHeight=this.virtualScroll.maxHeight||"400px",o.style.overflowY="auto",o.addEventListener("scroll",()=>this._updateVirtualScroll())),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:i,tbody:n,topSpacer:a}=this._virtualData,r=this.element.querySelector(".kupola-table-container");if(!r)return;const l=r.scrollTop,o=r.clientHeight,c=Math.max(0,Math.floor(l/e)-i),h=Math.min(t.length,Math.ceil((l+o)/e)+i);n.querySelectorAll(".kupola-table-virtual-row").forEach(f=>f.remove());const p=document.createDocumentFragment();for(let f=c;f<h;f++){const g=t[f],v=g[this.rowKey]??f,y=this._renderDataRow(g,f,v,this._selectedKeys.has(v),new Set,new Map);y.classList.add("kupola-table-virtual-row"),y.style.height=e+"px",p.appendChild(y)}a.style.height=c*e+"px";const m=n.querySelector(".kupola-table-virtual-spacer-bottom");m&&(m.style.height=(t.length-h)*e+"px"),a.after(p)}_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 o=document.createElement("select");o.className="ds-input kupola-table-edit-input",t.editOptions.forEach(c=>{const h=document.createElement("option");h.value=typeof c=="object"?c.value:c,h.textContent=typeof c=="object"?c.label:c,String(h.value)===String(n.value)&&(h.selected=!0),o.appendChild(h)}),o.addEventListener("change",()=>{this._editBuffer[t.key]=o.value}),i.appendChild(o)}else n.addEventListener("input",()=>{this._editBuffer[t.key]=n.value}),i.appendChild(n);const a=document.createElement("div");a.className="kupola-table-edit-actions";const r=document.createElement("button");r.className="kupola-table-edit-save",r.textContent="✓",r.type="button",r.addEventListener("click",()=>this._saveEdit(e,t));const l=document.createElement("button");return l.className="kupola-table-edit-cancel",l.textContent="✗",l.type="button",l.addEventListener("click",()=>this._cancelEdit()),a.appendChild(r),a.appendChild(l),i.appendChild(a),n.addEventListener("keydown",o=>{o.key==="Enter"&&this._saveEdit(e,t),o.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"),a=e.parentElement,r=i.clientX,l=a.offsetWidth,o=h=>{const u=Math.max(50,l+(h.clientX-r));a.style.width=u+"px";const p=this.columns.find(m=>m.key===n);p&&(p.width=u),this.onColumnResize&&this.onColumnResize(n,u)},c=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",o),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 a=this._data.findIndex(l=>String(l[this.rowKey])===this._dragState.fromKey),r=this._data.findIndex(l=>String(l[this.rowKey])===n);if(a>=0&&r>=0){const[l]=this._data.splice(a,1);this._data.splice(r,0,l),this.onRowDragEnd&&this.onRowDragEnd(l,a,r,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 a=this.element.querySelectorAll('th[data-fixed="left"]'),r=this.element.querySelectorAll('td[data-fixed="left"]'),l=this.columns.indexOf(n);let o=(this.selection?40:0)+(this.expandable?40:0);for(let c=0;c<l;c++)this.columns[c].fixed==="left"&&(o+=this.columns[c]._resolvedWidth||120);a.forEach(c=>{c.textContent.startsWith(n.title||n.key)&&(c.style.position="sticky",c.style.left=o+"px",c.style.zIndex="2",n._resolvedWidth=c.offsetWidth)}),r.forEach(c=>{c.style.position="sticky",c.style.left=o+"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(r=>{r.style.position="sticky",r.style.right=e+"px",r.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 a;n.addEventListener("input",()=>{clearTimeout(a),a=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 a=document.createElement("button");a.className="ds-btn ds-btn--sm",a.textContent="反选",a.type="button",a.addEventListener("click",()=>this.invertSelection()),e.appendChild(a)}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 l=document.createElement("select");l.className="kupola-table-page-size",this._pageSizes.forEach(o=>{const c=document.createElement("option");c.value=o,c.textContent=`${o} 条/页`,o===this._pageSize&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",()=>{this._pageSize=parseInt(l.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(l)}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(l=>{if(l==="..."){const o=document.createElement("span");o.className="kupola-table-page-ellipsis",o.textContent="...",i.appendChild(o)}else{const o=this._createPageBtn(l,()=>this._goToPage(l));l===this._currentPage&&o.classList.add("active"),i.appendChild(o)}});const a=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));a.disabled=this._currentPage>=t,i.appendChild(a),e.appendChild(i);const r=document.createElement("span");return r.className="kupola-table-page-info",r.textContent=`${this._currentPage} / ${t}`,e.appendChild(r),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,a)=>a+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(h=>{let u=c[h.key];return u==null&&(u=""),u=String(u).replace(/"/g,'""'),`"${u}"`}).join(",")),a="\uFEFF"+[i.join(","),...n].join(`
219
+ `),r=new Blob([a],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(r),o=document.createElement("a");o.href=l,o.download=t,o.click(),URL.revokeObjectURL(l)}_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 ns=!1;function Ds(){if(ns||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),ns=!0}function Te(s,t){return Ds(),new Ie(s,t)}function Ms(){document.querySelectorAll("[data-kupola-table]").forEach(s=>{const t=s.getAttribute("data-kupola-table");let e={};if(t)try{e=JSON.parse(t)}catch{}Te(s,e)})}typeof window<"u"&&(window.KupolaTable=Ie,window.initTable=Te);class Ae{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 a=this._btn("›",()=>this.setCurrent(this._current+1));a.disabled=this._current>=e,t.appendChild(a)}_renderFull(t){const e=this.totalPages;if(this._showTotal){const r=document.createElement("span");r.className="kupola-pagination-total",r.textContent=`共 ${this._total} 条`,t.appendChild(r)}if(this._showSizeChanger){const r=document.createElement("select");r.className="kupola-pagination-size",this._pageSizes.forEach(l=>{const o=document.createElement("option");o.value=l,o.textContent=`${l} 条/页`,l===this._pageSize&&(o.selected=!0),r.appendChild(o)}),r.addEventListener("change",()=>this.setPageSize(parseInt(r.value))),t.appendChild(r)}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(r=>{if(r==="..."){const l=document.createElement("span");l.className="kupola-pagination-ellipsis",l.textContent="···",i.appendChild(l)}else{const l=this._btn(r,()=>this.setCurrent(r));r===this._current&&l.classList.add("active"),i.appendChild(l)}});const a=this._btn("›",()=>this.setCurrent(this._current+1));if(a.disabled=this._current>=e,i.appendChild(a),t.appendChild(i),e>10){const r=document.createElement("span");r.className="kupola-pagination-jumper",r.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const l=r.querySelector("input");l.addEventListener("change",()=>{const o=parseInt(l.value);o>=1&&o<=e&&this.setCurrent(o)}),l.addEventListener("keydown",o=>{if(o.key==="Enter"){const c=parseInt(l.value);c>=1&&c<=e&&this.setCurrent(c)}}),t.appendChild(r)}}_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},(a,r)=>r+1);const i=[],n=Math.floor(e/2);if(this._current<=n+1){for(let a=1;a<=e-2;a++)i.push(a);i.push("...",t)}else if(this._current>=t-n){i.push(1,"...");for(let a=t-e+3;a<=t;a++)i.push(a)}else{i.push(1,"...");for(let a=this._current-n+2;a<=this._current+n-2;a++)i.push(a);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let as=!1;function Hs(){if(as||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),as=!0}function rs(s,t){return Hs(),new Ae(s,t)}typeof window<"u"&&(window.KupolaPagination=Ae,window.initPagination=rs);let ls=!1;class os 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(a=>{a.className="ds-dropdown__item",n.appendChild(a)}),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")||"",a=i.innerHTML,r=document.createElement("div");r.className="ds-collapse__item",r.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">${a}</div></div>
304
+ `,t.appendChild(r)}),this.innerHTML="",this.appendChild(t)}}class Is 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(s,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 s=="string"?s:s.href);p.search&&(u=Object.fromEntries(p.searchParams))}catch{}const d={id:c,method:a.method||"GET",url:typeof s=="string"?s:s.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(s,a){this.__kupolaRequest={method:s,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(s){if(this.__kupolaRequest){if(s){if(typeof s=="string")this.__kupolaRequest.requestBody=s;else if(s instanceof FormData)try{this.__kupolaRequest.requestBody=JSON.stringify(Object.fromEntries(s))}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 s=this.responseText;try{this.__kupolaEntry.response=JSON.parse(s)}catch{this.__kupolaEntry.response=s}}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 s=o.storageArea===localStorage?"localStorage":"sessionStorage";t.activeStorageType=s,t.updateStorageTabs(),n.innerHTML=t.getStorageContent(s)}}});const e=Storage.prototype.setItem;Storage.prototype.setItem=function(o,n){const s=this.getItem(o);e.call(this,o,n);const a=new StorageEvent("storage",{key:o,oldValue:s,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 s=new StorageEvent("storage",{key:o,oldValue:n,newValue:null,url:window.location.href,storageArea:this});window.dispatchEvent(s)}}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,s;this._dragMouseDownHandler=a=>{a.target.closest(".kupola-devtools__close")||(e=!0,r=a.clientX,o=a.clientY,n=this.panel.offsetLeft,s=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,s+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,...s]=o.split("=");return{key:n,value:s.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 s=JSON.parse(n);n=JSON.stringify(s,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 Bt(){try{const i=new URLSearchParams(window.location.search);(i.has("dev")||i.has("debug"))&&(window.kupolaDevTools=new Nt({enabled:!0}),window.kupolaDevTools.init(),window.addEventListener("click",e=>{window.kupolaDevTools&&window.kupolaDevTools.handleStorageClick&&window.kupolaDevTools.handleStorageClick(e)}))}catch(i){console.error("Error initializing Kupola DevTools:",i)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Bt):Bt(),window.KupolaDevTools=Nt;var Kt={},Ut;function Ds(){return Ut||(Ut=1,function(i){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,s=16,a="0 0 24 24"){const l=e[n];return l?`<svg ${t.replace('width="16"',`width="${s}"`).replace('height="16"',`height="${s}"`).replace('viewBox="0 0 24 24"',`viewBox="${a}"`)}>${l}</svg>`:""}function o(n=document){n.querySelectorAll("[data-icon]").forEach(s=>{const a=s.getAttribute("data-icon"),l=+s.getAttribute("data-size")||16,c=s.getAttribute("data-viewbox")||"0 0 24 24";s.innerHTML=r(a,l,c),s.classList.add("icon")})}i.Icons={svg:r,render:o,PATHS:e},document.readyState!=="loading"?o():document.addEventListener("DOMContentLoaded",()=>o())}(typeof window<"u"?window:globalThis)),Kt}Ds();var rt={exports:{}},Vt;function Ms(){return Vt||(Vt=1,function(i){class t{constructor(s){this.element=s,this.hoursEl=s.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=s.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=s.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const s=this.element.getAttribute("data-end-time");if(s)return new Date(s).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 s=new Date().getTime(),a=this.endTime-s;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(s,a,l){this.hoursEl&&(this.hoursEl.textContent=String(s).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(a).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(l).padStart(2,"0"))}setEndTime(s){this.endTime=s.getTime(),this.update()}addTime(s){this.endTime+=s*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 s=new t(n);n.__kupolaInstance=s,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(s=>{e(s)})}i.exports?i.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)}(rt)),rt.exports}Ms();var ot={exports:{}},Wt;function Ts(){return Wt||(Wt=1,function(i){class t{constructor(s){if(this.element=s,this.minusBtn=s.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=s.querySelector(".ds-number-input__btn--increase"),this.inputEl=s.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 s=()=>this.updateValue(-this.step),a=()=>this.updateValue(this.step),l=()=>this.handleInput();this.minusBtn.addEventListener("click",s),this.plusBtn.addEventListener("click",a),this.inputEl.addEventListener("input",l),this._listeners.push({el:this.minusBtn,event:"click",handler:s},{el:this.plusBtn,event:"click",handler:a},{el:this.inputEl,event:"input",handler:l})}updateValue(s){let a=parseInt(this.inputEl.value)||0;a+=s,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 s=parseInt(this.inputEl.value);isNaN(s)&&(s=0),s<this.min&&(s=this.min),s>this.max&&(s=this.max),this.inputEl.value=s,this.updateState(),this.dispatchChange()}updateState(){const s=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=s<=this.min,this.plusBtn.disabled=s>=this.max}setValue(s){s<this.min&&(s=this.min),s>this.max&&(s=this.max),this.inputEl.value=s,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(s,a){this.min=s,this.max=a,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("ds-number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:s,event:a,handler:l})=>{s.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 s=new t(n);n.__kupolaInstance=s,n.__kupolaInitialized=!0}catch(s){console.error("[NumberInput] Error initializing:",s)}}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)})}i.exports?i.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)}(ot)),ot.exports}Ts();var at={exports:{}},Yt;function Is(){return Yt||(Yt=1,function(i){class t{constructor(s){this.container=s,this.track=s.querySelector(".ds-slider-captcha__track"),this.btn=s.querySelector(".ds-slider-captcha__btn"),this.text=s.querySelector(".ds-slider-captcha__text"),this.progress=s.querySelector(".ds-slider-captcha__progress"),this.statusEl=s.querySelector(".ds-slider-captcha__status"),this.refreshBtn=s.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=s.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(s.getAttribute("data-angle"))||30,this.shape=s.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=s=>{this.isVerified||this.isProcessing||(s.preventDefault(),this.isDragging=!0,this.startX=s.clientX,this.startY=s.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=s=>{if(!this.isDragging)return;s.preventDefault();const a=this.track.offsetWidth,l=this.btn.offsetWidth,c=a-l-8;let h=s.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(s.clientX,s.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=s=>{this.isVerified||this.isProcessing||(s.preventDefault(),this.isDragging=!0,this.startX=s.touches[0].clientX,this.startY=s.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=s=>{if(!this.isDragging)return;s.preventDefault();const a=this.track.offsetWidth,l=this.btn.offsetWidth,c=a-l-8;let h=s.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(s.touches[0].clientX,s.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 s=this.track.offsetWidth,a=this.btn.offsetWidth,l=14,c=s*.35,h=s*.85-a,u=s*.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(s,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],_=p.t-m.t;if(_>0){const v=(p.x-m.x)/_;u=h-v}}}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 s=this.trackData[this.trackData.length-1].x,a=this.hasDistractor?Math.abs(s-this.distractorX):1/0,l=Math.abs(s-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,_=this.trackData[f].t-this.trackData[f-1].t;_>0&&_<500&&c.push(m/_)}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,_)=>m+_,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 s=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",s.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=s.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=s.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 s=new t(n);s.init(),n._kupolaSlideCaptcha=s})}function r(n){n._kupolaSlideCaptcha&&(n._kupolaSlideCaptcha.destroy(),n._kupolaSlideCaptcha=null)}function o(){document.querySelectorAll(".ds-slider-captcha").forEach(n=>{r(n)})}i.exports&&(i.exports={initSlideCaptchas:e,cleanupSlideCaptcha:r,cleanupAllSlideCaptchas:o})}(at)),at.exports}Is(),function(i){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(i.kupolaData){const g=`__ref_${Math.random().toString(36).slice(2,11)}__`;return i.kupolaData.set(g,d),{get value(){return i.kupolaData.get(g)},set value(f){i.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(i.kupolaData)return i.kupolaData.createReactive(d);const p=this,g={get(m,_){if(_==="__isReactive")return!0;if(_==="__raw")return m;const v=m[_];return typeof v=="object"&&v!==null&&!v.__isReactive&&(m[_]=p.reactive(v)),m[_]},set(m,_,v){return m[_]===v||(m[_]=v,p._notifyWatchers(_,v)),!0},deleteProperty(m,_){return delete m[_],p._notifyWatchers(_,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(),i.kupolaData){const m=[],_=i.kupolaData.get;i.kupolaData.get=function(v){return m.push(v),_.call(this,v)},d(),i.kupolaData.get=_,m.forEach(v=>{i.kupolaData.observe(v,f)})}}else typeof d=="object"&&d!==null&&(d._subscribers?d._subscribers.add(p):d._key&&i.kupolaData&&i.kupolaData.observe(d._key,()=>{p(d.value)}))}computed(d){const p=this.ref();let g=()=>{try{p.value=d()}catch(_){console.error("Computed property error:",_)}};const f=[];if(i.kupolaData){const _=i.kupolaData.get;i.kupolaData.get=function(v){return f.push(v),_.call(this,v)},g(),i.kupolaData.get=_,f.forEach(v=>{i.kupolaData.observe(v,g)}),this._computedDeps.set(p,f)}else g();let m=p._value;return Object.defineProperty(p,"value",{get:()=>m,set:_=>{console.warn("Cannot assign to a computed property")}}),g=()=>{try{m=d()}catch(_){console.error("Computed property error:",_)}},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=>{i.kupolaData&&i.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(i.kupolaData){const p=`__ref_${Math.random().toString(36).slice(2,11)}__`;return i.kupolaData.set(p,u),{get value(){return i.kupolaData.get(p)},set value(g){i.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(i.kupolaData)return i.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 s(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(i.kupolaData){const f=[],m=i.kupolaData.get;i.kupolaData.get=function(_){return f.push(_),m.call(this,_)},p(),i.kupolaData.get=m,f.forEach(_=>{i.kupolaData.observe(_,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}i.SetupContext=e,i.ref=r,i.reactive=o,i.onMounted=n,i.onUnmounted=s,i.onUpdated=a,i.watch=l,i.computed=c,i.setup=h,i._getCurrentSetupContext=()=>t,i._setCurrentSetupContext=u=>{t=u},i._clearSetupContext=()=>{t=null}}(window),function(i){class t{constructor(n,s={}){if(this.form=typeof n=="string"?document.querySelector(n):n,this.options={validateOnSubmit:!0,validateOnChange:!1,validateOnBlur:!1,preventDefault:!0,...s},this.submitHandlers=[],this.isSubmitting=!1,this.errors={},this.rules={},this.validator=i.kupolaValidator||new i.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 s=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(s),this.form.addEventListener("submit",s),()=>{const a=this.submitHandlers.indexOf(s);a>-1&&(this.submitHandlers.splice(a,1),this.form.removeEventListener("submit",s))}}setRules(n){return this.rules={...this.rules,...n},this._applyRulesToDOM(),this}_applyRulesToDOM(){Object.keys(this.rules).forEach(n=>{const s=this.form.querySelector(`[name="${n}"]`);if(!s)return;const a=this.rules[n],l=this._rulesToString(a);s.setAttribute("data-validate",l)})}_rulesToString(n){if(typeof n=="function")return"custom";const s=[];return Object.keys(n).forEach(a=>{const l=n[a];typeof l=="object"&&l!==null?a==="pattern"?s.push(`pattern:${l.source?.replace(/\//g,"")}`):a==="equalTo"?s.push(`equalTo:${l}`):s.push(a):typeof l=="number"||typeof l=="string"?s.push(`${a}:${l}`):l===!0&&s.push(a)}),s.join("|")}async validate(n=null){this.errors={};const s=[],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,s.push(...h))}return{valid:s.length===0,errors:s,fieldErrors:this.errors}}async _validateField(n){const s=n.name,a=this.rules[s];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")||s,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")||s,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(s=>{const a=this.form.querySelector(`[name="${s}"]`);if(a)if(a.type==="checkbox"){const l=Array.isArray(n[s])?n[s]:[n[s]];a.checked=l.includes(a.value)}else if(a.type==="radio"){const l=this.form.querySelector(`[name="${s}"][value="${n[s]}"]`);l&&(l.checked=!0)}else if(a.type==="file"){const l=new DataTransfer;n[s]instanceof FileList&&Array.from(n[s]).forEach(c=>{l.items.add(c)}),a.files=l.files}else a.value=n[s]}),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)}i.KupolaForm=t,i.useForm=e,i.createForm=r}(window);let Xt=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 s=async()=>{try{const a=await t();a?o(a):Date.now()-r<e?requestAnimationFrame(s):n(new Error("waitFor timeout"))}catch{Date.now()-r<e?requestAnimationFrame(s):n(new Error("waitFor timeout"))}};requestAnimationFrame(s)})}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 s=new TouchEvent("touchstart",{touches:[{clientX:e,clientY:r}],bubbles:!0});t.dispatchEvent(s);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=Xt,window.testUtils=Xt;let lt=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 lt;function As(i){return new lt(i)}function qs(i,t={}){return I.t(i,t)}function zs(i,t,e={}){return I.n(i,t,e)}function Ps(i){return I.setLocale(i)}function $s(){return I.getLocale()}function Rs(i,t={}){return I.formatDate(i,t)}function Fs(i,t={}){return I.formatNumber(i,t)}function Os(i,t,e={}){return I.formatCurrency(i,t,e)}window.KupolaI18n=lt,window.kupolaI18n=I,window.createI18n=As,window.t=qs,window.n=zs,window.setLocale=Ps,window.getLocale=$s,window.formatDate=Rs,window.formatNumber=Fs,window.formatCurrency=Os;let Jt=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 s=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:s,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:s})),t.addEventListener(e,s,o);const l=()=>{if(t.removeEventListener(e,s,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),s=n.findIndex(a=>a.handler===r);if(s!==-1){const a=n[s];t.removeEventListener(e,a.wrapper,a.options),a.active=!1,n.splice(s,1),a.options.scope&&this._removeFromScope(a.options.scope,t,e,r)}}once(t,e,r,o={}){const n=s=>(this.off(t,e,n),r(s));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:s})=>{r.removeEventListener(o,s);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),s=n.findIndex(a=>a.target===e&&a.eventType===r&&a.handler===o);s!==-1&&n.splice(s,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(s=>{n.removeEventListener(o,s.wrapper,s.options)})}),this.listeners.clear(),this.scopes.clear()}};const q=new Jt;function Ns(i,t,e,r){return q.on(i,t,e,r)}function Bs(i,t,e){q.off(i,t,e)}function Ks(i,t,e,r){return q.once(i,t,e,r)}function Us(i){q.clearScope(i)}window.GlobalEventManager=Jt,window.globalEvents=q,window.on=Ns,window.off=Bs,window.once=Ks,window.clearScope=Us;let jt=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=s=>{if(s.nodeType===Node.ELEMENT_NODE){const a=s.tagName.toLowerCase();if(!e.includes(a)){s.parentNode.replaceChild(document.createTextNode(s.textContent),s);return}Array.from(s.attributes).forEach(l=>{const c=l.name.toLowerCase();r.includes(c)||c.startsWith("data-")?(c==="href"||c==="src")&&(this._isSafeUrl(l.value)||s.removeAttribute(l.name)):s.removeAttribute(l.name)})}for(let a=s.childNodes.length-1;a>=0;a--)n(s.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 Vs=new jt;window.kupolaSecurity=Vs,window.KupolaSecurity=jt;let Gt=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 s=o.apply(this,n);return s instanceof Promise?s.catch(a=>{throw ct.handleError(a,{type:"method",component:t.constructor?.name||"",hook:r,args:n}),a}):s}catch(s){throw ct.handleError(s,{type:"method",component:t.constructor?.name||"",hook:r,args:n}),s}}}})}};const ct=new Gt;window.kupolaErrorHandler=ct,window.KupolaErrorHandler=Gt;let Qt=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(s){n=s}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 Ws=new Qt;window.kupolaPerformance=Ws,window.KupolaPerformance=Qt;const Zt=window.KupolaComponent,te=window.KupolaComponentRegistry,ee=window.KupolaRouter,ie=window.KupolaHttp,se=window.KupolaStatePersist,ne=window.KupolaLifecycle,re=window.KupolaPluginManager,oe=window.KupolaDevTools,ae=window.kupolaRegistry,le=window.kupolaPersist,ce=window.kupolaLifecycle,de=window.kupolaPluginManager,he=window.KupolaUtils,ue=window.createRouter,pe=window.createHttp,fe=window.createLifecycle,me=window.createStore,ge=window.getStore,ye=window.registerComponent,ve=window.registerLazyComponent,_e=window.bootstrapComponents,we=window.defineMixin,xe=window.useMixin,be=window.initTheme,ke=window.setTheme,Ee=window.getTheme,Ce=window.setBrand,Se=window.getBrand,Le=window.initDropdowns,He=window.initSelects,De=window.initDatePickers,Me=window.initTimePickers,Te=window.initSliders,Ie=window.initCarousels,Ae=window.initDrawers,qe=window.initModals,ze=window.initDialogs,Pe=window.initNotifications,$e=window.initMessages,Re=window.initFileUploads,Fe=window.initCollapses,Oe=window.initColorPickers,Ne=window.initCalendars,Be=window.initDynamicTags,Ke=window.initImagePreviews,Ue=window.initTags,Ve=window.initStatCards,We=window.initHeatmaps,Ye=window.initTooltips,Xe=window.initValidation,Je=window.initVirtualLists,je=window.initIcons,Ge=window.initCountdowns,Qe=window.initNumberInputs,Ze=window.initSlideCaptchas,ti=window.setup,ei=window.ref,ii=window.reactive,si=window.onMounted,ni=window.onUnmounted,ri=window.onUpdated,oi=window.watch,ai=window.computed,li=window.KupolaForm,ci=window.useForm,di=window.createForm,hi=window.KupolaTestUtils,ui=window.testUtils,pi=window.KupolaI18n,fi=window.kupolaI18n,mi=window.createI18n,gi=window.t,yi=window.n,vi=window.setLocale,_i=window.getLocale,wi=window.formatDate,xi=window.formatNumber,bi=window.formatCurrency,ki=window.GlobalEventManager,Ei=window.globalEvents,Ci=window.on,Si=window.off,Li=window.once,Hi=window.clearScope,Di=window.KupolaSecurity,Mi=window.kupolaSecurity,Ti=window.KupolaErrorHandler,Ii=window.kupolaErrorHandler,Ai=window.KupolaPerformance,qi=window.kupolaPerformance,Ys={KupolaComponent:Zt,KupolaComponentRegistry:te,KupolaRouter:ee,KupolaHttp:ie,KupolaStatePersist:se,KupolaLifecycle:ne,KupolaPluginManager:re,KupolaDevTools:oe,KupolaSecurity:Di,KupolaErrorHandler:Ti,KupolaPerformance:Ai,kupolaRegistry:ae,kupolaPersist:le,kupolaLifecycle:ce,kupolaPluginManager:de,kupolaSecurity:Mi,kupolaErrorHandler:Ii,kupolaPerformance:qi,KupolaUtils:he,createRouter:ue,createHttp:pe,createLifecycle:fe,createStore:me,getStore:ge,registerComponent:ye,registerLazyComponent:ve,bootstrapComponents:_e,defineMixin:we,useMixin:xe,initTheme:be,setTheme:ke,getTheme:Ee,setBrand:Ce,getBrand:Se,initDropdowns:Le,initSelects:He,initDatePickers:De,initTimePickers:Me,initSliders:Te,initCarousels:Ie,initDrawers:Ae,initModals:qe,initDialogs:ze,initNotifications:Pe,initMessages:$e,initFileUploads:Re,initCollapses:Fe,initColorPickers:Oe,initCalendars:Ne,initDynamicTags:Be,initImagePreviews:Ke,initTags:Ue,initStatCards:Ve,initHeatmaps:We,initTooltips:Ye,initValidation:Xe,initVirtualLists:Je,initIcons:je,initCountdowns:Ge,initNumberInputs:Qe,initSlideCaptchas:Ze,setup:ti,ref:ei,reactive:ii,onMounted:si,onUnmounted:ni,onUpdated:ri,watch:oi,computed:ai,KupolaForm:li,useForm:ci,createForm:di,KupolaTestUtils:hi,testUtils:ui,KupolaI18n:pi,kupolaI18n:fi,createI18n:mi,t:gi,n:yi,setLocale:vi,getLocale:_i,formatDate:wi,formatNumber:xi,formatCurrency:bi,GlobalEventManager:ki,globalEvents:Ei,on:Ci,off:Si,once:Li,clearScope:Hi};y.GlobalEventManager=ki,y.KupolaComponent=Zt,y.KupolaComponentRegistry=te,y.KupolaDevTools=oe,y.KupolaErrorHandler=Ti,y.KupolaForm=li,y.KupolaHttp=ie,y.KupolaI18n=pi,y.KupolaLifecycle=ne,y.KupolaPerformance=Ai,y.KupolaPluginManager=re,y.KupolaRouter=ee,y.KupolaSecurity=Di,y.KupolaStatePersist=se,y.KupolaTestUtils=hi,y.KupolaUtils=he,y.bootstrapComponents=_e,y.clearScope=Hi,y.computed=ai,y.createForm=di,y.createHttp=pe,y.createI18n=mi,y.createLifecycle=fe,y.createRouter=ue,y.createStore=me,y.default=Ys,y.defineMixin=we,y.formatCurrency=bi,y.formatDate=wi,y.formatNumber=xi,y.getBrand=Se,y.getLocale=_i,y.getStore=ge,y.getTheme=Ee,y.globalEvents=Ei,y.initCalendars=Ne,y.initCarousels=Ie,y.initCollapses=Fe,y.initColorPickers=Oe,y.initCountdowns=Ge,y.initDatePickers=De,y.initDialogs=ze,y.initDrawers=Ae,y.initDropdowns=Le,y.initDynamicTags=Be,y.initFileUploads=Re,y.initHeatmaps=We,y.initIcons=je,y.initImagePreviews=Ke,y.initMessages=$e,y.initModals=qe,y.initNotifications=Pe,y.initNumberInputs=Qe,y.initSelects=He,y.initSlideCaptchas=Ze,y.initSliders=Te,y.initStatCards=Ve,y.initTags=Ue,y.initTheme=be,y.initTimePickers=Me,y.initTooltips=Ye,y.initValidation=Xe,y.initVirtualLists=Je,y.kupolaErrorHandler=Ii,y.kupolaI18n=fi,y.kupolaLifecycle=ce,y.kupolaPerformance=qi,y.kupolaPersist=le,y.kupolaPluginManager=de,y.kupolaRegistry=ae,y.kupolaSecurity=Mi,y.n=yi,y.off=Si,y.on=Ci,y.onMounted=si,y.onUnmounted=ni,y.onUpdated=ri,y.once=Li,y.reactive=ii,y.ref=ei,y.registerComponent=ye,y.registerLazyComponent=ve,y.setBrand=Ce,y.setLocale=vi,y.setTheme=ke,y.setup=ti,y.t=gi,y.testUtils=ui,y.useForm=ci,y.useMixin=xe,y.watch=oi,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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 a=e.querySelector(".ds-dialog__foot"),r=this.querySelector('[slot="footer"]');r&&a.appendChild(r);const l=e.querySelector(".ds-dialog__close");l&&l.addEventListener("click",()=>this.close()),e.addEventListener("click",o=>{o.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(ls||typeof customElements>"u")return;ls=!0;const s=[["k-dropdown",os],["k-tooltip",cs],["k-collapse",ds],["k-collapse-item",Is],["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=os,window.KupolaTooltipElement=cs,window.KupolaCollapseElement=ds,window.KupolaDrawerElement=hs,window.KupolaModalElement=us),d.BRAND_OPTIONS=B,d.CacheEntry=Ui,d.CacheManager=Ht,d.Calendar=ee,d.Carousel=Yt,d.Collapse=Zt,d.ColorPicker=te,d.ComponentInitializerRegistry=Bt,d.Countdown=ge,d.Datepicker=Rt,d.DependsError=$,d.DependsSource=N,d.Dialog=_i,d.Drawer=ot,d.Dropdown=Nt,d.DynamicTags=se,d.FetchedSource=ji,d.FileUpload=jt,d.FunctionSource=Zi,d.GlobalEvents=Se,d.Heatmap=wt,d.Icons=Ai,d.ImagePreview=_t,d.KupolaComponent=R,d.KupolaComponentRegistry=Ft,d.KupolaDataBind=zt,d.KupolaEventBus=$t,d.KupolaForm=xe,d.KupolaI18n=Z,d.KupolaLifecycle=A,d.KupolaPagination=Ae,d.KupolaStore=Y,d.KupolaStoreManager=Pt,d.KupolaTable=Ie,d.KupolaUtils=Tt,d.KupolaValidator=ue,d.Message=wi,d.Modal=T,d.Notification=yi,d.NumberInput=ye,d.PATHS=fe,d.RouteSource=Gi,d.Scheduler=Le,d.Select=Ot,d.SlideCaptcha=we,d.Slider=Wt,d.StatCard=le,d.StaticSource=Qi,d.StorageSource=De,d.Tag=ae,d.Timepicker=Vt,d.Tooltip=de,d.VirtualList=xt,d.WebSocketSource=Me,d.alertModal=mi,d.applyMixin=j,d.bootstrapComponents=Ye,d.cleanupAllDropdowns=ri,d.cleanupAllSlideCaptchas=Ee,d.cleanupCalendar=ie,d.cleanupCarousel=ui,d.cleanupCollapse=Qt,d.cleanupColorPicker=ft,d.cleanupCountdown=_e,d.cleanupDatepicker=nt,d.cleanupDrawer=Xt,d.cleanupDropdown=tt,d.cleanupDynamicTags=ne,d.cleanupFileUpload=Gt,d.cleanupHeatmap=ce,d.cleanupModal=Jt,d.cleanupNumberInput=ve,d.cleanupSelect=it,d.cleanupSlideCaptcha=ke,d.cleanupSlider=Ut,d.cleanupStatCard=oe,d.cleanupTag=re,d.cleanupTimepicker=Kt,d.cleanupTooltip=he,d.cleanupVirtualList=pe,d.clearCache=ss,d.configureHttpClient=Yi,d.confirmModal=fi,d.createBrandPicker=Ke,d.createI18n=Ge,d.createLifecycle=$e,d.createModal=ct,d.createSource=He,d.createStore=Fe,d.createThemeToggle=Ve,d.defineComponent=je,d.defineMixin=Xe,d.emit=Oi,d.emitGlobal=Ri,d.formatCurrency=ni,d.formatDate=ii,d.formatNumber=si,d.getBrand=O,d.getFormInstance=$i,d.getHttpClient=Xi,d.getListenerCount=Wi,d.getLocale=ei,d.getStore=Ne,d.getTheme=F,d.globalEvents=z,d.initAllTables=Ms,d.initCalendar=mt,d.initCalendars=Ci,d.initCarousel=lt,d.initCarousels=hi,d.initCollapse=ut,d.initCollapses=Ei,d.initColorPicker=pt,d.initColorPickers=xi,d.initCountdown=Dt,d.initCountdowns=zi,d.initDatepicker=st,d.initDatepickers=oi,d.initDrawer=U,d.initDrawers=pi,d.initDropdown=Q,d.initDropdowns=ai,d.initDynamicTags=gt,d.initDynamicTagsAll=Si,d.initFileUpload=ht,d.initFileUploads=ki,d.initFormValidation=Ce,d.initHeatmap=bt,d.initHeatmaps=Ii,d.initImagePreview=Li,d.initMessages=bi,d.initModal=dt,d.initModals=gi,d.initNotifications=vi,d.initNumberInput=Mt,d.initNumberInputs=Pi,d.initPagination=rs,d.initSelect=et,d.initSelects=li,d.initSlideCaptchas=be,d.initSlider=rt,d.initSliders=di,d.initStatCard=vt,d.initStatCards=Hi,d.initTable=Te,d.initTag=yt,d.initTags=Mi,d.initTheme=qt,d.initTimepicker=at,d.initTimepickers=ci,d.initTooltip=Et,d.initTooltips=Ti,d.initVirtualList=St,d.kupolaBootstrap=G,d.kupolaData=X,d.kupolaEvents=Be,d.kupolaI18n=P,d.kupolaInitializer=D,d.kupolaLifecycle=Pe,d.kupolaStoreManager=J,d.n=Qe,d.off=Ni,d.offAll=Ki,d.offByScope=Vi,d.on=Bi,d.once=Fi,d.ref=L,d.registerComponent=We,d.registerLazyComponent=Ue,d.registerWebComponents=ps,d.renderIcon=Lt,d.resetHttpClient=Ji,d.setBrand=W,d.setLocale=ti,d.setTheme=K,d.showImagePreview=Di,d.svg=me,d.t=Ze,d.useDeps=ts,d.useMixin=Je,d.useQuery=es,d.validateForm=qi,d.validator=M,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
258
316
  //# sourceMappingURL=kupola.umd.js.map