zum-framework 1.0.2 → 1.0.3
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.
- package/dist/zum.cjs +79 -56
- package/dist/zum.iife.min.js +12 -15
- package/dist/zum.mjs +79 -56
- package/package.json +1 -1
package/dist/zum.cjs
CHANGED
|
@@ -477,23 +477,41 @@ var _Zum = class _Zum {
|
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
479
|
// ═══ AUTO-CONTRAST ═══
|
|
480
|
+
static _shouldSkipAutoContrast(el) {
|
|
481
|
+
if (!el || el.nodeType !== Node.ELEMENT_NODE || !el.matches) return true;
|
|
482
|
+
const skipTags = "input, textarea, select, option, button, a, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
483
|
+
if (el.matches(skipTags)) return true;
|
|
484
|
+
if (el.hasAttribute("data-no-auto-contrast") || el.classList.contains("no-auto-contrast") || el.classList.contains("zum-keep-color")) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
if (el.style && el.style.color && el.dataset.contrastApplied !== "true") {
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
static _hasDirectText(el) {
|
|
493
|
+
return Array.from(el.childNodes).some(
|
|
494
|
+
(node) => node.nodeType === Node.TEXT_NODE && node.textContent && node.textContent.trim().length > 0
|
|
495
|
+
);
|
|
496
|
+
}
|
|
480
497
|
static _initAutoContrast() {
|
|
481
498
|
if (_Zum._contrastInitialized) return;
|
|
482
499
|
if (!hasDOM()) return;
|
|
500
|
+
if (!_Zum.themeSettings.autoContrast) {
|
|
501
|
+
_Zum._contrastInitialized = true;
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
483
504
|
const styleEl = document.createElement("style");
|
|
484
505
|
styleEl.setAttribute("data-Zum-contrast", "true");
|
|
485
506
|
styleEl.textContent = `
|
|
486
|
-
.zum-contrast
|
|
487
|
-
.zum-contrast-text { transition: color 0.3s ease-in-out !important; }
|
|
488
|
-
@media (prefers-color-scheme: dark) { .zum-contrast-text { color: #f1f5f9 !important; } }
|
|
489
|
-
@media (prefers-color-scheme: light) { .zum-contrast-text { color: #0f172a !important; } }
|
|
507
|
+
.zum-contrast-text { transition: color 0.25s ease-in-out; }
|
|
490
508
|
`;
|
|
491
509
|
document.head.appendChild(styleEl);
|
|
492
510
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
493
511
|
mutations.forEach((mutation) => {
|
|
494
512
|
if (mutation.addedNodes) {
|
|
495
513
|
mutation.addedNodes.forEach((node) => {
|
|
496
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
514
|
+
if (node.nodeType === Node.ELEMENT_NODE && !_Zum._contrastProcessing.has(node)) {
|
|
497
515
|
setTimeout(() => _Zum._applyContrastToElement(node), 50);
|
|
498
516
|
}
|
|
499
517
|
});
|
|
@@ -503,13 +521,14 @@ var _Zum = class _Zum {
|
|
|
503
521
|
if (document.body) {
|
|
504
522
|
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
505
523
|
}
|
|
524
|
+
const runInitial = () => setTimeout(() => _Zum._applyContrastToAll(), 100);
|
|
506
525
|
if (document.readyState === "loading") {
|
|
507
|
-
document.addEventListener("DOMContentLoaded",
|
|
526
|
+
document.addEventListener("DOMContentLoaded", runInitial);
|
|
508
527
|
} else {
|
|
509
|
-
|
|
528
|
+
runInitial();
|
|
510
529
|
}
|
|
511
530
|
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
512
|
-
const onSystemChange = () => setTimeout(() => _Zum.
|
|
531
|
+
const onSystemChange = () => setTimeout(() => _Zum.refreshContrast(), 50);
|
|
513
532
|
if (darkModeMediaQuery.addEventListener) {
|
|
514
533
|
darkModeMediaQuery.addEventListener("change", onSystemChange);
|
|
515
534
|
} else if (darkModeMediaQuery.addListener) {
|
|
@@ -519,40 +538,62 @@ var _Zum = class _Zum {
|
|
|
519
538
|
zlog("\u2705 Auto-contrast system initialized");
|
|
520
539
|
}
|
|
521
540
|
static _getRealBackground(el) {
|
|
541
|
+
var _a;
|
|
522
542
|
let current = el;
|
|
523
543
|
let attempts = 0;
|
|
524
544
|
while (current && attempts < 30) {
|
|
525
545
|
const bg = getComputedStyle(current).backgroundColor;
|
|
526
|
-
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent" && bg !== "")
|
|
527
|
-
|
|
546
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent" && bg !== "") {
|
|
547
|
+
const match = bg.match(/rgba?\(([^)]+)\)/);
|
|
548
|
+
if (match) {
|
|
549
|
+
const parts = match[1].split(",").map((v) => parseFloat(v.trim()));
|
|
550
|
+
const alpha = parts.length === 4 ? parts[3] : 1;
|
|
551
|
+
if (alpha > 0.05) return bg;
|
|
552
|
+
} else {
|
|
553
|
+
return bg;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
528
556
|
if (current.parentElement) current = current.parentElement;
|
|
529
557
|
else if (current.parentNode && current.parentNode.host) current = current.parentNode.host;
|
|
530
558
|
else current = null;
|
|
531
559
|
attempts++;
|
|
532
560
|
}
|
|
533
561
|
const theme = _Zum.getTheme();
|
|
534
|
-
return theme ? theme.colors.background
|
|
562
|
+
return ((_a = theme == null ? void 0 : theme.colors) == null ? void 0 : _a.background) || "#ffffff";
|
|
563
|
+
}
|
|
564
|
+
static _processContrastNode(el) {
|
|
565
|
+
var _a, _b, _c, _d, _e, _f;
|
|
566
|
+
if (_Zum._shouldSkipAutoContrast(el)) return;
|
|
567
|
+
if (!_Zum._hasDirectText(el)) return;
|
|
568
|
+
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastApplied === "true") return;
|
|
569
|
+
const bg = _Zum._getRealBackground(el);
|
|
570
|
+
const currentColor = getComputedStyle(el).color;
|
|
571
|
+
const minRatio = (_b = (_a = _Zum.themeSettings) == null ? void 0 : _a.minContrastRatio) != null ? _b : 3;
|
|
572
|
+
if (currentColor && el.dataset.contrastApplied !== "true") {
|
|
573
|
+
const existingRatio = _Zum.getContrastRatio(currentColor, bg);
|
|
574
|
+
if (existingRatio >= minRatio) {
|
|
575
|
+
_Zum._contrastProcessed.add(el);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const lum = _Zum._calculateLuminance(bg);
|
|
580
|
+
const threshold = (_d = (_c = _Zum.themeSettings) == null ? void 0 : _c.contrastThreshold) != null ? _d : 0.5;
|
|
581
|
+
const theme = _Zum.getTheme();
|
|
582
|
+
const darkText = ((_e = theme == null ? void 0 : theme.colors) == null ? void 0 : _e.text) && _Zum._calculateLuminance(theme.colors.text) < 0.3 ? theme.colors.text : "#0f172a";
|
|
583
|
+
const lightText = ((_f = theme == null ? void 0 : theme.colors) == null ? void 0 : _f.text) && _Zum._calculateLuminance(theme.colors.text) > 0.7 ? theme.colors.text : "#f1f5f9";
|
|
584
|
+
const color = lum > threshold ? darkText : lightText;
|
|
585
|
+
el.style.color = color;
|
|
586
|
+
el.dataset.contrastColor = color;
|
|
587
|
+
el.dataset.contrastApplied = "true";
|
|
588
|
+
el.classList.add("zum-contrast-text");
|
|
589
|
+
_Zum._contrastProcessed.add(el);
|
|
535
590
|
}
|
|
536
591
|
static _applyContrastToAll() {
|
|
537
|
-
if (!hasDOM() || !document.body) return;
|
|
538
|
-
const skip = "input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
539
|
-
const process2 = (el) => {
|
|
540
|
-
if (!el || !el.matches) return;
|
|
541
|
-
if (el.matches(skip)) return;
|
|
542
|
-
if (!el.textContent || !el.textContent.trim()) return;
|
|
543
|
-
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastColor) return;
|
|
544
|
-
const bg = _Zum._getRealBackground(el);
|
|
545
|
-
const lum = _Zum._calculateLuminance(bg);
|
|
546
|
-
const color = lum > 0.5 ? "#0f172a" : "#f1f5f9";
|
|
547
|
-
el.style.setProperty("color", color, "important");
|
|
548
|
-
el.dataset.contrastColor = color;
|
|
549
|
-
el.classList.add("zum-contrast-text");
|
|
550
|
-
_Zum._contrastProcessed.add(el);
|
|
551
|
-
};
|
|
592
|
+
if (!hasDOM() || !document.body || !_Zum.themeSettings.autoContrast) return;
|
|
552
593
|
const walk = (root) => {
|
|
553
594
|
if (!root || !root.querySelectorAll) return;
|
|
554
595
|
root.querySelectorAll("*").forEach((el) => {
|
|
555
|
-
|
|
596
|
+
_Zum._processContrastNode(el);
|
|
556
597
|
if (el.shadowRoot) walk(el.shadowRoot);
|
|
557
598
|
});
|
|
558
599
|
};
|
|
@@ -560,32 +601,17 @@ var _Zum = class _Zum {
|
|
|
560
601
|
zlog("\u2705 Contrast applied to all elements");
|
|
561
602
|
}
|
|
562
603
|
static _applyContrastToElement(element) {
|
|
563
|
-
if (!element || !hasDOM()) return;
|
|
564
|
-
const skip = "input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
565
|
-
const process2 = (el) => {
|
|
566
|
-
if (!el || !el.matches) return;
|
|
567
|
-
if (el.matches(skip)) return;
|
|
568
|
-
if (!el.textContent || !el.textContent.trim()) return;
|
|
569
|
-
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastColor) return;
|
|
570
|
-
const bg = _Zum._getRealBackground(el);
|
|
571
|
-
const lum = _Zum._calculateLuminance(bg);
|
|
572
|
-
const color = lum > 0.5 ? "#0f172a" : "#f1f5f9";
|
|
573
|
-
el.style.setProperty("color", color, "important");
|
|
574
|
-
el.dataset.contrastColor = color;
|
|
575
|
-
el.classList.add("zum-contrast-text");
|
|
576
|
-
_Zum._contrastProcessed.add(el);
|
|
577
|
-
};
|
|
604
|
+
if (!element || !hasDOM() || !_Zum.themeSettings.autoContrast) return;
|
|
578
605
|
_Zum._contrastProcessing.add(element);
|
|
579
|
-
|
|
606
|
+
_Zum._processContrastNode(element);
|
|
580
607
|
const walk = (root) => {
|
|
581
608
|
if (!root || !root.querySelectorAll) return;
|
|
582
609
|
root.querySelectorAll("*").forEach((el) => {
|
|
583
|
-
|
|
610
|
+
_Zum._processContrastNode(el);
|
|
584
611
|
if (el.shadowRoot) walk(el.shadowRoot);
|
|
585
612
|
});
|
|
586
613
|
};
|
|
587
614
|
walk(element);
|
|
588
|
-
element.classList.add("zum-contrast");
|
|
589
615
|
setTimeout(() => _Zum._contrastProcessing.delete(element), 250);
|
|
590
616
|
}
|
|
591
617
|
static _resolveColorToRgb(color) {
|
|
@@ -647,6 +673,7 @@ var _Zum = class _Zum {
|
|
|
647
673
|
if (!el) return;
|
|
648
674
|
_Zum._contrastProcessed.delete(el);
|
|
649
675
|
delete el.dataset.contrastColor;
|
|
676
|
+
delete el.dataset.contrastApplied;
|
|
650
677
|
_Zum._applyContrastToElement(el);
|
|
651
678
|
}
|
|
652
679
|
static refreshContrast() {
|
|
@@ -656,6 +683,10 @@ var _Zum = class _Zum {
|
|
|
656
683
|
root.querySelectorAll("*").forEach((el) => {
|
|
657
684
|
_Zum._contrastProcessed.delete(el);
|
|
658
685
|
delete el.dataset.contrastColor;
|
|
686
|
+
if (el.dataset.contrastApplied === "true") {
|
|
687
|
+
el.style.removeProperty("color");
|
|
688
|
+
delete el.dataset.contrastApplied;
|
|
689
|
+
}
|
|
659
690
|
if (el.shadowRoot) reset(el.shadowRoot);
|
|
660
691
|
});
|
|
661
692
|
};
|
|
@@ -2396,9 +2427,6 @@ ${comp.css}`);
|
|
|
2396
2427
|
const manualOverride = localStorage.getItem(_Zum.themeSettings.systemPreferenceKey);
|
|
2397
2428
|
if (!manualOverride) {
|
|
2398
2429
|
const newTheme = e.matches ? "dark" : "light";
|
|
2399
|
-
document.querySelectorAll("*").forEach((el) => {
|
|
2400
|
-
el._zumContrastApplied = false;
|
|
2401
|
-
});
|
|
2402
2430
|
_Zum.applyTheme(newTheme, { manual: false, smooth: true, duration: 400 });
|
|
2403
2431
|
setTimeout(() => _Zum.refreshContrast(), 500);
|
|
2404
2432
|
zlog(`\u{1F504} Auto-switched to ${newTheme} theme (system preference)`);
|
|
@@ -2452,10 +2480,7 @@ ${comp.css}`);
|
|
|
2452
2480
|
_Zum._notifyThemeObservers(themeId);
|
|
2453
2481
|
if (updateContrast && _Zum.themeSettings.autoContrast) {
|
|
2454
2482
|
setTimeout(() => {
|
|
2455
|
-
|
|
2456
|
-
el._zumContrastApplied = false;
|
|
2457
|
-
});
|
|
2458
|
-
_Zum._applyContrastToAll();
|
|
2483
|
+
_Zum.refreshContrast();
|
|
2459
2484
|
}, smooth ? duration + 50 : 50);
|
|
2460
2485
|
}
|
|
2461
2486
|
zlog(`\u2705 Theme applied: ${themeId} (${theme.name})`);
|
|
@@ -3073,7 +3098,8 @@ __publicField(_Zum, "themeSettings", {
|
|
|
3073
3098
|
transitionDuration: 400,
|
|
3074
3099
|
transitionEasing: "ease-in-out",
|
|
3075
3100
|
autoContrast: true,
|
|
3076
|
-
contrastThreshold: 0.5
|
|
3101
|
+
contrastThreshold: 0.5,
|
|
3102
|
+
minContrastRatio: 3
|
|
3077
3103
|
});
|
|
3078
3104
|
__publicField(_Zum, "THEMES", {
|
|
3079
3105
|
light: {
|
|
@@ -3581,9 +3607,6 @@ if (hasDOM()) {
|
|
|
3581
3607
|
const onSystemChange = (e) => {
|
|
3582
3608
|
if (localStorage.getItem(Zum.themeSettings.systemPreferenceKey)) return;
|
|
3583
3609
|
const newTheme = e.matches ? "dark" : "light";
|
|
3584
|
-
document.querySelectorAll("*").forEach((el) => {
|
|
3585
|
-
el._zumContrastApplied = false;
|
|
3586
|
-
});
|
|
3587
3610
|
Zum.applyTheme(newTheme, { manual: false, smooth: true, duration: 400 });
|
|
3588
3611
|
setTimeout(() => Zum.refreshContrast(), 500);
|
|
3589
3612
|
zlog(`\u{1F504} Auto-switched to ${newTheme} (system preference)`);
|
package/dist/zum.iife.min.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
var ZumModule=(()=>{var U=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var X=(
|
|
1
|
+
var ZumModule=(()=>{var U=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var X=(_,e,t)=>e in _?U(_,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):_[e]=t;var Q=(_,e)=>{for(var t in e)U(_,t,{get:e[t],enumerable:!0})},ee=(_,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!V.call(_,r)&&r!==t&&U(_,r,{get:()=>e[r],enumerable:!(a=Y(e,r))||a.enumerable});return _};var te=_=>ee(U({},"__esModule",{value:!0}),_);var w=(_,e,t)=>X(_,typeof e!="symbol"?e+"":e,t);var re={};Q(re,{Zum:()=>O,ZumActivity:()=>ae,default:()=>ne});var j=()=>typeof window!="undefined"&&typeof document!="undefined",K={_debugEnabled:!1},W=typeof window!="undefined"&&(window.__ZUM_DEBUG__===!0||typeof process!="undefined"&&process.env&&!1),L=(..._)=>{(W||K._debugEnabled)&&console.log(..._)},z=(..._)=>{(W||K._debugEnabled)&&console.warn(..._)},T=(..._)=>{console.error(..._)},n=class n{static addBeforeUnloadHandler(e){return typeof e!="function"?()=>{}:(!n._beforeUnloadAttached&&typeof window!="undefined"&&(window.addEventListener("beforeunload",()=>{n._beforeUnloadHandlers.forEach(t=>{try{t()}catch(a){T(a)}})}),n._beforeUnloadAttached=!0),n._beforeUnloadHandlers.add(e),()=>n._beforeUnloadHandlers.delete(e))}static _debounce(e,t){let a,r=function(...s){let i=()=>{clearTimeout(a),e(...s)};clearTimeout(a),a=setTimeout(i,t)};return r.cancel=()=>{clearTimeout(a),a=null},r.flush=(...s)=>{clearTimeout(a),a=null,e(...s)},r}static _isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static _deepMerge(e,t){let a={...e};return n._isObject(e)&&n._isObject(t)&&Object.keys(t).forEach(r=>{n._isObject(t[r])?r in e?a[r]=n._deepMerge(e[r],t[r]):a[r]=t[r]:(Array.isArray(t[r]),a[r]=t[r])}),a}static _escapeHtml(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}static _scheduleAutoSave(e,t,a){a>0&&(e.__debouncedSave||(e.__debouncedSave=n._debounce(()=>{e.__isDestroyed||n.saveComponent(t,e)},a)),e.__debouncedSave())}static _scheduleOnUpdate(e,t){e.__onUpdate&&(e.__pendingUpdate=t,!e.__onUpdateScheduled&&(e.__onUpdateScheduled=!0,queueMicrotask(()=>{e.__onUpdateScheduled=!1;let a=e.__pendingUpdate;if(e.__pendingUpdate=null,a&&e.__onUpdate)try{e.__onUpdate.call(e,a)}catch(r){T(r)}})))}static _createReactiveState(e,t,a,r){return new Proxy(e,{set:(s,i,c)=>{let l=s[i];return l===c&&(typeof c!="object"||c===null)||(typeof c=="object"&&c!==null&&(c=n._createReactiveState(c,t,a,r)),s[i]=c,n._scheduleAutoSave(a,t,r),a.__isMounted&&a.__onUpdate&&n._scheduleOnUpdate(a,{property:i,oldValue:l,newValue:c,state:s}),a.__stateWatchers&&a.__stateWatchers[i]&&a.__stateWatchers[i].forEach(d=>{try{d(c,l,s)}catch(m){T(m)}})),!0},get:(s,i)=>{let c=s[i];return Array.isArray(c)?new Proxy(c,{get:(l,d)=>{let m=l[d];return typeof m=="function"&&["push","pop","shift","unshift","splice","sort","reverse"].includes(d)?function(...f){let h=[...l],E=Array.prototype[d].apply(l,f);return n._scheduleAutoSave(a,t,r),a.__isMounted&&a.__onUpdate&&n._scheduleOnUpdate(a,{property:i,oldValue:h,newValue:l,state:s}),a.__stateWatchers&&a.__stateWatchers[i]&&a.__stateWatchers[i].forEach(k=>{try{k(l,h,s)}catch(y){T(y)}}),E}:m}}):c}})}static get ready(){return n._readyPromise||(n._readyPromise=(async()=>(j()&&(n._injectAnimationStyles(),n._initAutoContrast()),!0))()),n._readyPromise}static create(e,t={}){return e&&typeof e=="object"&&!(e instanceof HTMLElement)&&(t=e,e=t.tag||"div"),e||(e="div"),new n(e,t).getElement()}static createMany(e,t=[],a="33/33/33"){if(!j())return null;t.length>3&&z(`Zum.createMany: received ${t.length} components but only 3 are supported.`);let r=t.slice(0,3),s=a.split("/").map(o=>parseFloat(o.trim()));if(s.length===0||s.some(isNaN)){let o=100/Math.max(r.length,1);s=r.map(()=>o)}for(;s.length<r.length;)s.push(100/Math.max(r.length,1));let i=s.reduce((o,x)=>o+x,0);i>0&&i!==100&&(s=s.map(o=>o*100/i));let c=document.createElement("div");c.className="Zum-many-container",c.style.cssText="width: 100%; max-width: 100%; height: 100dvh; height: 100vh; overflow: hidden; position: relative; margin: 0; padding: 0; box-sizing: border-box;";let d=(e instanceof HTMLElement?e:e?n.create(e.tag||"div",e):null)||(r[0]?r[0]instanceof HTMLElement?r[0]:n.create(r[0].tag||"div",{...r[0],useShadow:!1}):null),m=r.map(o=>o instanceof HTMLElement?o:n.create(o.tag||"div",o)),v=null,f=document.createElement("div");f.className="Zum-many-mobile-scroll",f.style.cssText="width: 100%; max-width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; box-sizing: border-box;",d&&f.appendChild(d);let h=document.createElement("div");h.setAttribute("data-layout","mobile"),h.style.cssText="width: 100%; max-width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;",h.appendChild(f);let E=document.createElement("div");E.className="Zum-many-panels";let k=16;E.style.cssText=`display: flex; gap: ${k}px; width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;`;let y=(m.length-1)*k;m.forEach((o,x)=>{let A=document.createElement("div");A.className="Zum-many-panel";let R=s[x]||100/m.length,g=`calc(${R}% - ${(y*(R/100)).toFixed(2)}px)`;A.style.cssText=`flex: 0 0 ${g}; width: ${g}; max-width: ${g}; height: 100%; min-height: 0; display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden;`;let u=document.createElement("div");u.className="Zum-many-panel-scroll",u.style.cssText="width: 100%; height: 100%; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; box-sizing: border-box;",u.appendChild(o),A.appendChild(u),E.appendChild(A)});let $=document.createElement("div");if($.setAttribute("data-layout","desktop"),$.style.cssText="width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;",$.appendChild(E),!document.getElementById("Zum-many-styles")){let o=document.createElement("style");o.id="Zum-many-styles",o.textContent=`
|
|
2
2
|
.Zum-many-container { width: 100% !important; height: 100vh; height: 100dvh; overflow: hidden; }
|
|
3
3
|
@media (max-width: 767px) {
|
|
4
4
|
.Zum-many-container [data-layout="desktop"] { display: none !important; }
|
|
5
5
|
.Zum-many-container [data-layout="mobile"] { display: block !important; }
|
|
6
6
|
}
|
|
7
|
-
`,document.head.appendChild(o)}let
|
|
8
|
-
`),(document.head||document.documentElement).appendChild(e),n._animationsInjected=!0}static _parseAnim(e){if(!e)return null;if(typeof e=="object")return{...e,__raw:!0};let t=String(e).trim().toLowerCase().split(/\s+/),a={verb:"fade",direction:null,duration:500,easing:null,delay:0,scroll:!1,repeat:!1,stagger:0,staggerTarget:"> *",loop:!1,forceMotion:!1,disableMotion:!1},r=["fade","slide","zoom","scale","flip","rotate","blur","bounce","shake","pulse","reveal"],s=["up","down","left","right"],i={ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",linear:"linear",bounce:"cubic-bezier(.34,1.56,.64,1)",spring:"cubic-bezier(.16,1,.3,1)",snap:"cubic-bezier(.5,-0.5,.5,1.5)"},c={fast:250,normal:500,slow:800,slower:1200},l=!1;for(let d of t)r.includes(d)&&!l?(a.verb=d,l=!0):s.includes(d)?a.direction=d:/^\d+$/.test(d)?a.duration=parseInt(d,10):d in c?a.duration=c[d]:d in i?a.easing=i[d]:d.startsWith("delay-")?a.delay=parseInt(d.slice(6),10)||0:d==="on-scroll"?a.scroll=!0:d==="repeat"?(a.scroll=!0,a.repeat=!0):d==="loop"?a.loop=!0:d==="force-motion"?a.forceMotion=!0:d==="no-motion"?a.disableMotion=!0:d==="stagger"?a.stagger=80:d.startsWith("stagger-")?a.stagger=parseInt(d.slice(8),10)||80:d.startsWith("target-")&&(a.staggerTarget="."+d.slice(7));return a.easing||(a.easing="cubic-bezier(.2,.8,.2,1)"),a}static _resolveAnimName(e){let t=r=>r[0].toUpperCase()+r.slice(1);return{fade:"fade",slide:e.direction?`slide${t(e.direction)}`:"slideUp",flip:"flipIn",rotate:"rotateIn",zoom:"scale",scale:"scale",blur:"blurIn",bounce:"bounce",shake:"shake",pulse:"pulse",reveal:"reveal"}[e.verb]||"fade"}static _applyScrollAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),e.style.opacity="0",e.style.willChange="opacity, transform";let r=()=>{e.__isDestroyed||(e.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay}ms both`)},s=()=>{e.style.animation="none",e.style.opacity="0"},i=new IntersectionObserver(c=>{for(let l of c)l.isIntersecting?(r(),t.repeat||i.unobserve(e)):t.repeat&&s()},{threshold:.15,rootMargin:"0px 0px -10% 0px"});(e.__zumAnimObservers||(e.__zumAnimObservers=[])).push(i),i.observe(e)}static _applyStaggerAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),(t.staggerTarget==="> *"?Array.from(e.children):Array.from(e.querySelectorAll(t.staggerTarget))).forEach((s,i)=>{s.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay+i*t.stagger}ms both`})}_applyAnimation(e,t,a="in"){var c;if(!t||!j())return;let r=(c=window.matchMedia)==null?void 0:c.call(window,"(prefers-reduced-motion: reduce)").matches,s=n._parseAnim(t);if(!s||r&&n.respectReducedMotion&&!s.forceMotion&&a==="in"||s.disableMotion||s.__raw)return;if(s.scroll)return n._applyScrollAnim(e,s);if(s.stagger)return n._applyStaggerAnim(e,s);let i=n._resolveAnimName(s);n._injectAnimationStyles(),e.style.animation=`${i} ${s.duration}ms ${s.easing} ${s.delay}ms both`,s.loop&&(e.style.animationIterationCount="infinite")}static animate(e,t="fade",a={}){if(!e||!t)return;let r=n._parseAnim(t);if(!r||(a.duration&&(r.duration=a.duration),a.easing&&(r.easing=a.easing),a.delay&&(r.delay=a.delay),r.__raw))return;if(r.scroll)return n._applyScrollAnim(e,r);if(r.stagger)return n._applyStaggerAnim(e,r);let s=n._resolveAnimName(r);n._injectAnimationStyles(),e.style.animation=`${s} ${r.duration}ms ${r.easing} ${r.delay}ms both`,r.loop&&(e.style.animationIterationCount="infinite")}static async animateOut(e,t="fade",a={}){var d,m;if(!e||!t)return;let r=n._parseAnim(t);if(!r)return;let s=n._resolveAnimName(r),i=n.animations[s];if(!i)return;n._injectAnimationStyles();let c=r.duration||a.duration||((d=i.options)==null?void 0:d.duration)||600,l=r.easing||a.easing||((m=i.options)==null?void 0:m.easing)||"ease";return new Promise(v=>{let f=!1,h=()=>{f||(f=!0,e.removeEventListener("animationend",h),v())};e.addEventListener("animationend",h),e.style.animation=`${s}Out ${c}ms ${l} ${r.delay||0}ms both`,setTimeout(h,c+(r.delay||0)+100)})}static _initAutoContrast(){if(n._contrastInitialized||!j())return;let e=document.createElement("style");e.setAttribute("data-Zum-contrast","true"),e.textContent=`
|
|
9
|
-
.zum-contrast
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@media (prefers-color-scheme: light) { .zum-contrast-text { color: #0f172a !important; } }
|
|
13
|
-
`,document.head.appendChild(e);let t=new MutationObserver(s=>{s.forEach(i=>{i.addedNodes&&i.addedNodes.forEach(c=>{c.nodeType===Node.ELEMENT_NODE&&setTimeout(()=>n._applyContrastToElement(c),50)})})});document.body&&t.observe(document.body,{childList:!0,subtree:!0}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>setTimeout(()=>n._applyContrastToAll(),100)):setTimeout(()=>n._applyContrastToAll(),100);let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>setTimeout(()=>n._applyContrastToAll(),50);a.addEventListener?a.addEventListener("change",r):a.addListener&&a.addListener(r),n._contrastInitialized=!0,M("\u2705 Auto-contrast system initialized")}static _getRealBackground(e){let t=e,a=0;for(;t&&a<30;){let s=getComputedStyle(t).backgroundColor;if(s&&s!=="rgba(0, 0, 0, 0)"&&s!=="transparent"&&s!=="")return s;if(t!==e&&n._contrastProcessing.has(t))break;t.parentElement?t=t.parentElement:t.parentNode&&t.parentNode.host?t=t.parentNode.host:t=null,a++}let r=n.getTheme();return r?r.colors.background:"#ffffff"}static _applyContrastToAll(){if(!j()||!document.body)return;let e="input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr",t=r=>{if(!r||!r.matches||r.matches(e)||!r.textContent||!r.textContent.trim()||n._contrastProcessed.has(r)&&r.dataset.contrastColor)return;let s=n._getRealBackground(r),c=n._calculateLuminance(s)>.5?"#0f172a":"#f1f5f9";r.style.setProperty("color",c,"important"),r.dataset.contrastColor=c,r.classList.add("zum-contrast-text"),n._contrastProcessed.add(r)},a=r=>{!r||!r.querySelectorAll||r.querySelectorAll("*").forEach(s=>{t(s),s.shadowRoot&&a(s.shadowRoot)})};a(document.body),M("\u2705 Contrast applied to all elements")}static _applyContrastToElement(e){if(!e||!j())return;let t="input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr",a=s=>{if(!s||!s.matches||s.matches(t)||!s.textContent||!s.textContent.trim()||n._contrastProcessed.has(s)&&s.dataset.contrastColor)return;let i=n._getRealBackground(s),l=n._calculateLuminance(i)>.5?"#0f172a":"#f1f5f9";s.style.setProperty("color",l,"important"),s.dataset.contrastColor=l,s.classList.add("zum-contrast-text"),n._contrastProcessed.add(s)};n._contrastProcessing.add(e),a(e);let r=s=>{!s||!s.querySelectorAll||s.querySelectorAll("*").forEach(i=>{a(i),i.shadowRoot&&r(i.shadowRoot)})};r(e),e.classList.add("zum-contrast"),setTimeout(()=>n._contrastProcessing.delete(e),250)}static _resolveColorToRgb(e){if(!e||typeof document=="undefined")return null;if(e.startsWith("#")||e.startsWith("rgb"))return e;let t=document.createElement("span");t.style.color=e,t.style.display="none",document.body.appendChild(t);let a=getComputedStyle(t).color;return document.body.removeChild(t),a||null}static _calculateLuminance(e){if(!e)return .5;let t=n._resolveColorToRgb(e);if(!t)return .5;let a,r,s;if(t.startsWith("#")){let i=t.replace("#","");if(i.length===3)a=parseInt(i[0]+i[0],16),r=parseInt(i[1]+i[1],16),s=parseInt(i[2]+i[2],16);else if(i.length===6)a=parseInt(i.slice(0,2),16),r=parseInt(i.slice(2,4),16),s=parseInt(i.slice(4,6),16);else return .5}else if(t.startsWith("rgb")){let i=t.match(/[\d.]+/g);if(i&&i.length>=3)a=parseFloat(i[0]),r=parseFloat(i[1]),s=parseFloat(i[2]);else return .5}else return .5;return(.299*a+.587*r+.114*s)/255}static getContrastColor(e,t={}){var c,l;let{mode:a="luminance",foreground:r=null}=t,s=n._calculateLuminance(e),i=(l=(c=n.themeSettings)==null?void 0:c.contrastThreshold)!=null?l:.5;if(a==="wcag"&&r){let d=n._calculateLuminance(r);return(Math.max(s,d)+.05)/(Math.min(s,d)+.05)>=4.5?r:s>i?"#0f172a":"#f1f5f9"}return s>i?"#0f172a":"#f1f5f9"}static getThemeContrastColor(e){var a,r;return n._calculateLuminance(e)>((r=(a=n.themeSettings)==null?void 0:a.contrastThreshold)!=null?r:.5)?"#0f172a":"#f1f5f9"}static applyContrast(e){e&&(n._contrastProcessed.delete(e),delete e.dataset.contrastColor,n._applyContrastToElement(e))}static refreshContrast(){if(!j()||!document.body)return;let e=t=>{!t||!t.querySelectorAll||t.querySelectorAll("*").forEach(a=>{n._contrastProcessed.delete(a),delete a.dataset.contrastColor,a.shadowRoot&&e(a.shadowRoot)})};e(document.body),n._applyContrastToAll(),M("\u{1F3A8} Contrast refreshed everywhere")}_buildComponent(){if(!j())return;let{html:e="",style:t={},className:a="",events:r={},children:s=[],attributes:i={},css:c="",script:l="",props:d={},state:m={},websocket:v=null,onMount:f=null,onDestroy:h=null,onUpdate:_=null,anim:P="fade",autoSave:b=!1,autoSaveDelay:$=500,exclude:z=[],render:D=null,autoContrast:N=!0,safe:H=!0}=this.options,o=document.createElement(this.tag);o.__isDestroyed=!1,this._applyAnimation(o,P);let x=(d==null?void 0:d.componentId)||(d==null?void 0:d.name)||`component-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(o.__componentName=x,a&&(o.className=a),Object.assign(o.style,t),e){let g=e;Object.entries(d).forEach(([u,O])=>{let p=`{{${u}}}`;if(typeof O=="string"||typeof O=="number"){let y=H?n._escapeHtml(O):String(O);g=g.split(p).join(y)}}),o.innerHTML=g}let C=b?$:0;if(b){let g=n._autoGenerateState(o,z);o.__state=n._createReactiveState(g,x,o,C)}else m&&typeof m=="object"?o.__state=n._createReactiveState({...m},x,o,0):o.__state={};if(D&&n._setupAutoRender(o,D),Object.entries(i).forEach(([g,u])=>o.setAttribute(g,u)),o.__props=d,v){let{url:g,protocols:u=[],onopen:O=null,onmessage:p=null,onclose:y=null,onerror:S=null,autoReconnect:k=!1,reconnectInterval:Z=3e3,maxReconnects:q=1/0}=v;o.__wsQueue=[],o.__reconnectAttempts=0,o.__createWebSocket=function(){if(!o.__websocketDestroyed)try{let L=u.length>0?new WebSocket(g,u):new WebSocket(g);o.__websocket=L,L.onopen=F=>{for(;o.__wsQueue.length&&L.readyState===WebSocket.OPEN;){let B=o.__wsQueue.shift();try{L.send(typeof B=="string"?B:JSON.stringify(B))}catch(G){E(G)}}o.__reconnectAttempts=0,O&&O.call(o,F,L)},L.onmessage=F=>{p&&p.call(o,F,L)},L.onclose=F=>{y&&y.call(o,F,L),k&&!o.__websocketDestroyed&&o.__reconnectAttempts<q&&(o.__reconnectAttempts++,setTimeout(()=>{o.__websocketDestroyed||o.__createWebSocket()},Z))},L.onerror=F=>{S&&S.call(o,F,L)}}catch(L){E("WebSocket creation failed:",L)}},o.sendWebSocket=L=>{if(o.__websocket&&o.__websocket.readyState===WebSocket.OPEN)try{o.__websocket.send(typeof L=="string"?L:JSON.stringify(L))}catch(F){E(F)}else o.__wsQueue.push(L)},o.closeWebSocket=(L=1e3,F="")=>{o.__websocketDestroyed=!0,o.__websocket&&o.__websocket.close(L,F)},setTimeout(()=>o.__createWebSocket(),10)}if(o.__events=[],Object.entries(r).forEach(([g,u])=>{o.addEventListener(g,u),o.__events.push({event:g,handler:u})}),s.filter(Boolean).map(g=>g instanceof HTMLElement?g:typeof g=="object"&&!Array.isArray(g)?n.create(g.tag||"div",{...g,useShadow:!1,props:{...d,...g.props}}):g).filter(g=>g instanceof HTMLElement).forEach(g=>o.appendChild(g)),o.__onMount=f,o.__onDestroy=h,_){let g=o.__onUpdate;g?o.__onUpdate=function(u){try{g.call(this,u)}catch(O){E(O)}try{_.call(this,u)}catch(O){E(O)}}:o.__onUpdate=_}if(setTimeout(()=>{if(!o.__isDestroyed){if(o.__isMounted=!0,b&&n._autoBindFormElements(o),o.__onMount)try{o.__onMount.call(o)}catch(g){E(g)}N!==!1&&setTimeout(()=>{o.__isDestroyed||n._applyContrastToElement(o)},50)}},0),c){let g=document.createElement("style");g.textContent=c,g.setAttribute("data-Zum-css","true"),document.head.appendChild(g),o.__ZumCss=g}l&&setTimeout(()=>{o.__isDestroyed||n._executeScriptWithState(l,o)},10),this.elementWrapper.appendChild(o)}static _executeScriptWithState(e,t){try{typeof e=="function"?e.call(t,t.__state):typeof e=="string"&&new Function("state",e).call(t,t.__state)}catch(a){E("Error executing script with state:",a)}}static addComponents(...e){if(!j())return null;let t=[],a=o=>{Array.isArray(o)?o.forEach(a):o&&t.push(o)};if(e.forEach(a),t.length===0)return null;let r=document.createElement("div");r.style.display="contents";let s={},i={},c=[],l={},d=[],m=[],v=[],f=[],h=[],_=[];t.forEach((o,x)=>{if(o instanceof HTMLElement){c.push(o);return}if(typeof o=="string"){let R=document.createElement("div");R.textContent=o,c.push(R);return}if(typeof o!="object")return;o.events&&typeof o.events=="object"&&Object.entries(o.events).forEach(([R,g])=>{l[R]||(l[R]=[]),typeof g=="function"&&l[R].push(g)}),o.state&&Object.keys(o.state).forEach(R=>{R in s&&I(`Zum.addComponents: state key "${R}" overrides an earlier value.`),s[R]=o.state[R]}),o.props&&Object.assign(i,o.props),typeof o.onMount=="function"&&d.push(o.onMount),typeof o.onDestroy=="function"&&m.push(o.onDestroy),typeof o.onUpdate=="function"&&v.push(o.onUpdate),typeof o.onRefresh=="function"&&f.push(o.onRefresh),typeof o.css=="string"&&o.css.trim()&&h.push(`/* --- Component ${x+1}: ${o.tag||"div"} --- */
|
|
14
|
-
${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string"&&o.script.trim()&&_.push(new Function("state",o.script));let C={...o};delete C.events,delete C.state,delete C.onMount,delete C.onDestroy,delete C.onUpdate,delete C.onRefresh,c.push(n.create(o.tag||"div",C))});let P={};Object.entries(l).forEach(([o,x])=>{P[o]=function(C){x.forEach(R=>{try{R.call(this,C)}catch(g){E(`addComponent event (${o}):`,g)}})}});let b=function(){d.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},$=function(){m.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},z=function(o){v.forEach(x=>{try{x.call(this,o)}catch(C){E(C)}})},D=function(){f.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},N=n.create("div",{children:c,props:i,state:s,events:P,css:h.join(`
|
|
7
|
+
`,document.head.appendChild(o)}let D=()=>window.innerWidth>=768,F=()=>{let o=D()?"desktop":"mobile";v!==o&&(o==="desktop"?(h.parentNode===c&&c.removeChild(h),c.appendChild($),c.setAttribute("data-layout","desktop")):($.parentNode===c&&c.removeChild($),c.appendChild(h),c.setAttribute("data-layout","mobile")),v=o)};F();let N=null,H=()=>{N||(N=requestAnimationFrame(()=>{F(),N=null}))};return window.addEventListener("resize",H),c.__cleanupResize=()=>{window.removeEventListener("resize",H),N&&cancelAnimationFrame(N),N=null},c.__droppedCount=Math.max(0,t.length-3),c.__destroyMany=()=>{c.__isDestroyed=!0;try{c.__cleanupResize()}catch(o){}},c}constructor(e,t={}){this.tag=e||"div",this.options=t,this.elementWrapper=document.createElement("div"),this.elementWrapper.style.display="contents",this._initWithoutLicense()}getElement(){return this.elementWrapper}async _initWithoutLicense(){await n.ready,this._buildComponent()}static _injectAnimationStyles(){if(n._animationsInjected||typeof document=="undefined")return;let e=document.createElement("style");e.setAttribute("data-Zum-animations","true"),e.textContent=Object.values(n.animations).map(t=>t.keyframes).join(`
|
|
8
|
+
`),(document.head||document.documentElement).appendChild(e),n._animationsInjected=!0}static _parseAnim(e){if(!e)return null;if(typeof e=="object")return{...e,__raw:!0};let t=String(e).trim().toLowerCase().split(/\s+/),a={verb:"fade",direction:null,duration:500,easing:null,delay:0,scroll:!1,repeat:!1,stagger:0,staggerTarget:"> *",loop:!1,forceMotion:!1,disableMotion:!1},r=["fade","slide","zoom","scale","flip","rotate","blur","bounce","shake","pulse","reveal"],s=["up","down","left","right"],i={ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",linear:"linear",bounce:"cubic-bezier(.34,1.56,.64,1)",spring:"cubic-bezier(.16,1,.3,1)",snap:"cubic-bezier(.5,-0.5,.5,1.5)"},c={fast:250,normal:500,slow:800,slower:1200},l=!1;for(let d of t)r.includes(d)&&!l?(a.verb=d,l=!0):s.includes(d)?a.direction=d:/^\d+$/.test(d)?a.duration=parseInt(d,10):d in c?a.duration=c[d]:d in i?a.easing=i[d]:d.startsWith("delay-")?a.delay=parseInt(d.slice(6),10)||0:d==="on-scroll"?a.scroll=!0:d==="repeat"?(a.scroll=!0,a.repeat=!0):d==="loop"?a.loop=!0:d==="force-motion"?a.forceMotion=!0:d==="no-motion"?a.disableMotion=!0:d==="stagger"?a.stagger=80:d.startsWith("stagger-")?a.stagger=parseInt(d.slice(8),10)||80:d.startsWith("target-")&&(a.staggerTarget="."+d.slice(7));return a.easing||(a.easing="cubic-bezier(.2,.8,.2,1)"),a}static _resolveAnimName(e){let t=r=>r[0].toUpperCase()+r.slice(1);return{fade:"fade",slide:e.direction?`slide${t(e.direction)}`:"slideUp",flip:"flipIn",rotate:"rotateIn",zoom:"scale",scale:"scale",blur:"blurIn",bounce:"bounce",shake:"shake",pulse:"pulse",reveal:"reveal"}[e.verb]||"fade"}static _applyScrollAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),e.style.opacity="0",e.style.willChange="opacity, transform";let r=()=>{e.__isDestroyed||(e.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay}ms both`)},s=()=>{e.style.animation="none",e.style.opacity="0"},i=new IntersectionObserver(c=>{for(let l of c)l.isIntersecting?(r(),t.repeat||i.unobserve(e)):t.repeat&&s()},{threshold:.15,rootMargin:"0px 0px -10% 0px"});(e.__zumAnimObservers||(e.__zumAnimObservers=[])).push(i),i.observe(e)}static _applyStaggerAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),(t.staggerTarget==="> *"?Array.from(e.children):Array.from(e.querySelectorAll(t.staggerTarget))).forEach((s,i)=>{s.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay+i*t.stagger}ms both`})}_applyAnimation(e,t,a="in"){var c;if(!t||!j())return;let r=(c=window.matchMedia)==null?void 0:c.call(window,"(prefers-reduced-motion: reduce)").matches,s=n._parseAnim(t);if(!s||r&&n.respectReducedMotion&&!s.forceMotion&&a==="in"||s.disableMotion||s.__raw)return;if(s.scroll)return n._applyScrollAnim(e,s);if(s.stagger)return n._applyStaggerAnim(e,s);let i=n._resolveAnimName(s);n._injectAnimationStyles(),e.style.animation=`${i} ${s.duration}ms ${s.easing} ${s.delay}ms both`,s.loop&&(e.style.animationIterationCount="infinite")}static animate(e,t="fade",a={}){if(!e||!t)return;let r=n._parseAnim(t);if(!r||(a.duration&&(r.duration=a.duration),a.easing&&(r.easing=a.easing),a.delay&&(r.delay=a.delay),r.__raw))return;if(r.scroll)return n._applyScrollAnim(e,r);if(r.stagger)return n._applyStaggerAnim(e,r);let s=n._resolveAnimName(r);n._injectAnimationStyles(),e.style.animation=`${s} ${r.duration}ms ${r.easing} ${r.delay}ms both`,r.loop&&(e.style.animationIterationCount="infinite")}static async animateOut(e,t="fade",a={}){var d,m;if(!e||!t)return;let r=n._parseAnim(t);if(!r)return;let s=n._resolveAnimName(r),i=n.animations[s];if(!i)return;n._injectAnimationStyles();let c=r.duration||a.duration||((d=i.options)==null?void 0:d.duration)||600,l=r.easing||a.easing||((m=i.options)==null?void 0:m.easing)||"ease";return new Promise(v=>{let f=!1,h=()=>{f||(f=!0,e.removeEventListener("animationend",h),v())};e.addEventListener("animationend",h),e.style.animation=`${s}Out ${c}ms ${l} ${r.delay||0}ms both`,setTimeout(h,c+(r.delay||0)+100)})}static _shouldSkipAutoContrast(e){return!!(!e||e.nodeType!==Node.ELEMENT_NODE||!e.matches||e.matches("input, textarea, select, option, button, a, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr")||e.hasAttribute("data-no-auto-contrast")||e.classList.contains("no-auto-contrast")||e.classList.contains("zum-keep-color")||e.style&&e.style.color&&e.dataset.contrastApplied!=="true")}static _hasDirectText(e){return Array.from(e.childNodes).some(t=>t.nodeType===Node.TEXT_NODE&&t.textContent&&t.textContent.trim().length>0)}static _initAutoContrast(){if(n._contrastInitialized||!j())return;if(!n.themeSettings.autoContrast){n._contrastInitialized=!0;return}let e=document.createElement("style");e.setAttribute("data-Zum-contrast","true"),e.textContent=`
|
|
9
|
+
.zum-contrast-text { transition: color 0.25s ease-in-out; }
|
|
10
|
+
`,document.head.appendChild(e);let t=new MutationObserver(i=>{i.forEach(c=>{c.addedNodes&&c.addedNodes.forEach(l=>{l.nodeType===Node.ELEMENT_NODE&&!n._contrastProcessing.has(l)&&setTimeout(()=>n._applyContrastToElement(l),50)})})});document.body&&t.observe(document.body,{childList:!0,subtree:!0});let a=()=>setTimeout(()=>n._applyContrastToAll(),100);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",a):a();let r=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>setTimeout(()=>n.refreshContrast(),50);r.addEventListener?r.addEventListener("change",s):r.addListener&&r.addListener(s),n._contrastInitialized=!0,L("\u2705 Auto-contrast system initialized")}static _getRealBackground(e){var s;let t=e,a=0;for(;t&&a<30;){let i=getComputedStyle(t).backgroundColor;if(i&&i!=="rgba(0, 0, 0, 0)"&&i!=="transparent"&&i!==""){let c=i.match(/rgba?\(([^)]+)\)/);if(c){let l=c[1].split(",").map(m=>parseFloat(m.trim()));if((l.length===4?l[3]:1)>.05)return i}else return i}t.parentElement?t=t.parentElement:t.parentNode&&t.parentNode.host?t=t.parentNode.host:t=null,a++}let r=n.getTheme();return((s=r==null?void 0:r.colors)==null?void 0:s.background)||"#ffffff"}static _processContrastNode(e){var v,f,h,E,k,y;if(n._shouldSkipAutoContrast(e)||!n._hasDirectText(e)||n._contrastProcessed.has(e)&&e.dataset.contrastApplied==="true")return;let t=n._getRealBackground(e),a=getComputedStyle(e).color,r=(f=(v=n.themeSettings)==null?void 0:v.minContrastRatio)!=null?f:3;if(a&&e.dataset.contrastApplied!=="true"&&n.getContrastRatio(a,t)>=r){n._contrastProcessed.add(e);return}let s=n._calculateLuminance(t),i=(E=(h=n.themeSettings)==null?void 0:h.contrastThreshold)!=null?E:.5,c=n.getTheme(),l=(k=c==null?void 0:c.colors)!=null&&k.text&&n._calculateLuminance(c.colors.text)<.3?c.colors.text:"#0f172a",d=(y=c==null?void 0:c.colors)!=null&&y.text&&n._calculateLuminance(c.colors.text)>.7?c.colors.text:"#f1f5f9",m=s>i?l:d;e.style.color=m,e.dataset.contrastColor=m,e.dataset.contrastApplied="true",e.classList.add("zum-contrast-text"),n._contrastProcessed.add(e)}static _applyContrastToAll(){if(!j()||!document.body||!n.themeSettings.autoContrast)return;let e=t=>{!t||!t.querySelectorAll||t.querySelectorAll("*").forEach(a=>{n._processContrastNode(a),a.shadowRoot&&e(a.shadowRoot)})};e(document.body),L("\u2705 Contrast applied to all elements")}static _applyContrastToElement(e){if(!e||!j()||!n.themeSettings.autoContrast)return;n._contrastProcessing.add(e),n._processContrastNode(e);let t=a=>{!a||!a.querySelectorAll||a.querySelectorAll("*").forEach(r=>{n._processContrastNode(r),r.shadowRoot&&t(r.shadowRoot)})};t(e),setTimeout(()=>n._contrastProcessing.delete(e),250)}static _resolveColorToRgb(e){if(!e||typeof document=="undefined")return null;if(e.startsWith("#")||e.startsWith("rgb"))return e;let t=document.createElement("span");t.style.color=e,t.style.display="none",document.body.appendChild(t);let a=getComputedStyle(t).color;return document.body.removeChild(t),a||null}static _calculateLuminance(e){if(!e)return .5;let t=n._resolveColorToRgb(e);if(!t)return .5;let a,r,s;if(t.startsWith("#")){let i=t.replace("#","");if(i.length===3)a=parseInt(i[0]+i[0],16),r=parseInt(i[1]+i[1],16),s=parseInt(i[2]+i[2],16);else if(i.length===6)a=parseInt(i.slice(0,2),16),r=parseInt(i.slice(2,4),16),s=parseInt(i.slice(4,6),16);else return .5}else if(t.startsWith("rgb")){let i=t.match(/[\d.]+/g);if(i&&i.length>=3)a=parseFloat(i[0]),r=parseFloat(i[1]),s=parseFloat(i[2]);else return .5}else return .5;return(.299*a+.587*r+.114*s)/255}static getContrastColor(e,t={}){var c,l;let{mode:a="luminance",foreground:r=null}=t,s=n._calculateLuminance(e),i=(l=(c=n.themeSettings)==null?void 0:c.contrastThreshold)!=null?l:.5;if(a==="wcag"&&r){let d=n._calculateLuminance(r);return(Math.max(s,d)+.05)/(Math.min(s,d)+.05)>=4.5?r:s>i?"#0f172a":"#f1f5f9"}return s>i?"#0f172a":"#f1f5f9"}static getThemeContrastColor(e){var a,r;return n._calculateLuminance(e)>((r=(a=n.themeSettings)==null?void 0:a.contrastThreshold)!=null?r:.5)?"#0f172a":"#f1f5f9"}static applyContrast(e){e&&(n._contrastProcessed.delete(e),delete e.dataset.contrastColor,delete e.dataset.contrastApplied,n._applyContrastToElement(e))}static refreshContrast(){if(!j()||!document.body)return;let e=t=>{!t||!t.querySelectorAll||t.querySelectorAll("*").forEach(a=>{n._contrastProcessed.delete(a),delete a.dataset.contrastColor,a.dataset.contrastApplied==="true"&&(a.style.removeProperty("color"),delete a.dataset.contrastApplied),a.shadowRoot&&e(a.shadowRoot)})};e(document.body),n._applyContrastToAll(),L("\u{1F3A8} Contrast refreshed everywhere")}_buildComponent(){if(!j())return;let{html:e="",style:t={},className:a="",events:r={},children:s=[],attributes:i={},css:c="",script:l="",props:d={},state:m={},websocket:v=null,onMount:f=null,onDestroy:h=null,onUpdate:E=null,anim:k="fade",autoSave:y=!1,autoSaveDelay:$=500,exclude:D=[],render:F=null,autoContrast:N=!0,safe:H=!0}=this.options,o=document.createElement(this.tag);o.__isDestroyed=!1,this._applyAnimation(o,k);let x=(d==null?void 0:d.componentId)||(d==null?void 0:d.name)||`component-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(o.__componentName=x,a&&(o.className=a),Object.assign(o.style,t),e){let g=e;Object.entries(d).forEach(([u,M])=>{let p=`{{${u}}}`;if(typeof M=="string"||typeof M=="number"){let b=H?n._escapeHtml(M):String(M);g=g.split(p).join(b)}}),o.innerHTML=g}let A=y?$:0;if(y){let g=n._autoGenerateState(o,D);o.__state=n._createReactiveState(g,x,o,A)}else m&&typeof m=="object"?o.__state=n._createReactiveState({...m},x,o,0):o.__state={};if(F&&n._setupAutoRender(o,F),Object.entries(i).forEach(([g,u])=>o.setAttribute(g,u)),o.__props=d,v){let{url:g,protocols:u=[],onopen:M=null,onmessage:p=null,onclose:b=null,onerror:S=null,autoReconnect:C=!1,reconnectInterval:Z=3e3,maxReconnects:q=1/0}=v;o.__wsQueue=[],o.__reconnectAttempts=0,o.__createWebSocket=function(){if(!o.__websocketDestroyed)try{let P=u.length>0?new WebSocket(g,u):new WebSocket(g);o.__websocket=P,P.onopen=I=>{for(;o.__wsQueue.length&&P.readyState===WebSocket.OPEN;){let B=o.__wsQueue.shift();try{P.send(typeof B=="string"?B:JSON.stringify(B))}catch(G){T(G)}}o.__reconnectAttempts=0,M&&M.call(o,I,P)},P.onmessage=I=>{p&&p.call(o,I,P)},P.onclose=I=>{b&&b.call(o,I,P),C&&!o.__websocketDestroyed&&o.__reconnectAttempts<q&&(o.__reconnectAttempts++,setTimeout(()=>{o.__websocketDestroyed||o.__createWebSocket()},Z))},P.onerror=I=>{S&&S.call(o,I,P)}}catch(P){T("WebSocket creation failed:",P)}},o.sendWebSocket=P=>{if(o.__websocket&&o.__websocket.readyState===WebSocket.OPEN)try{o.__websocket.send(typeof P=="string"?P:JSON.stringify(P))}catch(I){T(I)}else o.__wsQueue.push(P)},o.closeWebSocket=(P=1e3,I="")=>{o.__websocketDestroyed=!0,o.__websocket&&o.__websocket.close(P,I)},setTimeout(()=>o.__createWebSocket(),10)}if(o.__events=[],Object.entries(r).forEach(([g,u])=>{o.addEventListener(g,u),o.__events.push({event:g,handler:u})}),s.filter(Boolean).map(g=>g instanceof HTMLElement?g:typeof g=="object"&&!Array.isArray(g)?n.create(g.tag||"div",{...g,useShadow:!1,props:{...d,...g.props}}):g).filter(g=>g instanceof HTMLElement).forEach(g=>o.appendChild(g)),o.__onMount=f,o.__onDestroy=h,E){let g=o.__onUpdate;g?o.__onUpdate=function(u){try{g.call(this,u)}catch(M){T(M)}try{E.call(this,u)}catch(M){T(M)}}:o.__onUpdate=E}if(setTimeout(()=>{if(!o.__isDestroyed){if(o.__isMounted=!0,y&&n._autoBindFormElements(o),o.__onMount)try{o.__onMount.call(o)}catch(g){T(g)}N!==!1&&setTimeout(()=>{o.__isDestroyed||n._applyContrastToElement(o)},50)}},0),c){let g=document.createElement("style");g.textContent=c,g.setAttribute("data-Zum-css","true"),document.head.appendChild(g),o.__ZumCss=g}l&&setTimeout(()=>{o.__isDestroyed||n._executeScriptWithState(l,o)},10),this.elementWrapper.appendChild(o)}static _executeScriptWithState(e,t){try{typeof e=="function"?e.call(t,t.__state):typeof e=="string"&&new Function("state",e).call(t,t.__state)}catch(a){T("Error executing script with state:",a)}}static addComponents(...e){if(!j())return null;let t=[],a=o=>{Array.isArray(o)?o.forEach(a):o&&t.push(o)};if(e.forEach(a),t.length===0)return null;let r=document.createElement("div");r.style.display="contents";let s={},i={},c=[],l={},d=[],m=[],v=[],f=[],h=[],E=[];t.forEach((o,x)=>{if(o instanceof HTMLElement){c.push(o);return}if(typeof o=="string"){let R=document.createElement("div");R.textContent=o,c.push(R);return}if(typeof o!="object")return;o.events&&typeof o.events=="object"&&Object.entries(o.events).forEach(([R,g])=>{l[R]||(l[R]=[]),typeof g=="function"&&l[R].push(g)}),o.state&&Object.keys(o.state).forEach(R=>{R in s&&z(`Zum.addComponents: state key "${R}" overrides an earlier value.`),s[R]=o.state[R]}),o.props&&Object.assign(i,o.props),typeof o.onMount=="function"&&d.push(o.onMount),typeof o.onDestroy=="function"&&m.push(o.onDestroy),typeof o.onUpdate=="function"&&v.push(o.onUpdate),typeof o.onRefresh=="function"&&f.push(o.onRefresh),typeof o.css=="string"&&o.css.trim()&&h.push(`/* --- Component ${x+1}: ${o.tag||"div"} --- */
|
|
11
|
+
${o.css}`),typeof o.script=="function"?E.push(o.script):typeof o.script=="string"&&o.script.trim()&&E.push(new Function("state",o.script));let A={...o};delete A.events,delete A.state,delete A.onMount,delete A.onDestroy,delete A.onUpdate,delete A.onRefresh,c.push(n.create(o.tag||"div",A))});let k={};Object.entries(l).forEach(([o,x])=>{k[o]=function(A){x.forEach(R=>{try{R.call(this,A)}catch(g){T(`addComponent event (${o}):`,g)}})}});let y=function(){d.forEach(o=>{try{o.call(this)}catch(x){T(x)}})},$=function(){m.forEach(o=>{try{o.call(this)}catch(x){T(x)}})},D=function(o){v.forEach(x=>{try{x.call(this,o)}catch(A){T(A)}})},F=function(){f.forEach(o=>{try{o.call(this)}catch(x){T(x)}})},N=n.create("div",{children:c,props:i,state:s,events:k,css:h.join(`
|
|
15
12
|
|
|
16
|
-
`),script:
|
|
13
|
+
`),script:E.length>0?function(){E.forEach(o=>{try{o.call(this,this.__state)}catch(x){T("addComponent script:",x)}})}:null,onMount:d.length>0?y:null,onDestroy:m.length>0?$:null,onUpdate:v.length>0?D:null,onRefresh:f.length>0?F:null,style:{display:"contents"}});r.appendChild(N),r.__combinedComponent=N,r.__childCount=c.length;let H={...s};return r.__state=new Proxy(H,{set:(o,x,A)=>{if(o[x]=A,r.__innerState&&r.__innerState[x]!==A)try{r.__innerState[x]=A}catch(R){T(R)}return!0},get:(o,x)=>o[x]}),setTimeout(()=>{let o=N.firstElementChild;o&&o.__state&&(r.__innerState=o.__state,Object.keys(o.__state).forEach(x=>{x in H||(H[x]=o.__state[x])}))},0),L(`\u2705 addComponents: combined ${c.length} components`),r}static createList(e,t){return n.create("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map(a=>t(a))})}static setAttributeComp(e,t={}){let a=e.__isShadowHost?e:e.__hostElement||e;!a||!(a instanceof HTMLElement)||Object.entries(t).forEach(([r,s])=>a.setAttribute(r,s))}static destroy(e){if(!e)return;e.__isDestroyed=!0;let t=a=>{try{a()}catch(r){T("Zum.destroy cleanup error:",r)}};t(()=>{e.__destroyMany&&e.__destroyMany()}),t(()=>{e.__cleanupResize&&e.__cleanupResize()}),t(()=>{e.__zumAnimObservers&&(e.__zumAnimObservers.forEach(a=>{try{a.disconnect()}catch(r){}}),e.__zumAnimObservers.length=0)}),t(()=>{if(e.__websocket){try{e.__websocket.close(1e3,"destroyed")}catch(a){}e.__websocketDestroyed=!0}}),t(()=>{e.__debouncedSave&&e.__debouncedSave.cancel&&e.__debouncedSave.cancel()}),t(()=>{if(e.__state)try{Object.freeze(e.__state)}catch(a){}e.__stateWatchers&&Object.keys(e.__stateWatchers).forEach(a=>{e.__stateWatchers[a].length=0}),e.__onUpdate=null,e.__onMount=null}),t(()=>{e.__onDestroy&&e.__onDestroy.call(e)}),t(()=>{e.__ZumCss&&e.__ZumCss.parentNode&&e.__ZumCss.parentNode.removeChild(e.__ZumCss)}),t(()=>{let a=e.__hostElement||e;a&&a.parentNode&&a.parentNode.removeChild(a)})}static isMounted(e){return e.__isMounted===!0}static triggerUpdate(e,t={}){e.__onUpdate&&e.__isMounted&&e.__onUpdate.call(e,t)}static triggerRefresh(e){let t=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let a of e.children){if(a.__onRefresh){t=a;break}if(a.__shadowRoot){for(let r of a.__shadowRoot.children)if(r.__onRefresh){t=r;break}if(t!==e)break}}if(t.__onRefresh&&typeof t.__onRefresh=="function")try{t.__onRefresh.call(t)}catch(a){T("\u274C onRefresh failed:",a)}}static async triggerRestore(){n._hasRestored=!1,sessionStorage.removeItem("__Zum_loaded"),sessionStorage.removeItem("__Zum_refreshing"),await new n("div",{html:"<div></div>"})._checkAndRestore()}static getKey(){return localStorage.getItem("app-name")}static popLastComponent(){let e=n.getKey();try{let t=localStorage.getItem(e);if(!t)return null;let a=JSON.parse(t);if(!Array.isArray(a)||a.length===0)return null;let r=a.pop();return a.length===0?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(a)),r}catch(t){return T("\u274C Error popping component:",t),null}}static saveComponent(e,t){let a=n.getKey();if(!a)return;let r=t;if(t.style&&t.style.display==="contents"&&t.children.length>0)for(let l of t.children){if(l.__ZumComponent){r=l;break}if(l.__shadowRoot){for(let d of l.__shadowRoot.children)if(d.__ZumComponent){r=d;break}if(r!==t)break}if(l.__isShadowHost){r=l;break}}if(!r.__ZumComponent&&r.querySelector){let l=r.querySelector("[__ZumComponent]");l!=null&&l.__ZumComponent&&(r=l)}if(!r.__ZumComponent){T("\u274C Cannot save component: no __ZumComponent found");return}let s=r.__ZumComponent.options,i={};r.__state&&Object.keys(r.__state).forEach(l=>{i[l]=r.__state[l]});let c={name:e,tag:r.__ZumComponent.tag,html:s.html,css:s.css,script:s.script?s.script.toString():null,onRefresh:s.onRefresh?s.onRefresh.toString():null,props:s.props||{},state:i};try{let l=JSON.parse(localStorage.getItem(a))||[];l=l.filter(d=>d.name!==e),l.push(c),localStorage.setItem(a,JSON.stringify(l)),L(`\u2705 Saved component: ${e}`)}catch(l){T("\u274C Failed to save component:",l)}}static async restoreComponents(){let e=n.getKey();if(!e)return[];try{let t=JSON.parse(localStorage.getItem(e));if(!t||t.length===0)return L("\u2139\uFE0F No components to restore"),[];L(`\u{1F504} Restoring ${t.length} components...`);let a=[];for(let r=0;r<t.length;r++){let s=t[r],i=null,c=null;if(s.script)try{i=new Function("return "+s.script)(),typeof i!="function"&&(z("\u26A0\uFE0F Restored script is not a function for:",s.name),i=null)}catch(d){T("\u274C Failed to restore script:",d)}if(s.onRefresh)try{c=new Function("return "+s.onRefresh)()}catch(d){T("\u274C Failed to restore onRefresh:",d)}let l=n.create(s.tag,{html:s.html,css:s.css,script:i,onRefresh:c,props:s.props||{},state:s.state||{}});if(i&&typeof i=="function"){let d=l;if(l.style&&l.style.display==="contents"&&l.children.length>0)for(let m of l.children){if(m.__ZumComponent){d=m;break}if(m.__shadowRoot){for(let v of m.__shadowRoot.children)if(v.__ZumComponent){d=v;break}if(d!==l)break}}setTimeout(()=>{try{i.call(d,d.__state)}catch(m){T("\u274C Script execution failed:",s.name,m)}},20)}a.push(l)}return L(`\u2705 Successfully restored ${a.length} components`),a}catch(t){return T("\u274C Failed to restore components:",t),[]}}static wipeConfigs(){let e=n.getKey();try{e&&localStorage.removeItem(e),L("All Zum component configs wiped")}catch(t){T("\u274C Failed to wipe configs:",t)}}static clearComponents(){let e=n.getKey();e&&(localStorage.removeItem(e),L("\u{1F5D1}\uFE0F Component configs cleared"))}async _checkAndRestore(){if(!n._hasRestored)try{let e=n.getKey();if(!e){n._hasRestored=!0;return}let t=localStorage.getItem(e);if(!t){n._hasRestored=!0;return}let a=JSON.parse(t);if(!Array.isArray(a)||a.length===0){n._hasRestored=!0;return}await n.restoreComponents(),n._hasRestored=!0}catch(e){T("\u274C Error during restore:",e),n._hasRestored=!0}}static createSkeleton(e=n.SKELETON_TYPES.DEFAULT,t,a={}){let r={...n.DEFAULT_SKELETON_OPTIONS,...a},s=n._getSkeletonTemplate(e,r.count),i=n.create("div",{className:`skeleton skeleton-${e} ${r.customClass}`.trim(),html:s,attributes:{"data-skeleton":e,role:"status","aria-live":"polite","aria-label":`Loading ${e.replace(/-/g," ")}`},useShadow:!1});return n.mount(i,t),i}static removeSkeleton(e,t={}){var i;let a={...n.REMOVE_SKELETON_OPTIONS,...t},r=n._findSkeletonElement(e,a.selector);if(!r)return(i=a.callback)==null||i.call(a),null;let s=()=>{var l;let c=r.parentNode;c&&c.removeChild(r),(l=a.callback)==null||l.call(a)};if(a.animate&&a.animationType!=="none"){r.style.transition=`all ${a.duration}ms ease-out`,r.style.opacity="0";let c=setTimeout(s,a.duration+a.delay);return{element:r,cancel:()=>{clearTimeout(c),r.style.transition="none",s()}}}return s(),null}static hasSkeleton(e){return!!n._findSkeletonElement(e)}static toggleSkeleton(e,t){let a=n._findSkeletonElement(e);if(!a)return!1;let r=typeof t=="boolean"?t:a.style.display==="none";return a.style.display=r?"":"none",r}static _findSkeletonElement(e,t=".skeleton"){var r;if(!e)return null;if(e.querySelector)return e.querySelector(t);if((r=e.el)!=null&&r.querySelector)return e.el.querySelector(t);let a=n.getShadowRoot(e);return a?a.querySelector(t):null}static _getSkeletonTemplate(e,t){let a={[n.SKELETON_TYPES.DEFAULT]:()=>`
|
|
17
14
|
<div class="skeleton-default" style="padding: 20px;">
|
|
18
15
|
${Array(t).fill(0).map(()=>'<div style="height: 16px; background: #e5e7eb; border-radius: 4px; margin-bottom: 12px; animation: pulse 1.5s infinite;"></div>').join("")}
|
|
19
16
|
</div>
|
|
@@ -155,7 +152,7 @@ ${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string
|
|
|
155
152
|
<div style="height: 120px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
156
153
|
</div>
|
|
157
154
|
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
158
|
-
`};return(a[e]||a[n.SKELETON_TYPES.DEFAULT])(t)}static createSpinner(e="Loading...",t){let a=n.create("div",{html:`<div class="spinner-container"><div class="spinner-circle"></div><div class="spinner-text">${e}</div></div>`,css:".spinner-container{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:20px;color:#555;gap:8px}.spinner-circle{width:40px;height:40px;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite}.spinner-text{font-size:14px;color:#666}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createBorderSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="border-spinner-overlay"><div class="border-spinner-circle"></div><div class="border-spinner-text">${e}</div></div>`,css:".border-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;pointer-events:none;padding:10px}.border-spinner-circle{position:absolute;top:0;left:0;width:calc(100% - 4px);height:calc(100% - 4px);border:2px solid rgba(0,123,255,.2);border-top:2px solid #007bff;border-radius:4px;box-sizing:border-box;animation:border-spin 1.5s linear infinite}.border-spinner-text{margin-top:50px;font-size:14px;color:#007bff;z-index:1001;background:#fff;padding:2px 5px;border-radius:3px}@keyframes border-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createRingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="ring-spinner-overlay"><div class="ring-spinner-circle"></div><div class="ring-spinner-text">${e}</div></div>`,css:".ring-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.ring-spinner-circle{width:50px;height:50px;border:6px solid #e0e0e0;border-top:6px solid #007bff;border-radius:50%;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.ring-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createScalingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="scaling-spinner-overlay"><div class="scaling-spinner-container"><div class="scaling-spinner-circle"></div></div><div class="scaling-spinner-text">${e}</div></div>`,css:".scaling-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.scaling-spinner-container{width:30%;padding-bottom:30%;position:relative;max-width:80px;max-height:80px}.scaling-spinner-circle{position:absolute;top:0;left:0;width:100%;height:100%;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;box-sizing:border-box;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.scaling-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static destroySpinner(e){n.destroy(e)}static getShadowRoot(e){return e.shadowRoot||e.__shadowRoot||null}static isShadowHost(e){return!!(e.shadowRoot||e.__isShadowHost||e.__hostElement)}static getAllShadowHosts(){return j()?Array.from(document.querySelectorAll("*")).filter(e=>n.isShadowHost(e)):[]}static queryFromRoot(e,t){if(!e)return null;if(e instanceof ShadowRoot||e===document)return e.querySelector(t);let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static queryAllFromRoot(e,t){if(!e)return[];if(e instanceof ShadowRoot||e===document)return e.querySelectorAll(t);let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static querySelector(e,t){let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static querySelectorAll(e,t){let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static find(e){if(!j())return null;let t=null;function a(r){if(!t&&(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.DOCUMENT_FRAGMENT_NODE)){if(r.nodeType===Node.ELEMENT_NODE&&r.matches(e)){t=r;return}r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}}return a(document.body),t}static findAll(e){if(!j())return[];let t=[];function a(r){r.nodeType===Node.ELEMENT_NODE&&r.matches(e)&&t.push(r),r.nodeType===Node.ELEMENT_NODE&&r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}return a(document.body),t}static elementExists(e,t){return!!n.querySelector(e,t)}static getComputedStyle(e,t){let a=n.querySelector(e,t);return a?window.getComputedStyle(a):null}static mount(e,t){if(!e||!t)return null;let a=t instanceof HTMLElement?t:document.querySelector(t);if(!a)return null;let r=e instanceof HTMLElement?e:typeof e=="string"?document.querySelector(e):null;return r?(a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50),r):null}static unmount(e,t){if(!e)return null;let a=t?t instanceof HTMLElement?t:document.querySelector(t):e.parentNode;return!a||!a.contains(e)?null:(a.removeChild(e),e)}static append(e,t){return!e||!t?null:((n.getShadowRoot(e)||e).appendChild(t),setTimeout(()=>n._applyContrastToElement(t),50),t)}static addChildren(e,t){if(!e||!(t!=null&&t.length))return;let a=n.getShadowRoot(e)||e;t.forEach(r=>{a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50)})}static replaceChild(e,t,a){if(!e||!a)return null;let r=n.querySelector(e,t);return r?(r.parentNode.replaceChild(a,r),setTimeout(()=>n._applyContrastToElement(a),50),a):null}static clone(e,t=!0){if(!e)return null;let a=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__ZumComponent){a=s;break}if(s.__shadowRoot||s.__isShadowHost){a=s;break}}return(n.getShadowRoot(a)||a).cloneNode(t)}static show(e){e&&((n.getShadowRoot(e)||e).style.display="")}static hide(e){e&&((n.getShadowRoot(e)||e).style.display="none")}static addEventListener(e,t,a,r){let s=n.querySelector(e,t);s&&(s.addEventListener(a,r),(s.__events||(s.__events=[])).push({event:a,handler:r}))}static removeEventListener(e,t,a,r=null){let s=n.querySelector(e,t);s!=null&&s.__events&&(s.__events=s.__events.filter(i=>i.event===a&&(!r||i.handler===r)?(s.removeEventListener(i.event,i.handler),!1):!0))}static clearEventListeners(e,t){let a=n.querySelector(e,t);a!=null&&a.__events&&(a.__events.forEach(({event:r,handler:s})=>a.removeEventListener(r,s)),a.__events=[])}static on(e,t,a,r){n.addEventListener(e,t,a,r)}static updateContent(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateText(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateStyles(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static updateAttributes(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static bulkUpdateContent(e,t){let a=n.getShadowRoot(e);a&&t.forEach(r=>{let s=n.queryFromRoot(a,r.selector);s&&(r.properties&&Object.assign(s,r.properties),r.attributes&&Object.entries(r.attributes).forEach(([i,c])=>s.setAttribute(i,c)),r.styles&&Object.assign(s.style,r.styles),r.html&&(s.innerHTML=r.html),r.text&&(s.textContent=r.text))})}static addElement(e,t,a,r={}){let s=n.getShadowRoot(e);if(!s)return null;let i=t?n.queryFromRoot(s,t):s;if(!i)return null;let c=document.createElement(a);return r.text&&(c.textContent=r.text),r.html&&(c.innerHTML=r.html),r.className&&(c.className=r.className),r.style&&Object.assign(c.style,r.style),r.attributes&&Object.entries(r.attributes).forEach(([l,d])=>c.setAttribute(l,d)),i.appendChild(c),setTimeout(()=>n._applyContrastToElement(c),50),c}static removeElement(e,t){let a=n.querySelector(e,t);a!=null&&a.parentNode&&a.parentNode.removeChild(a)}static toggleClass(e,t,a,r){let s=n.querySelector(e,t);s&&s.classList.toggle(a,r)}static data(e,t,a,r){let s=n.querySelector(e,t);return s?r===void 0?s.dataset[a]||null:(s.dataset[a]=r,null):null}static text(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static html(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static css(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static attr(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static destroyWidget(e){var t,a;(t=e.__swiper)!=null&&t.destroy&&e.__swiper.destroy(),(a=e.__chart)!=null&&a.destroy&&e.__chart.destroy(),e.__quill=e.__swiper=e.__chart=null}static getState(e){let t=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let a of e.children){if(a.__state){t=a;break}if(a.__shadowRoot){for(let r of a.__shadowRoot.children)if(r.__state){t=r;break}if(t!==e)break}}return t!=null&&t.__state?t.__state:(I("No state found on element"),null)}static setState(e,t,a={}){if(!(e!=null&&e.__state))return;let{deep:r=!1}=a;if(!r){Object.assign(e.__state,t);return}let s=(c,l)=>{Object.keys(l).forEach(d=>{let m=l[d];m&&typeof m=="object"&&!Array.isArray(m)?((!c[d]||typeof c[d]!="object")&&(c[d]={}),s(c[d],m)):c[d]=m})},i=JSON.parse(JSON.stringify({...e.__state}));s(i,t),Object.assign(e.__state,i)}static watchState(e,t,a){let r=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__state){r=s;break}if(s.__shadowRoot){for(let i of s.__shadowRoot.children)if(i.__state){r=i;break}if(r!==e)break}}if(!(r!=null&&r.__state)){I("No state found on element");return}r.__stateWatchers||(r.__stateWatchers={}),r.__stateWatchers[t]||(r.__stateWatchers[t]=[]),r.__stateWatchers[t].push(a)}static async fetch(e,t={}){let{url:a=null,method:r="GET",headers:s={},body:i=null,cacheFirst:c=!0,localChanges:l=!0,diff:d=!0,diffIdKey:m="id",autoRefresh:v=0,onDiff:f=null,onSuccess:h=null,onError:_=null,_customFetch:P=null,pagination:b=!1,pageSize:$=10,initialPage:z=1,pageParam:D="page",sizeParam:N="limit",dataPath:H=null}=t;n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache()),n._fetchCache.has(e)||n._fetchCache.set(e,{serverData:null,localChanges:{},lastFetch:null,subscribers:[],previousData:null,pages:new Map,paginationMeta:null});let o=n._fetchCache.get(e),x=p=>H?H.split(".").reduce((y,S)=>y==null?void 0:y[S],p):Array.isArray(p)?p:p.data||p.items||p.posts||p.results||[p],C=p=>p.pagination?p.pagination:p.meta?p.meta:{page:p.page||1,totalPages:p.totalPages||p.total_pages||1,total:p.total||p.totalItems||0,pageSize:p.pageSize||p.per_page||$},R=p=>{if(!a)return null;let y=a.replace(`{${D}}`,p).replace(`{${N}}`,$);if(!a.includes("{")){let S=a.includes("?")?"&":"?";y=`${a}${S}${D}=${p}&${N}=${$}`}return y},g=async p=>{if(b&&o.pages.has(p))return o.paginationMeta.currentPage=p,o.pages.get(p);let y;if(P)y=await P(p);else if(a){let Z=R(p),q={method:r,headers:{"Content-Type":"application/json",...s}};i&&(q.body=JSON.stringify(i));let L=await fetch(Z,q);if(!L.ok)throw new Error(`HTTP ${L.status}`);y=await L.json()}else throw new Error("No url or _customFetch");let S=x(y),k=C(y);return b&&(o.pages.set(p,S),o.paginationMeta={...k,currentPage:p,pageSize:$,hasNext:p<k.totalPages,hasPrev:p>1}),S},u={data:null,loading:!0,error:null,lastFetch:null,hasLocalChanges:Object.keys(o.localChanges).length>0,diff:{summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1},added:[],updated:[],deleted:[],unchanged:[]},pagination:b?{currentPage:z,totalPages:1,totalItems:0,pageSize:$,hasNext:!1,hasPrev:!1,cachedPages:[]}:null,nextPage:b?async()=>{var p;if(u.pagination.hasNext){u.loading=!0,O();try{let y=await g(u.pagination.currentPage+1);u.data=y,u.pagination.currentPage++,u.pagination.hasPrev=!0,u.pagination.hasNext=((p=o.paginationMeta)==null?void 0:p.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(y){u.error=y.message}u.loading=!1,O()}}:null,prevPage:b?async()=>{var p;if(u.pagination.hasPrev){u.loading=!0,O();try{let y=await g(u.pagination.currentPage-1);u.data=y,u.pagination.currentPage--,u.pagination.hasNext=!0,u.pagination.hasPrev=((p=o.paginationMeta)==null?void 0:p.hasPrev)||u.pagination.currentPage>1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(y){u.error=y.message}u.loading=!1,O()}}:null,goToPage:b?async p=>{var y;u.loading=!0,O();try{let S=await g(p);u.data=S,u.pagination.currentPage=p,u.pagination.hasPrev=p>1,u.pagination.hasNext=((y=o.paginationMeta)==null?void 0:y.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(S){u.error=S.message}u.loading=!1,O()}:null,refresh:async()=>{var p;u.loading=!0,u.error=null,O();try{let y=b&&((p=u.pagination)==null?void 0:p.currentPage)||1,S;if(b)o.pages.delete(y),S=await g(y);else{if(P)S=await P();else if(a){let k=await fetch(a,{method:r,headers:s});if(!k.ok)throw new Error(`HTTP ${k.status}`);S=await k.json()}S=x(S)}if(d&&o.previousData){let k=n._differ.diff(o.previousData,S,m);k?(u.diff={summary:k.summary,added:k.added,updated:k.updated,deleted:k.deleted,unchanged:k.unchanged},u.data=k.all,f&&f(u.diff)):u.data=S}else u.data=S;o.previousData=JSON.parse(JSON.stringify(S)),o.serverData=S,o.lastFetch=Date.now(),u.lastFetch=o.lastFetch,l&&o.localChanges&&u.data&&(u.data=u.data.map(k=>{let Z=k[m],q=o.localChanges[Z];return q?{...k,...q,__localEdit:!0}:k})),u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.loading=!1,h&&h(u.data)}catch(y){u.error=y.message,u.loading=!1,_&&_(y)}O()},updateItem:(p,y)=>{if(o.localChanges[p]||(o.localChanges[p]={}),Object.assign(o.localChanges[p],y),u.data){let S=u.data.find(k=>k[m]==p);S&&Object.assign(S,y)}u.hasLocalChanges=!0,O(),n._saveFetchCache()},revertItem:p=>{var S;delete o.localChanges[p];let y=(S=o.serverData)==null?void 0:S.find(k=>k[m]==p);if(y&&u.data){let k=u.data.findIndex(Z=>Z[m]==p);k>=0&&(u.data[k]={...y})}u.hasLocalChanges=Object.keys(o.localChanges).length>0,O(),n._saveFetchCache()},syncToServer:async(p=null)=>{let y=p||a;try{(await fetch(y,{method:"PATCH",headers:{"Content-Type":"application/json",...s},body:JSON.stringify({changes:{...o.localChanges}})})).ok&&(o.localChanges={},u.hasLocalChanges=!1,O(),n._saveFetchCache())}catch(S){E("Sync failed:",S)}},subscribe:p=>(o.subscribers.push(p),()=>{o.subscribers=o.subscribers.filter(y=>y!==p)})};function O(){o.subscribers.forEach(p=>p(u))}if(b){u.loading=!0,O();try{let p=await g(z);u.data=p,u.pagination={...o.paginationMeta,cachedPages:Array.from(o.pages.keys())},u.lastFetch=Date.now()}catch(p){u.error=p.message}u.loading=!1,O()}else c&&o.serverData&&(u.data=o.serverData.map(p=>{var S;let y=(S=o.localChanges)==null?void 0:S[p[m]];return y?{...p,...y,__localEdit:!0}:p}),u.loading=!1,u.lastFetch=o.lastFetch,u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.diff.summary.total=u.data.length),await u.refresh();if(v>0){let p=setInterval(()=>u.refresh(),v);u._autoRefreshInterval=p}return u._saveCache=()=>n._saveFetchCache(),u}static _saveFetchCache(){if(!n._fetchCache)return;let e={};n._fetchCache.forEach((t,a)=>{e[a]={serverData:t.serverData,localChanges:t.localChanges,lastFetch:t.lastFetch,previousData:t.previousData}});try{localStorage.setItem("__Zum_fetch_cache",JSON.stringify(e))}catch(t){}}static _loadFetchCache(){try{let e=localStorage.getItem("__Zum_fetch_cache");if(e){let t=JSON.parse(e);Object.entries(t).forEach(([a,r])=>n._fetchCache.set(a,r))}}catch(e){}}static _initFetchCache(){n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache())}static clearFetchCache(){localStorage.removeItem("__Zum_fetch_cache"),n._fetchCache&&n._fetchCache.clear(),M("\u{1F5D1}\uFE0F Fetch cache cleared")}static rememberScroll(e,t={}){let{scrollBehavior:a="smooth",scope:r="global",saveDelay:s=200,highlightTarget:i=!0,offsetTop:c=0}=t,l=`${r}::${e}`,d,m=0,v=null,f=n._scrollMemory.get(l);return f&&(m=f.position||0,v=f.elementId||null),{save:function(h=null){m=window.scrollY||window.pageYOffset,h&&(v=h),n._scrollMemory.set(l,{position:m,elementId:v,timestamp:Date.now()})},restore:function(){let h=n._scrollMemory.get(l);if(!h)return!1;let{position:_,elementId:P}=h;if(P){let b=document.getElementById(P);if(b){let $=b.getBoundingClientRect(),z=window.pageYOffset||document.documentElement.scrollTop,D=$.top+z,N=window.innerHeight,H=D-N/2+$.height/2+c;if(window.scrollTo({top:Math.max(0,H),behavior:a}),i){let o=b.style.transition,x=b.style.boxShadow,C=b.style.borderColor;b.style.transition="box-shadow 0.3s, border-color 0.3s",b.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",b.style.borderColor="#3b82f6",setTimeout(()=>{b.style.transition=o,b.style.boxShadow=x,b.style.borderColor=C},2e3)}return!0}}return _>0?(window.scrollTo({top:_,behavior:a}),!0):!1},startTracking:function(h=document){let _=()=>{clearTimeout(d),d=setTimeout(()=>this.save(),s)};window.addEventListener("scroll",_,{passive:!0});let P=$=>{let z=$.target.closest("[id]");z&&z.id&&this.save(z.id)};h.addEventListener("click",P);let b=()=>this.save();return window.addEventListener("beforeunload",b),()=>{window.removeEventListener("scroll",_),h.removeEventListener("click",P),window.removeEventListener("beforeunload",b)}},clear:function(){n._scrollMemory.delete(l),m=0,v=null},getData:function(){return n._scrollMemory.get(l)||null}}}static saveScrollToState(e,t=null){let a=n.getState(e);a&&(a.__scrollPosition=window.scrollY||window.pageYOffset,t&&(a.__lastFocusedElement=t))}static restoreScrollFromState(e,t={}){let a=n.getState(e);if(!a)return!1;let{highlightTarget:r=!0,scrollBehavior:s="smooth",offsetTop:i=0}=t,c=a.__scrollPosition,l=a.__lastFocusedElement;if(l){let d=n.querySelector(e,`#${l}`)||document.getElementById(l);if(d){let m=d.getBoundingClientRect(),v=window.pageYOffset||document.documentElement.scrollTop,f=m.top+v,h=window.innerHeight,_=f-h/2+m.height/2+i;return window.scrollTo({top:Math.max(0,_),behavior:s}),r&&(d.style.transition="box-shadow 0.3s, border-color 0.3s",d.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",d.style.borderColor="#3b82f6",setTimeout(()=>{d.style.boxShadow="",d.style.borderColor=""},2e3)),!0}}return c>0?(window.scrollTo({top:c,behavior:s}),!0):!1}static initTheme(e="light"){return n._themeStylesInjected||n._injectThemeStyles(),n.THEMES[e]?(n._currentTheme=e,n.applyTheme(e),!0):(I(`Theme "${e}" not found. Using light theme.`),n._currentTheme="light",n.applyTheme("light"),!1)}static restoreThemePreference(){let e=localStorage.getItem(n.themeSettings.persistKey);if(e&&n.THEMES[e])return n.applyTheme(e,{manual:!1}),!0;if(n.themeSettings.respectSystemPreference){let t=n.getSystemThemePreference();return n.applyTheme(t,{manual:!1}),!0}return!1}static getSystemThemePreference(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static initThemeWithSystemPreference(){let e=localStorage.getItem(n.themeSettings.persistKey),t=localStorage.getItem(n.themeSettings.systemPreferenceKey);if(e&&t&&n.THEMES[e]){n.applyTheme(e,{manual:!0}),M(`\u2705 Theme initialized with manual preference: ${e}`);return}let a=n.getSystemThemePreference();n.applyTheme(a,{manual:!1});let r=window.matchMedia("(prefers-color-scheme: dark)"),s=i=>{if(!localStorage.getItem(n.themeSettings.systemPreferenceKey)){let l=i.matches?"dark":"light";document.querySelectorAll("*").forEach(d=>{d._zumContrastApplied=!1}),n.applyTheme(l,{manual:!1,smooth:!0,duration:400}),setTimeout(()=>n.refreshContrast(),500),M(`\u{1F504} Auto-switched to ${l} theme (system preference)`)}};r.addEventListener?r.addEventListener("change",s):r.addListener&&r.addListener(s),M(`\u2705 Theme initialized with system preference: ${a}`)}static isUsingSystemTheme(){return!localStorage.getItem(n.themeSettings.systemPreferenceKey)}static resetToSystemTheme(){localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.getSystemThemePreference();n.applyTheme(e,{manual:!1}),M(`\u{1F504} Reset to system theme: ${e}`)}static applyTheme(e,t={}){if(!j())return!1;let{smooth:a=!0,duration:r=400,ease:s="ease-in-out",updateContrast:i=!0,manual:c=!0}=t,l=n.THEMES[e];if(!l)return I(`Theme "${e}" not found.`),!1;n._currentTheme=e,c?localStorage.setItem(n.themeSettings.systemPreferenceKey,"true"):localStorage.removeItem(n.themeSettings.systemPreferenceKey);let d=document.documentElement,m=l.colors;document.querySelectorAll("style[data-Zum-themes], style[data-Zum-theme]").forEach(f=>f.remove()),n._injectThemeStyles(),Object.entries(m).forEach(([f,h])=>d.style.setProperty(`--Zum-${f}`,h)),Object.entries(l.typography).forEach(([f,h])=>d.style.setProperty(`--Zum-font-${f}`,h)),Object.entries(l.spacing).forEach(([f,h])=>d.style.setProperty(`--Zum-spacing-${f}`,h)),Object.entries(l.borderRadius).forEach(([f,h])=>d.style.setProperty(`--Zum-radius-${f}`,h)),Object.entries(l.shadows).forEach(([f,h])=>d.style.setProperty(`--Zum-shadow-${f}`,h)),Object.entries(l.transitions).forEach(([f,h])=>d.style.setProperty(`--Zum-transition-${f}`,h)),document.body.style.backgroundColor=m.background,document.body.style.color=m.text,document.body.style.fontFamily=l.typography.fontFamily,document.body.style.fontSize=l.typography.fontSize,document.body.style.lineHeight=l.typography.lineHeight,document.documentElement.style.backgroundColor=m.background;let v=document.querySelector('meta[name="theme-color"]');return v&&(v.content=m.background),document.documentElement.setAttribute("data-theme",e),document.body.setAttribute("data-theme",e),n.themeSettings.persist&&localStorage.setItem(n.themeSettings.persistKey,e),n._notifyThemeObservers(e),i&&n.themeSettings.autoContrast&&setTimeout(()=>{document.querySelectorAll("*").forEach(f=>{f._zumContrastApplied=!1}),n._applyContrastToAll()},a?r+50:50),M(`\u2705 Theme applied: ${e} (${l.name})`),!0}static toggleTheme(){return n.applyTheme(n._currentTheme==="light"?"dark":"light")}static applyThemeToElement(e,t=null){if(!e)return!1;let a=t?n.THEMES[t]:n.getTheme();if(!a)return!1;let r=e._isShadowHost?n.getShadowRoot(e):e;return r?(Object.entries(a.colors).forEach(([s,i])=>r.style.setProperty(`--Zum-${s}`,i)),r.style.backgroundColor=a.colors.background,r.style.color=a.colors.text,!0):!1}static applyThemeToCustomElement(e,t){let a=n.getTheme(t);if(!a||!e)return!1;let r=n.getThemeCSSProperties(t);return e.style.cssText+=r,e.setAttribute("data-theme",t),e.style.backgroundColor=a.colors.background,e.style.color=a.colors.text,!0}static applyThemeToElementDirect(e,t,a){if(e&&n.isShadowHost(e)){let r=n.getShadowRoot(e);if(!r)return;r.querySelectorAll("style[data-Zum-theme]").forEach(i=>i.remove());let s=document.createElement("style");s.setAttribute("data-Zum-theme","true"),s.textContent=`:host { background: ${t}; color: ${a}; }`,r.appendChild(s)}}static getCurrentTheme(){return n._currentTheme}static getTheme(e=null){return n.THEMES[e||n._currentTheme]||null}static getThemeSafe(e){return n.THEMES[e]||n.THEMES[n.themeSettings.defaultTheme]||n.THEMES.light}static getThemeName(e){let t=n.getTheme(e);return t?t.name:e}static getThemeNames(){let e={};return Object.entries(n.THEMES).forEach(([t,a])=>{e[t]=a.name||t}),e}static getThemeColors(e=null){let t=n.getTheme(e);return t?t.colors:null}static getThemeColor(e,t=null){let a=t?n.THEMES[t]:n.getTheme();return a&&a.colors[e]||null}static getAvailableThemes(){return Object.keys(n.THEMES)}static themeExists(e){return!!n.THEMES[e]}static getThemeSettings(){return{...n.themeSettings}}static updateThemeSettings(e){return Object.assign(n.themeSettings,e),n.themeSettings}static setDefaultTheme(e){return n.themeExists(e)?(n.themeSettings.defaultTheme=e,!0):!1}static resetToDefaultTheme(){return n.applyTheme(n.themeSettings.defaultTheme,{manual:!1})}static setThemePersistence(e){n.themeSettings.persist=e,e||(localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey))}static isDarkTheme(){return n._currentTheme==="dark"}static isLightTheme(){return n._currentTheme==="light"}static getThemeMode(){return n.isUsingSystemTheme()?"system":"manual"}static addTheme(e,t){n.THEMES[e]&&I(`Theme "${e}" already exists. Overwriting.`);let r=["colors","typography","spacing","borderRadius","shadows","transitions"].filter(s=>!t[s]);return r.length>0?(E(`Theme missing required keys: ${r.join(", ")}`),!1):(n.THEMES[e]={id:e,name:t.name||e,...t},!0)}static defineTheme(e,t){if(!t||!t.colors)return E("Zum.defineTheme: theme must include a colors object."),!1;let a=n.THEMES.light;return n.THEMES[e]={id:e,name:t.name||e,colors:{...a.colors,...t.colors},typography:{...a.typography,...t.typography||{}},spacing:{...a.spacing,...t.spacing||{}},borderRadius:{...a.borderRadius,...t.borderRadius||{}},shadows:{...a.shadows,...t.shadows||{}},transitions:{...a.transitions,...t.transitions||{}}},!0}static removeTheme(e){return e==="light"||e==="dark"?(I("Cannot remove default themes (light/dark)"),!1):n.THEMES[e]?(delete n.THEMES[e],!0):!1}static duplicateTheme(e,t){let a=n.getTheme(e);return a?n.addTheme(t,{...a,id:t,name:`${a.name} (Copy)`}):!1}static exportTheme(e){let t=n.getTheme(e);return t?JSON.stringify(t,null,2):null}static importTheme(e){try{let t=JSON.parse(e);if(!t.id||!t.colors||!t.typography)throw new Error("Invalid theme format");return n.addTheme(t.id,t),!0}catch(t){return E("Failed to import theme:",t),!1}}static observeTheme(e){return typeof e!="function"?()=>{}:(n._themeObservers.push(e),e(n._currentTheme),()=>{n._themeObservers=n._themeObservers.filter(t=>t!==e)})}static onThemeChange(e){return n.observeTheme(e)}static _notifyThemeObservers(e){n._themeObservers.forEach(t=>{try{t(e)}catch(a){E("Theme observer error:",a)}})}static getContrastRatio(e,t){let a=n._calculateLuminance(e),r=n._calculateLuminance(t),s=Math.max(a,r),i=Math.min(a,r);return(s+.05)/(i+.05)}static checkThemeAccessibility(e){let t=n.getTheme(e);if(!t)return null;let a={theme:e,name:t.name,passed:!0,checks:[]},r=n.getContrastRatio(t.colors.text,t.colors.background);a.checks.push({name:"Text contrast",ratio:r.toFixed(2),passed:r>=4.5,wcag:r>=4.5?"AA":"Fail"});let s=n.getContrastRatio(t.colors.textSecondary,t.colors.background);a.checks.push({name:"Secondary text",ratio:s.toFixed(2),passed:s>=3,wcag:s>=3?"AA":"Fail"});let i=n.getContrastRatio(t.colors.primary,t.colors.background);return a.checks.push({name:"Interactive",ratio:i.toFixed(2),passed:i>=3,wcag:i>=3?"AA":"Fail"}),a.passed=a.checks.every(c=>c.passed),a}static getAccessibleThemes(){return Object.keys(n.THEMES).filter(e=>{let t=n.checkThemeAccessibility(e);return t&&t.passed})}static createThemeToggle(e={}){let{lightIcon:t="\u2600\uFE0F",darkIcon:a="\u{1F319}",systemIcon:r="\u{1F313}",className:s="theme-toggle",position:i="fixed",top:c="20px",right:l="20px",smooth:d=!0,duration:m=400}=e,v=document.createElement("button");v.className=s;let f=0,h=b=>{!localStorage.getItem(n.themeSettings.systemPreferenceKey)?(v.textContent=r,v.title="System theme",f=0):b==="dark"?(v.textContent=a,v.title="Dark theme",f=2):(v.textContent=t,v.title="Light theme",f=1),v.setAttribute("data-theme",b)},_=document.createElement("style");_.textContent=`
|
|
155
|
+
`};return(a[e]||a[n.SKELETON_TYPES.DEFAULT])(t)}static createSpinner(e="Loading...",t){let a=n.create("div",{html:`<div class="spinner-container"><div class="spinner-circle"></div><div class="spinner-text">${e}</div></div>`,css:".spinner-container{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:20px;color:#555;gap:8px}.spinner-circle{width:40px;height:40px;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite}.spinner-text{font-size:14px;color:#666}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createBorderSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="border-spinner-overlay"><div class="border-spinner-circle"></div><div class="border-spinner-text">${e}</div></div>`,css:".border-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;pointer-events:none;padding:10px}.border-spinner-circle{position:absolute;top:0;left:0;width:calc(100% - 4px);height:calc(100% - 4px);border:2px solid rgba(0,123,255,.2);border-top:2px solid #007bff;border-radius:4px;box-sizing:border-box;animation:border-spin 1.5s linear infinite}.border-spinner-text{margin-top:50px;font-size:14px;color:#007bff;z-index:1001;background:#fff;padding:2px 5px;border-radius:3px}@keyframes border-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createRingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="ring-spinner-overlay"><div class="ring-spinner-circle"></div><div class="ring-spinner-text">${e}</div></div>`,css:".ring-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.ring-spinner-circle{width:50px;height:50px;border:6px solid #e0e0e0;border-top:6px solid #007bff;border-radius:50%;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.ring-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createScalingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="scaling-spinner-overlay"><div class="scaling-spinner-container"><div class="scaling-spinner-circle"></div></div><div class="scaling-spinner-text">${e}</div></div>`,css:".scaling-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.scaling-spinner-container{width:30%;padding-bottom:30%;position:relative;max-width:80px;max-height:80px}.scaling-spinner-circle{position:absolute;top:0;left:0;width:100%;height:100%;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;box-sizing:border-box;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.scaling-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static destroySpinner(e){n.destroy(e)}static getShadowRoot(e){return e.shadowRoot||e.__shadowRoot||null}static isShadowHost(e){return!!(e.shadowRoot||e.__isShadowHost||e.__hostElement)}static getAllShadowHosts(){return j()?Array.from(document.querySelectorAll("*")).filter(e=>n.isShadowHost(e)):[]}static queryFromRoot(e,t){if(!e)return null;if(e instanceof ShadowRoot||e===document)return e.querySelector(t);let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static queryAllFromRoot(e,t){if(!e)return[];if(e instanceof ShadowRoot||e===document)return e.querySelectorAll(t);let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static querySelector(e,t){let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static querySelectorAll(e,t){let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static find(e){if(!j())return null;let t=null;function a(r){if(!t&&(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.DOCUMENT_FRAGMENT_NODE)){if(r.nodeType===Node.ELEMENT_NODE&&r.matches(e)){t=r;return}r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}}return a(document.body),t}static findAll(e){if(!j())return[];let t=[];function a(r){r.nodeType===Node.ELEMENT_NODE&&r.matches(e)&&t.push(r),r.nodeType===Node.ELEMENT_NODE&&r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}return a(document.body),t}static elementExists(e,t){return!!n.querySelector(e,t)}static getComputedStyle(e,t){let a=n.querySelector(e,t);return a?window.getComputedStyle(a):null}static mount(e,t){if(!e||!t)return null;let a=t instanceof HTMLElement?t:document.querySelector(t);if(!a)return null;let r=e instanceof HTMLElement?e:typeof e=="string"?document.querySelector(e):null;return r?(a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50),r):null}static unmount(e,t){if(!e)return null;let a=t?t instanceof HTMLElement?t:document.querySelector(t):e.parentNode;return!a||!a.contains(e)?null:(a.removeChild(e),e)}static append(e,t){return!e||!t?null:((n.getShadowRoot(e)||e).appendChild(t),setTimeout(()=>n._applyContrastToElement(t),50),t)}static addChildren(e,t){if(!e||!(t!=null&&t.length))return;let a=n.getShadowRoot(e)||e;t.forEach(r=>{a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50)})}static replaceChild(e,t,a){if(!e||!a)return null;let r=n.querySelector(e,t);return r?(r.parentNode.replaceChild(a,r),setTimeout(()=>n._applyContrastToElement(a),50),a):null}static clone(e,t=!0){if(!e)return null;let a=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__ZumComponent){a=s;break}if(s.__shadowRoot||s.__isShadowHost){a=s;break}}return(n.getShadowRoot(a)||a).cloneNode(t)}static show(e){e&&((n.getShadowRoot(e)||e).style.display="")}static hide(e){e&&((n.getShadowRoot(e)||e).style.display="none")}static addEventListener(e,t,a,r){let s=n.querySelector(e,t);s&&(s.addEventListener(a,r),(s.__events||(s.__events=[])).push({event:a,handler:r}))}static removeEventListener(e,t,a,r=null){let s=n.querySelector(e,t);s!=null&&s.__events&&(s.__events=s.__events.filter(i=>i.event===a&&(!r||i.handler===r)?(s.removeEventListener(i.event,i.handler),!1):!0))}static clearEventListeners(e,t){let a=n.querySelector(e,t);a!=null&&a.__events&&(a.__events.forEach(({event:r,handler:s})=>a.removeEventListener(r,s)),a.__events=[])}static on(e,t,a,r){n.addEventListener(e,t,a,r)}static updateContent(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateText(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateStyles(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static updateAttributes(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static bulkUpdateContent(e,t){let a=n.getShadowRoot(e);a&&t.forEach(r=>{let s=n.queryFromRoot(a,r.selector);s&&(r.properties&&Object.assign(s,r.properties),r.attributes&&Object.entries(r.attributes).forEach(([i,c])=>s.setAttribute(i,c)),r.styles&&Object.assign(s.style,r.styles),r.html&&(s.innerHTML=r.html),r.text&&(s.textContent=r.text))})}static addElement(e,t,a,r={}){let s=n.getShadowRoot(e);if(!s)return null;let i=t?n.queryFromRoot(s,t):s;if(!i)return null;let c=document.createElement(a);return r.text&&(c.textContent=r.text),r.html&&(c.innerHTML=r.html),r.className&&(c.className=r.className),r.style&&Object.assign(c.style,r.style),r.attributes&&Object.entries(r.attributes).forEach(([l,d])=>c.setAttribute(l,d)),i.appendChild(c),setTimeout(()=>n._applyContrastToElement(c),50),c}static removeElement(e,t){let a=n.querySelector(e,t);a!=null&&a.parentNode&&a.parentNode.removeChild(a)}static toggleClass(e,t,a,r){let s=n.querySelector(e,t);s&&s.classList.toggle(a,r)}static data(e,t,a,r){let s=n.querySelector(e,t);return s?r===void 0?s.dataset[a]||null:(s.dataset[a]=r,null):null}static text(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static html(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static css(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static attr(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static destroyWidget(e){var t,a;(t=e.__swiper)!=null&&t.destroy&&e.__swiper.destroy(),(a=e.__chart)!=null&&a.destroy&&e.__chart.destroy(),e.__quill=e.__swiper=e.__chart=null}static getState(e){let t=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let a of e.children){if(a.__state){t=a;break}if(a.__shadowRoot){for(let r of a.__shadowRoot.children)if(r.__state){t=r;break}if(t!==e)break}}return t!=null&&t.__state?t.__state:(z("No state found on element"),null)}static setState(e,t,a={}){if(!(e!=null&&e.__state))return;let{deep:r=!1}=a;if(!r){Object.assign(e.__state,t);return}let s=(c,l)=>{Object.keys(l).forEach(d=>{let m=l[d];m&&typeof m=="object"&&!Array.isArray(m)?((!c[d]||typeof c[d]!="object")&&(c[d]={}),s(c[d],m)):c[d]=m})},i=JSON.parse(JSON.stringify({...e.__state}));s(i,t),Object.assign(e.__state,i)}static watchState(e,t,a){let r=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__state){r=s;break}if(s.__shadowRoot){for(let i of s.__shadowRoot.children)if(i.__state){r=i;break}if(r!==e)break}}if(!(r!=null&&r.__state)){z("No state found on element");return}r.__stateWatchers||(r.__stateWatchers={}),r.__stateWatchers[t]||(r.__stateWatchers[t]=[]),r.__stateWatchers[t].push(a)}static async fetch(e,t={}){let{url:a=null,method:r="GET",headers:s={},body:i=null,cacheFirst:c=!0,localChanges:l=!0,diff:d=!0,diffIdKey:m="id",autoRefresh:v=0,onDiff:f=null,onSuccess:h=null,onError:E=null,_customFetch:k=null,pagination:y=!1,pageSize:$=10,initialPage:D=1,pageParam:F="page",sizeParam:N="limit",dataPath:H=null}=t;n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache()),n._fetchCache.has(e)||n._fetchCache.set(e,{serverData:null,localChanges:{},lastFetch:null,subscribers:[],previousData:null,pages:new Map,paginationMeta:null});let o=n._fetchCache.get(e),x=p=>H?H.split(".").reduce((b,S)=>b==null?void 0:b[S],p):Array.isArray(p)?p:p.data||p.items||p.posts||p.results||[p],A=p=>p.pagination?p.pagination:p.meta?p.meta:{page:p.page||1,totalPages:p.totalPages||p.total_pages||1,total:p.total||p.totalItems||0,pageSize:p.pageSize||p.per_page||$},R=p=>{if(!a)return null;let b=a.replace(`{${F}}`,p).replace(`{${N}}`,$);if(!a.includes("{")){let S=a.includes("?")?"&":"?";b=`${a}${S}${F}=${p}&${N}=${$}`}return b},g=async p=>{if(y&&o.pages.has(p))return o.paginationMeta.currentPage=p,o.pages.get(p);let b;if(k)b=await k(p);else if(a){let Z=R(p),q={method:r,headers:{"Content-Type":"application/json",...s}};i&&(q.body=JSON.stringify(i));let P=await fetch(Z,q);if(!P.ok)throw new Error(`HTTP ${P.status}`);b=await P.json()}else throw new Error("No url or _customFetch");let S=x(b),C=A(b);return y&&(o.pages.set(p,S),o.paginationMeta={...C,currentPage:p,pageSize:$,hasNext:p<C.totalPages,hasPrev:p>1}),S},u={data:null,loading:!0,error:null,lastFetch:null,hasLocalChanges:Object.keys(o.localChanges).length>0,diff:{summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1},added:[],updated:[],deleted:[],unchanged:[]},pagination:y?{currentPage:D,totalPages:1,totalItems:0,pageSize:$,hasNext:!1,hasPrev:!1,cachedPages:[]}:null,nextPage:y?async()=>{var p;if(u.pagination.hasNext){u.loading=!0,M();try{let b=await g(u.pagination.currentPage+1);u.data=b,u.pagination.currentPage++,u.pagination.hasPrev=!0,u.pagination.hasNext=((p=o.paginationMeta)==null?void 0:p.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(b){u.error=b.message}u.loading=!1,M()}}:null,prevPage:y?async()=>{var p;if(u.pagination.hasPrev){u.loading=!0,M();try{let b=await g(u.pagination.currentPage-1);u.data=b,u.pagination.currentPage--,u.pagination.hasNext=!0,u.pagination.hasPrev=((p=o.paginationMeta)==null?void 0:p.hasPrev)||u.pagination.currentPage>1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(b){u.error=b.message}u.loading=!1,M()}}:null,goToPage:y?async p=>{var b;u.loading=!0,M();try{let S=await g(p);u.data=S,u.pagination.currentPage=p,u.pagination.hasPrev=p>1,u.pagination.hasNext=((b=o.paginationMeta)==null?void 0:b.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(S){u.error=S.message}u.loading=!1,M()}:null,refresh:async()=>{var p;u.loading=!0,u.error=null,M();try{let b=y&&((p=u.pagination)==null?void 0:p.currentPage)||1,S;if(y)o.pages.delete(b),S=await g(b);else{if(k)S=await k();else if(a){let C=await fetch(a,{method:r,headers:s});if(!C.ok)throw new Error(`HTTP ${C.status}`);S=await C.json()}S=x(S)}if(d&&o.previousData){let C=n._differ.diff(o.previousData,S,m);C?(u.diff={summary:C.summary,added:C.added,updated:C.updated,deleted:C.deleted,unchanged:C.unchanged},u.data=C.all,f&&f(u.diff)):u.data=S}else u.data=S;o.previousData=JSON.parse(JSON.stringify(S)),o.serverData=S,o.lastFetch=Date.now(),u.lastFetch=o.lastFetch,l&&o.localChanges&&u.data&&(u.data=u.data.map(C=>{let Z=C[m],q=o.localChanges[Z];return q?{...C,...q,__localEdit:!0}:C})),u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.loading=!1,h&&h(u.data)}catch(b){u.error=b.message,u.loading=!1,E&&E(b)}M()},updateItem:(p,b)=>{if(o.localChanges[p]||(o.localChanges[p]={}),Object.assign(o.localChanges[p],b),u.data){let S=u.data.find(C=>C[m]==p);S&&Object.assign(S,b)}u.hasLocalChanges=!0,M(),n._saveFetchCache()},revertItem:p=>{var S;delete o.localChanges[p];let b=(S=o.serverData)==null?void 0:S.find(C=>C[m]==p);if(b&&u.data){let C=u.data.findIndex(Z=>Z[m]==p);C>=0&&(u.data[C]={...b})}u.hasLocalChanges=Object.keys(o.localChanges).length>0,M(),n._saveFetchCache()},syncToServer:async(p=null)=>{let b=p||a;try{(await fetch(b,{method:"PATCH",headers:{"Content-Type":"application/json",...s},body:JSON.stringify({changes:{...o.localChanges}})})).ok&&(o.localChanges={},u.hasLocalChanges=!1,M(),n._saveFetchCache())}catch(S){T("Sync failed:",S)}},subscribe:p=>(o.subscribers.push(p),()=>{o.subscribers=o.subscribers.filter(b=>b!==p)})};function M(){o.subscribers.forEach(p=>p(u))}if(y){u.loading=!0,M();try{let p=await g(D);u.data=p,u.pagination={...o.paginationMeta,cachedPages:Array.from(o.pages.keys())},u.lastFetch=Date.now()}catch(p){u.error=p.message}u.loading=!1,M()}else c&&o.serverData&&(u.data=o.serverData.map(p=>{var S;let b=(S=o.localChanges)==null?void 0:S[p[m]];return b?{...p,...b,__localEdit:!0}:p}),u.loading=!1,u.lastFetch=o.lastFetch,u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.diff.summary.total=u.data.length),await u.refresh();if(v>0){let p=setInterval(()=>u.refresh(),v);u._autoRefreshInterval=p}return u._saveCache=()=>n._saveFetchCache(),u}static _saveFetchCache(){if(!n._fetchCache)return;let e={};n._fetchCache.forEach((t,a)=>{e[a]={serverData:t.serverData,localChanges:t.localChanges,lastFetch:t.lastFetch,previousData:t.previousData}});try{localStorage.setItem("__Zum_fetch_cache",JSON.stringify(e))}catch(t){}}static _loadFetchCache(){try{let e=localStorage.getItem("__Zum_fetch_cache");if(e){let t=JSON.parse(e);Object.entries(t).forEach(([a,r])=>n._fetchCache.set(a,r))}}catch(e){}}static _initFetchCache(){n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache())}static clearFetchCache(){localStorage.removeItem("__Zum_fetch_cache"),n._fetchCache&&n._fetchCache.clear(),L("\u{1F5D1}\uFE0F Fetch cache cleared")}static rememberScroll(e,t={}){let{scrollBehavior:a="smooth",scope:r="global",saveDelay:s=200,highlightTarget:i=!0,offsetTop:c=0}=t,l=`${r}::${e}`,d,m=0,v=null,f=n._scrollMemory.get(l);return f&&(m=f.position||0,v=f.elementId||null),{save:function(h=null){m=window.scrollY||window.pageYOffset,h&&(v=h),n._scrollMemory.set(l,{position:m,elementId:v,timestamp:Date.now()})},restore:function(){let h=n._scrollMemory.get(l);if(!h)return!1;let{position:E,elementId:k}=h;if(k){let y=document.getElementById(k);if(y){let $=y.getBoundingClientRect(),D=window.pageYOffset||document.documentElement.scrollTop,F=$.top+D,N=window.innerHeight,H=F-N/2+$.height/2+c;if(window.scrollTo({top:Math.max(0,H),behavior:a}),i){let o=y.style.transition,x=y.style.boxShadow,A=y.style.borderColor;y.style.transition="box-shadow 0.3s, border-color 0.3s",y.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",y.style.borderColor="#3b82f6",setTimeout(()=>{y.style.transition=o,y.style.boxShadow=x,y.style.borderColor=A},2e3)}return!0}}return E>0?(window.scrollTo({top:E,behavior:a}),!0):!1},startTracking:function(h=document){let E=()=>{clearTimeout(d),d=setTimeout(()=>this.save(),s)};window.addEventListener("scroll",E,{passive:!0});let k=$=>{let D=$.target.closest("[id]");D&&D.id&&this.save(D.id)};h.addEventListener("click",k);let y=()=>this.save();return window.addEventListener("beforeunload",y),()=>{window.removeEventListener("scroll",E),h.removeEventListener("click",k),window.removeEventListener("beforeunload",y)}},clear:function(){n._scrollMemory.delete(l),m=0,v=null},getData:function(){return n._scrollMemory.get(l)||null}}}static saveScrollToState(e,t=null){let a=n.getState(e);a&&(a.__scrollPosition=window.scrollY||window.pageYOffset,t&&(a.__lastFocusedElement=t))}static restoreScrollFromState(e,t={}){let a=n.getState(e);if(!a)return!1;let{highlightTarget:r=!0,scrollBehavior:s="smooth",offsetTop:i=0}=t,c=a.__scrollPosition,l=a.__lastFocusedElement;if(l){let d=n.querySelector(e,`#${l}`)||document.getElementById(l);if(d){let m=d.getBoundingClientRect(),v=window.pageYOffset||document.documentElement.scrollTop,f=m.top+v,h=window.innerHeight,E=f-h/2+m.height/2+i;return window.scrollTo({top:Math.max(0,E),behavior:s}),r&&(d.style.transition="box-shadow 0.3s, border-color 0.3s",d.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",d.style.borderColor="#3b82f6",setTimeout(()=>{d.style.boxShadow="",d.style.borderColor=""},2e3)),!0}}return c>0?(window.scrollTo({top:c,behavior:s}),!0):!1}static initTheme(e="light"){return n._themeStylesInjected||n._injectThemeStyles(),n.THEMES[e]?(n._currentTheme=e,n.applyTheme(e),!0):(z(`Theme "${e}" not found. Using light theme.`),n._currentTheme="light",n.applyTheme("light"),!1)}static restoreThemePreference(){let e=localStorage.getItem(n.themeSettings.persistKey);if(e&&n.THEMES[e])return n.applyTheme(e,{manual:!1}),!0;if(n.themeSettings.respectSystemPreference){let t=n.getSystemThemePreference();return n.applyTheme(t,{manual:!1}),!0}return!1}static getSystemThemePreference(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static initThemeWithSystemPreference(){let e=localStorage.getItem(n.themeSettings.persistKey),t=localStorage.getItem(n.themeSettings.systemPreferenceKey);if(e&&t&&n.THEMES[e]){n.applyTheme(e,{manual:!0}),L(`\u2705 Theme initialized with manual preference: ${e}`);return}let a=n.getSystemThemePreference();n.applyTheme(a,{manual:!1});let r=window.matchMedia("(prefers-color-scheme: dark)"),s=i=>{if(!localStorage.getItem(n.themeSettings.systemPreferenceKey)){let l=i.matches?"dark":"light";n.applyTheme(l,{manual:!1,smooth:!0,duration:400}),setTimeout(()=>n.refreshContrast(),500),L(`\u{1F504} Auto-switched to ${l} theme (system preference)`)}};r.addEventListener?r.addEventListener("change",s):r.addListener&&r.addListener(s),L(`\u2705 Theme initialized with system preference: ${a}`)}static isUsingSystemTheme(){return!localStorage.getItem(n.themeSettings.systemPreferenceKey)}static resetToSystemTheme(){localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.getSystemThemePreference();n.applyTheme(e,{manual:!1}),L(`\u{1F504} Reset to system theme: ${e}`)}static applyTheme(e,t={}){if(!j())return!1;let{smooth:a=!0,duration:r=400,ease:s="ease-in-out",updateContrast:i=!0,manual:c=!0}=t,l=n.THEMES[e];if(!l)return z(`Theme "${e}" not found.`),!1;n._currentTheme=e,c?localStorage.setItem(n.themeSettings.systemPreferenceKey,"true"):localStorage.removeItem(n.themeSettings.systemPreferenceKey);let d=document.documentElement,m=l.colors;document.querySelectorAll("style[data-Zum-themes], style[data-Zum-theme]").forEach(f=>f.remove()),n._injectThemeStyles(),Object.entries(m).forEach(([f,h])=>d.style.setProperty(`--Zum-${f}`,h)),Object.entries(l.typography).forEach(([f,h])=>d.style.setProperty(`--Zum-font-${f}`,h)),Object.entries(l.spacing).forEach(([f,h])=>d.style.setProperty(`--Zum-spacing-${f}`,h)),Object.entries(l.borderRadius).forEach(([f,h])=>d.style.setProperty(`--Zum-radius-${f}`,h)),Object.entries(l.shadows).forEach(([f,h])=>d.style.setProperty(`--Zum-shadow-${f}`,h)),Object.entries(l.transitions).forEach(([f,h])=>d.style.setProperty(`--Zum-transition-${f}`,h)),document.body.style.backgroundColor=m.background,document.body.style.color=m.text,document.body.style.fontFamily=l.typography.fontFamily,document.body.style.fontSize=l.typography.fontSize,document.body.style.lineHeight=l.typography.lineHeight,document.documentElement.style.backgroundColor=m.background;let v=document.querySelector('meta[name="theme-color"]');return v&&(v.content=m.background),document.documentElement.setAttribute("data-theme",e),document.body.setAttribute("data-theme",e),n.themeSettings.persist&&localStorage.setItem(n.themeSettings.persistKey,e),n._notifyThemeObservers(e),i&&n.themeSettings.autoContrast&&setTimeout(()=>{n.refreshContrast()},a?r+50:50),L(`\u2705 Theme applied: ${e} (${l.name})`),!0}static toggleTheme(){return n.applyTheme(n._currentTheme==="light"?"dark":"light")}static applyThemeToElement(e,t=null){if(!e)return!1;let a=t?n.THEMES[t]:n.getTheme();if(!a)return!1;let r=e._isShadowHost?n.getShadowRoot(e):e;return r?(Object.entries(a.colors).forEach(([s,i])=>r.style.setProperty(`--Zum-${s}`,i)),r.style.backgroundColor=a.colors.background,r.style.color=a.colors.text,!0):!1}static applyThemeToCustomElement(e,t){let a=n.getTheme(t);if(!a||!e)return!1;let r=n.getThemeCSSProperties(t);return e.style.cssText+=r,e.setAttribute("data-theme",t),e.style.backgroundColor=a.colors.background,e.style.color=a.colors.text,!0}static applyThemeToElementDirect(e,t,a){if(e&&n.isShadowHost(e)){let r=n.getShadowRoot(e);if(!r)return;r.querySelectorAll("style[data-Zum-theme]").forEach(i=>i.remove());let s=document.createElement("style");s.setAttribute("data-Zum-theme","true"),s.textContent=`:host { background: ${t}; color: ${a}; }`,r.appendChild(s)}}static getCurrentTheme(){return n._currentTheme}static getTheme(e=null){return n.THEMES[e||n._currentTheme]||null}static getThemeSafe(e){return n.THEMES[e]||n.THEMES[n.themeSettings.defaultTheme]||n.THEMES.light}static getThemeName(e){let t=n.getTheme(e);return t?t.name:e}static getThemeNames(){let e={};return Object.entries(n.THEMES).forEach(([t,a])=>{e[t]=a.name||t}),e}static getThemeColors(e=null){let t=n.getTheme(e);return t?t.colors:null}static getThemeColor(e,t=null){let a=t?n.THEMES[t]:n.getTheme();return a&&a.colors[e]||null}static getAvailableThemes(){return Object.keys(n.THEMES)}static themeExists(e){return!!n.THEMES[e]}static getThemeSettings(){return{...n.themeSettings}}static updateThemeSettings(e){return Object.assign(n.themeSettings,e),n.themeSettings}static setDefaultTheme(e){return n.themeExists(e)?(n.themeSettings.defaultTheme=e,!0):!1}static resetToDefaultTheme(){return n.applyTheme(n.themeSettings.defaultTheme,{manual:!1})}static setThemePersistence(e){n.themeSettings.persist=e,e||(localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey))}static isDarkTheme(){return n._currentTheme==="dark"}static isLightTheme(){return n._currentTheme==="light"}static getThemeMode(){return n.isUsingSystemTheme()?"system":"manual"}static addTheme(e,t){n.THEMES[e]&&z(`Theme "${e}" already exists. Overwriting.`);let r=["colors","typography","spacing","borderRadius","shadows","transitions"].filter(s=>!t[s]);return r.length>0?(T(`Theme missing required keys: ${r.join(", ")}`),!1):(n.THEMES[e]={id:e,name:t.name||e,...t},!0)}static defineTheme(e,t){if(!t||!t.colors)return T("Zum.defineTheme: theme must include a colors object."),!1;let a=n.THEMES.light;return n.THEMES[e]={id:e,name:t.name||e,colors:{...a.colors,...t.colors},typography:{...a.typography,...t.typography||{}},spacing:{...a.spacing,...t.spacing||{}},borderRadius:{...a.borderRadius,...t.borderRadius||{}},shadows:{...a.shadows,...t.shadows||{}},transitions:{...a.transitions,...t.transitions||{}}},!0}static removeTheme(e){return e==="light"||e==="dark"?(z("Cannot remove default themes (light/dark)"),!1):n.THEMES[e]?(delete n.THEMES[e],!0):!1}static duplicateTheme(e,t){let a=n.getTheme(e);return a?n.addTheme(t,{...a,id:t,name:`${a.name} (Copy)`}):!1}static exportTheme(e){let t=n.getTheme(e);return t?JSON.stringify(t,null,2):null}static importTheme(e){try{let t=JSON.parse(e);if(!t.id||!t.colors||!t.typography)throw new Error("Invalid theme format");return n.addTheme(t.id,t),!0}catch(t){return T("Failed to import theme:",t),!1}}static observeTheme(e){return typeof e!="function"?()=>{}:(n._themeObservers.push(e),e(n._currentTheme),()=>{n._themeObservers=n._themeObservers.filter(t=>t!==e)})}static onThemeChange(e){return n.observeTheme(e)}static _notifyThemeObservers(e){n._themeObservers.forEach(t=>{try{t(e)}catch(a){T("Theme observer error:",a)}})}static getContrastRatio(e,t){let a=n._calculateLuminance(e),r=n._calculateLuminance(t),s=Math.max(a,r),i=Math.min(a,r);return(s+.05)/(i+.05)}static checkThemeAccessibility(e){let t=n.getTheme(e);if(!t)return null;let a={theme:e,name:t.name,passed:!0,checks:[]},r=n.getContrastRatio(t.colors.text,t.colors.background);a.checks.push({name:"Text contrast",ratio:r.toFixed(2),passed:r>=4.5,wcag:r>=4.5?"AA":"Fail"});let s=n.getContrastRatio(t.colors.textSecondary,t.colors.background);a.checks.push({name:"Secondary text",ratio:s.toFixed(2),passed:s>=3,wcag:s>=3?"AA":"Fail"});let i=n.getContrastRatio(t.colors.primary,t.colors.background);return a.checks.push({name:"Interactive",ratio:i.toFixed(2),passed:i>=3,wcag:i>=3?"AA":"Fail"}),a.passed=a.checks.every(c=>c.passed),a}static getAccessibleThemes(){return Object.keys(n.THEMES).filter(e=>{let t=n.checkThemeAccessibility(e);return t&&t.passed})}static createThemeToggle(e={}){let{lightIcon:t="\u2600\uFE0F",darkIcon:a="\u{1F319}",systemIcon:r="\u{1F313}",className:s="theme-toggle",position:i="fixed",top:c="20px",right:l="20px",smooth:d=!0,duration:m=400}=e,v=document.createElement("button");v.className=s;let f=0,h=y=>{!localStorage.getItem(n.themeSettings.systemPreferenceKey)?(v.textContent=r,v.title="System theme",f=0):y==="dark"?(v.textContent=a,v.title="Dark theme",f=2):(v.textContent=t,v.title="Light theme",f=1),v.setAttribute("data-theme",y)},E=document.createElement("style");E.textContent=`
|
|
159
156
|
.${s} {
|
|
160
157
|
position: ${i}; top: ${c}; right: ${l}; z-index: 9999;
|
|
161
158
|
background: var(--Zum-surface); color: var(--Zum-text);
|
|
@@ -168,7 +165,7 @@ ${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string
|
|
|
168
165
|
}
|
|
169
166
|
.${s}:hover { transform: scale(1.1); box-shadow: var(--Zum-shadow-lg); }
|
|
170
167
|
.${s}:active { transform: scale(0.95); }
|
|
171
|
-
`,document.head.appendChild(
|
|
168
|
+
`,document.head.appendChild(E),h(n._currentTheme),v.addEventListener("click",()=>{if(f===0)n.applyTheme("light",{smooth:d,duration:m,manual:!0}),h("light");else if(f===1)n.applyTheme("dark",{smooth:d,duration:m,manual:!0}),h("dark");else{localStorage.removeItem(n.themeSettings.systemPreferenceKey);let y=n.getSystemThemePreference();n.applyTheme(y,{smooth:d,duration:m,manual:!1}),h(y)}}),n.observeTheme(h);let k=window.matchMedia("(prefers-color-scheme: dark)");return k.addEventListener&&k.addEventListener("change",()=>{if(!localStorage.getItem(n.themeSettings.systemPreferenceKey)){let y=k.matches?"dark":"light";n.applyTheme(y,{smooth:d,duration:m,manual:!1}),h(y)}}),v}static createThemeSelector(e={}){let{className:t="theme-selector",includeSystem:a=!0,currentTheme:r=n._currentTheme,onChange:s=null}=e,i=document.createElement("select");if(i.className=t,i.style.cssText="padding: 8px 12px; border-radius: 6px; border: 1px solid var(--Zum-border); background: var(--Zum-surface); color: var(--Zum-text); cursor: pointer; font-size: 14px;",a){let c=document.createElement("option");c.value="system",c.textContent="\u{1F313} System",n.isUsingSystemTheme()&&(c.selected=!0),i.appendChild(c)}return Object.entries(n.THEMES).forEach(([c,l])=>{let d=document.createElement("option");d.value=c,d.textContent=l.name||c,c===r&&!n.isUsingSystemTheme()&&(d.selected=!0),i.appendChild(d)}),i.addEventListener("change",c=>{let l=c.target.value;if(l==="system"){localStorage.removeItem(n.themeSettings.systemPreferenceKey);let d=n.getSystemThemePreference();n.applyTheme(d,{manual:!1})}else n.applyTheme(l,{manual:!0});s&&s(l)}),n.observeTheme(c=>{i.value=n.isUsingSystemTheme()?"system":c}),i}static createThemePreview(e){let t=n.getTheme(e);if(!t)return null;let a=document.createElement("div");return a.className="theme-preview",a.style.cssText=`display: flex; flex-direction: column; gap: 10px; padding: 20px; background: ${t.colors.background}; color: ${t.colors.text}; border-radius: 8px; border: 1px solid ${t.colors.border}; font-family: ${t.typography.fontFamily}; max-width: 300px;`,a.innerHTML=`
|
|
172
169
|
<h3 style="color: ${t.colors.primary};">${t.name}</h3>
|
|
173
170
|
<p style="color: ${t.colors.textSecondary};">Theme preview</p>
|
|
174
171
|
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
|
|
@@ -201,7 +198,7 @@ ${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string
|
|
|
201
198
|
::-webkit-scrollbar-track { background: var(--Zum-scrollbarTrack, #f1f5f9); }
|
|
202
199
|
::-webkit-scrollbar-thumb { background: var(--Zum-scrollbarThumb, #cbd5e1); border-radius: var(--Zum-radius-full, 9999px); }
|
|
203
200
|
::selection { background: var(--Zum-primary, #3b82f6); color: var(--Zum-text, #ffffff); }
|
|
204
|
-
`,document.head.appendChild(e),n._themeStylesInjected=!0}static refreshTheme(){let e=n._currentTheme;e&&(n.applyTheme(e),document.querySelectorAll(".theme-aware, [data-theme]").forEach(t=>{t!==document.documentElement&&t!==document.body&&t.setAttribute("data-theme",e)}),window.dispatchEvent(new CustomEvent("zum-theme-refreshed",{detail:{theme:e}})),M(`\u{1F504} Theme refreshed: ${e}`))}static reloadTheme(){return n.applyTheme(n._currentTheme)}static clearThemePreferences(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),M("\u{1F5D1}\uFE0F Theme preferences cleared")}static clearAllThemeData(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),n._currentTheme=n.themeSettings.defaultTheme,n._themeObservers=[],document.querySelectorAll("style[data-Zum-themes]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-theme]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-contrast]").forEach(e=>e.remove()),n._themeStylesInjected=!1,n._contrastInitialized=!1,document.documentElement.removeAttribute("data-theme"),document.body&&document.body.removeAttribute("data-theme"),M("\u{1F5D1}\uFE0F All theme data cleared")}static clearAllZumData(){["Zum_theme_preference","Zum_theme_preference_manual","ZumKey","app-name","__Zum_fetch_cache","__Zum_refreshing","__Zum_loaded","__Zum_license_cache","__Zum_pubkey"].forEach(t=>{localStorage.removeItem(t),sessionStorage.removeItem(t)}),M("\u{1F5D1}\uFE0F All Zum data cleared from localStorage")}static getZumStorageKeys(){let e=[];for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);a&&(a.includes("Zum")||a==="app-name")&&e.push(a)}return e}static inspectZumStorage(){let e=n.getZumStorageKeys();return M("\u{1F4E6} Zum data in localStorage:"),e.forEach(t=>{let a=localStorage.getItem(t);M(` ${t}:`,a?a.substring(0,100)+(a.length>100?"...":""):"null")}),e}static resetTheme(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.themeSettings.defaultTheme||"light";n.applyTheme(e,{manual:!1}),M(`\u{1F504} Theme reset to: ${e}`)}static fullReset(){n.clearAllZumData(),M("\u{1F504} Full reset complete. Reloading..."),setTimeout(()=>location.reload(),100)}};T(n,"config",null),T(n,"configPromise",Promise.resolve(null)),T(n,"_readyPromise",null),T(n,"_scrollMemory",new Map),T(n,"_fetchCache",null),T(n,"_animationsInjected",!1),T(n,"_contrastInitialized",!1),T(n,"_contrastProcessing",new WeakSet),T(n,"_contrastProcessed",new WeakSet),T(n,"_debugEnabled",!1),T(n,"_debugLog",[]),T(n,"_debugLogLimit",500),T(n,"_debugDedupe",new Map),T(n,"_debugPerfMarks",new Map),T(n,"_beforeUnloadHandlers",new Set),T(n,"_beforeUnloadAttached",!1),T(n,"_hasRestored",!1),T(n,"respectReducedMotion",!0),T(n,"animations",{fade:{keyframes:"@keyframes fade { 0% { opacity: 0; } 100% { opacity: 1; } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideUp:{keyframes:"@keyframes slideUp { 0% { opacity: 0; transform: translateY(40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideDown:{keyframes:"@keyframes slideDown { 0% { opacity: 0; transform: translateY(-40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideLeft:{keyframes:"@keyframes slideLeft { 0% { opacity: 0; transform: translateX(40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideRight:{keyframes:"@keyframes slideRight { 0% { opacity: 0; transform: translateX(-40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},scale:{keyframes:"@keyframes scale { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},bounce:{keyframes:"@keyframes bounce { 0% { opacity: 0; transform: scale(0.3); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},blurIn:{keyframes:"@keyframes blurIn { 0% { opacity: 0; filter: blur(20px); } 100% { opacity: 1; filter: blur(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},rotateIn:{keyframes:"@keyframes rotateIn { 0% { opacity: 0; transform: rotate(-8deg); } 100% { opacity: 1; transform: rotate(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},flipIn:{keyframes:"@keyframes flipIn { 0% { opacity: 0; transform: perspective(400px) rotateX(-90deg); } 100% { opacity: 1; transform: perspective(400px) rotateX(0); } }",options:{duration:700,easing:"ease-out"}},shake:{keyframes:"@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }",options:{duration:500,easing:"ease-in-out"}},pulse:{keyframes:"@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }",options:{duration:1e3,easing:"ease-in-out"}},reveal:{keyframes:"@keyframes reveal { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }",options:{duration:800,easing:"cubic-bezier(.2,.8,.2,1)"}}}),T(n,"SKELETON_TYPES",{DEFAULT:"default",FEED_PAGE:"feed-page",PROFILE_PAGE:"profile-page",CHAT_PAGE:"chat-page",CHAT_DETAIL_PAGE:"chat-detail-page",SERVICE_PAGE:"service-page",DASHBOARD_PAGE:"dashboard-page",SETTINGS_PAGE:"settings-page",SEARCH_PAGE:"search-page",PRODUCT_GRID:"product-grid",NOTIFICATIONS_PAGE:"notifications-page",FORM_PAGE:"form-page"}),T(n,"DEFAULT_SKELETON_OPTIONS",{count:6,customClass:"",colors:{base:"#f5f5f5",highlight:"#e8e8e8"},animationDuration:1.5}),T(n,"REMOVE_SKELETON_OPTIONS",{animate:!0,animationType:"fade",duration:300,delay:0,callback:null,removeStyles:!0,selector:".skeleton"}),T(n,"_differ",{diff(e,t,a="id"){if(!e||!t)return null;let r=new Map(e.map(c=>[c[a],c])),s=new Map(t.map(c=>[c[a],c])),i={added:[],updated:[],deleted:[],unchanged:[],all:[],summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1}};return s.forEach((c,l)=>{let d=r.get(l);if(!d)i.added.push({id:l,item:{...c,__change:"added"}});else if(JSON.stringify(d)!==JSON.stringify(c)){let m={};new Set([...Object.keys(d),...Object.keys(c)]).forEach(f=>{f!=="__change"&&JSON.stringify(d[f])!==JSON.stringify(c[f])&&(m[f]={from:d[f],to:c[f]})}),i.updated.push({id:l,item:{...c,__change:"updated"},changes:m})}else i.unchanged.push({id:l,item:{...c,__change:"unchanged"}})}),r.forEach((c,l)=>{s.has(l)||i.deleted.push({id:l,item:{...c,__change:"deleted"}})}),i.all=[...i.added.map(c=>c.item),...i.updated.map(c=>c.item),...i.unchanged.map(c=>c.item),...i.deleted.map(c=>c.item)],i.summary={added:i.added.length,updated:i.updated.length,deleted:i.deleted.length,unchanged:i.unchanged.length,total:i.all.length,hasChanges:i.added.length>0||i.updated.length>0||i.deleted.length>0},i}}),T(n,"themeSettings",{defaultTheme:"light",persist:!0,persistKey:"Zum_theme_preference",systemPreferenceKey:"Zum_theme_preference_manual",respectSystemPreference:!0,smoothTransitions:!0,transitionDuration:400,transitionEasing:"ease-in-out",autoContrast:!0,contrastThreshold:.5}),T(n,"THEMES",{light:{id:"light",name:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",success:"#22c55e",danger:"#ef4444",warning:"#f59e0b",info:"#06b6d4",background:"#ffffff",surface:"#f8fafc",surface2:"#f1f5f9",text:"#0f172a",textSecondary:"#475569",textMuted:"#94a3b8",border:"#e2e8f0",borderLight:"#f1f5f9",shadow:"rgba(0,0,0,0.05)",shadowHover:"rgba(0,0,0,0.1)",gradient:"linear-gradient(135deg, #3b82f6, #8b5cf6)",cardBg:"#ffffff",inputBg:"#ffffff",inputBorder:"#e2e8f0",inputFocus:"#3b82f6",navbarBg:"#ffffff",sidebarBg:"#f8fafc",footerBg:"#f1f5f9",modalBg:"rgba(0,0,0,0.5)",tooltipBg:"#0f172a",tooltipText:"#ffffff",skeletonBase:"#f1f5f9",skeletonHighlight:"#e2e8f0",scrollbarTrack:"#f1f5f9",scrollbarThumb:"#cbd5e1"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px rgba(0,0,0,0.07)",lg:"0 10px 15px rgba(0,0,0,0.1)",xl:"0 20px 25px rgba(0,0,0,0.15)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},dark:{id:"dark",name:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",success:"#4ade80",danger:"#f87171",warning:"#fbbf24",info:"#22d3ee",background:"#0f172a",surface:"#1e293b",surface2:"#334155",text:"#f1f5f9",textSecondary:"#94a3b8",textMuted:"#64748b",border:"#334155",borderLight:"#1e293b",shadow:"rgba(0,0,0,0.3)",shadowHover:"rgba(0,0,0,0.4)",gradient:"linear-gradient(135deg, #60a5fa, #a78bfa)",cardBg:"#1e293b",inputBg:"#1e293b",inputBorder:"#334155",inputFocus:"#60a5fa",navbarBg:"#0f172a",sidebarBg:"#1e293b",footerBg:"#0f172a",modalBg:"rgba(0,0,0,0.7)",tooltipBg:"#334155",tooltipText:"#f1f5f9",skeletonBase:"#1e293b",skeletonHighlight:"#334155",scrollbarTrack:"#1e293b",scrollbarThumb:"#475569"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px rgba(0,0,0,0.4)",lg:"0 10px 15px rgba(0,0,0,0.5)",xl:"0 20px 25px rgba(0,0,0,0.6)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},sepia:{id:"sepia",name:"Sepia",colors:{primary:"#8b7d6b",secondary:"#a8907a",success:"#6b8b6b",danger:"#8b6b6b",warning:"#8b7d4b",info:"#6b7d8b",background:"#f5ece0",surface:"#ede4d8",surface2:"#e5dcd0",text:"#3d3529",textSecondary:"#6b6357",textMuted:"#8b8377",border:"#d4c8b8",borderLight:"#e5dcd0",shadow:"rgba(61,53,41,0.08)",shadowHover:"rgba(61,53,41,0.15)",gradient:"linear-gradient(135deg, #8b7d6b, #a8907a)",cardBg:"#ede4d8",inputBg:"#f5ece0",inputBorder:"#d4c8b8",inputFocus:"#8b7d6b",navbarBg:"#ede4d8",sidebarBg:"#e5dcd0",footerBg:"#e5dcd0",modalBg:"rgba(61,53,41,0.6)",tooltipBg:"#3d3529",tooltipText:"#f5ece0",skeletonBase:"#e5dcd0",skeletonHighlight:"#d4c8b8",scrollbarTrack:"#ede4d8",scrollbarThumb:"#c4b8a8"},typography:{fontFamily:'Georgia, "Times New Roman", serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"17px",lineHeight:"1.7"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"3px",md:"6px",lg:"10px",xl:"14px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(61,53,41,0.05)",md:"0 4px 6px rgba(61,53,41,0.07)",lg:"0 10px 15px rgba(61,53,41,0.1)",xl:"0 20px 25px rgba(61,53,41,0.12)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}}}),T(n,"_currentTheme","light"),T(n,"_themeObservers",[]),T(n,"_themeStylesInjected",!1),T(n,"debug",{enable(){return n._debugEnabled=!0,!0},disable(){n._debugEnabled=!1},isEnabled(){return n._debugEnabled},log(...e){if(!n._debugEnabled)return;let t;try{t=JSON.stringify(e)}catch(s){t=String(e)}let a=Date.now(),r=n._debugDedupe.get(t);r&&a-r<250||(n._debugDedupe.set(t,a),console.log("\u{1F41B}",...e),n._debugLog.push({ts:a,args:e}),n._debugLog.length>n._debugLogLimit&&n._debugLog.shift())},getLog(){return n._debugLog.slice()},clearLog(){n._debugLog.length=0,n._debugDedupe.clear()}}),T(n,"Activity",{_pages:new Map,_layers:[],_activeLayer:null,_container:null,_cacheTTL:1e3*60*60,_started:!1,_cleanupInterval:null,_activeOverlays:{sidebar:null,optionMenu:null,toolPick:null,dialog:null},_sweepCache(){if(typeof sessionStorage=="undefined")return;let e=Date.now();for(let t=sessionStorage.length-1;t>=0;t--){let a=sessionStorage.key(t);a&&a.startsWith("zum-activity-cache:")}},start(){this._started||!j()||(this._started=!0,this._container=document.getElementById("zum-activity-root"),this._container||(this._container=document.createElement("div"),this._container.id="zum-activity-root",this._container.style.cssText="position: relative; width: 100%; height: 100%; overflow: hidden;",document.body.appendChild(this._container)),this._injectBaseStyles(),this._cleanupInterval=setInterval(()=>this._sweepCache(),6e4),window.addEventListener("hashchange",()=>this._handleHashChange()),this._handleHashChange())},stop(){this._started&&(this._started=!1,clearInterval(this._cleanupInterval),window.removeEventListener("hashchange",this._handleHashChange))},addLazyPage(e,t){this._pages.set(e,{factory:t,cache:!0})},addPage(e,t){this._pages.set(e,{factory:t,cache:!1})},navigateTo(e){window.location.hash!==`#${e}`&&(window.location.hash=e)},goBack(){window.history.back()},getCurrentPath(){let e=window.location.hash.replace(/^#/,"")||"/";return e.length>1&&e.startsWith("/")||e.startsWith("/")?e:"/"+e},findTrigger(e){return e?typeof e=="string"?document.querySelector(e):e:null},_handleHashChange(){if(this._pages.size===0)return;let e=this.getCurrentPath(),t=this._matchRoute(e);if(!t){E(`ZumActivity: No route found for "${e}"`);return}let{page:a,params:r}=t;this._closeTopOverlay()||this._renderPage(e,a,r)},_matchRoute(e){for(let[t,a]of this._pages.entries()){let r=t.length>1&&!t.startsWith("/")?"/"+t:t,s=new RegExp(`^${r.replace(/:[a-zA-Z0-9_]+/g,"([^/]+)")}$`),i=e.match(s);if(i){let c={};return(t.match(/:[a-zA-Z0-9_]+/g)||[]).map(d=>d.slice(1)).forEach((d,m)=>c[d]=decodeURIComponent(i[m+1])),{page:a,params:c}}}return null},async _renderPage(e,t,a){let r=`zum-activity-cache:${e}`,s=this._layers.find(i=>i.path===e);if(s||(s=document.createElement("div"),s.className="activity-page-layer",s.path=e,s.style.cssText="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow-y: auto; background: var(--Zum-background); z-index: 1; display: none; transition: transform 0.3s ease;",this._container.appendChild(s),this._layers.push(s)),this._activeLayer&&(this._activeLayer.style.display="none"),s.style.display="block",this._activeLayer=s,!s.innerHTML.trim()){let i=sessionStorage.getItem(r);if(!i||!t.cache){try{i=await t.factory(a)}catch(l){E("Page factory error:",l),i='<div class="activity-error">Failed to load page.</div>'}if(t.cache)try{let l=i instanceof HTMLElement?i.outerHTML:String(i);sessionStorage.setItem(r,l)}catch(l){}}let c=document.createElement("div");c.className="activity-page-inner",i instanceof HTMLElement?c.appendChild(i):c.innerHTML=String(i),s.appendChild(c)}},_closeTopOverlay(){for(let[e,t]of Object.entries(this._activeOverlays))if(t)return this._closeOverlay(e),!0;return!1},_closeOverlay(e){let t=this._activeOverlays[e];t&&(t.remove(),this._activeOverlays[e]=null,document.body.style.overflow="")},_injectBaseStyles(){if(document.getElementById("activity-base-styles"))return;let e=document.createElement("style");e.id="activity-base-styles",e.textContent=`
|
|
201
|
+
`,document.head.appendChild(e),n._themeStylesInjected=!0}static refreshTheme(){let e=n._currentTheme;e&&(n.applyTheme(e),document.querySelectorAll(".theme-aware, [data-theme]").forEach(t=>{t!==document.documentElement&&t!==document.body&&t.setAttribute("data-theme",e)}),window.dispatchEvent(new CustomEvent("zum-theme-refreshed",{detail:{theme:e}})),L(`\u{1F504} Theme refreshed: ${e}`))}static reloadTheme(){return n.applyTheme(n._currentTheme)}static clearThemePreferences(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),L("\u{1F5D1}\uFE0F Theme preferences cleared")}static clearAllThemeData(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),n._currentTheme=n.themeSettings.defaultTheme,n._themeObservers=[],document.querySelectorAll("style[data-Zum-themes]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-theme]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-contrast]").forEach(e=>e.remove()),n._themeStylesInjected=!1,n._contrastInitialized=!1,document.documentElement.removeAttribute("data-theme"),document.body&&document.body.removeAttribute("data-theme"),L("\u{1F5D1}\uFE0F All theme data cleared")}static clearAllZumData(){["Zum_theme_preference","Zum_theme_preference_manual","ZumKey","app-name","__Zum_fetch_cache","__Zum_refreshing","__Zum_loaded","__Zum_license_cache","__Zum_pubkey"].forEach(t=>{localStorage.removeItem(t),sessionStorage.removeItem(t)}),L("\u{1F5D1}\uFE0F All Zum data cleared from localStorage")}static getZumStorageKeys(){let e=[];for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);a&&(a.includes("Zum")||a==="app-name")&&e.push(a)}return e}static inspectZumStorage(){let e=n.getZumStorageKeys();return L("\u{1F4E6} Zum data in localStorage:"),e.forEach(t=>{let a=localStorage.getItem(t);L(` ${t}:`,a?a.substring(0,100)+(a.length>100?"...":""):"null")}),e}static resetTheme(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.themeSettings.defaultTheme||"light";n.applyTheme(e,{manual:!1}),L(`\u{1F504} Theme reset to: ${e}`)}static fullReset(){n.clearAllZumData(),L("\u{1F504} Full reset complete. Reloading..."),setTimeout(()=>location.reload(),100)}};w(n,"config",null),w(n,"configPromise",Promise.resolve(null)),w(n,"_readyPromise",null),w(n,"_scrollMemory",new Map),w(n,"_fetchCache",null),w(n,"_animationsInjected",!1),w(n,"_contrastInitialized",!1),w(n,"_contrastProcessing",new WeakSet),w(n,"_contrastProcessed",new WeakSet),w(n,"_debugEnabled",!1),w(n,"_debugLog",[]),w(n,"_debugLogLimit",500),w(n,"_debugDedupe",new Map),w(n,"_debugPerfMarks",new Map),w(n,"_beforeUnloadHandlers",new Set),w(n,"_beforeUnloadAttached",!1),w(n,"_hasRestored",!1),w(n,"respectReducedMotion",!0),w(n,"animations",{fade:{keyframes:"@keyframes fade { 0% { opacity: 0; } 100% { opacity: 1; } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideUp:{keyframes:"@keyframes slideUp { 0% { opacity: 0; transform: translateY(40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideDown:{keyframes:"@keyframes slideDown { 0% { opacity: 0; transform: translateY(-40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideLeft:{keyframes:"@keyframes slideLeft { 0% { opacity: 0; transform: translateX(40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideRight:{keyframes:"@keyframes slideRight { 0% { opacity: 0; transform: translateX(-40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},scale:{keyframes:"@keyframes scale { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},bounce:{keyframes:"@keyframes bounce { 0% { opacity: 0; transform: scale(0.3); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},blurIn:{keyframes:"@keyframes blurIn { 0% { opacity: 0; filter: blur(20px); } 100% { opacity: 1; filter: blur(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},rotateIn:{keyframes:"@keyframes rotateIn { 0% { opacity: 0; transform: rotate(-8deg); } 100% { opacity: 1; transform: rotate(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},flipIn:{keyframes:"@keyframes flipIn { 0% { opacity: 0; transform: perspective(400px) rotateX(-90deg); } 100% { opacity: 1; transform: perspective(400px) rotateX(0); } }",options:{duration:700,easing:"ease-out"}},shake:{keyframes:"@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }",options:{duration:500,easing:"ease-in-out"}},pulse:{keyframes:"@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }",options:{duration:1e3,easing:"ease-in-out"}},reveal:{keyframes:"@keyframes reveal { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }",options:{duration:800,easing:"cubic-bezier(.2,.8,.2,1)"}}}),w(n,"SKELETON_TYPES",{DEFAULT:"default",FEED_PAGE:"feed-page",PROFILE_PAGE:"profile-page",CHAT_PAGE:"chat-page",CHAT_DETAIL_PAGE:"chat-detail-page",SERVICE_PAGE:"service-page",DASHBOARD_PAGE:"dashboard-page",SETTINGS_PAGE:"settings-page",SEARCH_PAGE:"search-page",PRODUCT_GRID:"product-grid",NOTIFICATIONS_PAGE:"notifications-page",FORM_PAGE:"form-page"}),w(n,"DEFAULT_SKELETON_OPTIONS",{count:6,customClass:"",colors:{base:"#f5f5f5",highlight:"#e8e8e8"},animationDuration:1.5}),w(n,"REMOVE_SKELETON_OPTIONS",{animate:!0,animationType:"fade",duration:300,delay:0,callback:null,removeStyles:!0,selector:".skeleton"}),w(n,"_differ",{diff(e,t,a="id"){if(!e||!t)return null;let r=new Map(e.map(c=>[c[a],c])),s=new Map(t.map(c=>[c[a],c])),i={added:[],updated:[],deleted:[],unchanged:[],all:[],summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1}};return s.forEach((c,l)=>{let d=r.get(l);if(!d)i.added.push({id:l,item:{...c,__change:"added"}});else if(JSON.stringify(d)!==JSON.stringify(c)){let m={};new Set([...Object.keys(d),...Object.keys(c)]).forEach(f=>{f!=="__change"&&JSON.stringify(d[f])!==JSON.stringify(c[f])&&(m[f]={from:d[f],to:c[f]})}),i.updated.push({id:l,item:{...c,__change:"updated"},changes:m})}else i.unchanged.push({id:l,item:{...c,__change:"unchanged"}})}),r.forEach((c,l)=>{s.has(l)||i.deleted.push({id:l,item:{...c,__change:"deleted"}})}),i.all=[...i.added.map(c=>c.item),...i.updated.map(c=>c.item),...i.unchanged.map(c=>c.item),...i.deleted.map(c=>c.item)],i.summary={added:i.added.length,updated:i.updated.length,deleted:i.deleted.length,unchanged:i.unchanged.length,total:i.all.length,hasChanges:i.added.length>0||i.updated.length>0||i.deleted.length>0},i}}),w(n,"themeSettings",{defaultTheme:"light",persist:!0,persistKey:"Zum_theme_preference",systemPreferenceKey:"Zum_theme_preference_manual",respectSystemPreference:!0,smoothTransitions:!0,transitionDuration:400,transitionEasing:"ease-in-out",autoContrast:!0,contrastThreshold:.5,minContrastRatio:3}),w(n,"THEMES",{light:{id:"light",name:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",success:"#22c55e",danger:"#ef4444",warning:"#f59e0b",info:"#06b6d4",background:"#ffffff",surface:"#f8fafc",surface2:"#f1f5f9",text:"#0f172a",textSecondary:"#475569",textMuted:"#94a3b8",border:"#e2e8f0",borderLight:"#f1f5f9",shadow:"rgba(0,0,0,0.05)",shadowHover:"rgba(0,0,0,0.1)",gradient:"linear-gradient(135deg, #3b82f6, #8b5cf6)",cardBg:"#ffffff",inputBg:"#ffffff",inputBorder:"#e2e8f0",inputFocus:"#3b82f6",navbarBg:"#ffffff",sidebarBg:"#f8fafc",footerBg:"#f1f5f9",modalBg:"rgba(0,0,0,0.5)",tooltipBg:"#0f172a",tooltipText:"#ffffff",skeletonBase:"#f1f5f9",skeletonHighlight:"#e2e8f0",scrollbarTrack:"#f1f5f9",scrollbarThumb:"#cbd5e1"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px rgba(0,0,0,0.07)",lg:"0 10px 15px rgba(0,0,0,0.1)",xl:"0 20px 25px rgba(0,0,0,0.15)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},dark:{id:"dark",name:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",success:"#4ade80",danger:"#f87171",warning:"#fbbf24",info:"#22d3ee",background:"#0f172a",surface:"#1e293b",surface2:"#334155",text:"#f1f5f9",textSecondary:"#94a3b8",textMuted:"#64748b",border:"#334155",borderLight:"#1e293b",shadow:"rgba(0,0,0,0.3)",shadowHover:"rgba(0,0,0,0.4)",gradient:"linear-gradient(135deg, #60a5fa, #a78bfa)",cardBg:"#1e293b",inputBg:"#1e293b",inputBorder:"#334155",inputFocus:"#60a5fa",navbarBg:"#0f172a",sidebarBg:"#1e293b",footerBg:"#0f172a",modalBg:"rgba(0,0,0,0.7)",tooltipBg:"#334155",tooltipText:"#f1f5f9",skeletonBase:"#1e293b",skeletonHighlight:"#334155",scrollbarTrack:"#1e293b",scrollbarThumb:"#475569"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px rgba(0,0,0,0.4)",lg:"0 10px 15px rgba(0,0,0,0.5)",xl:"0 20px 25px rgba(0,0,0,0.6)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},sepia:{id:"sepia",name:"Sepia",colors:{primary:"#8b7d6b",secondary:"#a8907a",success:"#6b8b6b",danger:"#8b6b6b",warning:"#8b7d4b",info:"#6b7d8b",background:"#f5ece0",surface:"#ede4d8",surface2:"#e5dcd0",text:"#3d3529",textSecondary:"#6b6357",textMuted:"#8b8377",border:"#d4c8b8",borderLight:"#e5dcd0",shadow:"rgba(61,53,41,0.08)",shadowHover:"rgba(61,53,41,0.15)",gradient:"linear-gradient(135deg, #8b7d6b, #a8907a)",cardBg:"#ede4d8",inputBg:"#f5ece0",inputBorder:"#d4c8b8",inputFocus:"#8b7d6b",navbarBg:"#ede4d8",sidebarBg:"#e5dcd0",footerBg:"#e5dcd0",modalBg:"rgba(61,53,41,0.6)",tooltipBg:"#3d3529",tooltipText:"#f5ece0",skeletonBase:"#e5dcd0",skeletonHighlight:"#d4c8b8",scrollbarTrack:"#ede4d8",scrollbarThumb:"#c4b8a8"},typography:{fontFamily:'Georgia, "Times New Roman", serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"17px",lineHeight:"1.7"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"3px",md:"6px",lg:"10px",xl:"14px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(61,53,41,0.05)",md:"0 4px 6px rgba(61,53,41,0.07)",lg:"0 10px 15px rgba(61,53,41,0.1)",xl:"0 20px 25px rgba(61,53,41,0.12)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}}}),w(n,"_currentTheme","light"),w(n,"_themeObservers",[]),w(n,"_themeStylesInjected",!1),w(n,"debug",{enable(){return n._debugEnabled=!0,!0},disable(){n._debugEnabled=!1},isEnabled(){return n._debugEnabled},log(...e){if(!n._debugEnabled)return;let t;try{t=JSON.stringify(e)}catch(s){t=String(e)}let a=Date.now(),r=n._debugDedupe.get(t);r&&a-r<250||(n._debugDedupe.set(t,a),console.log("\u{1F41B}",...e),n._debugLog.push({ts:a,args:e}),n._debugLog.length>n._debugLogLimit&&n._debugLog.shift())},getLog(){return n._debugLog.slice()},clearLog(){n._debugLog.length=0,n._debugDedupe.clear()}}),w(n,"Activity",{_pages:new Map,_layers:[],_activeLayer:null,_container:null,_cacheTTL:1e3*60*60,_started:!1,_cleanupInterval:null,_activeOverlays:{sidebar:null,optionMenu:null,toolPick:null,dialog:null},_sweepCache(){if(typeof sessionStorage=="undefined")return;let e=Date.now();for(let t=sessionStorage.length-1;t>=0;t--){let a=sessionStorage.key(t);a&&a.startsWith("zum-activity-cache:")}},start(){this._started||!j()||(this._started=!0,this._container=document.getElementById("zum-activity-root"),this._container||(this._container=document.createElement("div"),this._container.id="zum-activity-root",this._container.style.cssText="position: relative; width: 100%; height: 100%; overflow: hidden;",document.body.appendChild(this._container)),this._injectBaseStyles(),this._cleanupInterval=setInterval(()=>this._sweepCache(),6e4),window.addEventListener("hashchange",()=>this._handleHashChange()),this._handleHashChange())},stop(){this._started&&(this._started=!1,clearInterval(this._cleanupInterval),window.removeEventListener("hashchange",this._handleHashChange))},addLazyPage(e,t){this._pages.set(e,{factory:t,cache:!0})},addPage(e,t){this._pages.set(e,{factory:t,cache:!1})},navigateTo(e){window.location.hash!==`#${e}`&&(window.location.hash=e)},goBack(){window.history.back()},getCurrentPath(){let e=window.location.hash.replace(/^#/,"")||"/";return e.length>1&&e.startsWith("/")||e.startsWith("/")?e:"/"+e},findTrigger(e){return e?typeof e=="string"?document.querySelector(e):e:null},_handleHashChange(){if(this._pages.size===0)return;let e=this.getCurrentPath(),t=this._matchRoute(e);if(!t){T(`ZumActivity: No route found for "${e}"`);return}let{page:a,params:r}=t;this._closeTopOverlay()||this._renderPage(e,a,r)},_matchRoute(e){for(let[t,a]of this._pages.entries()){let r=t.length>1&&!t.startsWith("/")?"/"+t:t,s=new RegExp(`^${r.replace(/:[a-zA-Z0-9_]+/g,"([^/]+)")}$`),i=e.match(s);if(i){let c={};return(t.match(/:[a-zA-Z0-9_]+/g)||[]).map(d=>d.slice(1)).forEach((d,m)=>c[d]=decodeURIComponent(i[m+1])),{page:a,params:c}}}return null},async _renderPage(e,t,a){let r=`zum-activity-cache:${e}`,s=this._layers.find(i=>i.path===e);if(s||(s=document.createElement("div"),s.className="activity-page-layer",s.path=e,s.style.cssText="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow-y: auto; background: var(--Zum-background); z-index: 1; display: none; transition: transform 0.3s ease;",this._container.appendChild(s),this._layers.push(s)),this._activeLayer&&(this._activeLayer.style.display="none"),s.style.display="block",this._activeLayer=s,!s.innerHTML.trim()){let i=sessionStorage.getItem(r);if(!i||!t.cache){try{i=await t.factory(a)}catch(l){T("Page factory error:",l),i='<div class="activity-error">Failed to load page.</div>'}if(t.cache)try{let l=i instanceof HTMLElement?i.outerHTML:String(i);sessionStorage.setItem(r,l)}catch(l){}}let c=document.createElement("div");c.className="activity-page-inner",i instanceof HTMLElement?c.appendChild(i):c.innerHTML=String(i),s.appendChild(c)}},_closeTopOverlay(){for(let[e,t]of Object.entries(this._activeOverlays))if(t)return this._closeOverlay(e),!0;return!1},_closeOverlay(e){let t=this._activeOverlays[e];t&&(t.remove(),this._activeOverlays[e]=null,document.body.style.overflow="")},_injectBaseStyles(){if(document.getElementById("activity-base-styles"))return;let e=document.createElement("style");e.id="activity-base-styles",e.textContent=`
|
|
205
202
|
.activity-page-layer { transition: opacity 0.2s ease, transform 0.2s ease; }
|
|
206
203
|
.activity-page-inner { max-width: 500px; margin: 0 auto; padding: 16px; width: 100%; box-sizing: border-box; }
|
|
207
204
|
@media (min-width: 768px) { .activity-page-inner { max-width: 100%; padding: 32px; } }
|
|
@@ -234,8 +231,8 @@ ${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string
|
|
|
234
231
|
`).join("")}
|
|
235
232
|
</div>
|
|
236
233
|
</div>
|
|
237
|
-
`,document.body.appendChild(t),this._activeOverlays.dialog=t,requestAnimationFrame(()=>t.classList.add("open")),t.querySelectorAll(".activity-dialog-btn").forEach(a=>{a.onclick=()=>{let r=a.getAttribute("data-action");this._closeOverlay("dialog"),e.onAction&&e.onAction(r)}})},showOptionMenu(e,t){this._closeOverlay("optionMenu");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-option-menu",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.optionMenu=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.left}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("optionMenu"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("optionMenu"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)},showToolPick(e,t){this._closeOverlay("toolPick");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-tool-pick",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.icon||""} ${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.toolPick=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.right-160}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("toolPick"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("toolPick"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)}});var
|
|
234
|
+
`,document.body.appendChild(t),this._activeOverlays.dialog=t,requestAnimationFrame(()=>t.classList.add("open")),t.querySelectorAll(".activity-dialog-btn").forEach(a=>{a.onclick=()=>{let r=a.getAttribute("data-action");this._closeOverlay("dialog"),e.onAction&&e.onAction(r)}})},showOptionMenu(e,t){this._closeOverlay("optionMenu");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-option-menu",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.optionMenu=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.left}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("optionMenu"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("optionMenu"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)},showToolPick(e,t){this._closeOverlay("toolPick");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-tool-pick",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.icon||""} ${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.toolPick=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.right-160}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("toolPick"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("toolPick"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)}});var O=n;if(j()){window.Zum=O,window.ZumActivity=O.Activity,(function(){if(!document.querySelector('meta[name="color-scheme"]')){let e=document.createElement("meta");e.name="color-scheme",e.content="light dark",document.head.appendChild(e)}if(!document.querySelector('meta[name="theme-color"]')){let e=document.createElement("meta");e.name="theme-color",e.content="#ffffff",e.setAttribute("media","(prefers-color-scheme: light)"),document.head.appendChild(e);let t=document.createElement("meta");t.name="theme-color",t.content="#0f172a",t.setAttribute("media","(prefers-color-scheme: dark)"),document.head.appendChild(t)}})(),window.__ACTIVITY_NO_AUTOSTART__||queueMicrotask(()=>{O.Activity._started||(O.Activity.start(),window.location.hash||O.Activity.navigateTo("/"))});try{let _=!window.__ZUM_NO_SYSTEM_THEME__&&O.themeSettings.respectSystemPreference!==!1,e=localStorage.getItem(O.themeSettings.persistKey),t=!!localStorage.getItem(O.themeSettings.systemPreferenceKey),a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,r;if(e&&t&&O.THEMES[e]?r=e:_&&a?r="dark":_&&!a?r="light":r=O.themeSettings.defaultTheme||"light",O._currentTheme=r,O._injectThemeStyles(),O.applyTheme(r,{manual:t&&e===r}),window.matchMedia&&_){let s=window.matchMedia("(prefers-color-scheme: dark)"),i=c=>{if(localStorage.getItem(O.themeSettings.systemPreferenceKey))return;let l=c.matches?"dark":"light";O.applyTheme(l,{manual:!1,smooth:!0,duration:400}),setTimeout(()=>O.refreshContrast(),500),L(`\u{1F504} Auto-switched to ${l} (system preference)`)};s.addEventListener?s.addEventListener("change",i):s.addListener&&s.addListener(i)}O._initAutoContrast()}catch(_){z("Theme initialization error:",_),O._currentTheme=O.themeSettings.defaultTheme||"light",O.applyTheme(O._currentTheme,{manual:!1})}if(!document.getElementById("app-global-styles")){let _=document.createElement("style");_.id="app-global-styles",_.textContent=`
|
|
238
235
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
239
236
|
html, body { width: 100%; min-height: 100%; }
|
|
240
237
|
body { font-family: Arial, sans-serif; overflow-x: hidden; }
|
|
241
|
-
`,document.head.appendChild(
|
|
238
|
+
`,document.head.appendChild(_)}}var ae=O.Activity;var ne=O;return te(re);})();
|
package/dist/zum.mjs
CHANGED
|
@@ -454,23 +454,41 @@ var _Zum = class _Zum {
|
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
// ═══ AUTO-CONTRAST ═══
|
|
457
|
+
static _shouldSkipAutoContrast(el) {
|
|
458
|
+
if (!el || el.nodeType !== Node.ELEMENT_NODE || !el.matches) return true;
|
|
459
|
+
const skipTags = "input, textarea, select, option, button, a, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
460
|
+
if (el.matches(skipTags)) return true;
|
|
461
|
+
if (el.hasAttribute("data-no-auto-contrast") || el.classList.contains("no-auto-contrast") || el.classList.contains("zum-keep-color")) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
if (el.style && el.style.color && el.dataset.contrastApplied !== "true") {
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
static _hasDirectText(el) {
|
|
470
|
+
return Array.from(el.childNodes).some(
|
|
471
|
+
(node) => node.nodeType === Node.TEXT_NODE && node.textContent && node.textContent.trim().length > 0
|
|
472
|
+
);
|
|
473
|
+
}
|
|
457
474
|
static _initAutoContrast() {
|
|
458
475
|
if (_Zum._contrastInitialized) return;
|
|
459
476
|
if (!hasDOM()) return;
|
|
477
|
+
if (!_Zum.themeSettings.autoContrast) {
|
|
478
|
+
_Zum._contrastInitialized = true;
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
460
481
|
const styleEl = document.createElement("style");
|
|
461
482
|
styleEl.setAttribute("data-Zum-contrast", "true");
|
|
462
483
|
styleEl.textContent = `
|
|
463
|
-
.zum-contrast
|
|
464
|
-
.zum-contrast-text { transition: color 0.3s ease-in-out !important; }
|
|
465
|
-
@media (prefers-color-scheme: dark) { .zum-contrast-text { color: #f1f5f9 !important; } }
|
|
466
|
-
@media (prefers-color-scheme: light) { .zum-contrast-text { color: #0f172a !important; } }
|
|
484
|
+
.zum-contrast-text { transition: color 0.25s ease-in-out; }
|
|
467
485
|
`;
|
|
468
486
|
document.head.appendChild(styleEl);
|
|
469
487
|
const mutationObserver = new MutationObserver((mutations) => {
|
|
470
488
|
mutations.forEach((mutation) => {
|
|
471
489
|
if (mutation.addedNodes) {
|
|
472
490
|
mutation.addedNodes.forEach((node) => {
|
|
473
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
491
|
+
if (node.nodeType === Node.ELEMENT_NODE && !_Zum._contrastProcessing.has(node)) {
|
|
474
492
|
setTimeout(() => _Zum._applyContrastToElement(node), 50);
|
|
475
493
|
}
|
|
476
494
|
});
|
|
@@ -480,13 +498,14 @@ var _Zum = class _Zum {
|
|
|
480
498
|
if (document.body) {
|
|
481
499
|
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
482
500
|
}
|
|
501
|
+
const runInitial = () => setTimeout(() => _Zum._applyContrastToAll(), 100);
|
|
483
502
|
if (document.readyState === "loading") {
|
|
484
|
-
document.addEventListener("DOMContentLoaded",
|
|
503
|
+
document.addEventListener("DOMContentLoaded", runInitial);
|
|
485
504
|
} else {
|
|
486
|
-
|
|
505
|
+
runInitial();
|
|
487
506
|
}
|
|
488
507
|
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
489
|
-
const onSystemChange = () => setTimeout(() => _Zum.
|
|
508
|
+
const onSystemChange = () => setTimeout(() => _Zum.refreshContrast(), 50);
|
|
490
509
|
if (darkModeMediaQuery.addEventListener) {
|
|
491
510
|
darkModeMediaQuery.addEventListener("change", onSystemChange);
|
|
492
511
|
} else if (darkModeMediaQuery.addListener) {
|
|
@@ -496,40 +515,62 @@ var _Zum = class _Zum {
|
|
|
496
515
|
zlog("\u2705 Auto-contrast system initialized");
|
|
497
516
|
}
|
|
498
517
|
static _getRealBackground(el) {
|
|
518
|
+
var _a;
|
|
499
519
|
let current = el;
|
|
500
520
|
let attempts = 0;
|
|
501
521
|
while (current && attempts < 30) {
|
|
502
522
|
const bg = getComputedStyle(current).backgroundColor;
|
|
503
|
-
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent" && bg !== "")
|
|
504
|
-
|
|
523
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent" && bg !== "") {
|
|
524
|
+
const match = bg.match(/rgba?\(([^)]+)\)/);
|
|
525
|
+
if (match) {
|
|
526
|
+
const parts = match[1].split(",").map((v) => parseFloat(v.trim()));
|
|
527
|
+
const alpha = parts.length === 4 ? parts[3] : 1;
|
|
528
|
+
if (alpha > 0.05) return bg;
|
|
529
|
+
} else {
|
|
530
|
+
return bg;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
505
533
|
if (current.parentElement) current = current.parentElement;
|
|
506
534
|
else if (current.parentNode && current.parentNode.host) current = current.parentNode.host;
|
|
507
535
|
else current = null;
|
|
508
536
|
attempts++;
|
|
509
537
|
}
|
|
510
538
|
const theme = _Zum.getTheme();
|
|
511
|
-
return theme ? theme.colors.background
|
|
539
|
+
return ((_a = theme == null ? void 0 : theme.colors) == null ? void 0 : _a.background) || "#ffffff";
|
|
540
|
+
}
|
|
541
|
+
static _processContrastNode(el) {
|
|
542
|
+
var _a, _b, _c, _d, _e, _f;
|
|
543
|
+
if (_Zum._shouldSkipAutoContrast(el)) return;
|
|
544
|
+
if (!_Zum._hasDirectText(el)) return;
|
|
545
|
+
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastApplied === "true") return;
|
|
546
|
+
const bg = _Zum._getRealBackground(el);
|
|
547
|
+
const currentColor = getComputedStyle(el).color;
|
|
548
|
+
const minRatio = (_b = (_a = _Zum.themeSettings) == null ? void 0 : _a.minContrastRatio) != null ? _b : 3;
|
|
549
|
+
if (currentColor && el.dataset.contrastApplied !== "true") {
|
|
550
|
+
const existingRatio = _Zum.getContrastRatio(currentColor, bg);
|
|
551
|
+
if (existingRatio >= minRatio) {
|
|
552
|
+
_Zum._contrastProcessed.add(el);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const lum = _Zum._calculateLuminance(bg);
|
|
557
|
+
const threshold = (_d = (_c = _Zum.themeSettings) == null ? void 0 : _c.contrastThreshold) != null ? _d : 0.5;
|
|
558
|
+
const theme = _Zum.getTheme();
|
|
559
|
+
const darkText = ((_e = theme == null ? void 0 : theme.colors) == null ? void 0 : _e.text) && _Zum._calculateLuminance(theme.colors.text) < 0.3 ? theme.colors.text : "#0f172a";
|
|
560
|
+
const lightText = ((_f = theme == null ? void 0 : theme.colors) == null ? void 0 : _f.text) && _Zum._calculateLuminance(theme.colors.text) > 0.7 ? theme.colors.text : "#f1f5f9";
|
|
561
|
+
const color = lum > threshold ? darkText : lightText;
|
|
562
|
+
el.style.color = color;
|
|
563
|
+
el.dataset.contrastColor = color;
|
|
564
|
+
el.dataset.contrastApplied = "true";
|
|
565
|
+
el.classList.add("zum-contrast-text");
|
|
566
|
+
_Zum._contrastProcessed.add(el);
|
|
512
567
|
}
|
|
513
568
|
static _applyContrastToAll() {
|
|
514
|
-
if (!hasDOM() || !document.body) return;
|
|
515
|
-
const skip = "input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
516
|
-
const process2 = (el) => {
|
|
517
|
-
if (!el || !el.matches) return;
|
|
518
|
-
if (el.matches(skip)) return;
|
|
519
|
-
if (!el.textContent || !el.textContent.trim()) return;
|
|
520
|
-
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastColor) return;
|
|
521
|
-
const bg = _Zum._getRealBackground(el);
|
|
522
|
-
const lum = _Zum._calculateLuminance(bg);
|
|
523
|
-
const color = lum > 0.5 ? "#0f172a" : "#f1f5f9";
|
|
524
|
-
el.style.setProperty("color", color, "important");
|
|
525
|
-
el.dataset.contrastColor = color;
|
|
526
|
-
el.classList.add("zum-contrast-text");
|
|
527
|
-
_Zum._contrastProcessed.add(el);
|
|
528
|
-
};
|
|
569
|
+
if (!hasDOM() || !document.body || !_Zum.themeSettings.autoContrast) return;
|
|
529
570
|
const walk = (root) => {
|
|
530
571
|
if (!root || !root.querySelectorAll) return;
|
|
531
572
|
root.querySelectorAll("*").forEach((el) => {
|
|
532
|
-
|
|
573
|
+
_Zum._processContrastNode(el);
|
|
533
574
|
if (el.shadowRoot) walk(el.shadowRoot);
|
|
534
575
|
});
|
|
535
576
|
};
|
|
@@ -537,32 +578,17 @@ var _Zum = class _Zum {
|
|
|
537
578
|
zlog("\u2705 Contrast applied to all elements");
|
|
538
579
|
}
|
|
539
580
|
static _applyContrastToElement(element) {
|
|
540
|
-
if (!element || !hasDOM()) return;
|
|
541
|
-
const skip = "input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr";
|
|
542
|
-
const process2 = (el) => {
|
|
543
|
-
if (!el || !el.matches) return;
|
|
544
|
-
if (el.matches(skip)) return;
|
|
545
|
-
if (!el.textContent || !el.textContent.trim()) return;
|
|
546
|
-
if (_Zum._contrastProcessed.has(el) && el.dataset.contrastColor) return;
|
|
547
|
-
const bg = _Zum._getRealBackground(el);
|
|
548
|
-
const lum = _Zum._calculateLuminance(bg);
|
|
549
|
-
const color = lum > 0.5 ? "#0f172a" : "#f1f5f9";
|
|
550
|
-
el.style.setProperty("color", color, "important");
|
|
551
|
-
el.dataset.contrastColor = color;
|
|
552
|
-
el.classList.add("zum-contrast-text");
|
|
553
|
-
_Zum._contrastProcessed.add(el);
|
|
554
|
-
};
|
|
581
|
+
if (!element || !hasDOM() || !_Zum.themeSettings.autoContrast) return;
|
|
555
582
|
_Zum._contrastProcessing.add(element);
|
|
556
|
-
|
|
583
|
+
_Zum._processContrastNode(element);
|
|
557
584
|
const walk = (root) => {
|
|
558
585
|
if (!root || !root.querySelectorAll) return;
|
|
559
586
|
root.querySelectorAll("*").forEach((el) => {
|
|
560
|
-
|
|
587
|
+
_Zum._processContrastNode(el);
|
|
561
588
|
if (el.shadowRoot) walk(el.shadowRoot);
|
|
562
589
|
});
|
|
563
590
|
};
|
|
564
591
|
walk(element);
|
|
565
|
-
element.classList.add("zum-contrast");
|
|
566
592
|
setTimeout(() => _Zum._contrastProcessing.delete(element), 250);
|
|
567
593
|
}
|
|
568
594
|
static _resolveColorToRgb(color) {
|
|
@@ -624,6 +650,7 @@ var _Zum = class _Zum {
|
|
|
624
650
|
if (!el) return;
|
|
625
651
|
_Zum._contrastProcessed.delete(el);
|
|
626
652
|
delete el.dataset.contrastColor;
|
|
653
|
+
delete el.dataset.contrastApplied;
|
|
627
654
|
_Zum._applyContrastToElement(el);
|
|
628
655
|
}
|
|
629
656
|
static refreshContrast() {
|
|
@@ -633,6 +660,10 @@ var _Zum = class _Zum {
|
|
|
633
660
|
root.querySelectorAll("*").forEach((el) => {
|
|
634
661
|
_Zum._contrastProcessed.delete(el);
|
|
635
662
|
delete el.dataset.contrastColor;
|
|
663
|
+
if (el.dataset.contrastApplied === "true") {
|
|
664
|
+
el.style.removeProperty("color");
|
|
665
|
+
delete el.dataset.contrastApplied;
|
|
666
|
+
}
|
|
636
667
|
if (el.shadowRoot) reset(el.shadowRoot);
|
|
637
668
|
});
|
|
638
669
|
};
|
|
@@ -2373,9 +2404,6 @@ ${comp.css}`);
|
|
|
2373
2404
|
const manualOverride = localStorage.getItem(_Zum.themeSettings.systemPreferenceKey);
|
|
2374
2405
|
if (!manualOverride) {
|
|
2375
2406
|
const newTheme = e.matches ? "dark" : "light";
|
|
2376
|
-
document.querySelectorAll("*").forEach((el) => {
|
|
2377
|
-
el._zumContrastApplied = false;
|
|
2378
|
-
});
|
|
2379
2407
|
_Zum.applyTheme(newTheme, { manual: false, smooth: true, duration: 400 });
|
|
2380
2408
|
setTimeout(() => _Zum.refreshContrast(), 500);
|
|
2381
2409
|
zlog(`\u{1F504} Auto-switched to ${newTheme} theme (system preference)`);
|
|
@@ -2429,10 +2457,7 @@ ${comp.css}`);
|
|
|
2429
2457
|
_Zum._notifyThemeObservers(themeId);
|
|
2430
2458
|
if (updateContrast && _Zum.themeSettings.autoContrast) {
|
|
2431
2459
|
setTimeout(() => {
|
|
2432
|
-
|
|
2433
|
-
el._zumContrastApplied = false;
|
|
2434
|
-
});
|
|
2435
|
-
_Zum._applyContrastToAll();
|
|
2460
|
+
_Zum.refreshContrast();
|
|
2436
2461
|
}, smooth ? duration + 50 : 50);
|
|
2437
2462
|
}
|
|
2438
2463
|
zlog(`\u2705 Theme applied: ${themeId} (${theme.name})`);
|
|
@@ -3050,7 +3075,8 @@ __publicField(_Zum, "themeSettings", {
|
|
|
3050
3075
|
transitionDuration: 400,
|
|
3051
3076
|
transitionEasing: "ease-in-out",
|
|
3052
3077
|
autoContrast: true,
|
|
3053
|
-
contrastThreshold: 0.5
|
|
3078
|
+
contrastThreshold: 0.5,
|
|
3079
|
+
minContrastRatio: 3
|
|
3054
3080
|
});
|
|
3055
3081
|
__publicField(_Zum, "THEMES", {
|
|
3056
3082
|
light: {
|
|
@@ -3558,9 +3584,6 @@ if (hasDOM()) {
|
|
|
3558
3584
|
const onSystemChange = (e) => {
|
|
3559
3585
|
if (localStorage.getItem(Zum.themeSettings.systemPreferenceKey)) return;
|
|
3560
3586
|
const newTheme = e.matches ? "dark" : "light";
|
|
3561
|
-
document.querySelectorAll("*").forEach((el) => {
|
|
3562
|
-
el._zumContrastApplied = false;
|
|
3563
|
-
});
|
|
3564
3587
|
Zum.applyTheme(newTheme, { manual: false, smooth: true, duration: 400 });
|
|
3565
3588
|
setTimeout(() => Zum.refreshContrast(), 500);
|
|
3566
3589
|
zlog(`\u{1F504} Auto-switched to ${newTheme} (system preference)`);
|