customer-chat-sdk 1.1.13 → 1.1.16
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconManager.d.ts","sourceRoot":"","sources":["../../src/core/IconManager.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,YAAY;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,oBAAoB,CAAqC;IACjE,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAoC;IAGlD,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,uBAAuB,CAAI;IACnC,OAAO,CAAC,uBAAuB,CAAM;IAGrC,OAAO,CAAC,aAAa,CAA2D;IAChF,OAAO,CAAC,oBAAoB,CAAI;IAChC,OAAO,CAAC,oBAAoB,CAAK;IAGjC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,eAAe,CAAqC;IAG5D,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,iBAAiB,CAA+B;IAGxD,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,eAAe,CAAsD;IAC7E,OAAO,CAAC,gBAAgB,CAAsD;IAC9E,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,mBAAmB,CAA2C;IACtE,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,cAAc,CAAiB;IAGvC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,eAAe,CAAsB;gBAG3C,QAAQ,CAAC,EAAE,YAAY,EACvB,KAAK,GAAE,OAAe,EACtB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,EAC7B,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,iBAAiB,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAA;QACtC,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,eAAe,CAAC,EAAE,MAAM,CAAA;KACzB;IAmBH;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"IconManager.d.ts","sourceRoot":"","sources":["../../src/core/IconManager.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,YAAY;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,oBAAoB,CAAqC;IACjE,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAoC;IAGlD,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,uBAAuB,CAAI;IACnC,OAAO,CAAC,uBAAuB,CAAM;IAGrC,OAAO,CAAC,aAAa,CAA2D;IAChF,OAAO,CAAC,oBAAoB,CAAI;IAChC,OAAO,CAAC,oBAAoB,CAAK;IAGjC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,eAAe,CAAqC;IAG5D,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,iBAAiB,CAA+B;IAGxD,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,eAAe,CAAsD;IAC7E,OAAO,CAAC,gBAAgB,CAAsD;IAC9E,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,mBAAmB,CAA2C;IACtE,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,cAAc,CAAiB;IAGvC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,eAAe,CAAsB;gBAG3C,QAAQ,CAAC,EAAE,YAAY,EACvB,KAAK,GAAE,OAAe,EACtB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,EAC7B,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,iBAAiB,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAA;QACtC,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,eAAe,CAAC,EAAE,MAAM,CAAA;KACzB;IAmBH;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsQ3B;;OAEG;IACH,sBAAsB,IAAI,IAAI;IAI9B;;OAEG;IACH,IAAI,IAAI,IAAI;IAuCZ;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAIhC;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAqB7C;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAI1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAsB5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAwExB;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAInC;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAInD;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IA8BpD;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAUzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,SAAS;IAmNjB;;OAEG;IACH,OAAO,CAAC,MAAM;IA4Od;;OAEG;IACH,OAAO,CAAC,QAAQ;IAmHhB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA+F5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8EzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAcnB;;OAEG;IACH,YAAY,IAAI,IAAI;IAmBpB;;OAEG;IACH,WAAW,IAAI,IAAI;IAmBnB;;OAEG;IACH,OAAO,CAAC,YAAY;IAyIpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqCxB;;OAEG;IACH,OAAO,CAAC,WAAW;CAmDpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../src/core/IframeManager.ts"],"names":[],"mappings":"AACA,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAA;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC7B,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;IACpD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,gBAAgB,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,cAAc,CAA+C;gBAEzD,MAAM,GAAE,aAAkB;IAetC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC3B;;OAEG;IACH,IAAI,IAAI,IAAI;IA2CZ;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,IAAI,IAAI,IAAI;IA6BZ;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,OAAO,IAAI,IAAI;IAsBf;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAM7B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACH,OAAO,CAAC,YAAY;IAuLpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA8D1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoCzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../src/core/IframeManager.ts"],"names":[],"mappings":"AACA,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAA;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC7B,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;IACpD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,gBAAgB,CAA2B;IACnD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,cAAc,CAA+C;gBAEzD,MAAM,GAAE,aAAkB;IAetC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC3B;;OAEG;IACH,IAAI,IAAI,IAAI;IA2CZ;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,IAAI,IAAI,IAAI;IA6BZ;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,OAAO,IAAI,IAAI;IAsBf;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAM7B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACH,OAAO,CAAC,YAAY;IAuLpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA8D1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoCzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+E3B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IA2B9B;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CA0BzB"}
|
package/dist/customer-sdk.cjs.js
CHANGED
|
@@ -204,6 +204,36 @@ class IconManager {
|
|
|
204
204
|
this.iconElement.appendChild(imgContainer);
|
|
205
205
|
// 添加到目标元素(如果 target 是字符串,需要重新查找,因为可能在初始化时元素还不存在)
|
|
206
206
|
const targetElement = this.getTargetElement();
|
|
207
|
+
// 确保目标容器有 overflow-x: hidden,防止图标超出边界时出现横向滚动条
|
|
208
|
+
// 注意:只在启用侧边吸附时才设置,避免影响其他场景
|
|
209
|
+
if (this.sideAttach && targetElement !== document.body) {
|
|
210
|
+
const computedStyle = window.getComputedStyle(targetElement);
|
|
211
|
+
const currentOverflowX = computedStyle.overflowX;
|
|
212
|
+
const currentOverflowY = computedStyle.overflowY;
|
|
213
|
+
// 如果当前 overflow-x 不是 hidden,设置 overflow-x: hidden
|
|
214
|
+
// 同时设置 overflow-y: hidden 或 auto,避免纵向滚动条
|
|
215
|
+
if (currentOverflowX !== 'hidden') {
|
|
216
|
+
// 保存原始 overflow 值(如果还没有保存)
|
|
217
|
+
if (!targetElement.dataset.originalOverflowX) {
|
|
218
|
+
targetElement.dataset.originalOverflowX = currentOverflowX || 'visible';
|
|
219
|
+
targetElement.dataset.originalOverflowY = currentOverflowY || 'visible';
|
|
220
|
+
}
|
|
221
|
+
// 设置 overflow-x: hidden,防止横向滚动条
|
|
222
|
+
targetElement.style.overflowX = 'hidden';
|
|
223
|
+
// 如果当前 overflow-y 是 visible,设置为 auto,避免纵向滚动条
|
|
224
|
+
// 如果已经是 auto 或 scroll,保持不变
|
|
225
|
+
if (currentOverflowY === 'visible') {
|
|
226
|
+
targetElement.style.overflowY = 'auto';
|
|
227
|
+
}
|
|
228
|
+
if (this.debug) {
|
|
229
|
+
console.log('[IconManager] Set overflow-x: hidden on target container', {
|
|
230
|
+
target: this.target,
|
|
231
|
+
originalOverflowX: currentOverflowX,
|
|
232
|
+
originalOverflowY: currentOverflowY
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
207
237
|
if (targetElement) {
|
|
208
238
|
targetElement.appendChild(this.iconElement);
|
|
209
239
|
}
|
|
@@ -1713,7 +1743,7 @@ class IframeManager {
|
|
|
1713
1743
|
maxWidth: '100%', // 不超过 target 的宽度
|
|
1714
1744
|
maxHeight: '100%',
|
|
1715
1745
|
backgroundColor: '#ffffff',
|
|
1716
|
-
borderRadius: isPC ? '0' : '
|
|
1746
|
+
borderRadius: isPC ? '0' : '0',
|
|
1717
1747
|
boxShadow: isPC ? 'none' : '0 -4px 16px rgba(0, 0, 0, 0.25)',
|
|
1718
1748
|
border: 'none',
|
|
1719
1749
|
position: 'absolute', // 相对于 target 元素定位
|
|
@@ -1759,7 +1789,7 @@ class IframeManager {
|
|
|
1759
1789
|
maxWidth: '100%',
|
|
1760
1790
|
maxHeight: '100%',
|
|
1761
1791
|
backgroundColor: '#ffffff',
|
|
1762
|
-
borderRadius: '
|
|
1792
|
+
borderRadius: '0',
|
|
1763
1793
|
boxShadow: '0 -4px 16px rgba(0, 0, 0, 0.25)',
|
|
1764
1794
|
border: 'none',
|
|
1765
1795
|
position: 'fixed',
|
|
@@ -2003,11 +2033,64 @@ class IframeManager {
|
|
|
2003
2033
|
this.config.onMessage(messageType, data);
|
|
2004
2034
|
}
|
|
2005
2035
|
break;
|
|
2006
|
-
|
|
2007
|
-
//
|
|
2036
|
+
case 'goto-login':
|
|
2037
|
+
// 登录跳转消息 - 通过 window.postMessage 抛出给外层
|
|
2008
2038
|
if (this.debug) {
|
|
2009
|
-
console.log('
|
|
2039
|
+
console.log('Received goto-login message, forwarding to parent window');
|
|
2040
|
+
}
|
|
2041
|
+
this.forwardMessageToParent(data);
|
|
2042
|
+
if (this.config.onMessage) {
|
|
2043
|
+
this.config.onMessage(messageType, data);
|
|
2044
|
+
}
|
|
2045
|
+
break;
|
|
2046
|
+
default:
|
|
2047
|
+
// 处理动态消息:gotoActivityDetailById:xxx
|
|
2048
|
+
if (typeof messageType === 'string' && messageType.startsWith('gotoActivityDetailById:')) {
|
|
2049
|
+
// 活动详情跳转消息 - 通过 window.postMessage 抛出给外层
|
|
2050
|
+
if (this.debug) {
|
|
2051
|
+
console.log('Received gotoActivityDetailById message, forwarding to parent window:', messageType);
|
|
2052
|
+
}
|
|
2053
|
+
this.forwardMessageToParent(data);
|
|
2054
|
+
if (this.config.onMessage) {
|
|
2055
|
+
this.config.onMessage(messageType, data);
|
|
2056
|
+
}
|
|
2010
2057
|
}
|
|
2058
|
+
else {
|
|
2059
|
+
// 其他自定义消息处理
|
|
2060
|
+
if (this.debug) {
|
|
2061
|
+
console.log('Custom message:', data);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* 将消息转发给父窗口(通过 window.postMessage)
|
|
2069
|
+
* 这样 Vue 页面中的监听器也能收到消息
|
|
2070
|
+
*/
|
|
2071
|
+
forwardMessageToParent(data) {
|
|
2072
|
+
try {
|
|
2073
|
+
// 方式1:使用 window.postMessage 发送消息(跨窗口通信)
|
|
2074
|
+
// 如果存在父窗口且不是当前窗口,发送给父窗口
|
|
2075
|
+
if (window.parent && window.parent !== window) {
|
|
2076
|
+
window.parent.postMessage(data, '*');
|
|
2077
|
+
}
|
|
2078
|
+
// 方式2:使用 dispatchEvent 创建 MessageEvent(在同一窗口内触发所有监听器)
|
|
2079
|
+
// 这样 Vue 页面中的 window.addEventListener('message') 也能收到
|
|
2080
|
+
const messageEvent = new MessageEvent('message', {
|
|
2081
|
+
data: data,
|
|
2082
|
+
origin: window.location.origin,
|
|
2083
|
+
source: window
|
|
2084
|
+
});
|
|
2085
|
+
window.dispatchEvent(messageEvent);
|
|
2086
|
+
if (this.debug) {
|
|
2087
|
+
console.log('Message forwarded via window.postMessage and dispatchEvent:', data);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
catch (error) {
|
|
2091
|
+
if (this.debug) {
|
|
2092
|
+
console.error('Failed to forward message:', error);
|
|
2093
|
+
}
|
|
2011
2094
|
}
|
|
2012
2095
|
}
|
|
2013
2096
|
/**
|
package/dist/customer-sdk.esm.js
CHANGED
|
@@ -200,6 +200,36 @@ class IconManager {
|
|
|
200
200
|
this.iconElement.appendChild(imgContainer);
|
|
201
201
|
// 添加到目标元素(如果 target 是字符串,需要重新查找,因为可能在初始化时元素还不存在)
|
|
202
202
|
const targetElement = this.getTargetElement();
|
|
203
|
+
// 确保目标容器有 overflow-x: hidden,防止图标超出边界时出现横向滚动条
|
|
204
|
+
// 注意:只在启用侧边吸附时才设置,避免影响其他场景
|
|
205
|
+
if (this.sideAttach && targetElement !== document.body) {
|
|
206
|
+
const computedStyle = window.getComputedStyle(targetElement);
|
|
207
|
+
const currentOverflowX = computedStyle.overflowX;
|
|
208
|
+
const currentOverflowY = computedStyle.overflowY;
|
|
209
|
+
// 如果当前 overflow-x 不是 hidden,设置 overflow-x: hidden
|
|
210
|
+
// 同时设置 overflow-y: hidden 或 auto,避免纵向滚动条
|
|
211
|
+
if (currentOverflowX !== 'hidden') {
|
|
212
|
+
// 保存原始 overflow 值(如果还没有保存)
|
|
213
|
+
if (!targetElement.dataset.originalOverflowX) {
|
|
214
|
+
targetElement.dataset.originalOverflowX = currentOverflowX || 'visible';
|
|
215
|
+
targetElement.dataset.originalOverflowY = currentOverflowY || 'visible';
|
|
216
|
+
}
|
|
217
|
+
// 设置 overflow-x: hidden,防止横向滚动条
|
|
218
|
+
targetElement.style.overflowX = 'hidden';
|
|
219
|
+
// 如果当前 overflow-y 是 visible,设置为 auto,避免纵向滚动条
|
|
220
|
+
// 如果已经是 auto 或 scroll,保持不变
|
|
221
|
+
if (currentOverflowY === 'visible') {
|
|
222
|
+
targetElement.style.overflowY = 'auto';
|
|
223
|
+
}
|
|
224
|
+
if (this.debug) {
|
|
225
|
+
console.log('[IconManager] Set overflow-x: hidden on target container', {
|
|
226
|
+
target: this.target,
|
|
227
|
+
originalOverflowX: currentOverflowX,
|
|
228
|
+
originalOverflowY: currentOverflowY
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
203
233
|
if (targetElement) {
|
|
204
234
|
targetElement.appendChild(this.iconElement);
|
|
205
235
|
}
|
|
@@ -1709,7 +1739,7 @@ class IframeManager {
|
|
|
1709
1739
|
maxWidth: '100%', // 不超过 target 的宽度
|
|
1710
1740
|
maxHeight: '100%',
|
|
1711
1741
|
backgroundColor: '#ffffff',
|
|
1712
|
-
borderRadius: isPC ? '0' : '
|
|
1742
|
+
borderRadius: isPC ? '0' : '0',
|
|
1713
1743
|
boxShadow: isPC ? 'none' : '0 -4px 16px rgba(0, 0, 0, 0.25)',
|
|
1714
1744
|
border: 'none',
|
|
1715
1745
|
position: 'absolute', // 相对于 target 元素定位
|
|
@@ -1755,7 +1785,7 @@ class IframeManager {
|
|
|
1755
1785
|
maxWidth: '100%',
|
|
1756
1786
|
maxHeight: '100%',
|
|
1757
1787
|
backgroundColor: '#ffffff',
|
|
1758
|
-
borderRadius: '
|
|
1788
|
+
borderRadius: '0',
|
|
1759
1789
|
boxShadow: '0 -4px 16px rgba(0, 0, 0, 0.25)',
|
|
1760
1790
|
border: 'none',
|
|
1761
1791
|
position: 'fixed',
|
|
@@ -1999,11 +2029,64 @@ class IframeManager {
|
|
|
1999
2029
|
this.config.onMessage(messageType, data);
|
|
2000
2030
|
}
|
|
2001
2031
|
break;
|
|
2002
|
-
|
|
2003
|
-
//
|
|
2032
|
+
case 'goto-login':
|
|
2033
|
+
// 登录跳转消息 - 通过 window.postMessage 抛出给外层
|
|
2004
2034
|
if (this.debug) {
|
|
2005
|
-
console.log('
|
|
2035
|
+
console.log('Received goto-login message, forwarding to parent window');
|
|
2036
|
+
}
|
|
2037
|
+
this.forwardMessageToParent(data);
|
|
2038
|
+
if (this.config.onMessage) {
|
|
2039
|
+
this.config.onMessage(messageType, data);
|
|
2040
|
+
}
|
|
2041
|
+
break;
|
|
2042
|
+
default:
|
|
2043
|
+
// 处理动态消息:gotoActivityDetailById:xxx
|
|
2044
|
+
if (typeof messageType === 'string' && messageType.startsWith('gotoActivityDetailById:')) {
|
|
2045
|
+
// 活动详情跳转消息 - 通过 window.postMessage 抛出给外层
|
|
2046
|
+
if (this.debug) {
|
|
2047
|
+
console.log('Received gotoActivityDetailById message, forwarding to parent window:', messageType);
|
|
2048
|
+
}
|
|
2049
|
+
this.forwardMessageToParent(data);
|
|
2050
|
+
if (this.config.onMessage) {
|
|
2051
|
+
this.config.onMessage(messageType, data);
|
|
2052
|
+
}
|
|
2006
2053
|
}
|
|
2054
|
+
else {
|
|
2055
|
+
// 其他自定义消息处理
|
|
2056
|
+
if (this.debug) {
|
|
2057
|
+
console.log('Custom message:', data);
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
break;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* 将消息转发给父窗口(通过 window.postMessage)
|
|
2065
|
+
* 这样 Vue 页面中的监听器也能收到消息
|
|
2066
|
+
*/
|
|
2067
|
+
forwardMessageToParent(data) {
|
|
2068
|
+
try {
|
|
2069
|
+
// 方式1:使用 window.postMessage 发送消息(跨窗口通信)
|
|
2070
|
+
// 如果存在父窗口且不是当前窗口,发送给父窗口
|
|
2071
|
+
if (window.parent && window.parent !== window) {
|
|
2072
|
+
window.parent.postMessage(data, '*');
|
|
2073
|
+
}
|
|
2074
|
+
// 方式2:使用 dispatchEvent 创建 MessageEvent(在同一窗口内触发所有监听器)
|
|
2075
|
+
// 这样 Vue 页面中的 window.addEventListener('message') 也能收到
|
|
2076
|
+
const messageEvent = new MessageEvent('message', {
|
|
2077
|
+
data: data,
|
|
2078
|
+
origin: window.location.origin,
|
|
2079
|
+
source: window
|
|
2080
|
+
});
|
|
2081
|
+
window.dispatchEvent(messageEvent);
|
|
2082
|
+
if (this.debug) {
|
|
2083
|
+
console.log('Message forwarded via window.postMessage and dispatchEvent:', data);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
catch (error) {
|
|
2087
|
+
if (this.debug) {
|
|
2088
|
+
console.error('Failed to forward message:', error);
|
|
2089
|
+
}
|
|
2007
2090
|
}
|
|
2008
2091
|
}
|
|
2009
2092
|
/**
|
package/dist/customer-sdk.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((A="undefined"!=typeof globalThis?globalThis:A||self).CustomerSDK={})}(this,function(A){"use strict";class e{constructor(A,e=!1,t,n){this.iconElement=null,this.badgeElement=null,this.onClickCallback=null,this.notificationCallback=null,this.iconPosition=null,this.debug=!1,this.isClickEnabled=!0,this.target=null,this.isDragging=!1,this.dragStarted=!1,this.hasMoved=!1,this.dragOffset={x:0,y:0},this.lastTouchPosition={x:0,y:0},this.touchStartTime=0,this.clickThreshold=15,this.cachedContainer=null,this.cachedContainerRect=null,this.cachedIconSize={width:0,height:0},this.lastContainerUpdateTime=0,this.containerUpdateInterval=100,this.cachedIframes=[],this.lastIframeUpdateTime=0,this.iframeUpdateInterval=16,this.rafId=null,this.pendingPosition={x:0,y:0,needsUpdate:!1},this.activeDetectionRafId=null,this.lastMousePosition={x:0,y:0,timestamp:0},this.onDragHandler=null,this.stopDragHandler=null,this.startDragHandler=null,this.mouseLeaveHandler=null,this.pointerLeaveHandler=null,this.blurHandler=null,this.dragTimeoutId=null,this.mouseLeaveTimeout=null,this.pointerLeaveTimeout=null,this.isStoppingDrag=!1,this.sideAttach=!0,this.sideHideRatio=.5,this.magnetic=!0,this.magneticDirection="x",this.margin=10,this.isAttachedToSide=!1,this.attachedSide="",this.autoAttachDelay=3e3,this.autoAttachTimer=null,this.iconPosition=A||null,this.debug=e,this.target=t||null,n&&(this.sideAttach=void 0===n.sideAttach||n.sideAttach,this.sideHideRatio=void 0!==n.sideHideRatio?n.sideHideRatio:.5,this.magnetic=void 0===n.magnetic||n.magnetic,this.magneticDirection=n.magneticDirection||"x",this.margin=void 0!==n.margin?n.margin:10,this.autoAttachDelay=void 0!==n.autoAttachDelay?n.autoAttachDelay:3e3)}async show(){if(this.iconElement)return;this.iconElement=document.createElement("div"),this.iconElement.className="customer-sdk-icon";const A={position:"absolute",width:"30px",height:"30px",backgroundColor:"transparent",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:"1000002",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",userSelect:"none",transition:"transform 0.2s ease",border:"none",outline:"none",overflow:"visible"};if(this.iconPosition)void 0!==this.iconPosition.x?(A.left="number"==typeof this.iconPosition.x?`${this.iconPosition.x}px`:this.iconPosition.x,A.right="auto"):A.right="20px",void 0!==this.iconPosition.y?(A.top="number"==typeof this.iconPosition.y?`${this.iconPosition.y}px`:this.iconPosition.y,A.bottom="auto"):A.bottom="80px";else if(this.sideAttach&&this.magnetic){const e=30*this.sideHideRatio;A.right=`-${e}px`,A.left="auto",A.bottom="80px",A.transform="translateX(0)",this.isAttachedToSide=!0,this.attachedSide="right"}else A.bottom="80px",A.right="20px";if(this.sideAttach&&this.isAttachedToSide&&this.attachedSide){const e=30*this.sideHideRatio;"left"===this.attachedSide?(A.left=`-${e}px`,A.right="auto",A.transform="translateX(0)"):"right"===this.attachedSide&&(A.right=`-${e}px`,A.left="auto",A.transform="translateX(0)")}Object.assign(this.iconElement.style,A);const e=document.createElement("img");e.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAArKSURBVHgB7Z1NbFTXFcf/93mwaGyEabLoIgFTqWRFMZUitSoIu80ial01SFWrKgsGKXYpWdRtFilRK4xUgbKICosmCKIySKCo2UAE6i61XVroDuOoi2YT02RZVFNwQTAzN+e8N88ej9+8j5n3ce5wf5JhPvyY4f3f/9xzz73vXoUeYKish6oljCiFYQ2MaAebVR3D/Jzf1xpDUPTTggIW6feXoOlH0Q9wS9exRK/Pl6qYX6qoJRiOgoEMvqpHWUjlYJ9iQeEJmTb07y6y2CT6HP99/z01C8MwQmB26OMSyuTIH9LTkSA35oLn9FmKCB/WHmP2YUUtQjhiBV4jqsIoJKJJbOC8ZLHFCczhl75UWXvCFuPUDiBXV5TGeWlhXIzALCx9m6Ni3RqfeRL71PJZVYEAChfYdayDc1klSkXBCRr9caxooQsTuIccG4qbiddxsKjQnbvAlDwNVzfgXK8L2wq30ZSMHcs7GctV4IFX9ZTyXGtM8pQq2i2qnCQ3H0NO5CLwk+radnDYrj3CWB5udpAx7FoS96YVdxVy1XCJzgmfG2RMZg5268P9FI6BzP8TRlN3Q/YvkRGZCOyG5H5cApcVLZFkGbJTF3igrEccErfX+rVZk5XIqbbBmyb1y2oDZqy4yfHbZT6HSJHUHDwwqQ/QP1aBpWvIIOXlM+o8UiAVga246ZOWyF0LbMXNjjRE7kpgbi/oS1yCJTNIoP33zqjL6JCOBW5Up24+sWXHvKDyJplojEal5tEBHWXRLG6tHzNW3BxQ7oTBSxvpnKMDOhKYxbVdofxwu1BUW+DqIBKSWODBSf17K24hjFRLbuk3EYkEbhTHbW25KBxMJR2giJ1k2aRKCJR0VR9jd9ySZmwH26RKCKRBicfWYxJLYGp3j9p2VxA0th43VEeGaBuahRIzVEc6uFbCtBVXIDFDdaiDBw/pUdSp7bXIpY6xsCm5oQ5W9fiNuaUgVHjfuK2DN01ovj/IaIE3PwVs/TL9PEOPv7T2vX/fAe7+H/j4c5hPiItLbQ9SyasmRcOCvvJN4OvPAXueB7Y9He+4a/8CFkjoq1TO/9snMA7tuEbcHvReoINNc++eHcCb48De59E1t+94gp+46rncGNq4OFBg6vfehAEzIl/5FnDkB/GdmpQL1w0SWmP2/lk11vryOoFNyJx3Pgu89eN0HBuHP3zkCc1ttmgCXLwui1ZVlCGYw98Brv82P3GZ174L/P031LY/C9FQs3qg9bU1Dm5MWP8UAuEE6v1D+QobxPErnptFQtWt0mNsb14daI2Daxtk3j+09WnPQUWLy7xJbf6RcciEqlu8rknzS2sEpnT7AITB4v759ewSqU6QLHJjJaLV5/4DieFZorjNSA3XpUfY4ofpFQdLDM/vH5YrLsNO5qRPGs1hekVgGu9N9Z6YbuEQKD1rZVjkrcIuwuYw3dwG74MQ+ITxiTMBN7s/DGmsFKlcgd3ihqAxX253TYIjjahQTVq6qxihIbCuyilLcvlRcrvbDo447GYp6IaLXYGVoPUzjhgSmlthcSW52NfUF3gXBGCqe324pCnFxbqhqcO3Q0iZMckCm4w/Hi0Bvt2FtXWqG2W0v5w5SyhFdsv4boiBV8F3pCRYe3egJ+D/h6AwPewoR0b3yPTw3Mzer0EEvN2BQ/m0CAfzPKpeYY+QpoY3J3Eoj96Mgtn5nKw+ZLdI6QmoOraXoIsP0a1TWoPg6TLv/AW4/R/v9zmZSdJuv/MRsPCZd+xrL8avH/PnXryR7NidQqIRtcHbSkpjiy543feoK54nvX3vbW/Gow+LHWdclgXiYxc+T35su8996yfhRQ1JfXmHVUbBRDmCx11v3wl+fSFi4vobHwT/Dh977ZPOPveNP0VPwJPQ5JB5hzJfTjgNrt5q/x7PYQ7j48/av7cQ8l7U5164gVDiNDuZowwROIwoJy096PzYXkCEwFEnOmzgPyrRGt/V+bGhnxvRFZIyWV6GwA/C33+3HNxOc6ITdaIPv9j5se0+15TZJkxf/zempyhWb0SBbHsG+NEL7d8fooRlfGTV6Tu+4g0rvv4SIknz2Be+CvzqJW/UKAxu2//4V4hAbZrQi0Vn0uySfx5Hz8B3Kf70XRQOLzIuIkT79+r2ClHZeV5QN2nJoXqliLnQ1wy8L7cdgu4xvuuQyrchgKj+rClwJBJ0sZKDNURsY37xH+gJrna06G9GKMw7vHU5BCDsyu+YizcgBl1nB/dhEUI4cQVGw8mipIuUzeuUHspwMMMnx6h1MVo4LuwCLVVJYL4LTUqixRyqwEj4whQVnqkPzNo6jSeiXGxiWyzNvWRadyzME1hjFoL4ecWswsfF67Lcy/iaenc2lOQ4mOFB9uNS18FogUOzxJvA/d7RymSdwQn9X2mryp4uy55Oy1Hm278LnvVRKFTbuH9WbeGHq7VoR5aLmXbTbaTw6w8Eiusx5z9YvcO/hg8hjKAJc1LgPOGCsHbXh5LmlZ3SVgTeUJW5/6AvspQSIH8fyeIytb7VpHlFYHdVFiUrm/bhk8rhuujM2p9GK1lcsu/cw9Ory/yvXSdLYJhm/OWUipyKyhGEEyrJOQGjW3aCXSOwG6aFjC75FL1Wlu9anqGxZEDfvDk8M2sEdsuWSo6LixSXmwPu37JrTamsaYVKc3hm1q34rh1ycb34JQ2LEJdF5RB84oqZ5VJVw7rNpIMXBP+ZnqFQPYqCyEtc7sNyCOa7H1hQnmpjQhgORGOeihvr1hcI3rNB4ViRAv/vAfD9t5EpQgsUHUPJ1amg19vvujKpP7Xb2ZkBDw0un1GBm3K0nTZLbfFBWMxAU8RtQ/jOZwW3xZZowtzLhE98V+2vDIsMVD080oYKfP+0mpVavrR4/d6wfQuZyFtXSoquEGHVLQvcMd9ajAgbKfASVUa0DdXy0DjVWrUKIvbyKzbhkkNUYtVM7LsLbagWAodmB2Nxfz22wDZUy0BTnzdOaPZJdH8whYWTHPthKQY698vvkQYJSLwEGq9BXO13N68UvztpL5Gk3W0m8R3+PGZccrCfroxFWHKBxU3S7jbT8SKGAxN6hA6ekTaXuuegpKrah91J2t1mOl6jY/msmlfKDkhkDZ/jTsVlulqE5d4ZdVlpK3JWUMZ8kM8xuiCVdWY3TegydaHOwZIaLC5FyQq6JLWFhK3I6ZGWuExq62Tdoy9EV8t+W+3qAjp3fA7TEpdJfSnwoUN6uFbHjJ3ukwzuCtEfLG6qN+mkvtIdlzT7qM9m+8mJmOd+btriMpksZeiK/Ai7bVkzBnSOSk9hrJuuUBiZ79YwMKmnqCt11BZEWqD2lgcOktaWk5LLdhy2XV7HXNVBOSvXNpPrfiuDk3qartxfPLFuzsm1zeS+oU7DzdPk5sLvf8qZ3FzbTGE7JvG28qqOc09A2J6jVHbanaFaAAVvieVVwOhbHO01oblfqxwcLEpYn8IF9mmUOqfooYjdyLugUMe2IkZgn0boLhvVRnPy5OAyDe2dlyKsjziBfdxkrIZRcnWZnu6DTOZ0HZc3DKKydFKJrMGLFbiZFbGBl8FiF9XN4oEUhVvSRW3GCIFb4TDOW9NTSByln11ZJWi8zDKvxMsLe/J6ntLCbxyMFLiVoSk9VH2IEVd03rKedzX3XD7EO3AG7gvlDc3ddR8qLLpZr6LX6iRoHxZLGzFvgkOj+ALBlx6CtCZy6AAAAABJRU5ErkJggg==",e.style.width="100%",e.style.height="100%",e.style.objectFit="cover",e.style.display="block",e.alt="Customer Service",e.onload=()=>{this.debug&&console.log("Icon image loaded successfully"),this.iconElement&&(e.style.opacity="1",e.style.visibility="visible")},e.onerror=A=>{console.error("Failed to load icon image",A)},e.style.opacity="1",e.style.visibility="visible";const t=document.createElement("div");Object.assign(t.style,{width:"100%",height:"100%",borderRadius:"50%",overflow:"hidden",position:"relative"}),t.appendChild(e),this.iconElement.appendChild(t);const n=this.getTargetElement();n?n.appendChild(this.iconElement):(document.body.appendChild(this.iconElement),this.debug&&console.warn("Target element not found, icon added to document.body")),this.setupDragEvents(),this.magnetic&&!this.iconPosition&&setTimeout(()=>{if(this.iconElement){const A=this.getTargetElement();if(A){const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=this.iconElement.offsetHeight||30,r=20,o=80,i=e.width-t-r,s=e.height-n-o;if(this.iconElement.style.left=`${i}px`,this.iconElement.style.top=`${s}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.sideAttach){this.isAttachedToSide=!0,this.attachedSide="right";const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto",this.iconElement.style.bottom=`${o}px`,this.iconElement.style.top="auto",this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease",this.debug&&console.log("[IconManager] Auto side attach on init",{isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide,hideDistance:A,right:`-${A}px`})}else this.magneticSnap(),this.debug&&console.log("[IconManager] Auto magnetic snap on init",{isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide})}}},200),this.sideAttach&&this.autoAttachDelay>0&&!this.isAttachedToSide&&setTimeout(()=>{this.startAutoAttachTimer()},300),this.debug&&console.log("CustomerSDK icon displayed")}forceCleanupDragEvents(){this.cleanupDragEvents()}hide(){if(this.cleanupDragEvents(),this.clearAutoAttachTimer(),this.iconElement){const A=window.getComputedStyle(this.iconElement),e=A.left,t=A.top;if("auto"!==e&&"auto"!==t&&""!==e&&""!==t){const A=parseFloat(e),n=parseFloat(t);isNaN(A)||isNaN(n)||(this.iconPosition={x:A,y:n},this.debug&&console.log("Icon position saved before hide:",this.iconPosition))}this.iconElement.remove(),this.iconElement=null,this.debug&&console.log("CustomerSDK icon hidden")}}setPosition(A){}setIconPosition(A){this.iconPosition=A,this.iconElement&&(void 0!==A.x&&(this.iconElement.style.left="number"==typeof A.x?`${A.x}px`:A.x,this.iconElement.style.right="auto"),void 0!==A.y&&(this.iconElement.style.top="number"==typeof A.y?`${A.y}px`:A.y,this.iconElement.style.bottom="auto"))}setStyle(A){}startAutoAttachTimer(){this.clearAutoAttachTimer(),this.isAttachedToSide||(this.autoAttachTimer=window.setTimeout(()=>{!this.iconElement||this.isDragging||this.dragStarted||this.autoAttachToSide(),this.autoAttachTimer=null},this.autoAttachDelay),this.debug&&console.log(`[IconManager] Auto attach timer started, will attach in ${this.autoAttachDelay}ms`))}clearAutoAttachTimer(){null!==this.autoAttachTimer&&(window.clearTimeout(this.autoAttachTimer),this.autoAttachTimer=null,this.debug&&console.log("[IconManager] Auto attach timer cleared"))}autoAttachToSide(){if(this.iconElement&&this.sideAttach)try{const A=this.getTargetElement();if(!A)return;const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=window.getComputedStyle(this.iconElement),r=parseFloat(n.left)||0,o=n.right,i=e.width;let s=!0;if("auto"!==o&&""!==o){const A=parseFloat(o);if(!isNaN(A)){s=i-t-A>=i/2}}else s=r>=i/2;if(s){this.isAttachedToSide=!0,this.attachedSide="right";const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto"}else{this.isAttachedToSide=!0,this.attachedSide="left";const A=t*this.sideHideRatio;this.iconElement.style.left=`-${A}px`,this.iconElement.style.right="auto"}const a=window.getComputedStyle(this.iconElement);"auto"!==a.top&&""!==a.top?(this.iconElement.style.top=a.top,this.iconElement.style.bottom="auto"):"auto"!==a.bottom&&""!==a.bottom&&(this.iconElement.style.bottom=a.bottom,this.iconElement.style.top="auto"),this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease",this.debug&&console.log("[IconManager] Auto attached to side",{attachedSide:this.attachedSide,hideDistance:t*this.sideHideRatio})}catch(A){this.debug&&console.error("[IconManager] Error in autoAttachToSide:",A)}}onClick(A){this.onClickCallback=A}onNotification(A){this.notificationCallback=A}showNotification(A){if(!this.iconElement)return void(this.debug&&console.warn("Icon not displayed, cannot show notification"));const{showBadge:e=!0,badgeCount:t=0,badgeText:n="",pulse:r=!1}=A;(e||t>0)&&this.createBadge(t,n,r),this.notificationCallback&&this.notificationCallback({badgeCount:t,badgeText:n,pulse:r}),this.debug&&console.log("Notification shown:",{badgeCount:t,badgeText:n})}clearNotification(){this.badgeElement&&(this.badgeElement.remove(),this.badgeElement=null),this.debug&&console.log("Notification cleared")}setupDragEvents(){this.iconElement&&(this.startDragHandler=this.startDrag.bind(this),this.onDragHandler=this.onDrag.bind(this),this.stopDragHandler=this.stopDrag.bind(this),this.iconElement.addEventListener("mousedown",this.startDragHandler),this.iconElement.addEventListener("touchstart",this.startDragHandler,{passive:!1}))}startDrag(A){if(!this.iconElement||!this.isClickEnabled)return;if(this.clearAutoAttachTimer(),this.isStoppingDrag)return void(this.debug&&console.warn("[IconManager] startDrag called while stopping, ignoring"));if(this.isDragging||this.dragStarted)return void(this.debug&&console.warn("[IconManager] startDrag called but already dragging, ignoring",{isDragging:this.isDragging,dragStarted:this.dragStarted}));null===this.dragTimeoutId&&null===this.activeDetectionRafId&&null===this.rafId||(this.debug&&console.warn("[IconManager] startDrag found leftover resources, cleaning up",{hasTimeout:null!==this.dragTimeoutId,hasActiveDetection:null!==this.activeDetectionRafId,hasRaf:null!==this.rafId}),this.cleanupDragEvents());const e=A.target;if(e&&("IFRAME"===e.tagName||e.closest("iframe")||e.closest(".customer-sdk-container")||e.closest(".customer-sdk-overlay")))return;A.preventDefault(),A.stopPropagation(),this.hasMoved=!1,this.dragStarted=!1,this.isDragging=!1,this.touchStartTime=Date.now();const t="touches"in A?A.touches[0].clientX:A.clientX,n="touches"in A?A.touches[0].clientY:A.clientY;this.lastTouchPosition.x=t,this.lastTouchPosition.y=n;try{const A=this.iconElement.getBoundingClientRect();if(!this.getTargetElement())return void(this.debug&&console.warn("Container not found"));this.dragOffset.x=t-A.left,this.dragOffset.y=n-A.top;const e=document.querySelectorAll("iframe");this.cachedIframes=Array.from(e).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=Date.now(),this.debug&&console.log(`[IconManager] Drag start - Found ${this.cachedIframes.length} iframe(s)`,{iframes:this.cachedIframes.map(({rect:A})=>({left:A.left,top:A.top,right:A.right,bottom:A.bottom,width:A.width,height:A.height}))}),this.onDragHandler&&(document.addEventListener("mousemove",this.onDragHandler),document.addEventListener("touchmove",this.onDragHandler,{passive:!1})),this.stopDragHandler&&(document.addEventListener("mouseup",this.stopDragHandler),document.addEventListener("touchend",this.stopDragHandler)),this.mouseLeaveHandler=A=>{!A.relatedTarget&&(A.clientY<=0||A.clientX<=0||A.clientX>=window.innerWidth||A.clientY>=window.innerHeight)&&(this.mouseLeaveTimeout&&clearTimeout(this.mouseLeaveTimeout),this.mouseLeaveTimeout=window.setTimeout(()=>{!this.isDragging&&!this.dragStarted||this.isStoppingDrag||(this.debug&&console.log("[IconManager] Mouse left window, stopping drag"),this.stopDrag()),this.mouseLeaveTimeout=null},50))},this.pointerLeaveHandler=A=>{!A.relatedTarget&&(A.clientY<=0||A.clientX<=0||A.clientX>=window.innerWidth||A.clientY>=window.innerHeight)&&(this.pointerLeaveTimeout&&clearTimeout(this.pointerLeaveTimeout),this.pointerLeaveTimeout=window.setTimeout(()=>{!this.isDragging&&!this.dragStarted||this.isStoppingDrag||(this.debug&&console.log("[IconManager] Pointer left window, stopping drag"),this.stopDrag()),this.pointerLeaveTimeout=null},50))},document.addEventListener("mouseleave",this.mouseLeaveHandler),document.addEventListener("pointerleave",this.pointerLeaveHandler),this.blurHandler=()=>{this.isStoppingDrag||(this.isDragging||this.dragStarted)&&(this.debug&&console.log("[IconManager] Window lost focus, stopping drag"),this.stopDrag())},window.addEventListener("blur",this.blurHandler),this.dragTimeoutId=window.setTimeout(()=>{this.isDragging&&(this.debug&&console.log("Drag timeout, stopping drag (likely mouse moved over iframe)"),this.stopDrag())},50),this.startActiveDetection(),this.debug&&console.log("[IconManager] Drag start",{startPosition:{x:t,y:n},iconRect:{left:A.left,top:A.top,width:A.width,height:A.height},dragOffset:this.dragOffset})}catch(A){this.debug&&console.error("Error in startDrag:",A)}}onDrag(A){if(!this.iconElement)return;A.preventDefault();const e="touches"in A?A.touches[0].clientX:A.clientX,t="touches"in A?A.touches[0].clientY:A.clientY;if(this.isDragging){const A=Date.now();if(0===this.cachedIframes.length||A-this.lastIframeUpdateTime>this.iframeUpdateInterval){const e=document.querySelectorAll("iframe"),t=this.cachedIframes.length;this.cachedIframes=Array.from(e).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=A,this.debug&&this.cachedIframes.length!==t&&console.log(`[IconManager] Iframe cache updated - Found ${this.cachedIframes.length} iframe(s)`,{iframes:this.cachedIframes.map(({rect:A})=>({left:A.left,top:A.top,right:A.right,bottom:A.bottom}))})}for(const{rect:A,element:n}of this.cachedIframes)if(e>=A.left&&e<=A.right&&t>=A.top&&t<=A.bottom)return this.debug&&console.log("[IconManager] Mouse over iframe detected, stopping drag immediately",{mousePosition:{x:e,y:t},iframeRect:{left:A.left,top:A.top,right:A.right,bottom:A.bottom},iframeSrc:n.src||"no src"}),void this.stopDrag()}const n=Date.now(),r=n-this.lastMousePosition.timestamp;this.lastMousePosition={x:e,y:t,timestamp:n},this.debug&&r>50&&this.lastMousePosition.timestamp>0&&console.warn(`[IconManager] Long gap between mousemove events: ${r}ms`,{lastPosition:{x:this.lastMousePosition.x,y:this.lastMousePosition.y},currentPosition:{x:e,y:t}}),null!==this.dragTimeoutId&&(window.clearTimeout(this.dragTimeoutId),this.dragTimeoutId=window.setTimeout(()=>{if(this.isDragging){if(this.debug){const A=Date.now()-this.lastMousePosition.timestamp;console.warn("[IconManager] Drag timeout triggered, stopping drag (likely mouse moved over iframe)",{timeSinceLastMove:A,lastMousePosition:this.lastMousePosition,iframeCount:this.cachedIframes.length})}this.stopDrag()}},50));const o=Math.abs(e-this.lastTouchPosition.x),i=Math.abs(t-this.lastTouchPosition.y);if(Math.sqrt(o*o+i*i)>this.clickThreshold&&(this.hasMoved=!0,!this.dragStarted)){this.dragStarted=!0,this.isDragging=!0,this.isAttachedToSide&&(this.isAttachedToSide=!1,this.attachedSide="",this.iconElement&&(this.iconElement.style.transform=""));const A=window.getComputedStyle(this.iconElement);if("auto"!==A.right||"auto"!==A.bottom){const A=this.iconElement.getBoundingClientRect(),n=this.getTargetElement();if(n){const r=n.getBoundingClientRect(),o=A.left-r.left,i=A.top-r.top;this.iconElement.style.left=`${o}px`,this.iconElement.style.top=`${i}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.dragOffset.x=e-A.left,this.dragOffset.y=t-A.top}}this.iconElement.style.transition="none",this.iconElement.style.cursor="grabbing",this.debug&&console.log("Drag started (moved > threshold)")}if(this.isDragging)try{const A=Date.now(),n=this.getTargetElement();if(!n)return;(!this.cachedContainer||this.cachedContainer!==n||A-this.lastContainerUpdateTime>this.containerUpdateInterval)&&(this.cachedContainer=n,this.cachedContainerRect=n.getBoundingClientRect(),this.cachedIconSize={width:this.iconElement.offsetWidth,height:this.iconElement.offsetHeight},this.lastContainerUpdateTime=A);const r=this.cachedContainerRect,o=this.cachedIconSize.width,i=this.cachedIconSize.height;let s=e-this.dragOffset.x-r.left,a=t-this.dragOffset.y-r.top;if(n===document.body)s=Math.max(0,Math.min(s,window.innerWidth-o)),a=Math.max(0,Math.min(a,window.innerHeight-i));else{const A=r.width,e=r.height;s=Math.max(0,Math.min(s,A-o)),a=Math.max(0,Math.min(a,e-i))}this.pendingPosition.x=s,this.pendingPosition.y=a,this.pendingPosition.needsUpdate=!0,null===this.rafId&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.pendingPosition.needsUpdate&&this.iconElement&&this.isDragging&&(this.iconElement.style.left=`${this.pendingPosition.x}px`,this.iconElement.style.top=`${this.pendingPosition.y}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.pendingPosition.needsUpdate=!1)})),this.lastTouchPosition.x=e,this.lastTouchPosition.y=t}catch(A){this.debug&&console.error("Error in onDrag:",A)}}stopDrag(A){if(this.isStoppingDrag)return void(this.debug&&console.warn("[IconManager] stopDrag already in progress, ignoring duplicate call"));if(!(this.isDragging||this.dragStarted||this.dragTimeoutId||this.activeDetectionRafId))return void(this.debug&&console.warn("[IconManager] stopDrag called but not dragging, ignoring"));this.isStoppingDrag=!0;const e=this.isDragging?"drag_stopped":"not_dragging",t=this.iconElement?{left:this.iconElement.style.left,top:this.iconElement.style.top,computed:"auto"!==window.getComputedStyle(this.iconElement).left?{left:window.getComputedStyle(this.iconElement).left,top:window.getComputedStyle(this.iconElement).top}:null}:null;if(this.cleanupDragEvents(),!this.iconElement)return this.hasMoved=!1,this.isDragging=!1,this.dragStarted=!1,void(this.isStoppingDrag=!1);this.iconElement.style.transition="transform 0.2s ease",this.iconElement.style.cursor="pointer";const n=Date.now()-this.touchStartTime,r=!this.hasMoved&&n<1e3&&!this.dragStarted;this.debug&&console.log("[IconManager] Drag end",{stopReason:e,hasMoved:this.hasMoved,dragStarted:this.dragStarted,touchDuration:n,isValidClick:r,finalPosition:t,lastMousePosition:this.lastMousePosition});const o=r;if(this.dragStarted&&this.magnetic&&this.iconElement&&this.magneticSnap(),this.dragStarted&&this.isDragging&&this.iconElement){const A=window.getComputedStyle(this.iconElement),e=A.left,t=A.top;if("auto"!==e&&"auto"!==t){const A=parseFloat(e),n=parseFloat(t);isNaN(A)||isNaN(n)||(this.iconPosition={x:A,y:n},this.debug&&console.log("Icon position saved:",this.iconPosition))}}this.hasMoved=!1,this.isDragging=!1,this.dragStarted=!1,this.isStoppingDrag=!1,!this.isAttachedToSide&&this.sideAttach&&this.autoAttachDelay>0&&this.startAutoAttachTimer(),o&&setTimeout(()=>{!this.isClickEnabled||this.dragStarted||this.hasMoved||this.isDragging||this.handleClick()},100)}startActiveDetection(){if(null!==this.activeDetectionRafId)return void(this.debug&&console.log("[IconManager] Active detection already running"));this.debug&&console.log("[IconManager] Starting active detection mechanism");const A=()=>{if(!this.isDragging||this.isStoppingDrag)return this.debug&&console.log("[IconManager] Active detection stopped (drag ended or stopping)"),void(this.activeDetectionRafId=null);const e=Date.now(),t=e-this.lastMousePosition.timestamp;if(t>50){const A=this.lastMousePosition.x,n=this.lastMousePosition.y;if(this.debug&&t>100&&console.warn(`[IconManager] Active detection: No mousemove event for ${t}ms`,{lastMousePosition:{x:A,y:n},timestamp:this.lastMousePosition.timestamp,isDragging:this.isDragging,dragStarted:this.dragStarted}),0===this.cachedIframes.length||e-this.lastIframeUpdateTime>this.iframeUpdateInterval){const A=document.querySelectorAll("iframe");this.cachedIframes=Array.from(A).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=e,this.debug&&console.log(`[IconManager] Active detection: Updated iframe cache (${this.cachedIframes.length} iframes)`)}for(const{rect:e,element:r}of this.cachedIframes)if(A>=e.left&&A<=e.right&&n>=e.top&&n<=e.bottom)return this.debug&&console.log("[IconManager] Active detection: Mouse over iframe detected, stopping drag immediately",{mousePosition:{x:A,y:n},iframeRect:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},iframeSrc:r.src||"no src",timeSinceLastMove:t}),void this.stopDrag()}this.activeDetectionRafId=requestAnimationFrame(A)};this.activeDetectionRafId=requestAnimationFrame(A)}stopActiveDetection(){null!==this.activeDetectionRafId&&(this.debug&&console.log("[IconManager] Stopping active detection mechanism"),cancelAnimationFrame(this.activeDetectionRafId),this.activeDetectionRafId=null)}cleanupDragEvents(){this.onDragHandler&&(document.removeEventListener("mousemove",this.onDragHandler),document.removeEventListener("touchmove",this.onDragHandler)),this.stopDragHandler&&(document.removeEventListener("mouseup",this.stopDragHandler),document.removeEventListener("touchend",this.stopDragHandler)),this.mouseLeaveHandler&&(document.removeEventListener("mouseleave",this.mouseLeaveHandler),this.mouseLeaveHandler=null),this.pointerLeaveHandler&&(document.removeEventListener("pointerleave",this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.blurHandler&&(window.removeEventListener("blur",this.blurHandler),this.blurHandler=null),null!==this.mouseLeaveTimeout&&(window.clearTimeout(this.mouseLeaveTimeout),this.mouseLeaveTimeout=null),null!==this.pointerLeaveTimeout&&(window.clearTimeout(this.pointerLeaveTimeout),this.pointerLeaveTimeout=null),null!==this.dragTimeoutId&&(window.clearTimeout(this.dragTimeoutId),this.dragTimeoutId=null),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.stopActiveDetection(),null!==this.activeDetectionRafId&&(this.debug&&console.warn("[IconManager] Active detection RAF ID still exists, force cleaning"),cancelAnimationFrame(this.activeDetectionRafId),this.activeDetectionRafId=null),this.cachedContainer=null,this.cachedContainerRect=null,this.cachedIframes=[],this.pendingPosition.needsUpdate=!1,this.debug&&console.log("[IconManager] Cleanup completed",{isDragging:this.isDragging,dragStarted:this.dragStarted,isStoppingDrag:this.isStoppingDrag,hasTimeout:null!==this.dragTimeoutId,hasActiveDetection:null!==this.activeDetectionRafId,hasRaf:null!==this.rafId})}handleClick(){this.isClickEnabled&&(this.clearAutoAttachTimer(),this.onClickCallback&&this.onClickCallback())}disableClick(){this.isClickEnabled=!1,this.iconElement&&this.startDragHandler&&(this.iconElement.removeEventListener("mousedown",this.startDragHandler),this.iconElement.removeEventListener("touchstart",this.startDragHandler)),this.iconElement&&(this.iconElement.style.pointerEvents="none",this.iconElement.style.cursor="default"),this.forceCleanupDragEvents()}enableClick(){this.isClickEnabled=!0,this.iconElement&&this.startDragHandler?(this.iconElement.addEventListener("mousedown",this.startDragHandler),this.iconElement.addEventListener("touchstart",this.startDragHandler,{passive:!1})):this.iconElement&&this.setupDragEvents(),this.iconElement&&(this.iconElement.style.pointerEvents="auto",this.iconElement.style.cursor="pointer")}magneticSnap(){if(this.iconElement)try{const A=this.getTargetElement();if(!A)return;const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=this.iconElement.offsetHeight||30,r=window.getComputedStyle(this.iconElement),o=parseFloat(r.left)||0,i=parseFloat(r.top)||0;let s=o,a=i;if("x"===this.magneticDirection||"both"===this.magneticDirection){const A=e.width;if(o<A/2)if(s=this.margin,this.sideAttach&&o<t/2){this.isAttachedToSide=!0,this.attachedSide="left";s=-(t*this.sideHideRatio)}else this.isAttachedToSide=!1,this.attachedSide="";else if(s=A-t-this.margin,this.sideAttach){if(A-o-t<t/2||isNaN(o)||0===o||o>=A-t-this.margin-t/2){this.isAttachedToSide=!0,this.attachedSide="right";s=A-t*(1-this.sideHideRatio)}else this.isAttachedToSide=!1,this.attachedSide=""}else this.isAttachedToSide=!1,this.attachedSide=""}if("y"===this.magneticDirection||"both"===this.magneticDirection){const A=e.height;a=i<A/2?this.margin:A-n-this.margin}if(this.isAttachedToSide&&"right"===this.attachedSide){const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto"}else if(this.isAttachedToSide&&"left"===this.attachedSide){const A=t*this.sideHideRatio;this.iconElement.style.left=`-${A}px`,this.iconElement.style.right="auto"}else this.iconElement.style.left=`${s}px`,this.iconElement.style.right="auto";this.iconElement.style.top=`${a}px`,this.iconElement.style.bottom="auto",this.isAttachedToSide&&this.attachedSide?(this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease"):this.iconElement.style.transform="",this.isAttachedToSide&&"right"===this.attachedSide?this.iconPosition=null:this.iconPosition={x:s,y:a},this.debug&&console.log("[IconManager] Magnetic snap applied",{newPosition:{x:s,y:a},isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide})}catch(A){this.debug&&console.error("[IconManager] Error in magneticSnap:",A)}}getTargetElement(){if(!this.target)return document.body;if("string"==typeof this.target){const A=document.querySelector(this.target);return A||(this.debug&&console.warn(`Target element not found: ${this.target}, falling back to document.body`),document.body)}return this.target instanceof HTMLElement?document.body.contains(this.target)?this.target:(this.debug&&console.warn("Target element no longer in DOM, falling back to document.body"),document.body):document.body}createBadge(A,e="",t=!1){this.clearNotification(),this.badgeElement=document.createElement("div"),this.badgeElement.className="customer-sdk-icon-badge",this.badgeElement.textContent=A>0?A>99?"99+":A.toString():e||"",Object.assign(this.badgeElement.style,{position:"absolute",top:"-4px",left:"-4px",right:"auto",minWidth:"18px",height:"18px",borderRadius:"50%",backgroundColor:"#ff4444",color:"#ffffff",fontSize:"10px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000001",boxShadow:"0 -1px 4px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15)",...0===A&&""===e&&{width:"12px",height:"12px",minWidth:"12px",top:"-2px",left:"-2px"},...t&&{animation:"sdk-badge-pulse 1.5s infinite"}}),this.iconElement&&this.iconElement.appendChild(this.badgeElement)}}class t{constructor(A={}){this.iframeElement=null,this.containerElement=null,this.isOpen=!1,this.isCreated=!1,this.debug=!1,this.targetElement=null,this.messageHandler=null,this.config={src:"",mode:"auto",width:450,height:600,allowClose:!0,...A},this.debug=A.debug??!1}async init(){try{this.setupMessageListener(),this.cleanupOrphanedElements(),this.createIframe(),this.isCreated=!0,this.debug&&console.log("CustomerSDK iframe initialized (hidden, SSE connected)")}catch(A){throw console.error("Failed to initialize iframe:",A),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),A}}show(){if(!this.isOpen){if(!this.isCreated)throw new Error("Iframe not initialized. Call init() first.");try{this.containerElement&&(this.containerElement.parentNode||document.body.appendChild(this.containerElement),Object.assign(this.containerElement.style,{position:"fixed",visibility:"visible",opacity:"1",display:"block"}),this.preventBodyScroll(!0)),this.isOpen=!0,this.debug&&console.log("CustomerSDK iframe shown")}catch(A){console.error("Failed to show iframe:",A)}}}open(){this.show()}hide(){this.isOpen&&(this.containerElement&&Object.assign(this.containerElement.style,{visibility:"hidden",opacity:"0",display:"none"}),this.preventBodyScroll(!1),this.isOpen=!1,this.debug&&console.log("CustomerSDK iframe hidden (SSE still connected)"),this.config.onClose&&this.config.onClose())}close(){this.hide()}destroy(){this.hide(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.containerElement&&(this.containerElement.remove(),this.containerElement=null,this.iframeElement=null),this.isCreated=!1,this.debug&&console.log("CustomerSDK container destroyed")}isIframeOpen(){return this.isOpen}sendToIframe(A){this.iframeElement&&this.iframeElement.contentWindow&&this.iframeElement.contentWindow.postMessage(A,"*")}cleanupOrphanedElements(){document.querySelectorAll(".customer-sdk-container").forEach(A=>{A!==this.containerElement&&(A.remove(),this.debug&&console.log("清理旧的容器元素"))})}createIframe(){this.containerElement=document.createElement("div"),this.containerElement.className="customer-sdk-container",this.iframeElement=document.createElement("iframe"),this.iframeElement.className="customer-sdk-iframe",this.iframeElement.src=this.config.src||"",this.iframeElement.frameBorder="0",this.iframeElement.setAttribute("allow",["microphone","camera","geolocation","clipboard-read","clipboard-write","fullscreen","autoplay","encrypted-media"].join("; ")),this.iframeElement.setAttribute("sandbox",["allow-same-origin","allow-scripts","allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-storage-access-by-user-activation"].join(" ")),this.config.target&&(this.targetElement=this.getTargetElement(this.config.target));const A="popup"===this.getActualMode();this.iframeElement.scrolling="auto";const e=!!this.targetElement&&this.targetElement!==document.body?{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:A?"0":"12px 12px 0 0",boxShadow:A?"none":"0 -4px 16px rgba(0, 0, 0, 0.25)",border:"none",position:"absolute",zIndex:"999999",top:"0",left:"0",bottom:"0",right:"0",transform:"none",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"}:A?{width:`${this.config.width||450}px`,height:"100%",maxWidth:"90vw",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:"0",boxShadow:"none",border:"none",position:"fixed",zIndex:"999999",top:"0",left:"50%",bottom:"0",right:"auto",transform:"translateX(-50%)",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"}:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:"12px 12px 0 0",boxShadow:"0 -4px 16px rgba(0, 0, 0, 0.25)",border:"none",position:"fixed",zIndex:"999999",top:"0",left:"0",bottom:"0",right:"0",transform:"none",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"};Object.assign(this.containerElement.style,e);if(Object.assign(this.iframeElement.style,{width:"100%",height:"100%",border:"none",borderRadius:"inherit"}),this.containerElement.appendChild(this.iframeElement),this.iframeElement.addEventListener("load",()=>{A||this.injectMobileStyles()}),this.targetElement&&this.targetElement!==document.body){"static"===window.getComputedStyle(this.targetElement).position&&(this.targetElement.style.position="relative",this.debug&&console.log("Set target element position to relative for iframe container")),this.targetElement.appendChild(this.containerElement),this.debug&&console.log("Iframe container added to target element")}else document.body.appendChild(this.containerElement),this.debug&&console.log("Iframe container added to document.body");this.debug&&console.log("CustomerSDK container created (hidden, ready for SSE)")}injectMobileStyles(){if(this.iframeElement)try{const A=this.iframeElement.contentDocument||this.iframeElement.contentWindow?.document;if(A){const e=A.createElement("style");e.textContent="\n /* 移动端iframe全屏样式优化 */\n * {\n -webkit-overflow-scrolling: touch !important;\n }\n \n body, html, #app, .container {\n overflow: auto !important;\n -webkit-overflow-scrolling: touch !important;\n }\n \n /* 隐藏所有滚动条 */\n ::-webkit-scrollbar {\n width: 0px !important;\n height: 0px !important;\n background: transparent !important;\n }\n \n /* Firefox */\n html {\n scrollbar-width: none !important;\n }\n \n /* IE/Edge */\n body {\n -ms-overflow-style: none !important;\n }\n \n /* 确保内容可以滚动 */\n body {\n overflow: auto !important;\n height: 100vh !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n ",A.head?.appendChild(e),this.debug&&console.log("CustomerSDK mobile styles injected successfully")}}catch(A){this.debug&&console.log("Cannot inject styles due to cross-origin restrictions:",A)}}preventBodyScroll(A){if(A){const A=window.scrollY;Object.assign(document.body.style,{position:"fixed",top:`-${A}px`,width:"100%",overflow:"hidden"}),document.body.setAttribute("data-scroll-position",A.toString())}else{const A=parseInt(document.body.getAttribute("data-scroll-position")||"0");Object.assign(document.body.style,{position:"",top:"",width:"",overflow:""}),document.body.removeAttribute("data-scroll-position"),window.scrollTo(0,A)}}isMobileDevice(){return window.innerWidth<=768||/Android|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent)}getActualMode(){return"auto"===this.config.mode?this.isMobileDevice()?"fullscreen":"popup":this.config.mode}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=A=>{this.config.src&&A.origin!==new URL(this.config.src).origin||this.handleIframeMessage(A.data)},window.addEventListener("message",this.messageHandler,!1)}handleIframeMessage(A){let e;if(this.debug&&console.log("Message from iframe:",A),"string"==typeof A)e=A;else{if(!A||!A.type)return void(this.debug&&console.log("Unknown message format:",A));e=A.type}switch(e){case"iframe_ready":this.debug&&console.log("Iframe is ready");break;case"close_iframe":case"close":this.close();break;case"resize_iframe":case"resize":"popup"===this.getActualMode()&&A.width&&A.height?this.resizeIframe(A.width,A.height):this.debug&&console.log("Resize request ignored (fullscreen mode)");break;case"new-message":this.debug&&console.log("Received new message notification"),this.config.onMessage&&this.config.onMessage(e,A);break;default:this.debug&&console.log("Custom message:",A)}}resizeIframe(A,e){this.containerElement&&(this.containerElement.style.width=`${A}px`,this.containerElement.style.height=`${e}px`)}getTargetElement(A){if("string"==typeof A){const e=document.querySelector(A);return e||(this.debug&&console.warn(`Target element not found: ${A}, falling back to document.body`),document.body)}return A instanceof HTMLElement?document.body.contains(A)?A:(this.debug&&console.warn("Target element no longer in DOM, falling back to document.body"),document.body):document.body}}const n="p".charCodeAt(0),r="H".charCodeAt(0),o="Y".charCodeAt(0),i="s".charCodeAt(0);let s;function a(A){let e=-1;s||(s=function(){const A=new Int32Array(256);for(let e=0;e<256;e++){let t=e;for(let A=0;A<8;A++)t=1&t?3988292384^t>>>1:t>>>1;A[e]=t}return A}());for(let t=0;t<A.length;t++)e=s[255&(e^A[t])]^e>>>8;return-1^e}function c(A,e,t=!1){const s=new Uint8Array(13);e*=39.3701,s[0]=n,s[1]=r,s[2]=o,s[3]=i,s[4]=e>>>24,s[5]=e>>>16,s[6]=e>>>8,s[7]=255&e,s[8]=s[4],s[9]=s[5],s[10]=s[6],s[11]=s[7],s[12]=1;const c=a(s),l=new Uint8Array(4);if(l[0]=c>>>24,l[1]=c>>>16,l[2]=c>>>8,l[3]=255&c,t){const e=function(A){for(let e=A.length-1;e>=4;e--)if(9===A[e-4]&&A[e-3]===n&&A[e-2]===r&&A[e-1]===o&&A[e]===i)return e-3;return 0}(A);return A.set(s,e),A.set(l,e+13),A}{const e=new Uint8Array(4);e[0]=0,e[1]=0,e[2]=0,e[3]=9;const t=new Uint8Array(54);return t.set(A,0),t.set(e,33),t.set(s,37),t.set(l,50),t}}const l="[modern-screenshot]",u="undefined"!=typeof window,h=u&&"Worker"in window,g=u&&"atob"in window,d=u&&"btoa"in window,B=u?window.navigator?.userAgent:"",w=B.includes("Chrome"),f=B.includes("AppleWebKit")&&!w,m=B.includes("Firefox"),p=A=>1===A.nodeType,C=A=>"object"==typeof A.className,Q=A=>"image"===A.tagName,y=A=>p(A)&&void 0!==A.style&&!C(A),U=A=>8===A.nodeType,F=A=>"IMG"===A.tagName,b=A=>"VIDEO"===A.tagName,E=A=>"SLOT"===A.tagName;function v(A){const e=A?.createElement?.("canvas");return e&&(e.height=e.width=1),Boolean(e)&&"toDataURL"in e&&Boolean(e.toDataURL("image/webp").includes("image/webp"))}const H=A=>A.startsWith("data:");function I(A,e){if(A.match(/^[a-z]+:\/\//i))return A;if(u&&A.match(/^\/\//))return window.location.protocol+A;if(A.match(/^[a-z]+:/i))return A;if(!u)return A;const t=x().implementation.createHTMLDocument(),n=t.createElement("base"),r=t.createElement("a");return t.head.appendChild(n),t.body.appendChild(r),e&&(n.href=e),r.href=A,r.href}function x(A){return(A&&p(A)?A?.ownerDocument:A)??window.document}const S="http://www.w3.org/2000/svg";const L=A=>function(A,e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.onabort=()=>n(new Error(`Failed read blob to ${e}`)),r.readAsDataURL(A)})}(A,"dataUrl");function D(A,e){const t=x(e).createElement("img");return t.decoding="sync",t.loading="eager",t.src=A,t}function M(A,e){return new Promise(t=>{const{timeout:n,ownerDocument:r,onError:o,onWarn:i}=e??{},s="string"==typeof A?D(A,x(r)):A;let a=null,c=null;function l(){t(s),a&&clearTimeout(a),c?.()}if(n&&(a=setTimeout(l,n)),b(s)){const A=s.currentSrc||s.src;if(!A)return s.poster?M(s.poster,e).then(t):l();if(s.readyState>=2)return l();const n=l,r=e=>{i?.("Failed video load",A,e),o?.(e),l()};c=()=>{s.removeEventListener("loadeddata",n),s.removeEventListener("error",r)},s.addEventListener("loadeddata",n,{once:!0}),s.addEventListener("error",r,{once:!0})}else{const A=Q(s)?s.href.baseVal:s.currentSrc||s.src;if(!A)return l();const e=async()=>{if(F(s)&&"decode"in s)try{await s.decode()}catch(e){i?.("Failed to decode image, trying to render anyway",s.dataset.originalSrc||A,e)}l()},t=e=>{i?.("Failed image load",s.dataset.originalSrc||A,e),l()};if(F(s)&&s.complete)return e();c=()=>{s.removeEventListener("load",e),s.removeEventListener("error",t)},s.addEventListener("load",e,{once:!0}),s.addEventListener("error",t,{once:!0})}})}const K=function(){let A=0;return()=>(A+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${A}`)}();function T(A){return A?.split(",").map(A=>A.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let k=0;function R(A){const e=`${l}[#${k}]`;return k++,{time:t=>A&&console.time(`${e} ${t}`),timeEnd:t=>A&&console.timeEnd(`${e} ${t}`),warn:(...e)=>A&&((...A)=>console.warn(l,...A))(...e)}}async function P(A,e){return(t=A)&&"__CONTEXT__"in t?A:O(A,{...e,autoDestruct:!0});var t}async function O(A,e){const{scale:t=1,workerUrl:n,workerNumber:r=1}=e||{},o=Boolean(e?.debug),i=e?.features??!0,s=A.ownerDocument??(u?window.document:void 0),a=A.ownerDocument?.defaultView??(u?window:void 0),c=new Map,l={width:0,height:0,quality:1,type:"image/png",scale:t,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:(g=e?.fetch?.bypassingCache,{cache:g?"no-cache":"force-cache"}),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...e?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:r,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...e,__CONTEXT__:!0,log:R(o),node:A,ownerDocument:s,ownerWindow:a,dpi:1===t?null:96*t,svgStyleElement:N(s),svgDefsElement:s?.createElementNS(S,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:h&&n&&r?r:0})].map(()=>{try{const A=new Worker(n);return A.onmessage=async A=>{const{url:e,result:t}=A.data;t?c.get(e)?.resolve?.(t):c.get(e)?.reject?.(new Error(`Error receiving message from worker: ${e}`))},A.onmessageerror=A=>{const{url:e}=A.data;c.get(e)?.reject?.(new Error(`Error receiving message from worker: ${e}`))},A}catch(A){return l.log.warn("Failed to new Worker",A),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[v(s)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:c,drawImageCount:0,tasks:[],features:i,isEnable:A=>"restoreScrollPosition"===A?"boolean"!=typeof i&&(i[A]??!1):"boolean"==typeof i?i:i[A]??!0,shadowRoots:[]};var g;l.log.time("wait until load"),await async function(A,e){y(A)&&(F(A)||b(A)?await M(A,e):await Promise.all(["img","video"].flatMap(t=>Array.from(A.querySelectorAll(t)).map(A=>M(A,e)))))}(A,{timeout:l.timeout,onWarn:l.log.warn}),l.log.timeEnd("wait until load");const{width:d,height:B}=function(A,e){let{width:t,height:n}=e;if(p(A)&&(!t||!n)){const e=A.getBoundingClientRect();t=t||e.width||Number(A.getAttribute("width"))||0,n=n||e.height||Number(A.getAttribute("height"))||0}return{width:t,height:n}}(A,l);return l.width=d,l.height=B,l}function N(A){if(!A)return;const e=A.createElement("style"),t=e.ownerDocument.createTextNode("\n.______background-clip--text {\n background-clip: text;\n -webkit-background-clip: text;\n}\n");return e.appendChild(t),e}async function V(A,e){const{log:t,timeout:n,drawImageCount:r,drawImageInterval:o}=e;t.time("image to canvas");const i=await M(A,{timeout:n,onWarn:e.log.warn}),{canvas:s,context2d:a}=function(A,e){const{width:t,height:n,scale:r,backgroundColor:o,maximumCanvasSize:i}=e,s=A.createElement("canvas");s.width=Math.floor(t*r),s.height=Math.floor(n*r),s.style.width=`${t}px`,s.style.height=`${n}px`,i&&(s.width>i||s.height>i)&&(s.width>i&&s.height>i?s.width>s.height?(s.height*=i/s.width,s.width=i):(s.width*=i/s.height,s.height=i):s.width>i?(s.height*=i/s.width,s.width=i):(s.width*=i/s.height,s.height=i));const a=s.getContext("2d");a&&o&&(a.fillStyle=o,a.fillRect(0,0,s.width,s.height));return{canvas:s,context2d:a}}(A.ownerDocument,e),c=()=>{try{a?.drawImage(i,0,0,s.width,s.height)}catch(A){e.log.warn("Failed to drawImage",A)}};if(c(),e.isEnable("fixSvgXmlDecode"))for(let A=0;A<r;A++)await new Promise(e=>{setTimeout(()=>{a?.clearRect(0,0,s.width,s.height),c(),e()},A+o)});return e.drawImageCount=0,t.timeEnd("image to canvas"),s}function G(A,e){if(A.ownerDocument)try{const e=A.toDataURL();if("data:,"!==e)return D(e,A.ownerDocument)}catch(A){e.log.warn("Failed to clone canvas",A)}const t=A.cloneNode(!1),n=A.getContext("2d"),r=t.getContext("2d");try{return n&&r&&r.putImageData(n.getImageData(0,0,A.width,A.height),0,0),t}catch(A){e.log.warn("Failed to clone canvas",A)}return t}function W(A,e){return(A=>"CANVAS"===A.tagName)(A)?G(A,e):(A=>"IFRAME"===A.tagName)(A)?function(A,e){try{if(A?.contentDocument?.body)return eA(A.contentDocument.body,e)}catch(A){e.log.warn("Failed to clone iframe",A)}return A.cloneNode(!1)}(A,e):F(A)?function(A){const e=A.cloneNode(!1);return A.currentSrc&&A.currentSrc!==A.src&&(e.src=A.currentSrc,e.srcset=""),"lazy"===e.loading&&(e.loading="eager"),e}(A):b(A)?async function(A,e){if(A.ownerDocument&&!A.currentSrc&&A.poster)return D(A.poster,A.ownerDocument);const t=A.cloneNode(!1);t.crossOrigin="anonymous",A.currentSrc&&A.currentSrc!==A.src&&(t.src=A.currentSrc);const n=t.ownerDocument;if(n){let r=!0;if(await M(t,{onError:()=>r=!1,onWarn:e.log.warn}),!r)return A.poster?D(A.poster,A.ownerDocument):t;t.currentTime=A.currentTime,await new Promise(A=>{t.addEventListener("seeked",A,{once:!0})});const o=n.createElement("canvas");o.width=A.offsetWidth,o.height=A.offsetHeight;try{const A=o.getContext("2d");A&&A.drawImage(t,0,0,o.width,o.height)}catch(n){return e.log.warn("Failed to clone video",n),A.poster?D(A.poster,A.ownerDocument):t}return G(o,e)}return t}(A,e):A.cloneNode(!1)}const X=["width","height","-webkit-text-fill-color"],J=["stroke","fill"];function Y(A,e,t){const{defaultComputedStyles:n}=t,r=A.nodeName.toLowerCase(),o=C(A)&&"svg"!==r,i=o?J.map(e=>[e,A.getAttribute(e)]).filter(([,A])=>null!==A):[],s=[o&&"svg",r,i.map((A,e)=>`${A}=${e}`).join(","),e].filter(Boolean).join(":");if(n.has(s))return n.get(s);const a=function(A){let e=A.sandbox;if(!e){const{ownerDocument:t}=A;try{t&&(e=t.createElement("iframe"),e.id=`__SANDBOX__${K()}`,e.width="0",e.height="0",e.style.visibility="hidden",e.style.position="fixed",t.body.appendChild(e),e.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',A.sandbox=e)}catch(e){A.log.warn("Failed to getSandBox",e)}}return e}(t),c=a?.contentWindow;if(!c)return new Map;const l=c?.document;let u,h;o?(u=l.createElementNS(S,"svg"),h=u.ownerDocument.createElementNS(u.namespaceURI,r),i.forEach(([A,e])=>{h.setAttributeNS(null,A,e)}),u.appendChild(h)):u=h=l.createElement(r),h.textContent=" ",l.body.appendChild(u);const g=c.getComputedStyle(h,e),d=new Map;for(let A=g.length,e=0;e<A;e++){const A=g.item(e);X.includes(A)||d.set(A,g.getPropertyValue(A))}return l.body.removeChild(u),n.set(s,d),d}function $(A,e,t){const n=new Map,r=[],o=new Map;if(t)for(const A of t)i(A);else for(let e=A.length,t=0;t<e;t++){i(A.item(t))}for(let A=r.length,e=0;e<A;e++)o.get(r[e])?.forEach((A,e)=>n.set(e,A));function i(t){const i=A.getPropertyValue(t),s=A.getPropertyPriority(t),a=t.lastIndexOf("-"),c=a>-1?t.substring(0,a):void 0;if(c){let A=o.get(c);A||(A=new Map,o.set(c,A)),A.set(t,[i,s])}(e.get(t)!==i||s)&&(c?r.push(c):n.set(t,[i,s]))}return n}const Z=[":before",":after"],j=[":-webkit-scrollbar",":-webkit-scrollbar-button",":-webkit-scrollbar-thumb",":-webkit-scrollbar-track",":-webkit-scrollbar-track-piece",":-webkit-scrollbar-corner",":-webkit-resizer"];const _=new Set(["symbol"]);async function z(A,e,t,n,r){if(p(t)&&((A=>"STYLE"===A.tagName)(t)||(A=>"SCRIPT"===A.tagName)(t)))return;if(n.filter&&!n.filter(t))return;_.has(e.nodeName)||_.has(t.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;const o=await eA(t,n,!1,r);n.isEnable("restoreScrollPosition")&&function(A,e){if(!y(A)||!y(e))return;const{scrollTop:t,scrollLeft:n}=A;if(!t&&!n)return;const{transform:r}=e.style,o=new DOMMatrix(r),{a:i,b:s,c:a,d:c}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-n,-t),o.a=i,o.b=s,o.c=a,o.d=c,e.style.transform=o.toString()}(A,o),e.appendChild(o)}async function q(A,e,t,n){let r=A.firstChild;p(A)&&A.shadowRoot&&(r=A.shadowRoot?.firstChild,t.shadowRoots.push(A.shadowRoot));for(let o=r;o;o=o.nextSibling)if(!U(o))if(p(o)&&E(o)&&"function"==typeof o.assignedNodes){const r=o.assignedNodes();for(let o=0;o<r.length;o++)await z(A,e,r[o],t,n)}else await z(A,e,o,t,n)}const AA=/^[\w-:]+$/;async function eA(A,e,t=!1,n){const{ownerDocument:r,ownerWindow:o,fontFamilies:i,onCloneEachNode:s}=e;if(r&&(A=>3===A.nodeType)(A))return n&&/\S/.test(A.data)&&n(A.data),r.createTextNode(A.data);if(r&&o&&p(A)&&(y(A)||C(A))){const n=await W(A,e);if(e.isEnable("removeAbnormalAttributes")){const A=n.getAttributeNames();for(let e=A.length,t=0;t<e;t++){const e=A[t];AA.test(e)||n.removeAttribute(e)}}const r=e.currentNodeStyle=function(A,e,t,n){const{ownerWindow:r,includeStyleProperties:o,currentParentNodeStyle:i}=n,s=e.style,a=r.getComputedStyle(A),c=Y(A,null,n);i?.forEach((A,e)=>{c.delete(e)});const l=$(a,c,o);l.delete("transition-property"),l.delete("all"),l.delete("d"),l.delete("content"),t&&(l.delete("margin-top"),l.delete("margin-right"),l.delete("margin-bottom"),l.delete("margin-left"),l.delete("margin-block-start"),l.delete("margin-block-end"),l.delete("margin-inline-start"),l.delete("margin-inline-end"),l.set("box-sizing",["border-box",""])),"text"===l.get("background-clip")?.[0]&&e.classList.add("______background-clip--text"),w&&(l.has("font-kerning")||l.set("font-kerning",["normal",""]),"hidden"!==l.get("overflow-x")?.[0]&&"hidden"!==l.get("overflow-y")?.[0]||"ellipsis"!==l.get("text-overflow")?.[0]||A.scrollWidth!==A.clientWidth||l.set("text-overflow",["clip",""]));for(let A=s.length,e=0;e<A;e++)s.removeProperty(s.item(e));return l.forEach(([A,e],t)=>{s.setProperty(t,A,e)}),l}(A,n,t,e);t&&function(A,e){const{backgroundColor:t,width:n,height:r,style:o}=e,i=A.style;if(t&&i.setProperty("background-color",t,"important"),n&&i.setProperty("width",`${n}px`,"important"),r&&i.setProperty("height",`${r}px`,"important"),o)for(const A in o)i[A]=o[A]}(n,e);let o=!1;if(e.isEnable("copyScrollbar")){const e=[r.get("overflow-x")?.[0],r.get("overflow-y")?.[0]];o=e.includes("scroll")||(e.includes("auto")||e.includes("overlay"))&&(A.scrollHeight>A.clientHeight||A.scrollWidth>A.clientWidth)}const a=r.get("text-transform")?.[0],c=T(r.get("font-family")?.[0]),l=c?A=>{"uppercase"===a?A=A.toUpperCase():"lowercase"===a?A=A.toLowerCase():"capitalize"===a&&(A=A[0].toUpperCase()+A.substring(1)),c.forEach(e=>{let t=i.get(e);t||i.set(e,t=new Set),A.split("").forEach(A=>t.add(A))})}:void 0;return function(A,e,t,n,r){const{ownerWindow:o,svgStyleElement:i,svgStyles:s,currentNodeStyle:a}=n;function c(t){const i=o.getComputedStyle(A,t);let c=i.getPropertyValue("content");if(!c||"none"===c)return;r?.(c),c=c.replace(/(')|(")|(counter\(.+\))/g,"");const l=[K()],u=Y(A,t,n);a?.forEach((A,e)=>{u.delete(e)});const h=$(i,u,n.includeStyleProperties);h.delete("content"),h.delete("-webkit-locale"),"text"===h.get("background-clip")?.[0]&&e.classList.add("______background-clip--text");const g=[`content: '${c}';`];if(h.forEach(([A,e],t)=>{g.push(`${t}: ${A}${e?" !important":""};`)}),1===g.length)return;try{e.className=[e.className,...l].join(" ")}catch(A){return void n.log.warn("Failed to copyPseudoClass",A)}const d=g.join("\n ");let B=s.get(d);B||(B=[],s.set(d,B)),B.push(`.${l[0]}:${t}`)}i&&o&&(Z.forEach(c),t&&j.forEach(c))}(A,n,o,e,l),function(A,e){((A=>"TEXTAREA"===A.tagName)(A)||(A=>"INPUT"===A.tagName)(A)||(A=>"SELECT"===A.tagName)(A))&&e.setAttribute("value",A.value)}(A,n),b(A)||await q(A,n,e,l),await(s?.(n)),n}const a=A.cloneNode(!1);return await q(A,a,e),await(s?.(a)),a}function tA(A){if(A.ownerDocument=void 0,A.ownerWindow=void 0,A.svgStyleElement=void 0,A.svgDefsElement=void 0,A.svgStyles.clear(),A.defaultComputedStyles.clear(),A.sandbox){try{A.sandbox.remove()}catch(e){A.log.warn("Failed to destroyContext",e)}A.sandbox=void 0}A.workers=[],A.fontFamilies.clear(),A.fontCssTexts.clear(),A.requests.clear(),A.tasks=[],A.shadowRoots=[]}function nA(A,e){const{url:t,requestType:n="text",responseType:r="text",imageDom:o}=e;let i=t;const{timeout:s,acceptOfImage:a,requests:c,fetchFn:l,fetch:{requestInit:u,bypassingCache:h,placeholderImage:g},font:d,workers:B,fontFamilies:w}=A;"image"===n&&(f||m)&&A.drawImageCount++;let p=c.get(t);if(!p){h&&h instanceof RegExp&&h.test(i)&&(i+=(/\?/.test(i)?"&":"?")+(new Date).getTime());const e=n.startsWith("font")&&d&&d.minify,m=new Set;if(e){n.split(";")[1].split(",").forEach(A=>{w.has(A)&&w.get(A).forEach(A=>m.add(A))})}const C=e&&m.size,Q={url:i,timeout:s,responseType:C?"arrayBuffer":r,headers:"image"===n?{accept:a}:void 0,...u};p={type:n,resolve:void 0,reject:void 0,response:null},p.response=(async()=>{if(l&&"image"===n){const A=await l(t);if(A)return A}return!f&&t.startsWith("http")&&B.length?new Promise((A,e)=>{B[c.size&B.length-1].postMessage({rawUrl:t,...Q}),p.resolve=A,p.reject=e}):function(A){const{url:e,timeout:t,responseType:n,...r}=A,o=new AbortController,i=t?setTimeout(()=>o.abort(),t):void 0;return fetch(e,{signal:o.signal,...r}).then(A=>{if(!A.ok)throw new Error("Failed fetch, not 2xx response",{cause:A});switch(n){case"arrayBuffer":return A.arrayBuffer();case"dataUrl":return A.blob().then(L);default:return A.text()}}).finally(()=>clearTimeout(i))}(Q)})().catch(e=>{if(c.delete(t),"image"===n&&g)return A.log.warn("Failed to fetch image base64, trying to use placeholder image",i),"string"==typeof g?g:g(o);throw e}),c.set(t,p)}return p.response}async function rA(A,e,t,n){if(!oA(A))return A;for(const[r,o]of function(A,e){const t=[];return A.replace(iA,(A,n,r)=>(t.push([r,I(r,e)]),A)),t.filter(([A])=>!H(A))}(A,e))try{const e=await nA(t,{url:o,requestType:n?"image":"text",responseType:"dataUrl"});A=A.replace(sA(r),`$1${e}$3`)}catch(A){t.log.warn("Failed to fetch css data url",r,A)}return A}function oA(A){return/url\((['"]?)([^'"]+?)\1\)/.test(A)}const iA=/url\((['"]?)([^'"]+?)\1\)/g;function sA(A){const e=A.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}const aA=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function cA(A,e){const{tasks:t}=e;p(A)&&((F(A)||Q(A))&&t.push(...function(A,e){if(F(A)){const t=A.currentSrc||A.src;if(!H(t))return[nA(e,{url:t,imageDom:A,requestType:"image",responseType:"dataUrl"}).then(e=>{e&&(A.srcset="",A.dataset.originalSrc=t,A.src=e||"")})];(f||m)&&e.drawImageCount++}else if(C(A)&&!H(A.href.baseVal)){const t=A.href.baseVal;return[nA(e,{url:t,imageDom:A,requestType:"image",responseType:"dataUrl"}).then(e=>{e&&(A.dataset.originalSrc=t,A.href.baseVal=e||"")})]}return[]}(A,e)),"use"===A.tagName&&t.push(...function(A,e){const{ownerDocument:t,svgDefsElement:n}=e,r=A.getAttribute("href")??A.getAttribute("xlink:href");if(!r)return[];const[o,i]=r.split("#");if(i){const r=`#${i}`,s=e.shadowRoots.reduce((A,e)=>A??e.querySelector(`svg ${r}`),t?.querySelector(`svg ${r}`));if(o&&A.setAttribute("href",r),n?.querySelector(r))return[];if(s)return n?.appendChild(s.cloneNode(!0)),[];if(o)return[nA(e,{url:o,responseType:"text"}).then(A=>{n?.insertAdjacentHTML("beforeend",A)})]}return[]}(A,e))),y(A)&&t.push(...function(A,e){return aA.map(t=>{const n=A.getPropertyValue(t);return n&&"none"!==n?((f||m)&&e.drawImageCount++,rA(n,null,e,!0).then(e=>{e&&n!==e&&A.setProperty(t,e,A.getPropertyPriority(t))})):null}).filter(Boolean)}(A.style,e)),A.childNodes.forEach(A=>{cA(A,e)})}async function lA(A,e){const{ownerDocument:t,svgStyleElement:n,fontFamilies:r,fontCssTexts:o,tasks:i,font:s}=e;if(t&&n&&r.size)if(s&&s.cssText){const A=BA(s.cssText,e);n.appendChild(t.createTextNode(`${A}\n`))}else{const A=Array.from(t.styleSheets).filter(A=>{try{return"cssRules"in A&&Boolean(A.cssRules.length)}catch(t){return e.log.warn(`Error while reading CSS rules from ${A.href}`,t),!1}});await Promise.all(A.flatMap(A=>Array.from(A.cssRules).map(async(t,n)=>{if("CSSImportRule"===t.constructor.name){let r=n+1;const o=t.href;let i="";try{i=await nA(e,{url:o,requestType:"text",responseType:"text"})}catch(A){e.log.warn(`Error fetch remote css import from ${o}`,A)}const s=i.replace(iA,(A,e,t)=>A.replace(t,I(t,o)));for(const t of function(A){if(null==A)return[];const e=[];let t=A.replace(uA,"");for(;;){const A=hA.exec(t);if(!A)break;e.push(A[0])}t=t.replace(hA,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,r=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let A=n.exec(t);if(A)r.lastIndex=n.lastIndex;else{if(A=r.exec(t),!A)break;n.lastIndex=r.lastIndex}e.push(A[0])}return e}(s))try{A.insertRule(t,t.startsWith("@import")?r+=1:A.cssRules.length)}catch(A){e.log.warn("Error inserting rule from remote css import",{rule:t,error:A})}}})));A.flatMap(A=>Array.from(A.cssRules)).filter(A=>"CSSFontFaceRule"===A.constructor.name&&oA(A.style.getPropertyValue("src"))&&T(A.style.getPropertyValue("font-family"))?.some(A=>r.has(A))).forEach(A=>{const r=A,s=o.get(r.cssText);s?n.appendChild(t.createTextNode(`${s}\n`)):i.push(rA(r.cssText,r.parentStyleSheet?r.parentStyleSheet.href:null,e).then(A=>{A=BA(A,e),o.set(r.cssText,A),n.appendChild(t.createTextNode(`${A}\n`))}))})}}const uA=/(\/\*[\s\S]*?\*\/)/g,hA=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;const gA=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,dA=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function BA(A,e){const{font:t}=e,n=t?t?.preferredFormat:void 0;return n?A.replace(dA,A=>{for(;;){const[e,,t]=gA.exec(A)||[];if(!t)return"";if(t===n)return`src: ${e};`}}):A}async function wA(A,e){const t=await P(A,e);if(p(t.node)&&C(t.node))return t.node;const{ownerDocument:n,log:r,tasks:o,svgStyleElement:i,svgDefsElement:s,svgStyles:a,font:c,progress:l,autoDestruct:u,onCloneNode:h,onEmbedNode:g,onCreateForeignObjectSvg:d}=t;r.time("clone node");const B=await eA(t.node,t,!0);if(i&&n){let A="";a.forEach((e,t)=>{A+=`${e.join(",\n")} {\n ${t}\n}\n`}),i.appendChild(n.createTextNode(A))}r.timeEnd("clone node"),await(h?.(B)),!1!==c&&p(B)&&(r.time("embed web font"),await lA(0,t),r.timeEnd("embed web font")),r.time("embed node"),cA(B,t);const w=o.length;let f=0;l?.(f,w),await Promise.all([...Array.from({length:4})].map(async()=>{for(;;){const A=o.pop();if(!A)break;try{await A}catch(A){t.log.warn("Failed to run task",A)}l?.(++f,w)}})),r.timeEnd("embed node"),await(g?.(B));const m=function(A,e){const{width:t,height:n}=e,r=function(A,e,t){const n=x(t).createElementNS(S,"svg");return n.setAttributeNS(null,"width",A.toString()),n.setAttributeNS(null,"height",e.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${A} ${e}`),n}(t,n,A.ownerDocument),o=r.ownerDocument.createElementNS(r.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(A),r.appendChild(o),r}(B,t);return s&&m.insertBefore(s,m.children[0]),i&&m.insertBefore(i,m.children[0]),u&&tA(t),await(d?.(m)),m}async function fA(A,e){const t=await P(A,e),n=await wA(t),r=function(A,e){let t=(new XMLSerializer).serializeToString(A);return e&&(t=t.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}(n,t.isEnable("removeControlCharacter"));t.autoDestruct||(t.svgStyleElement=N(t.ownerDocument),t.svgDefsElement=t.ownerDocument?.createElementNS(S,"defs"),t.svgStyles.clear());const o=D(r,n.ownerDocument);return await V(o,t)}async function mA(A,e){const t=await P(A,e),{log:n,quality:r,type:o,dpi:i}=t,s=await fA(t);n.time("canvas to data url");let a=s.toDataURL(o,r);if(["image/png","image/jpeg"].includes(o)&&i&&g&&d){const[A,e]=a.split(",");let t=0,n=!1;if("image/png"===o){const A=function(A){let e=A.indexOf("AAlwSFlz");return-1===e&&(e=A.indexOf("AAAJcEhZ")),-1===e&&(e=A.indexOf("AAAACXBI")),e}(e);A>=0?(t=4*Math.ceil((A+28)/3),n=!0):t=44}else"image/jpeg"===o&&(t=24);const r=e.substring(0,t),s=e.substring(t),l=window.atob(r),u=new Uint8Array(l.length);for(let A=0;A<u.length;A++)u[A]=l.charCodeAt(A);const h="image/png"===o?c(u,i,n):function(A,e){return A[13]=1,A[14]=e>>8,A[15]=255&e,A[16]=e>>8,A[17]=255&e,A}(u,i);a=[A,",",window.btoa(String.fromCharCode(...h)),s].join("")}return n.timeEnd("canvas to data url"),a}async function pA(A,e){return mA(await P(A,{...e,type:"image/jpeg"}))}async function CA(A,e){return mA(await P(A,{...e,type:"image/png"}))}async function QA(A,e){return mA(await P(A,{...e,type:"image/webp"}))}var yA={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function UA(A){const e=A.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;const t=e[2].trim();return t.startsWith("#")?null:t}function FA(A){if(/%[0-9A-Fa-f]{2}/.test(A))return A;try{return encodeURI(A)}catch{return A}}var bA=function(A="[snapDOM]",{ttlMs:e=3e5,maxEntries:t=12}={}){const n=new Map;let r=0;function o(o,i,s){if(r>=t)return;const a=Date.now();(n.get(i)||0)>a||(n.set(i,a+e),r++,"warn"===o&&console&&console.warn?console.warn(`${A} ${s}`):console&&console.error&&console.error(`${A} ${s}`))}return{warnOnce(A,e){o("warn",A,e)},errorOnce(A,e){o("error",A,e)},reset(){n.clear(),r=0}}}("[snapDOM]",{ttlMs:18e4,maxEntries:10}),EA=new Map,vA=new Map;function HA(A,e){if(!e)return!1;if(function(A){return/^data:|^blob:|^about:blank$/i.test(A)}(A))return!1;if(function(A,e){try{const t="undefined"!=typeof location&&location.href?location.href:"http://localhost/",n=e.includes("{url}")?e.split("{url}")[0]:e,r=new URL(n||".",t),o=new URL(A,t);if(o.origin===r.origin)return!0;const i=o.searchParams;if(i&&(i.has("url")||i.has("target")))return!0}catch{}return!1}(A,e))return!1;try{const e="undefined"!=typeof location&&location.href?location.href:"http://localhost/",t=new URL(A,e);return"undefined"==typeof location||t.origin!==location.origin}catch{return!!e}}function IA(A){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(String(n.result||"")),n.onerror=()=>t(new Error("read_failed")),n.readAsDataURL(A)})}async function xA(A,e={}){const t=e.as??"blob",n=e.timeout??3e3,r=e.useProxy||"",o=e.errorTTL??8e3,i=e.headers||{},s=!!e.silent;if(/^data:/i.test(A))try{if("text"===t)return{ok:!0,data:String(A),status:200,url:A,fromCache:!1};if("dataURL"===t)return{ok:!0,data:String(A),status:200,url:A,fromCache:!1,mime:String(A).slice(5).split(";")[0]||""};const[,e="",n=""]=String(A).match(/^data:([^,]*),(.*)$/)||[],r=/;base64/i.test(e)?atob(n):decodeURIComponent(n),o=new Uint8Array([...r].map(A=>A.charCodeAt(0))),i=new Blob([o],{type:(e||"").split(";")[0]||""});return{ok:!0,data:i,status:200,url:A,fromCache:!1,mime:i.type||""}}catch{return{ok:!1,data:null,status:0,url:A,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(A))try{const e=await fetch(A);if(!e.ok)return{ok:!1,data:null,status:e.status,url:A,fromCache:!1,reason:"http_error"};const n=await e.blob(),r=n.type||e.headers.get("content-type")||"";if("dataURL"===t){return{ok:!0,data:await IA(n),status:e.status,url:A,fromCache:!1,mime:r}}if("text"===t){return{ok:!0,data:await n.text(),status:e.status,url:A,fromCache:!1,mime:r}}return{ok:!0,data:n,status:e.status,url:A,fromCache:!1,mime:r}}catch{return{ok:!1,data:null,status:0,url:A,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(A))return"dataURL"===t?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:A,fromCache:!1,mime:"image/png"}:{ok:!0,data:"text"===t?"":new Blob([]),status:200,url:A,fromCache:!1};const a=function(A,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,A].join("|")}(A,{as:t,timeout:n,useProxy:r,errorTTL:o}),c=vA.get(a);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&vA.delete(a);const l=EA.get(a);if(l)return l;const u=HA(A,r)?function(A,e){if(!e)return A;if(e.includes("{url}"))return e.replace("{urlRaw}",FA(A)).replace("{url}",encodeURIComponent(A));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(A)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(A)}`;if(e.endsWith("/"))return`${e}${FA(A)}`;const t=e.includes("?")?"&":"?";return`${e}${t}url=${encodeURIComponent(A)}`}(A,r):A;let h=e.credentials;if(!h)try{const e="undefined"!=typeof location&&location.href?location.href:"http://localhost/",t=new URL(A,e),n="undefined"!=typeof location&&t.origin===location.origin;h=n?"include":"omit"}catch{h="omit"}const g=new AbortController,d=setTimeout(()=>g.abort("timeout"),n),B=(async()=>{try{const n=await fetch(u,{signal:g.signal,credentials:h,headers:i});if(!n.ok){const r={ok:!1,data:null,status:n.status,url:u,fromCache:!1,reason:"http_error"};if(o>0&&vA.set(a,{until:Date.now()+o,result:r}),!s){const e=`${n.status} ${n.statusText||""}`.trim();bA.warnOnce(`http:${n.status}:${t}:${new URL(A,location?.href??"http://localhost/").origin}`,`HTTP error ${e} while fetching ${t} ${A}`)}return e.onError&&e.onError(r),r}if("text"===t){return{ok:!0,data:await n.text(),status:n.status,url:u,fromCache:!1}}const r=await n.blob(),c=r.type||n.headers.get("content-type")||"";if("dataURL"===t){return{ok:!0,data:await IA(r),status:n.status,url:u,fromCache:!1,mime:c}}return{ok:!0,data:r,status:n.status,url:u,fromCache:!1,mime:c}}catch(r){const i=r&&"object"==typeof r&&"name"in r&&"AbortError"===r.name?String(r.message||"").includes("timeout")?"timeout":"abort":"network",c={ok:!1,data:null,status:0,url:u,fromCache:!1,reason:i};if(!/^blob:/i.test(A)&&o>0&&vA.set(a,{until:Date.now()+o,result:c}),!s){const e=`${i}:${t}:${new URL(A,location?.href??"http://localhost/").origin}`,r="timeout"===i?`Timeout after ${n}ms. Consider increasing timeout or using a proxy for ${A}`:"abort"===i?`Request aborted while fetching ${t} ${A}`:`Network/CORS issue while fetching ${t} ${A}. A proxy may be required`;bA.errorOnce(e,r)}return e.onError&&e.onError(c),c}finally{clearTimeout(d),EA.delete(a)}})();return EA.set(a,B),B}function SA(A,e){if(!e||!A.width||!A.height)return A;const t=document.createElement("canvas");t.width=A.width,t.height=A.height;const n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,t.width,t.height),n.drawImage(A,0,0),t}async function LA(A,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(A)||"none"===A.trim())return A;const t=UA(A);if(!t)return A;const n=FA(t);if(yA.background.has(n)){const A=yA.background.get(n);return A?`url("${A}")`:"none"}try{const A=await xA(n,{as:"dataURL",useProxy:e.useProxy});return A.ok?(yA.background.set(n,A.data),`url("${A.data}")`):(yA.background.set(n,null),"none")}catch{return yA.background.set(n,null),"none"}}var DA=new Set(["meta","script","noscript","title","link","template"]),MA=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]);var KA=/(?:^|-)(animation|transition)(?:-|$)/i,TA=/^(--|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,kA=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope"]);function RA(A){const e=String(A).toLowerCase();return!!kA.has(e)||(!!TA.test(e)||!!KA.test(e))}function PA(A,e){if(e=String(e||"").toLowerCase(),MA.has(e))return"";const t=[],n=function(A){if(A=String(A).toLowerCase(),MA.has(A)){const e={};return yA.defaultStyle.set(A,e),e}if(yA.defaultStyle.has(A))return yA.defaultStyle.get(A);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));const t=document.createElement(A);t.style.all="initial",e.appendChild(t);const n=getComputedStyle(t),r={};for(let A of n){if(RA(A))continue;const e=n.getPropertyValue(A);r[A]=e}return e.removeChild(t),yA.defaultStyle.set(A,r),r}(e);for(let[e,r]of Object.entries(A)){if(RA(e))continue;const A=n[e];r&&r!==A&&t.push(`${e}:${r}`)}return t.sort(),t.join(";")}function OA(A,e=null){if(!(A instanceof Element))return window.getComputedStyle(A,e);let t=yA.computedStyle.get(A);if(t||(t=new Map,yA.computedStyle.set(A,t)),!t.has(e)){const n=window.getComputedStyle(A,e);t.set(e,n)}return t.get(e)}function NA(A){const e={};for(let t of A)e[t]=A.getPropertyValue(t);return e}function VA(A){const e=[];let t=0,n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&t++,")"===o&&t--,","===o&&0===t&&(e.push(A.slice(n,r).trim()),n=r+1)}return e.push(A.slice(n).trim()),e}function GA(A,{fast:e=!1}={}){if(e)return A();"requestIdleCallback"in window?requestIdleCallback(A,{timeout:50}):setTimeout(A,1)}function WA(){const A="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent:"",e=/^((?!chrome|android).)*safari/i.test(A),t=/AppleWebKit/i.test(A)&&/Mobile/i.test(A)&&!/Safari/i.test(A),n=/(MicroMessenger|wxwork|WeCom|WindowsWechat|MacWechat)/i.test(A);return e||t||n}var XA=new WeakMap,JA=new Map,YA=0;function $A(){YA++}var ZA=!1;var jA=new WeakMap;function _A(A,e=null,t={}){const n=XA.get(A);if(n&&n.epoch===YA)return n.snapshot;const r=e||getComputedStyle(A),o=function(A,e={}){const t={},n=A.getPropertyValue("visibility");for(let e=0;e<A.length;e++){const n=A[e];let r=A.getPropertyValue(n);"background-image"!==n&&"content"!==n||!r.includes("url(")||r.includes("data:")||(r="none"),t[n]=r}if(e.embedFonts){const e=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(const n of e)if(!t[n])try{const e=A.getPropertyValue(n);e&&(t[n]=e)}catch{}}return"hidden"===n&&(t.opacity="0"),t}(r,t);return function(A,e,t){if(A instanceof HTMLElement&&A.style&&A.style.height)return;const n=e.display||"";if(n.includes("flex")||n.includes("grid"))return;if(function(A){return A instanceof HTMLImageElement||A instanceof HTMLCanvasElement||A instanceof HTMLVideoElement||A instanceof HTMLIFrameElement||A instanceof SVGElement||A instanceof HTMLObjectElement||A instanceof HTMLEmbedElement}(A))return;const r=e.position;if("absolute"===r||"fixed"===r||"sticky"===r)return;if("none"!==e.transform)return;if(function(A){if(A.backgroundImage&&"none"!==A.backgroundImage)return!0;if(A.backgroundColor&&"rgba(0, 0, 0, 0)"!==A.backgroundColor&&"transparent"!==A.backgroundColor)return!0;if((parseFloat(A.borderTopWidth)||0)>0)return!0;if((parseFloat(A.borderBottomWidth)||0)>0)return!0;if((parseFloat(A.paddingTop)||0)>0)return!0;if((parseFloat(A.paddingBottom)||0)>0)return!0;const e=A.overflowBlock||A.overflowY||"visible";return"visible"!==e}(e))return;if(function(A){const e=A.parentElement;if(!e)return!1;const t=getComputedStyle(e).display||"";return t.includes("flex")||t.includes("grid")}(A))return;if(!function(A,e){if(A.textContent&&/\S/.test(A.textContent))return!0;const t=A.firstElementChild,n=A.lastElementChild;if(t&&"BR"===t.tagName||n&&"BR"===n.tagName)return!0;const r=A.scrollHeight;if(0===r)return!1;const o=parseFloat(e.paddingTop)||0,i=parseFloat(e.paddingBottom)||0;return r>o+i}(A,e))return;delete t.height,delete t["block-size"]}(A,r,o),XA.set(A,{epoch:YA,snapshot:o}),o}async function zA(A,e,t,n){if("STYLE"===A.tagName)return;const r=function(A,e){return A&&A.session&&A.persist?A:A&&(A.styleMap||A.styleCache||A.nodeMap)?{session:A,persist:{snapshotKeyCache:JA,defaultStyle:yA.defaultStyle,baseStyle:yA.baseStyle,image:yA.image,resource:yA.resource,background:yA.background,font:yA.font},options:e||{}}:{session:yA.session,persist:{snapshotKeyCache:JA,defaultStyle:yA.defaultStyle,baseStyle:yA.baseStyle,image:yA.image,resource:yA.resource,background:yA.background,font:yA.font},options:A||e||{}}}(t,n),o=r.options&&r.options.cache||"auto";if("disabled"!==o&&function(A=document.documentElement){if(!ZA){ZA=!0;try{new MutationObserver(()=>$A()).observe(A,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>$A()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{const A=document.fonts;A&&(A.addEventListener?.("loadingdone",$A),A.ready?.then(()=>$A()).catch(()=>{}))}catch{}}}(document.documentElement),"disabled"!==o||r.session.__bumpedForDisabled||($A(),JA.clear(),r.session.__bumpedForDisabled=!0),MA.has(A.tagName?.toLowerCase())){const t=A.getAttribute?.("style");t&&e.setAttribute("style",t)}const{session:i,persist:s}=r;i.styleCache.has(A)||i.styleCache.set(A,getComputedStyle(A));const a=_A(A,i.styleCache.get(A),r.options),c=function(A){let e=jA.get(A);return e||(e=Object.entries(A).sort((A,e)=>A[0]<e[0]?-1:A[0]>e[0]?1:0).map(([A,e])=>`${A}:${e}`).join(";"),jA.set(A,e),e)}(a);let l=s.snapshotKeyCache.get(c);if(!l){l=PA(a,A.tagName?.toLowerCase()||"div"),s.snapshotKeyCache.set(c,l)}i.styleMap.set(e,l)}function qA(A,e,t){return Promise.all(A.map(A=>new Promise(n=>{!function r(){GA(t=>{!t||"function"!=typeof t.timeRemaining||t.timeRemaining()>0?e(A,n):r()},{fast:t})}()})))}function Ae(A,e){return A?A=(A=(A=(A=(A=A.replace(/:host\(([^)]+)\)/g,(A,t)=>`:where(${e}:is(${t.trim()}))`)).replace(/:host\b/g,`:where(${e})`)).replace(/:host-context\(([^)]+)\)/g,(A,t)=>`:where(:where(${t.trim()}) ${e})`)).replace(/::slotted\(([^)]+)\)/g,(A,t)=>`:where(${e} ${t.trim()})`)).replace(/(^|})(\s*)([^@}{]+){/g,(A,t,n,r)=>{const o=function(A,e,t=!0){return A.split(",").map(A=>A.trim()).filter(Boolean).map(A=>{if(A.startsWith(":where("))return A;if(A.startsWith("@"))return A;const n=t?(r=(r=A).trim())?/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(r)?r:`${r}:not([data-sd-slotted])`:r:A;var r;return`:where(${e} ${n})`}).join(", ")}(r,e,!0);return`${t}${n}${o}{`}):""}function ee(A,e){try{let t=getComputedStyle(A).getPropertyValue(e).trim();if(t)return t}catch{}try{let A=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(A)return A}catch{}return""}async function te(A,e,t){const n=await async function(A,e=3){const t=()=>{try{return A.contentDocument||A.contentWindow?.document||null}catch{return null}};let n=t(),r=0;for(;r<e&&(!n||!n.body&&!n.documentElement);)await new Promise(A=>setTimeout(A,0)),n=t(),r++;return n&&(n.body||n.documentElement)?n:null}(A,3);if(!n)throw new Error("iframe document not accessible/ready");const{contentWidth:r,contentHeight:o,rect:i}=function(A){const e=A.getBoundingClientRect();let t=0,n=0,r=0,o=0;try{const e=getComputedStyle(A);t=parseFloat(e.borderLeftWidth)||0,n=parseFloat(e.borderRightWidth)||0,r=parseFloat(e.borderTopWidth)||0,o=parseFloat(e.borderBottomWidth)||0}catch{}return{contentWidth:Math.max(0,Math.round(e.width-(t+n))),contentHeight:Math.max(0,Math.round(e.height-(r+o))),rect:e}}(A),s=t?.snap;if(!s||"function"!=typeof s.toPng)throw new Error("snapdom.toPng not available in iframe or window");const a={...t,scale:1},c=function(A,e,t){const n=A.createElement("style");return n.setAttribute("data-sd-iframe-pin",""),n.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${t}px !important;min-width: ${e}px !important;min-height: ${t}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(A.head||A.documentElement).appendChild(n),()=>{try{n.remove()}catch{}}}(n,r,o);let l;try{l=await s.toPng(n.documentElement,a)}finally{c()}l.style.display="block",l.style.width=`${r}px`,l.style.height=`${o}px`;const u=document.createElement("div");return e.nodeMap.set(u,A),zA(A,u,e,t),u.style.overflow="hidden",u.style.display="block",u.style.width||(u.style.width=`${Math.round(i.width)}px`),u.style.height||(u.style.height=`${Math.round(i.height)}px`),u.appendChild(l),u}async function ne(A,e,t){if(!A)throw new Error("Invalid node");const n=new Set;let r,o=null,i=null;if(A.nodeType===Node.ELEMENT_NODE){const e=(A.localName||A.tagName||"").toLowerCase();if("snapdom-sandbox"===A.id||A.hasAttribute("data-snapdom-sandbox"))return null;if(DA.has(e))return null}if(A.nodeType===Node.TEXT_NODE)return A.cloneNode(!0);if(A.nodeType!==Node.ELEMENT_NODE)return A.cloneNode(!0);if("exclude"===A.getAttribute("data-capture")){if("hide"===t.excludeMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.excludeMode)return null}if(t.exclude&&Array.isArray(t.exclude))for(const e of t.exclude)try{if(A.matches?.(e)){if("hide"===t.excludeMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.excludeMode)return null}}catch(A){console.warn(`Invalid selector in exclude option: ${e}`,A)}if("function"==typeof t.filter)try{if(!t.filter(A)){if("hide"===t.filterMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.filterMode)return null}}catch(A){console.warn("Error in filter function:",A)}if("IFRAME"===A.tagName){let n=!1;try{n=!(!A.contentDocument&&!A.contentWindow?.document)}catch{n=!1}if(n)try{return await te(A,e,t)}catch(A){console.warn("[SnapDOM] iframe rasterization failed, fallback:",A)}if(t.placeholders){const n=document.createElement("div");return n.style.cssText=`width:${A.offsetWidth}px;height:${A.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,zA(A,n,e,t),n}{const n=A.getBoundingClientRect(),r=document.createElement("div");return r.style.cssText=`display:inline-block;width:${n.width}px;height:${n.height}px;visibility:hidden;`,zA(A,r,e,t),r}}if("placeholder"===A.getAttribute("data-capture")){const n=A.cloneNode(!1);e.nodeMap.set(n,A),zA(A,n,e,t);const r=document.createElement("div");return r.textContent=A.getAttribute("data-placeholder-text")||"",r.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",n.appendChild(r),n}if("CANVAS"===A.tagName){const n=A.toDataURL(),r=document.createElement("img");return r.src=n,r.width=A.width,r.height=A.height,e.nodeMap.set(r,A),zA(A,r,e,t),r}try{if(r=A.cloneNode(!1),function(A,e){if(!(A instanceof Element&&e instanceof Element))return;const t=A.getAttribute?.("style");let n,r=!(!t||!t.includes("var("));if(!r&&A.attributes?.length){const e=A.attributes;for(let A=0;A<e.length;A++){const t=e[A];if(t&&"string"==typeof t.value&&t.value.includes("var(")){r=!0;break}}}if(!r)return;try{n=getComputedStyle(A)}catch{return}const o=A.style;if(o&&o.length)for(let A=0;A<o.length;A++){const t=o[A],r=o.getPropertyValue(t);if(!r||!r.includes("var("))continue;const i=n.getPropertyValue(t);if(i)try{e.style.setProperty(t,i.trim(),o.getPropertyPriority(t))}catch{}}if(A.attributes?.length){const t=A.attributes;for(let A=0;A<t.length;A++){const r=t[A];if(!r||"string"!=typeof r.value||!r.value.includes("var("))continue;const o=r.name;let i="";try{i=n.getPropertyValue(o)}catch{}if(i)try{e.style.setProperty(o,i.trim())}catch{}}}}(A,r),e.nodeMap.set(r,A),"IMG"===A.tagName){!function(A,e){try{const t=A.currentSrc||A.src||"";if(!t)return;e.setAttribute("src",t),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}(A,r);try{const e=A.getBoundingClientRect();let t=Math.round(e.width||0),n=Math.round(e.height||0);if(!t||!n){const e=window.getComputedStyle(A),r=parseFloat(e.width)||0,o=parseFloat(e.height)||0,i=parseInt(A.getAttribute("width")||"",10)||0,s=parseInt(A.getAttribute("height")||"",10)||0,a=A.width||A.naturalWidth||0,c=A.height||A.naturalHeight||0;t=Math.round(t||r||i||a||0),n=Math.round(n||o||s||c||0)}t&&(r.dataset.snapdomWidth=String(t)),n&&(r.dataset.snapdomHeight=String(n))}catch{}}}catch(e){throw console.error("[Snapdom] Failed to clone node:",A,e),e}if(A instanceof HTMLTextAreaElement){const e=A.getBoundingClientRect();r.style.width=`${e.width}px`,r.style.height=`${e.height}px`}if(A instanceof HTMLInputElement&&(r.value=A.value,r.setAttribute("value",A.value),void 0!==A.checked&&(r.checked=A.checked,A.checked&&r.setAttribute("checked",""),A.indeterminate&&(r.indeterminate=A.indeterminate))),A instanceof HTMLSelectElement&&(o=A.value),A instanceof HTMLTextAreaElement&&(i=A.value),zA(A,r,e,t),A.shadowRoot){let o=function(A,n){if(A.nodeType===Node.ELEMENT_NODE&&"STYLE"===A.tagName)return n(null);ne(A,e,t).then(A=>{n(A||null)}).catch(()=>{n(null)})};try{const e=A.shadowRoot.querySelectorAll("slot");for(const A of e){let e=[];try{e=A.assignedNodes?.({flatten:!0})||A.assignedNodes?.()||[]}catch{e=A.assignedNodes?.()||[]}for(const A of e)n.add(A)}}catch{}const i=function(A){return A.shadowScopeSeq=(A.shadowScopeSeq||0)+1,`s${A.shadowScopeSeq}`}(e),s=`[data-sd="${i}"]`;try{r.setAttribute("data-sd",i)}catch{}const a=function(A){let e="";try{A.querySelectorAll("style").forEach(A=>{e+=(A.textContent||"")+"\n"});const t=A.adoptedStyleSheets||[];for(const A of t)try{if(A&&A.cssRules)for(const t of A.cssRules)e+=t.cssText+"\n"}catch{}}catch{}return e}(A.shadowRoot),c=Ae(a,s),l=function(A,e,t){const n=[];for(const t of e){const e=ee(A,t);e&&n.push(`${t}: ${e};`)}return n.length?`${t}{${n.join("")}}\n`:""}(A,function(A){const e=new Set;if(!A)return e;const t=/var\(\s*(--[A-Za-z0-9_-]+)\b/g;let n;for(;n=t.exec(A);)e.add(n[1]);return e}(a),s);!function(A,e,t){if(!e)return;const n=document.createElement("style");n.setAttribute("data-sd",t),n.textContent=e,A.insertBefore(n,A.firstChild||null)}(r,l+c,i);const u=document.createDocumentFragment(),h=await qA(Array.from(A.shadowRoot.childNodes),o,t.fast);u.append(...h.filter(A=>!!A)),r.appendChild(u)}if("SLOT"===A.tagName){let n=function(A,n){ne(A,e,t).then(A=>{var e;A&&(e=A)&&(e.nodeType===Node.ELEMENT_NODE&&e.setAttribute("data-sd-slotted",""),e.querySelectorAll&&e.querySelectorAll("*").forEach(A=>A.setAttribute("data-sd-slotted",""))),n(A||null)}).catch(()=>{n(null)})};const r=A.assignedNodes?.({flatten:!0})||[],o=r.length>0?r:Array.from(A.childNodes),i=document.createDocumentFragment(),s=await qA(Array.from(o),n,t.fast);return i.append(...s.filter(A=>!!A)),i}const s=await qA(Array.from(A.childNodes),function(A,r){if(n.has(A))return r(null);ne(A,e,t).then(A=>{r(A||null)}).catch(()=>{r(null)})},t.fast);if(r.append(...s.filter(A=>!!A)),null!==o&&r instanceof HTMLSelectElement){r.value=o;for(const A of r.options)A.value===o?A.setAttribute("selected",""):A.removeAttribute("selected")}return null!==i&&r instanceof HTMLTextAreaElement&&(r.textContent=i),r}var re=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],oe=[];function ie(A){const e="string"==typeof A?A:"",t=[...re,...oe];for(const A of t)if(A instanceof RegExp&&A.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}async function se(A,e,t,n=32,r="#000"){e=e.replace(/^['"]+|['"]+$/g,"");const o=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}const i=document.createElement("span");i.textContent=A,i.style.position="absolute",i.style.visibility="hidden",i.style.fontFamily=`"${e}"`,i.style.fontWeight=t||"normal",i.style.fontSize=`${n}px`,i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.padding="0",i.style.margin="0",document.body.appendChild(i);const s=i.getBoundingClientRect(),a=Math.ceil(s.width),c=Math.ceil(s.height);document.body.removeChild(i);const l=document.createElement("canvas");l.width=Math.max(1,a*o),l.height=Math.max(1,c*o);const u=l.getContext("2d");return u.scale(o,o),u.font=t?`${t} ${n}px "${e}"`:`${n}px "${e}"`,u.textAlign="left",u.textBaseline="top",u.fillStyle=r,u.fillText(A,0,0),{dataUrl:l.toDataURL(),width:a,height:c}}var ae=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function ce(A){if(!A)return"";for(let e of A.split(",")){let A=e.trim().replace(/^['"]+|['"]+$/g,"");if(A&&!ae.has(A.toLowerCase()))return A}return""}function le(A){const e=String(A??"400").trim().toLowerCase();if("normal"===e)return 400;if("bold"===e)return 700;const t=parseInt(e,10);return Number.isFinite(t)?Math.min(900,Math.max(100,t)):400}function ue(A){const e=String(A??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function he(A,e){if(!A)return!1;try{const t=new URL(A,location.href);if(t.origin===location.origin)return!0;const n=t.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(A=>n.endsWith(A)))return!0;const r=(t.pathname+t.search).toLowerCase();if(/\bfont(s)?\b/.test(r)||/\.woff2?(\b|$)/.test(r))return!0;for(const A of e){const e=A.toLowerCase().replace(/\s+/g,"+"),t=A.toLowerCase().replace(/\s+/g,"-");if(r.includes(e)||r.includes(t))return!0}return!1}catch{return!1}}function ge(A,e){return A?A.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(A,t,n)=>{const r=(n||"").trim();if(!r||/^data:|^blob:|^https?:|^file:|^about:/i.test(r))return A;let o=r;try{o=new URL(r,e||location.href).href}catch{}return`url("${o}")`}):A}var de=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g;async function Be(A,e,t){if(!A)return A;const n=new Set;function r(A,e){try{return new URL(A,e||location.href).href}catch{return A}}let o=ge(A,e||location.href);return o=await async function A(e,o,i=0){if(i>4)return console.warn(`[snapDOM] @import depth exceeded (4) at ${o}`),e;let s,a="",c=0;for(;s=de.exec(e);){a+=e.slice(c,s.index),c=de.lastIndex;const l=r((s[2]||s[4]||"").trim(),o);if(n.has(l)){console.warn(`[snapDOM] Skipping circular @import: ${l}`);continue}n.add(l);let u="";try{const A=await xA(l,{as:"text",useProxy:t,silent:!0});A.ok&&"string"==typeof A.data&&(u=A.data)}catch{}u?(u=ge(u,l),u=await A(u,l,i+1),a+=`\n/* inlined: ${l} */\n${u}\n`):a+=s[0]}return a+=e.slice(c),a}(o,e||location.href,0),o}var we=/url\((["']?)([^"')]+)\1\)/g,fe=/@font-face[^{}]*\{[^}]*\}/g;function me(A){if(!A)return[];const e=[],t=A.split(",").map(A=>A.trim()).filter(Boolean);for(const A of t){const t=A.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!t)continue;const n=t[1],r=t[2],o=A=>{if(!A.includes("?"))return parseInt(A,16);return[parseInt(A.replace(/\?/g,"0"),16),parseInt(A.replace(/\?/g,"F"),16)]};if(r){const A=o(n),t=o(r),i=Array.isArray(A)?A[0]:A,s=Array.isArray(t)?t[1]:t;e.push([Math.min(i,s),Math.max(i,s)])}else{const A=o(n);Array.isArray(A)?e.push([A[0],A[1]]):e.push([A,A])}}return e}function pe(A,e){if(!e.length)return!0;if(!A||0===A.size)return!0;for(const t of A)for(const[A,n]of e)if(t>=A&&t<=n)return!0;return!1}function Ce(A,e){const t=[];if(!A)return t;for(const n of A.matchAll(we)){let A=(n[2]||"").trim();if(A&&!A.startsWith("data:")){if(!/^https?:/i.test(A))try{A=new URL(A,e||location.href).href}catch{}t.push(A)}}return t}async function Qe(A,e,t=""){let n=A;for(const r of A.matchAll(we)){const A=UA(r[0]);if(!A)continue;let o=A;if(!o.startsWith("http")&&!o.startsWith("data:"))try{o=new URL(o,e||location.href).href}catch{}if(!ie(o))if(yA.resource?.has(o))yA.font?.add(o),n=n.replace(r[0],`url(${yA.resource.get(o)})`);else if(!yA.font?.has(o))try{const A=await xA(o,{as:"dataURL",useProxy:t,silent:!0});if(A.ok&&"string"==typeof A.data){const e=A.data;yA.resource?.set(o,e),yA.font?.add(o),n=n.replace(r[0],`url(${e})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",o)}}return n}function ye(A={}){const e=new Set((A.families||[]).map(A=>String(A).toLowerCase())),t=new Set((A.domains||[]).map(A=>String(A).toLowerCase())),n=new Set((A.subsets||[]).map(A=>String(A).toLowerCase()));return(A,r)=>{if(e.size&&e.has(A.family.toLowerCase()))return!0;if(t.size)for(const e of A.srcUrls)try{if(t.has(new URL(e).host.toLowerCase()))return!0}catch{}if(n.size){const A=function(A){if(!A.length)return null;const e=(e,t)=>A.some(([A,n])=>!(n<e||A>t)),t=e(0,255)||e(305,305),n=e(256,591)||e(7680,7935),r=e(880,1023),o=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":o?"cyrillic":r?"greek":n?"latin-ext":t?"latin":null}(r);if(A&&n.has(A))return!0}return!1}}async function Ue(A,e,t,n){let r;try{r=A.cssRules||[]}catch{return}const o=(A,e)=>{try{return new URL(A,e||location.href).href}catch{return A}};for(const A of r){if(A.type===CSSRule.IMPORT_RULE&&A.styleSheet){const r=A.href?o(A.href,e):e;if(n.depth>=4){console.warn(`[snapDOM] CSSOM import depth exceeded (4) at ${r}`);continue}if(r&&n.visitedSheets.has(r)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${r}`);continue}r&&n.visitedSheets.add(r);const i={...n,depth:(n.depth||0)+1};await Ue(A.styleSheet,r,t,i);continue}if(A.type===CSSRule.FONT_FACE_RULE){const r=ce((A.style.getPropertyValue("font-family")||"").trim());if(!r||ie(r))continue;const o=(A.style.getPropertyValue("font-weight")||"400").trim(),i=(A.style.getPropertyValue("font-style")||"normal").trim(),s=(A.style.getPropertyValue("font-stretch")||"100%").trim(),a=(A.style.getPropertyValue("src")||"").trim(),c=(A.style.getPropertyValue("unicode-range")||"").trim();if(!n.faceMatchesRequired(r,i,o,s))continue;const l=me(c);if(!pe(n.usedCodepoints,l))continue;const u={family:r,weightSpec:o,styleSpec:i,stretchSpec:s,unicodeRange:c,srcRaw:a,srcUrls:Ce(a,e||location.href),href:e||location.href};if(n.simpleExcluder&&n.simpleExcluder(u,l))continue;if(/url\(/i.test(a)){const A=await Qe(a,e||location.href,n.useProxy);await t(`@font-face{font-family:${r};src:${A};font-style:${i};font-weight:${o};font-stretch:${s};${c?`unicode-range:${c};`:""}}`)}else await t(`@font-face{font-family:${r};src:${a};font-style:${i};font-weight:${o};font-stretch:${s};${c?`unicode-range:${c};`:""}}`)}}}async function Fe({required:A,usedCodepoints:e,exclude:t,localFonts:n=[],useProxy:r=""}={}){A instanceof Set||(A=new Set),e instanceof Set||(e=new Set);const o=new Map;for(const e of A){const[A,t,n,r]=String(e).split("__");if(!A)continue;const i=o.get(A)||[];i.push({w:parseInt(t,10),s:n,st:parseInt(r,10)}),o.set(A,i)}function i(A,e,t,n){if(!o.has(A))return!1;const r=o.get(A),i=function(A){const e=String(A||"400").trim(),t=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(t){const A=le(t[1]),e=le(t[2]);return{min:Math.min(A,e),max:Math.max(A,e)}}const n=le(e);return{min:n,max:n}}(t),s=function(A){const e=String(A||"normal").trim().toLowerCase();return"italic"===e?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}(e),a=function(A){const e=String(A||"100%").trim(),t=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(t){const A=parseFloat(t[1]),e=parseFloat(t[2]);return{min:Math.min(A,e),max:Math.max(A,e)}}const n=e.match(/(\d+(?:\.\d+)?)\s*%/),r=n?parseFloat(n[1]):100;return{min:r,max:r}}(n),c=i.min!==i.max,l=i.min,u=A=>"normal"===s.kind&&"normal"===A||"normal"!==s.kind&&("italic"===A||"oblique"===A);let h=!1;for(const A of r){const e=c?A.w>=i.min&&A.w<=i.max:A.w===l,t=u(ue(A.s)),n=A.st>=a.min&&A.st<=a.max;if(e&&t&&n){h=!0;break}}if(h)return!0;if(!c)for(const A of r){const e=u(ue(A.s)),t=A.st>=a.min&&A.st<=a.max;if(Math.abs(l-A.w)<=300&&e&&t)return!0}return!1}const s=ye(t),a=function(A,e,t,n){return`fonts-embed-css::req=${Array.from(A||[]).sort().join("|")}::ex=${e?JSON.stringify({families:(e.families||[]).map(A=>String(A).toLowerCase()).sort(),domains:(e.domains||[]).map(A=>String(A).toLowerCase()).sort(),subsets:(e.subsets||[]).map(A=>String(A).toLowerCase()).sort()}):""}::lf=${(t||[]).map(A=>`${(A.family||"").toLowerCase()}::${A.weight||"normal"}::${A.style||"normal"}::${A.src||""}`).sort().join("|")}::px=${n||""}`}(A,t,n,r);if(yA.resource?.has(a))return yA.resource.get(a);const c=function(A){const e=new Set;for(const t of A||[]){const A=String(t).split("__")[0]?.trim();A&&e.add(A)}return e}(A),l=[],u=de;for(const A of document.querySelectorAll("style")){const e=A.textContent||"";for(const A of e.matchAll(u)){const e=(A[2]||A[4]||"").trim();if(!e||ie(e))continue;!!document.querySelector(`link[rel="stylesheet"][href="${e}"]`)||l.push(e)}}l.length&&await Promise.all(l.map(A=>new Promise(e=>{if(document.querySelector(`link[rel="stylesheet"][href="${A}"]`))return e(null);const t=document.createElement("link");t.rel="stylesheet",t.href=A,t.setAttribute("data-snapdom","injected-import"),t.onload=()=>e(t),t.onerror=()=>e(null),document.head.appendChild(t)})));let h="";const g=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(A=>!!A.href);for(const A of g)try{if(ie(A.href))continue;let n="",o=!1;try{o=new URL(A.href,location.href).origin===location.origin}catch{}if(!o&&!he(A.href,c))continue;if(o){const e=Array.from(document.styleSheets).find(e=>e.href===A.href);if(e)try{const A=e.cssRules||[];n=Array.from(A).map(A=>A.cssText).join("")}catch{}}if(!n){if(n=(await xA(A.href,{as:"text",useProxy:r})).data,ie(A.href))continue}n=await Be(n,A.href,r);let a="";for(const o of n.match(fe)||[]){const n=ce((o.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim());if(!n||ie(n))continue;const c=(o.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),l=(o.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),u=(o.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),h=(o.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),g=(o.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),d=Ce(g,A.href);if(!i(n,l,c,u))continue;const B=me(h);if(!pe(e,B))continue;const w={family:n,weightSpec:c,styleSpec:l,stretchSpec:u,unicodeRange:h,srcRaw:g,srcUrls:d,href:A.href};if(t&&s(w,B))continue;a+=/url\(/i.test(g)?await Qe(o,A.href,r):o}a.trim()&&(h+=a)}catch{console.warn("[snapDOM] Failed to process stylesheet:",A.href)}const d={requiredIndex:o,usedCodepoints:e,faceMatchesRequired:i,simpleExcluder:t?ye(t):null,useProxy:r,visitedSheets:new Set,depth:0};for(const A of document.styleSheets)if(!A.href||!g.some(e=>e.href===A.href))try{const e=A.href||location.href;e&&d.visitedSheets.add(e),await Ue(A,e,async A=>{h+=A},d)}catch{}try{for(const A of document.fonts||[]){if(!A||!A.family||"loaded"!==A.status||!A._snapdomSrc)continue;const e=String(A.family).replace(/^['"]+|['"]+$/g,"");if(ie(e))continue;if(!o.has(e))continue;if(t?.families&&t.families.some(A=>String(A).toLowerCase()===e.toLowerCase()))continue;let n=A._snapdomSrc;if(!String(n).startsWith("data:"))if(yA.resource?.has(A._snapdomSrc))n=yA.resource.get(A._snapdomSrc),yA.font?.add(A._snapdomSrc);else if(!yA.font?.has(A._snapdomSrc))try{const e=await xA(A._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(!e.ok||"string"!=typeof e.data)continue;n=e.data,yA.resource?.set(A._snapdomSrc,n),yA.font?.add(A._snapdomSrc)}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",A._snapdomSrc);continue}h+=`@font-face{font-family:'${e}';src:url(${n});font-style:${A.style||"normal"};font-weight:${A.weight||"normal"};}`}}catch{}for(const A of n){if(!A||"object"!=typeof A)continue;const e=String(A.family||"").replace(/^['"]+|['"]+$/g,"");if(!e||ie(e))continue;if(!o.has(e))continue;if(t?.families&&t.families.some(A=>String(A).toLowerCase()===e.toLowerCase()))continue;const n=null!=A.weight?String(A.weight):"normal",i=null!=A.style?String(A.style):"normal",s=null!=A.stretchPct?`${A.stretchPct}%`:"100%",a=String(A.src||"");let c=a;if(!c.startsWith("data:"))if(yA.resource?.has(a))c=yA.resource.get(a),yA.font?.add(a);else if(!yA.font?.has(a))try{const A=await xA(a,{as:"dataURL",useProxy:r,silent:!0});if(!A.ok||"string"!=typeof A.data)continue;c=A.data,yA.resource?.set(a,c),yA.font?.add(a)}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",a);continue}h+=`@font-face{font-family:'${e}';src:url(${c});font-style:${i};font-weight:${n};font-stretch:${s};}`}return h&&(h=function(A){if(!A)return A;const e=/@font-face[^{}]*\{[^}]*\}/gi,t=new Set,n=[];for(const r of A.match(e)||[]){const A=ce(r.match(/font-family:\s*([^;]+);/i)?.[1]||""),e=(r.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),o=(r.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),i=(r.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),s=(r.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),a=(r.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),c=Ce(a,location.href),l=c.length?c.map(A=>String(A).toLowerCase()).sort().join("|"):a.toLowerCase(),u=[String(A||"").toLowerCase(),e,o,i,s.toLowerCase(),l].join("|");t.has(u)||(t.add(u),n.push(r))}if(0===n.length)return A;let r=0;return A.replace(e,()=>n[r++]||"")}(h),yA.resource?.set(a,h)),h}function be(A){const e=new Set;if(!A)return e;const t=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT,null),n=A=>{const t=ce(A.fontFamily);if(!t)return;var n,r,o;e.add((n=A.fontWeight,r=A.fontStyle,o=A.fontStretch,`${t}__${le(n)}__${ue(r)}__${function(A){const e=String(A??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}(o)}`))};n(getComputedStyle(A));const r=getComputedStyle(A,"::before");r&&r.content&&"none"!==r.content&&n(r);const o=getComputedStyle(A,"::after");for(o&&o.content&&"none"!==o.content&&n(o);t.nextNode();){const A=t.currentNode;n(getComputedStyle(A));const e=getComputedStyle(A,"::before");e&&e.content&&"none"!==e.content&&n(e);const r=getComputedStyle(A,"::after");r&&r.content&&"none"!==r.content&&n(r)}return e}function Ee(A,e=!1){let t="",n=Math.max(1,A);for(;n>0;)n--,t=String.fromCharCode(97+n%26)+t,n=Math.floor(n/26);return e?t.toUpperCase():t}function ve(A,e=!0){const t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n=Math.max(1,Math.min(3999,A)),r="";for(const[A,e]of t)for(;n>=A;)r+=e,n-=A;return e?r:r.toLowerCase()}function He(A,e){switch((e||"decimal").toLowerCase()){case"decimal":default:return String(Math.max(0,A));case"decimal-leading-zero":return(A<10?"0":"")+String(Math.max(0,A));case"lower-alpha":return Ee(A,!1);case"upper-alpha":return Ee(A,!0);case"lower-roman":return ve(A,!1);case"upper-roman":return ve(A,!0)}}function Ie(A){const e=new WeakMap,t=A instanceof Document?A.documentElement:A,n=A=>{let e=0,t=A?.parentElement;if(!t)return 0;for(const n of t.children){if(n===A)break;"LI"===n.tagName&&e++}return e},r=(A,e,t)=>{const r=(A=>{const e=new Map;for(const[t,n]of A)e.set(t,n.slice());return e})(A);let o,i;try{o=t.style?.counterReset||getComputedStyle(t).counterReset}catch{}if(o&&"none"!==o)for(const A of o.split(",")){const t=A.trim().split(/\s+/),n=t[0],o=Number.isFinite(Number(t[1]))?Number(t[1]):0;if(!n)continue;const i=e.get(n);if(i&&i.length){const A=i.slice();A.push(o),r.set(n,A)}else r.set(n,[o])}try{i=t.style?.counterIncrement||getComputedStyle(t).counterIncrement}catch{}if(i&&"none"!==i)for(const A of i.split(",")){const e=A.trim().split(/\s+/),t=e[0],n=Number.isFinite(Number(e[1]))?Number(e[1]):1;if(!t)continue;const o=r.get(t)||[];0===o.length&&o.push(0),o[o.length-1]+=n,r.set(t,o)}try{if("list-item"===getComputedStyle(t).display&&(A=>A&&"LI"===A.tagName)(t)){const A=t.parentElement;let e=1;if(A&&"OL"===A.tagName){const r=A.getAttribute("start"),o=Number.isFinite(Number(r))?Number(r):1,i=n(t),s=t.getAttribute("value");e=Number.isFinite(Number(s))?Number(s):o+i}else e=1+n(t);const o=r.get("list-item")||[];0===o.length&&o.push(0),o[o.length-1]=e,r.set("list-item",o)}}catch{}return r},o=(A,t,n)=>{const i=r(n,t,A);e.set(A,i);let s=i;for(const e of A.children){s=o(e,i,s)}return i},i=new Map;return o(t,i,i),{get(A,t){const n=e.get(A)?.get(t);return n&&n.length?n[n.length-1]:0},getStack(A,t){const n=e.get(A)?.get(t);return n?n.slice():[]}}}var xe=null,Se=new WeakMap;function Le(A,e){const t=A.parentElement,n=t?Se.get(t):null;return n?{get(A,t){const r=e.get(A,t),o=n.get(t);return"number"==typeof o?Math.max(r,o):r},getStack(A,t){const r=e.getStack(A,t);if(!r.length)return r;const o=n.get(t);if("number"==typeof o){const A=r.slice();return A[A.length-1]=Math.max(A[A.length-1],o),A}return r}}:e}function De(A,e,t){const n=new Map;function r(A){const e=[];if(!A||"none"===A)return e;for(const t of String(A).split(",")){const A=t.trim().split(/\s+/),n=A[0],r=Number.isFinite(Number(A[1]))?Number(A[1]):void 0;n&&e.push({name:n,num:r})}return e}const o=r(e?.counterReset),i=r(e?.counterIncrement);function s(e){if(n.has(e))return n.get(e).slice();let r=t.getStack(A,e);r=r.length?r.slice():[];const s=o.find(A=>A.name===e);if(s){const A=Number.isFinite(s.num)?s.num:0;r=r.length?[...r,A]:[A]}const a=i.find(A=>A.name===e);if(a){const A=Number.isFinite(a.num)?a.num:1;0===r.length&&(r=[0]),r[r.length-1]+=A}return n.set(e,r.slice()),r}return{get(A,e){const t=s(e);return t.length?t[t.length-1]:0},getStack:(A,e)=>s(e),__incs:i}}function Me(A,e,t){let n;try{n=getComputedStyle(A,e)}catch{}const r=n?.content;if(!r||"none"===r||"normal"===r)return{text:"",incs:[]};const o=De(A,n,Le(A,t));let i=/\bcounter\s*\(|\bcounters\s*\(/.test(r||"")?function(A,e,t){if(!A||"none"===A)return A;try{const n=/\b(counter|counters)\s*\(([^)]+)\)/g;return(A.replace(n,(A,n,r)=>{const o=String(r).split(",").map(A=>A.trim());if("counter"===n){const A=o[0]?.replace(/^["']|["']$/g,""),n=(o[1]||"decimal").toLowerCase();return He(t.get(e,A),n)}{const A=o[0]?.replace(/^["']|["']$/g,""),n=o[1]?.replace(/^["']|["']$/g,"")??"",r=(o[2]||"decimal").toLowerCase(),i=t.getStack(e,A);return i.length?i.map(A=>He(A,r)).join(n):""}})||"").replace(/"([^"]*)"/g,"$1")}catch{return"- "}}(r,A,o):r;const s=function(A){if(!A)return"";const e=[],t=/"([^"]*)"/g;let n;for(;n=t.exec(A);)e.push(n[1]);return e.length?e.join(""):(A||"").replace(/"([^"]*)"/g,"$1")}(i);return{text:s,incs:o.__incs||[]}}async function Ke(A,e,t,n){if(!(A instanceof Element&&e instanceof Element))return;if(!xe)try{xe=Ie(A.ownerDocument||document)}catch{}for(const r of["::before","::after","::first-letter"])try{const o=OA(A,r);if(!o||"function"!=typeof o[Symbol.iterator])continue;if(!("none"!==o.content||"none"!==o.backgroundImage||"transparent"!==o.backgroundColor||"none"!==o.borderStyle&&0!==parseFloat(o.borderWidth)||o.transform&&"none"!==o.transform||"inline"!==o.display))continue;if("::first-letter"===r){const n=getComputedStyle(A);if(!(o.color!==n.color||o.fontSize!==n.fontSize||o.fontWeight!==n.fontWeight))continue;const r=Array.from(e.childNodes).find(A=>A.nodeType===Node.TEXT_NODE&&A.textContent?.trim().length>0);if(!r)continue;const i=r.textContent,s=i.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u),a=s?.[0],c=i.slice(a?.length||0);if(!a||/[\uD800-\uDFFF]/.test(a))continue;const l=document.createElement("span");l.textContent=a,l.dataset.snapdomPseudo="::first-letter";const u=PA(NA(o),"span");t.styleMap.set(l,u);const h=document.createTextNode(c);e.replaceChild(h,r),e.insertBefore(l,h);continue}const i=o.content,{text:s,incs:a}=Me(A,r,xe),c=o.backgroundImage,l=o.backgroundColor,u=o.fontFamily,h=parseInt(o.fontSize)||32,g=parseInt(o.fontWeight)||!1,d=o.color||"#000",B=o.borderStyle,w=parseFloat(o.borderWidth),f=o.transform,m=ie(u),p="none"!==i&&""!==s,C=c&&"none"!==c,Q=l&&"transparent"!==l&&"rgba(0, 0, 0, 0)"!==l,y=B&&"none"!==B&&w>0,U=f&&"none"!==f;if(!(p||C||Q||y||U)){if(a&&a.length&&A.parentElement){const e=Se.get(A.parentElement)||new Map;for(const{name:t}of a){if(!t)continue;const n=Le(A,xe),o=De(A,getComputedStyle(A,r),n).get(A,t);e.set(t,o)}Se.set(A.parentElement,e)}continue}const F=document.createElement("span");F.dataset.snapdomPseudo=r,F.style.verticalAlign="middle",F.style.pointerEvents="none";const b=PA(NA(o),"span");if(t.styleMap.set(F,b),m&&s&&1===s.length){const{dataUrl:A,width:t,height:n}=await se(s,u,g,h,d),r=document.createElement("img");r.src=A,r.style=`height:${h}px;width:${t/n*h}px;object-fit:contain;`,F.appendChild(r),e.dataset.snapdomHasIcon="true"}else if(s&&s.startsWith("url(")){const e=UA(s);if(e?.trim())try{const A=document.createElement("img"),t=await xA(FA(e),{as:"dataURL",useProxy:n.useProxy});A.src=t.data,A.style=`width:${h}px;height:auto;object-fit:contain;`,F.appendChild(A)}catch(e){console.error(`[snapdom] Error in pseudo ${r} for`,A,e)}}else!m&&p&&(F.textContent=s);if(F.style.background="none","mask"in F.style&&(F.style.mask="none"),C)try{const A=VA(c),e=await Promise.all(A.map(LA));F.style.backgroundImage=e.join(", ")}catch(A){console.warn(`[snapdom] Failed to inline background-image for ${r}`,A)}Q&&(F.style.backgroundColor=l);const E=F.childNodes.length>0||""!==F.textContent?.trim()||C||Q||y||U;if(a&&a.length&&A.parentElement){const e=Se.get(A.parentElement)||new Map,t=Le(A,xe),n=De(A,getComputedStyle(A,r),t);for(const{name:t}of a){if(!t)continue;const r=n.get(A,t);e.set(t,r)}Se.set(A.parentElement,e)}if(!E)continue;"::before"===r?e.insertBefore(F,e.firstChild):e.appendChild(F)}catch(e){console.warn(`[snapdom] Failed to capture ${r} for`,A,e)}const r=Array.from(A.children),o=Array.from(e.children).filter(A=>!A.dataset.snapdomPseudo);for(let A=0;A<Math.min(r.length,o.length);A++)await Ke(r[A],o[A],t,n)}function Te(A){if(!A||"auto"===A)return null;const e=Number.parseFloat(A);return Number.isFinite(e)?e:null}function ke(A,e){const t=[];for(let n=A;n&&n!==e;){const A=n.parentElement;if(!A)break;t.push(Array.prototype.indexOf.call(A.children,n)),n=A}return t.reverse()}function Re(A,e,t){let n=A;for(let A=0;A<e.length;A++){if(n=Pe(n,t)[e[A]],!n)return null}return n instanceof HTMLElement?n:null}function Pe(A,e){const t=[],n=A.children;for(let A=0;A<n.length;A++){const r=n[A];r.hasAttribute(e)||t.push(r)}return t}async function Oe(A,e={}){const t={styleMap:yA.session.styleMap,styleCache:yA.session.styleCache,nodeMap:yA.session.nodeMap};let n,r="",o="";!function(A){const e=getComputedStyle(A),t=e.outlineStyle,n=e.outlineWidth,r=e.borderStyle,o=e.borderWidth,i="none"!==t&&parseFloat(n)>0,s="none"===r||0===parseFloat(o);i&&s&&(A.style.border=`${n} solid transparent`)}(A);try{!function(A){if(!A)return;const e=new Set;if(A.querySelectorAll("use").forEach(A=>{const t=A.getAttribute("xlink:href")||A.getAttribute("href");t&&t.startsWith("#")&&e.add(t.slice(1))}),!e.size)return;const t=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),n=t.filter(A=>"symbol"===A.tagName.toLowerCase()),r=t.filter(A=>"defs"===A.tagName.toLowerCase());let o=A.querySelector("svg.inline-defs-container");o||(o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("aria-hidden","true"),o.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),o.classList.add("inline-defs-container"),A.insertBefore(o,A.firstChild));const i=new Set;A.querySelectorAll("symbol[id], defs > *[id]").forEach(A=>{i.add(A.id)}),e.forEach(A=>{if(i.has(A))return;const e=n.find(e=>e.id===A);if(e)return o.appendChild(e.cloneNode(!0)),void i.add(A);for(const e of r){const t=e.querySelector(`#${CSS.escape(A)}`);if(t){let e=o.querySelector("defs");e||(e=document.createElementNS("http://www.w3.org/2000/svg","defs"),o.appendChild(e)),e.appendChild(t.cloneNode(!0)),i.add(A);break}}})}(A)}catch(A){console.warn("inlineExternal defs or symbol failed:",A)}try{n=await ne(A,t,e)}catch(A){throw console.warn("deepClone failed:",A),A}try{await Ke(A,n,t,e)}catch(A){console.warn("inlinePseudoElements failed:",A)}await async function(A){if(!A)return;const e=A.querySelectorAll?A.querySelectorAll("img"):[];for(const A of e)try{const e=A.getAttribute("src")||A.currentSrc||"";if(Xe(e)){const t=await Ve(e);A.setAttribute("src",t)}const t=A.getAttribute("srcset");if(t&&t.includes("blob:")){const e=Je(t);let n=!1;for(const A of e)if(Xe(A.url))try{A.url=await Ve(A.url),n=!0}catch{}n&&A.setAttribute("srcset",Ye(e))}}catch{}const t=A.querySelectorAll?A.querySelectorAll("image"):[];for(const A of t)try{const e="http://www.w3.org/1999/xlink",t=A.getAttribute("href")||A.getAttributeNS?.(e,"href");if(Xe(t)){const n=await Ve(t);A.setAttribute("href",n),A.removeAttributeNS?.(e,"href")}}catch{}const n=A.querySelectorAll?A.querySelectorAll("[style*='blob:']"):[];for(const A of n)try{const e=A.getAttribute("style");if(e&&e.includes("blob:")){const t=await We(e);A.setAttribute("style",t)}}catch{}const r=A.querySelectorAll?A.querySelectorAll("style"):[];for(const A of r)try{const e=A.textContent||"";e.includes("blob:")&&(A.textContent=await We(e))}catch{}const o=["poster"];for(const e of o){const t=A.querySelectorAll?A.querySelectorAll(`[${e}^='blob:']`):[];for(const A of t)try{const t=A.getAttribute(e);Xe(t)&&A.setAttribute(e,await Ve(t))}catch{}}}(n);try{const A=n.querySelectorAll("style[data-sd]");for(const e of A)o+=e.textContent||"",e.remove()}catch{}const i=function(A){const e=Array.from(new Set(A.values())).filter(Boolean).sort(),t=new Map;let n=1;for(const A of e)t.set(A,"c"+n++);return t}(t.styleMap);r=Array.from(i.entries()).map(([A,e])=>`.${e}{${A}}`).join(""),r=o+r;for(const[A,e]of t.styleMap.entries()){if("STYLE"===A.tagName)continue;if(A.getRootNode&&A.getRootNode()instanceof ShadowRoot){A.setAttribute("style",e.replace(/;/g,"; "));continue}const t=i.get(e);t&&A.classList.add(t);const n=A.style?.backgroundImage,r=A.dataset?.snapdomHasIcon;n&&"none"!==n&&(A.style.backgroundImage=n),r&&(A.style.verticalAlign="middle",A.style.display="inline")}for(const[A,e]of t.nodeMap.entries()){const t=e.scrollLeft,n=e.scrollTop;if((t||n)&&A instanceof HTMLElement){A.style.overflow="hidden",A.style.scrollbarWidth="none",A.style.msOverflowStyle="none";const e=document.createElement("div");for(e.style.transform=`translate(${-t}px, ${-n}px)`,e.style.willChange="transform",e.style.display="inline-block",e.style.width="100%";A.firstChild;)e.appendChild(A.firstChild);A.appendChild(e)}}if(function(A,e){if(!A||!e)return;const t=A.scrollTop||0;if(!t)return;"static"===getComputedStyle(e).position&&(e.style.position="relative");const n=A.getBoundingClientRect(),r=A.clientHeight,o="data-snap-ph",i=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT);for(;i.nextNode();){const s=i.currentNode,a=getComputedStyle(s),c=a.position;if("sticky"!==c&&"-webkit-sticky"!==c)continue;const l=Te(a.top),u=Te(a.bottom);if(null==l&&null==u)continue;const h=Re(e,ke(s,A),o);if(!h)continue;const g=s.getBoundingClientRect(),d=g.width,B=g.height,w=g.left-n.left;if(!(d>0&&B>0))continue;if(!Number.isFinite(w))continue;const f=null!=l?l+t:t+(r-B-u);if(!Number.isFinite(f))continue;const m=Number.parseInt(a.zIndex,10),p=Number.isFinite(m),C=p?Math.max(m,1)+1:2,Q=p?m-1:0,y=h.cloneNode(!1);y.setAttribute(o,"1"),y.style.position="sticky",y.style.left=`${w}px`,y.style.top=`${f}px`,y.style.width=`${d}px`,y.style.height=`${B}px`,y.style.visibility="hidden",y.style.zIndex=String(Q),y.style.overflow="hidden",y.style.background="transparent",y.style.boxShadow="none",y.style.filter="none",h.parentElement?.insertBefore(y,h),h.style.position="absolute",h.style.left=`${w}px`,h.style.top=`${f}px`,h.style.bottom="auto",h.style.zIndex=String(C),h.style.pointerEvents="none"}}(A,n instanceof HTMLElement&&n.firstElementChild instanceof HTMLElement?n.firstElementChild:n),A===t.nodeMap.get(n)){const e=t.styleCache.get(A)||window.getComputedStyle(A);t.styleCache.set(A,e);const r=function(A){if(!A||"none"===A)return"";let e=A.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(A,e)=>{const t=e.split(",").map(A=>A.trim());return 6!==t.length?`matrix(${e})`:(t[4]="0",t[5]="0",`matrix(${t.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(A,e)=>{const t=e.split(",").map(A=>A.trim());return 16!==t.length?`matrix3d(${e})`:(t[12]="0",t[13]="0",`matrix3d(${t.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}(e.transform);n.style.margin="0",n.style.top="auto",n.style.left="auto",n.style.right="auto",n.style.bottom="auto",n.style.animation="none",n.style.transition="none",n.style.willChange="auto",n.style.float="none",n.style.clear="none",n.style.transform=r||""}for(const[A,e]of t.nodeMap.entries())"PRE"===e.tagName&&(A.style.marginTop="0",A.style.marginBlockStart="0");return{clone:n,classCSS:r,styleCache:t.styleCache}}var Ne=new Map;async function Ve(A){if(yA.resource?.has(A))return yA.resource.get(A);if(Ne.has(A))return Ne.get(A);const e=(async()=>{const e=await xA(A,{as:"dataURL",silent:!0});if(!e.ok||"string"!=typeof e.data)throw new Error(`[snapDOM] Failed to read blob URL: ${A}`);return yA.resource?.set(A,e.data),e.data})();Ne.set(A,e);try{const t=await e;return Ne.set(A,t),t}catch(e){throw Ne.delete(A),e}}var Ge=/\bblob:[^)"'\s]+/g;async function We(A){if(!A||-1===A.indexOf("blob:"))return A;const e=Array.from(new Set(A.match(Ge)||[]));if(0===e.length)return A;let t=A;for(const A of e)try{const e=await Ve(A);t=t.split(A).join(e)}catch{}return t}function Xe(A){return"string"==typeof A&&A.startsWith("blob:")}function Je(A){return(A||"").split(",").map(A=>A.trim()).filter(Boolean).map(A=>{const e=A.match(/^(\S+)(\s+.+)?$/);return e?{url:e[1],desc:e[2]||""}:null}).filter(Boolean)}function Ye(A){return A.map(A=>A.desc?`${A.url} ${A.desc.trim()}`:A.url).join(", ")}function $e(A){if(!A)return()=>{};const e=function(A){const e=getComputedStyle(A);let t=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");t=(t||"").trim();const n=parseInt(t,10);return Number.isFinite(n)&&n>0?n:0}(A);if(e<=0)return()=>{};if(!function(A){return!(A.childElementCount>0)&&Array.from(A.childNodes).some(A=>A.nodeType===Node.TEXT_NODE)}(A))return()=>{};const t=getComputedStyle(A),n=Math.round(function(A){const e=(A.lineHeight||"").trim(),t=parseFloat(A.fontSize)||16;return e&&"normal"!==e?e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*t):e.endsWith("%")?Math.round(parseFloat(e)/100*t):Math.round(1.2*t):Math.round(1.2*t)}(t)*e+function(A){return(parseFloat(A.paddingTop)||0)+(parseFloat(A.paddingBottom)||0)}(t)),r=A.textContent??"",o=r;if(A.scrollHeight<=n+.5)return()=>{};let i=0,s=r.length,a=-1;for(;i<=s;){const e=i+s>>1;A.textContent=r.slice(0,e)+"…",A.scrollHeight<=n+.5?(a=e,i=e+1):s=e-1}return A.textContent=(a>=0?r.slice(0,a):"")+"…",()=>{A.textContent=o}}async function Ze(A,e){if(!A)throw new Error("Element cannot be null or undefined");!function(A="soft"){switch(A){case"auto":return yA.session.styleMap=new Map,void(yA.session.nodeMap=new Map);case"soft":default:return yA.session.styleMap=new Map,yA.session.nodeMap=new Map,void(yA.session.styleCache=new WeakMap);case"full":return;case"disabled":yA.session.styleMap=new Map,yA.session.nodeMap=new Map,yA.session.styleCache=new WeakMap,yA.computedStyle=new WeakMap,yA.baseStyle=new Map,yA.defaultStyle=new Map,yA.image=new Map,yA.background=new Map,yA.resource=new Map,yA.font=new Set}}(e.cache);const t=e.fast,n=!!e.straighten,r=!!e.noShadows;let o,i,s,a,c,l="",u="",h=null;const g=$e(A);try{({clone:o,classCSS:i,styleCache:s}=await Oe(A,e)),n&&o&&(h=function(A,e){if(!A||!e||!e.style)return null;const t=getComputedStyle(A);try{e.style.transformOrigin="0 0"}catch{}try{"translate"in e.style&&(e.style.translate="none"),"rotate"in e.style&&(e.style.rotate="none")}catch{}const n=t.transform||"none";if("none"===n)try{const t=_e(A);if(1===t.a&&0===t.b&&0===t.c&&1===t.d)return e.style.transform="none",{a:1,b:0,c:0,d:1}}catch{}const r=n.match(/^matrix\(\s*([^)]+)\)$/i);if(r){const A=r[1].split(",").map(A=>parseFloat(A.trim()));if(6===A.length&&A.every(Number.isFinite)){const[t,n,r,o]=A,i=Math.sqrt(t*t+n*n)||0;let s=0,a=0,c=0,l=0,u=0,h=0;i>0&&(s=t/i,a=n/i,c=s*r+a*o,l=r-s*c,u=o-a*c,h=Math.sqrt(l*l+u*u)||0,h>0?c/=h:c=0);const g=i,d=0,B=c*h,w=h;try{e.style.transform=`matrix(${g}, ${d}, ${B}, ${w}, 0, 0)`}catch{}return{a:g,b:d,c:B,d:w}}}try{const A=String(n).trim();return e.style.transform=A+" translate(0px, 0px) rotate(0deg)",null}catch{return null}}(A,o)),r&&o&&function(A,e){if(!A||!e||!e.style)return;const t=getComputedStyle(A);try{e.style.boxShadow="none"}catch{}try{e.style.textShadow="none"}catch{}try{e.style.outline="none"}catch{}const n=(t.filter||"").replace(/\bblur\([^()]*\)\s*/gi,"").replace(/\bdrop-shadow\([^()]*\)\s*/gi,"").trim().replace(/\s+/g," ");try{e.style.filter=n.length?n:"none"}catch{}}(A,o)}finally{g()}await new Promise(A=>{GA(async()=>{await async function(A,e={}){const t=Array.from(A.querySelectorAll("img")),n=async A=>{if(!A.getAttribute("src")){const e=A.currentSrc||A.src||"";e&&A.setAttribute("src",e)}A.removeAttribute("srcset"),A.removeAttribute("sizes");const t=A.src||"";if(!t)return;const n=await xA(t,{as:"dataURL",useProxy:e.useProxy});if(n.ok&&"string"==typeof n.data&&n.data.startsWith("data:"))return A.src=n.data,A.width||(A.width=A.naturalWidth||100),void(A.height||(A.height=A.naturalHeight||100));const{fallbackURL:r}=e||{};if(r)try{const n=parseInt(A.dataset?.snapdomWidth||"",10)||0,o=parseInt(A.dataset?.snapdomHeight||"",10)||0,i=parseInt(A.getAttribute("width")||"",10)||0,s=parseInt(A.getAttribute("height")||"",10)||0,a=parseFloat(A.style?.width||"")||0,c=parseFloat(A.style?.height||"")||0,l=n||a||i||A.width||void 0,u=o||c||s||A.height||void 0,h="function"==typeof r?await r({width:l,height:u,src:t,element:A}):r;if(h){const t=await xA(h,{as:"dataURL",useProxy:e.useProxy});return A.src=t.data,!A.width&&l&&(A.width=l),!A.height&&u&&(A.height=u),A.width||(A.width=A.naturalWidth||100),void(A.height||(A.height=A.naturalHeight||100))}}catch{}const o=A.width||A.naturalWidth||100,i=A.height||A.naturalHeight||100;if(!1!==e.placeholders){const e=document.createElement("div");e.style.cssText=[`width:${o}px`,`height:${i}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${i}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),e.textContent="img",A.replaceWith(e)}else{const e=document.createElement("div");e.style.cssText=`display:inline-block;width:${o}px;height:${i}px;visibility:hidden;`,A.replaceWith(e)}};for(let A=0;A<t.length;A+=4){const e=t.slice(A,A+4).map(n);await Promise.allSettled(e)}}(o,e),A()},{fast:t})}),await new Promise(n=>{GA(async()=>{await async function(A,e,t,n={}){const r=[[A,e]],o=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],i=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],s=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;r.length;){const[A,e]=r.shift(),a=t.get(A)||OA(A);t.has(A)||t.set(A,a);const c=(()=>{const A=a.getPropertyValue("border-image"),e=a.getPropertyValue("border-image-source");return A&&"none"!==A||e&&"none"!==e})();for(const A of o){const t=a.getPropertyValue(A);if(!t||"none"===t)continue;const r=VA(t),o=await Promise.all(r.map(A=>LA(A,n)));o.some(A=>A&&"none"!==A&&!/^url\(undefined/.test(A))&&e.style.setProperty(A,o.join(", "))}for(const A of i){const t=a.getPropertyValue(A);t&&"initial"!==t&&e.style.setProperty(A,t)}if(c)for(const A of s){const t=a.getPropertyValue(A);t&&"initial"!==t&&e.style.setProperty(A,t)}const l=Array.from(A.children),u=Array.from(e.children);for(let A=0;A<Math.min(l.length,u.length);A++)r.push([l[A],u[A]])}}(A,o,s,e),n()},{fast:t})}),e.embedFonts&&await new Promise(n=>{GA(async()=>{const t=be(A),r=function(A){const e=new Set,t=A=>{if(A)for(const t of A)e.add(t.codePointAt(0))},n=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;n.nextNode();){const A=n.currentNode;if(A.nodeType===Node.TEXT_NODE)t(A.nodeValue||"");else if(A.nodeType===Node.ELEMENT_NODE){const n=A;for(const A of["::before","::after"]){const r=getComputedStyle(n,A),o=r?.getPropertyValue("content");if(o&&"none"!==o)if(/^"/.test(o)||/^'/.test(o))t(o.slice(1,-1));else{const A=o.match(/\\[0-9A-Fa-f]{1,6}/g);if(A)for(const t of A)try{e.add(parseInt(t.slice(1),16))}catch{}}}}}return e}(A);if(WA()){const A=new Set(Array.from(t).map(A=>String(A).split("__")[0]).filter(Boolean));await async function(A,e=2){try{await document.fonts.ready}catch{}const t=Array.from(A||[]).filter(Boolean);if(0===t.length)return;const n=()=>{const A=document.createElement("div");A.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(const e of t){const t=document.createElement("span");t.textContent="AaBbGg1234ÁÉÍÓÚçñ—∞",t.style.fontFamily=`"${e}"`,t.style.fontWeight="700",t.style.fontStyle="italic",t.style.fontSize="32px",t.style.lineHeight="1",t.style.whiteSpace="nowrap",t.style.margin="0",t.style.padding="0",A.appendChild(t)}document.body.appendChild(A),A.offsetWidth,document.body.removeChild(A)};for(let A=0;A<Math.max(1,e);A++)n(),await new Promise(A=>requestAnimationFrame(()=>requestAnimationFrame(A)))}(A,1)}l=await Fe({required:t,usedCodepoints:r,exclude:e.excludeFonts,useProxy:e.useProxy}),n()},{fast:t})});const d=function(A){const e=new Set;return A.nodeType!==Node.ELEMENT_NODE&&A.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(A.tagName&&e.add(A.tagName.toLowerCase()),"function"==typeof A.querySelectorAll&&A.querySelectorAll("*").forEach(A=>e.add(A.tagName.toLowerCase())),Array.from(e))}(o).sort(),B=d.join(",");yA.baseStyle.has(B)?u=yA.baseStyle.get(B):await new Promise(A=>{GA(()=>{u=function(A){const e=new Map;for(let t of A){const A=yA.defaultStyle.get(t);if(!A)continue;const n=Object.entries(A).map(([A,e])=>`${A}:${e};`).sort().join("");n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let t="";for(let[A,n]of e.entries())t+=`${n.join(",")} { ${A} }\n`;return t}(d),yA.baseStyle.set(B,u),A()},{fast:t})}),await new Promise(s=>{GA(()=>{const t=getComputedStyle(A);const g=A.getBoundingClientRect(),d=Math.max(1,Math.ceil(A.offsetWidth||parseFloat(t.width)||g.width||1)),B=Math.max(1,Math.ceil(A.offsetHeight||parseFloat(t.height)||g.height||1)),w=(A,e=NaN)=>{const t="string"==typeof A?parseFloat(A):A;return Number.isFinite(t)?t:e},f=w(e.width),m=w(e.height);let p=d,C=B;const Q=Number.isFinite(f),y=Number.isFinite(m),U=B>0?d/B:1;Q&&y?(p=Math.max(1,Math.ceil(f)),C=Math.max(1,Math.ceil(m))):Q?(p=Math.max(1,Math.ceil(f)),C=Math.max(1,Math.ceil(p/(U||1)))):y?(C=Math.max(1,Math.ceil(m)),p=Math.max(1,Math.ceil(C*(U||1)))):(p=d,C=B);let F=0,b=0,E=d,v=B;if(n&&h&&Number.isFinite(h.a)){const A=je(d,B,{a:h.a,b:h.b||0,c:h.c||0,d:h.d||1,e:0,f:0},0,0);F=A.minX,b=A.minY,E=A.maxX,v=A.maxY}else{if(!n&&function(A){const e=getComputedStyle(A),t=e.transform||"none";if("none"!==t&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(t))return!0;const n=e.rotate&&"none"!==e.rotate&&"0deg"!==e.rotate,r=e.scale&&"none"!==e.scale&&"1"!==e.scale,o=e.translate&&"none"!==e.translate&&"0px 0px"!==e.translate;return Boolean(n||r||o)}(A)){const e=t.transform&&"none"!==t.transform?t.transform:"",n=function(A){const e={rotate:"0deg",scale:null,translate:null},t="function"==typeof A.computedStyleMap?A.computedStyleMap():null;if(t){const n=A=>{try{return"function"!=typeof t.has||t.has(A)?"function"!=typeof t.get?null:t.get(A):null}catch{return null}},r=n("rotate");if(r)if(r.angle){const A=r.angle;e.rotate="rad"===A.unit?180*A.value/Math.PI+"deg":A.value+A.unit}else r.unit?e.rotate="rad"===r.unit?180*r.value/Math.PI+"deg":r.value+r.unit:e.rotate=String(r);else{const t=getComputedStyle(A);e.rotate=t.rotate&&"none"!==t.rotate?t.rotate:"0deg"}const o=n("scale");if(o){const A="x"in o&&null!=o.x?.value?o.x.value:Array.isArray(o)?o[0]?.value:Number(o)||1,t="y"in o&&null!=o.y?.value?o.y.value:Array.isArray(o)?o[1]?.value:A;e.scale=`${A} ${t}`}else{const t=getComputedStyle(A);e.scale=t.scale&&"none"!==t.scale?t.scale:null}const i=n("translate");if(i){const A="x"in i&&"value"in i.x?i.x.value:Array.isArray(i)?i[0]?.value:0,t="y"in i&&"value"in i.y?i.y.value:Array.isArray(i)?i[1]?.value:0,n="x"in i&&i.x?.unit?i.x.unit:"px",r="y"in i&&i.y?.unit?i.y.unit:"px";e.translate=`${A}${n} ${t}${r}`}else{const t=getComputedStyle(A);e.translate=t.translate&&"none"!==t.translate?t.translate:null}return e}const n=getComputedStyle(A);return e.rotate=n.rotate&&"none"!==n.rotate?n.rotate:"0deg",e.scale=n.scale&&"none"!==n.scale?n.scale:null,e.translate=n.translate&&"none"!==n.translate?n.translate:null,e}(A),r=function(A){const e=function(){if(ze)return ze;const A=document.createElement("div");return A.id="snapdom-measure-slot",A.setAttribute("aria-hidden","true"),Object.assign(A.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(A),ze=A,A}(),t=document.createElement("div");t.style.transformOrigin="0 0",A.baseTransform&&(t.style.transform=A.baseTransform);A.rotate&&(t.style.rotate=A.rotate);A.scale&&(t.style.scale=A.scale);A.translate&&(t.style.translate=A.translate);e.appendChild(t);const n=_e(t);return e.removeChild(t),n}({baseTransform:e,rotate:n.rotate||"0deg",scale:n.scale,translate:n.translate}),{ox:o,oy:i}=function(A,e,t){const n=(A.transformOrigin||"0 0").trim().split(/\s+/),[r,o]=[n[0]||"0",n[1]||"0"],i=(A,e)=>{const t=A.toLowerCase();return"left"===t||"top"===t?0:"center"===t?e/2:"right"===t||"bottom"===t?e:t.endsWith("px")?parseFloat(t)||0:t.endsWith("%")?(parseFloat(t)||0)*e/100:/^-?\d+(\.\d+)?$/.test(t)&&parseFloat(t)||0};return{ox:i(r,e),oy:i(o,t)}}(t,d,B),s=je(d,B,r.is2D?r:new DOMMatrix(r.toString()),o,i);F=s.minX,b=s.minY,E=s.maxX,v=s.maxY}}const H=function(A){const e=A.boxShadow||"";if(!e||"none"===e)return{top:0,right:0,bottom:0,left:0};const t=e.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(A=>A.trim());let n=0,r=0,o=0,i=0;for(const A of t){const e=A.match(/-?\d+(\.\d+)?px/g)?.map(A=>parseFloat(A))||[];if(e.length<2)continue;const[t,s,a=0,c=0]=e,l=Math.abs(t)+a+c,u=Math.abs(s)+a+c;r=Math.max(r,l+Math.max(t,0)),i=Math.max(i,l+Math.max(-t,0)),o=Math.max(o,u+Math.max(s,0)),n=Math.max(n,u+Math.max(-s,0))}return{top:Math.ceil(n),right:Math.ceil(r),bottom:Math.ceil(o),left:Math.ceil(i)}}(t),I=function(A){const e=(A.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),t=e?Math.ceil(parseFloat(e[1])||0):0;return{top:t,right:t,bottom:t,left:t}}(t),x=function(A){if("none"===(A.outlineStyle||"none"))return{top:0,right:0,bottom:0,left:0};const e=Math.ceil(parseFloat(A.outlineWidth||"0")||0);return{top:e,right:e,bottom:e,left:e}}(t),S=function(A){const e=`${A.filter||""} ${A.webkitFilter||""}`.trim();if(!e||"none"===e)return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};const t=e.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[];let n=0,r=0,o=0,i=0,s=!1;for(const A of t){s=!0;const e=A.match(/-?\d+(?:\.\d+)?px/gi)?.map(A=>parseFloat(A))||[],[t=0,a=0,c=0]=e,l=Math.abs(t)+c,u=Math.abs(a)+c;r=Math.max(r,l+Math.max(t,0)),i=Math.max(i,l+Math.max(-t,0)),o=Math.max(o,u+Math.max(a,0)),n=Math.max(n,u+Math.max(-a,0))}return{bleed:{top:Math.ceil(n),right:Math.ceil(r),bottom:Math.ceil(o),left:Math.ceil(i)},has:s}}(t),L=r?{top:0,right:0,bottom:0,left:0}:{top:H.top+I.top+x.top+S.bleed.top,right:H.right+I.right+x.right+S.bleed.right,bottom:H.bottom+I.bottom+x.bottom+S.bleed.bottom,left:H.left+I.left+x.left+S.bleed.left};F-=L.left,b-=L.top,E+=L.right,v+=L.bottom;const D=Math.max(1,Math.ceil(E-F)),M=Math.max(1,Math.ceil(v-b)),K=Math.max(1,Math.round(D*(Q||y?p/d:1))),T=Math.max(1,Math.round(M*(y||Q?C/B:1))),k="http://www.w3.org/2000/svg",R=(WA()?1:0)+(n?1:0),P=document.createElementNS(k,"foreignObject"),O=Math.floor(F),N=Math.floor(b);P.setAttribute("x",String(-(O-R))),P.setAttribute("y",String(-(N-R))),P.setAttribute("width",String(Math.ceil(d+2*R))),P.setAttribute("height",String(Math.ceil(B+2*R))),P.style.overflow="visible";const V=document.createElement("style");V.textContent=u+l+"svg{overflow:visible;} foreignObject{overflow:visible;}"+i,P.appendChild(V);const G=document.createElement("div");G.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),G.style.width=`${d}px`,G.style.height=`${B}px`,G.style.overflow="visible",o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),G.appendChild(o),P.appendChild(G);const W=(new XMLSerializer).serializeToString(P),X=D+2*R,J=M+2*R,Y=Q||y;e.meta={w0:d,h0:B,vbW:X,vbH:J,targetW:p,targetH:C};const $=WA()&&Y?X:K+2*R,Z=WA()&&Y?J:T+2*R;c=`<svg xmlns="${k}" width="${$}" height="${Z}" viewBox="0 0 ${X} ${J}">`+W+"</svg>",a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(c)}`,s()},{fast:t})});const w=document.getElementById("snapdom-sandbox");return w&&"absolute"===w.style.position&&w.remove(),a}function je(A,e,t,n,r){const o=t.a,i=t.b,s=t.c,a=t.d,c=t.e||0,l=t.f||0;function u(A,e){let t=A-n,u=e-r,h=o*t+s*u,g=i*t+a*u;return h+=n+c,g+=r+l,[h,g]}const h=[u(0,0),u(A,0),u(0,e),u(A,e)];let g=1/0,d=1/0,B=-1/0,w=-1/0;for(const[A,e]of h)A<g&&(g=A),e<d&&(d=e),A>B&&(B=A),e>w&&(w=e);return{minX:g,minY:d,maxX:B,maxY:w,width:B-g,height:w-d}}function _e(A){const e=getComputedStyle(A).transform;if(!e||"none"===e)return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}var ze=null;function qe(A){const e=function(A){let e=[],t="",n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&n++,")"===o&&(n=Math.max(0,n-1)),";"===o&&0===n?(e.push(t),t=""):t+=o}return t.trim()&&e.push(t),e.map(A=>A.trim()).filter(Boolean)}(A);let t=null,n=null,r=null;const o=[];for(const A of e){const e=A.indexOf(":");if(e<0)continue;const i=A.slice(0,e).trim().toLowerCase(),s=A.slice(e+1).trim();"box-shadow"===i?r=s:"filter"===i?t=s:"-webkit-filter"===i?n=s:o.push([i,s])}if(r){const A=function(A){const e=[];let t="",n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&n++,")"===o&&(n=Math.max(0,n-1)),","===o&&0===n?(e.push(t.trim()),t=""):t+=o}t.trim()&&e.push(t.trim());const r=[];for(const A of e){if(/\binset\b/i.test(A))continue;const e=A.match(/-?\d+(?:\.\d+)?px/gi)||[],[t="0px",n="0px",o="0px"]=e;let i=A.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/gi,"").trim().replace(/\s{2,}/g," ");const s=!!i&&","!==i;r.push(`drop-shadow(${t} ${n} ${o}${s?` ${i}`:""})`)}return r.join(" ")}(r);A&&(t=t?`${t} ${A}`:A,n=n?`${n} ${A}`:A)}const i=[...o];return t&&i.push(["filter",t]),n&&i.push(["-webkit-filter",n]),i.map(([A,e])=>`${A}:${e}`).join(";")}function At(A){return A=(A=A.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(A,e)=>A.replace(e,function(A){return A.replace(/([^{}]+)\{([^}]*)\}/g,(A,e,t)=>`${e}{${qe(t)}}`)}(e)))).replace(/style=(['"])([\s\S]*?)\1/gi,(A,e,t)=>`style=${e}${qe(t)}${e}`)}function et(A){if(!WA()||("string"!=typeof(e=A)||!/^data:image\/svg\+xml/i.test(e)))return A;var e;try{const e=function(A){const e=A.indexOf(",");return e>=0?decodeURIComponent(A.slice(e+1)):""}(A),t=At(e);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}catch{return A}}async function tt(A,e){let{width:t,height:n,scale:r=1,dpr:o=1,meta:i={}}=e;A=et(A);const s=new Image;s.loading="eager",s.decoding="sync",s.crossOrigin="anonymous",s.src=A,await s.decode();const a=s.naturalWidth,c=s.naturalHeight,l=Number.isFinite(i.w0)?i.w0:a,u=Number.isFinite(i.h0)?i.h0:c;let h,g;const d=Number.isFinite(t),B=Number.isFinite(n);if(d&&B)h=Math.max(1,t),g=Math.max(1,n);else if(d){const A=t/Math.max(1,l);h=t,g=Math.round(u*A)}else if(B){const A=n/Math.max(1,u);g=n,h=Math.round(l*A)}else h=a,g=c;h=Math.round(h*r),g=Math.round(g*r);const w=document.createElement("canvas");w.width=Math.ceil(h*o),w.height=Math.ceil(g*o),w.style.width=`${h}px`,w.style.height=`${g}px`;const f=w.getContext("2d");return 1!==o&&f.scale(o,o),f.drawImage(s,0,0,h,g),w}async function nt(A,e){const t=await tt(A,e),n=e.backgroundColor?SA(t,e.backgroundColor):t,r=new Image;return r.src=n.toDataURL(`image/${e.format}`,e.quality),await r.decode(),r.style.width=n.width/e.dpr+"px",r.style.height=n.height/e.dpr+"px",r}async function rt(A,e){const{scale:t=1,width:n,height:r,meta:o={}}=e,i=Number.isFinite(n),s=Number.isFinite(r),a=Number.isFinite(t)&&1!==t||i||s;if(WA()&&a){return await nt(A,{...e,format:"png",quality:1,meta:o})}const c=new Image;if(c.decoding="sync",c.loading="eager",c.src=A,await c.decode(),i&&s)c.style.width=`${n}px`,c.style.height=`${r}px`;else if(i){const A=Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.h0)?o.h0:c.naturalHeight,t=n/Math.max(1,A);c.style.width=`${n}px`,c.style.height=`${Math.round(e*t)}px`}else if(s){const A=Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.h0)?o.h0:c.naturalHeight,t=r/Math.max(1,e);c.style.height=`${r}px`,c.style.width=`${Math.round(A*t)}px`}else{const e=Math.round(c.naturalWidth*t),n=Math.round(c.naturalHeight*t);if(c.style.width=`${e}px`,c.style.height=`${n}px`,"string"==typeof A&&A.startsWith("data:image/svg+xml"))try{const t=decodeURIComponent(A.split(",")[1]).replace(/width="[^"]*"/,`width="${e}"`).replace(/height="[^"]*"/,`height="${n}"`);A=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,c.src=A}catch{}}return c}async function ot(A,e){const t=e.type;if("svg"===t){const e=decodeURIComponent(A.split(",")[1]);return new Blob([e],{type:"image/svg+xml"})}const n=await tt(A,e),r=e.backgroundColor?SA(n,e.backgroundColor):n;return new Promise(A=>r.toBlob(e=>A(e),`image/${t}`,e.quality))}var it=Symbol("snapdom.internal"),st=!1;async function at(A,e){if(!A)throw new Error("Element cannot be null or undefined");const t=function(A={}){const e=A.format??"png",t=function(A){if("string"==typeof A){const e=A.toLowerCase().trim();if("disabled"===e||"full"===e||"auto"===e||"soft"===e)return e}return"soft"}(A.cache);return{debug:A.debug??!1,fast:A.fast??!0,scale:A.scale??1,exclude:A.exclude??[],excludeMode:A.excludeMode??"hide",filter:A.filter??null,filterMode:A.filterMode??"hide",placeholders:!1!==A.placeholders,embedFonts:A.embedFonts??!1,iconFonts:Array.isArray(A.iconFonts)?A.iconFonts:A.iconFonts?[A.iconFonts]:[],localFonts:Array.isArray(A.localFonts)?A.localFonts:[],excludeFonts:A.excludeFonts??void 0,fallbackURL:A.fallbackURL??void 0,cache:t,useProxy:"string"==typeof A.useProxy?A.useProxy:"",width:A.width??null,height:A.height??null,format:e,type:A.type??"svg",quality:A.quality??.92,dpr:A.dpr??(window.devicePixelRatio||1),backgroundColor:A.backgroundColor??(["jpg","jpeg","webp"].includes(e)?"#ffffff":null),filename:A.filename??"snapDOM",straighten:A.straighten??!1,noShadows:A.noShadows??!1}}(e);if(WA()&&(!0===t.embedFonts||function(A){const e=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){const A=e.currentNode,t=getComputedStyle(A),n=t.backgroundImage&&"none"!==t.backgroundImage,r=t.maskImage&&"none"!==t.maskImage||t.webkitMaskImage&&"none"!==t.webkitMaskImage;if(n||r)return!0}return!1}(A)))for(let t=0;t<3;t++)try{await ct(A,e),console.log("Iteración número:",t),st=!1}catch{}return t.iconFonts&&t.iconFonts.length>0&&function(A){const e=Array.isArray(A)?A:[A];for(const A of e)A instanceof RegExp?oe.push(A):"string"==typeof A?oe.push(new RegExp(A,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",A)}(t.iconFonts),t.snap||(t.snap={toPng:(A,e)=>at.toPng(A,e),toSvg:(A,e)=>at.toSvg(A,e)}),at.capture(A,t,it)}async function ct(A,e){if(st)return;const t={...e,fast:!0,embedFonts:!0,scale:.2};let n;try{n=await Ze(A,t)}catch{return}await new Promise(A=>{const e=new Image;e.decoding="sync",e.loading="eager",e.style.position="fixed",e.style.left=0,e.style.top=0,e.style.width="10px",e.style.height="10px",e.style.opacity="0.01",e.style.transform="translateZ(10px)",e.style.willChange="transform,opacity;",e.src=n;document.body.appendChild(e),(async()=>{await new Promise(A=>setTimeout(A,100)),e&&e.parentNode&&e.parentNode.removeChild(e),st=!0,A()})()})}at.capture=async(A,e,t)=>{if(t!==it)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");const n=await Ze(A,e),r=A=>({...e,...A||{}}),o=A=>e=>{const t=r({...e||{},format:A}),o="jpeg"===A||"jpg"===A,i=null==t.backgroundColor||"transparent"===t.backgroundColor;return o&&i&&(t.backgroundColor="#ffffff"),nt(n,t)};return{url:n,toRaw:()=>n,toImg:A=>rt(n,r(A)),toSvg:A=>rt(n,r(A)),toCanvas:A=>tt(n,r(A)),toBlob:A=>ot(n,r(A)),toPng:o("png"),toJpg:o("jpeg"),toWebp:o("webp"),download:A=>async function(A,e){if(e.dpr=1,"svg"===e.format){const t=await ot(A,{...e,type:"svg"}),n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e.filename,r.click(),void URL.revokeObjectURL(n)}const t=await tt(A,e),n=e.backgroundColor?SA(t,e.backgroundColor):t,r=document.createElement("a");r.href=n.toDataURL(`image/${e.format}`,e.quality),r.download=e.filename,r.click()}(n,r(A))}},at.toRaw=(A,e)=>at(A,e).then(A=>A.toRaw()),at.toImg=(A,e)=>at(A,e).then(A=>A.toImg()),at.toSvg=(A,e)=>at(A,e).then(A=>A.toSvg()),at.toCanvas=(A,e)=>at(A,e).then(A=>A.toCanvas()),at.toBlob=(A,e)=>at(A,e).then(A=>A.toBlob()),at.toPng=(A,e)=>at(A,{...e,format:"png"}).then(A=>A.toPng()),at.toJpg=(A,e)=>at(A,{...e,format:"jpeg"}).then(A=>A.toJpg()),at.toWebp=(A,e)=>at(A,{...e,format:"webp"}).then(A=>A.toWebp()),at.download=(A,e)=>at(A,e).then(A=>A.download());"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function lt(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var ut={exports:{}};
|
|
1
|
+
!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((A="undefined"!=typeof globalThis?globalThis:A||self).CustomerSDK={})}(this,function(A){"use strict";class e{constructor(A,e=!1,t,n){this.iconElement=null,this.badgeElement=null,this.onClickCallback=null,this.notificationCallback=null,this.iconPosition=null,this.debug=!1,this.isClickEnabled=!0,this.target=null,this.isDragging=!1,this.dragStarted=!1,this.hasMoved=!1,this.dragOffset={x:0,y:0},this.lastTouchPosition={x:0,y:0},this.touchStartTime=0,this.clickThreshold=15,this.cachedContainer=null,this.cachedContainerRect=null,this.cachedIconSize={width:0,height:0},this.lastContainerUpdateTime=0,this.containerUpdateInterval=100,this.cachedIframes=[],this.lastIframeUpdateTime=0,this.iframeUpdateInterval=16,this.rafId=null,this.pendingPosition={x:0,y:0,needsUpdate:!1},this.activeDetectionRafId=null,this.lastMousePosition={x:0,y:0,timestamp:0},this.onDragHandler=null,this.stopDragHandler=null,this.startDragHandler=null,this.mouseLeaveHandler=null,this.pointerLeaveHandler=null,this.blurHandler=null,this.dragTimeoutId=null,this.mouseLeaveTimeout=null,this.pointerLeaveTimeout=null,this.isStoppingDrag=!1,this.sideAttach=!0,this.sideHideRatio=.5,this.magnetic=!0,this.magneticDirection="x",this.margin=10,this.isAttachedToSide=!1,this.attachedSide="",this.autoAttachDelay=3e3,this.autoAttachTimer=null,this.iconPosition=A||null,this.debug=e,this.target=t||null,n&&(this.sideAttach=void 0===n.sideAttach||n.sideAttach,this.sideHideRatio=void 0!==n.sideHideRatio?n.sideHideRatio:.5,this.magnetic=void 0===n.magnetic||n.magnetic,this.magneticDirection=n.magneticDirection||"x",this.margin=void 0!==n.margin?n.margin:10,this.autoAttachDelay=void 0!==n.autoAttachDelay?n.autoAttachDelay:3e3)}async show(){if(this.iconElement)return;this.iconElement=document.createElement("div"),this.iconElement.className="customer-sdk-icon";const A={position:"absolute",width:"30px",height:"30px",backgroundColor:"transparent",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:"1000002",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",userSelect:"none",transition:"transform 0.2s ease",border:"none",outline:"none",overflow:"visible"};if(this.iconPosition)void 0!==this.iconPosition.x?(A.left="number"==typeof this.iconPosition.x?`${this.iconPosition.x}px`:this.iconPosition.x,A.right="auto"):A.right="20px",void 0!==this.iconPosition.y?(A.top="number"==typeof this.iconPosition.y?`${this.iconPosition.y}px`:this.iconPosition.y,A.bottom="auto"):A.bottom="80px";else if(this.sideAttach&&this.magnetic){const e=30*this.sideHideRatio;A.right=`-${e}px`,A.left="auto",A.bottom="80px",A.transform="translateX(0)",this.isAttachedToSide=!0,this.attachedSide="right"}else A.bottom="80px",A.right="20px";if(this.sideAttach&&this.isAttachedToSide&&this.attachedSide){const e=30*this.sideHideRatio;"left"===this.attachedSide?(A.left=`-${e}px`,A.right="auto",A.transform="translateX(0)"):"right"===this.attachedSide&&(A.right=`-${e}px`,A.left="auto",A.transform="translateX(0)")}Object.assign(this.iconElement.style,A);const e=document.createElement("img");e.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAArKSURBVHgB7Z1NbFTXFcf/93mwaGyEabLoIgFTqWRFMZUitSoIu80ial01SFWrKgsGKXYpWdRtFilRK4xUgbKICosmCKIySKCo2UAE6i61XVroDuOoi2YT02RZVFNwQTAzN+e8N88ej9+8j5n3ce5wf5JhPvyY4f3f/9xzz73vXoUeYKish6oljCiFYQ2MaAebVR3D/Jzf1xpDUPTTggIW6feXoOlH0Q9wS9exRK/Pl6qYX6qoJRiOgoEMvqpHWUjlYJ9iQeEJmTb07y6y2CT6HP99/z01C8MwQmB26OMSyuTIH9LTkSA35oLn9FmKCB/WHmP2YUUtQjhiBV4jqsIoJKJJbOC8ZLHFCczhl75UWXvCFuPUDiBXV5TGeWlhXIzALCx9m6Ni3RqfeRL71PJZVYEAChfYdayDc1klSkXBCRr9caxooQsTuIccG4qbiddxsKjQnbvAlDwNVzfgXK8L2wq30ZSMHcs7GctV4IFX9ZTyXGtM8pQq2i2qnCQ3H0NO5CLwk+radnDYrj3CWB5udpAx7FoS96YVdxVy1XCJzgmfG2RMZg5268P9FI6BzP8TRlN3Q/YvkRGZCOyG5H5cApcVLZFkGbJTF3igrEccErfX+rVZk5XIqbbBmyb1y2oDZqy4yfHbZT6HSJHUHDwwqQ/QP1aBpWvIIOXlM+o8UiAVga246ZOWyF0LbMXNjjRE7kpgbi/oS1yCJTNIoP33zqjL6JCOBW5Up24+sWXHvKDyJplojEal5tEBHWXRLG6tHzNW3BxQ7oTBSxvpnKMDOhKYxbVdofxwu1BUW+DqIBKSWODBSf17K24hjFRLbuk3EYkEbhTHbW25KBxMJR2giJ1k2aRKCJR0VR9jd9ySZmwH26RKCKRBicfWYxJLYGp3j9p2VxA0th43VEeGaBuahRIzVEc6uFbCtBVXIDFDdaiDBw/pUdSp7bXIpY6xsCm5oQ5W9fiNuaUgVHjfuK2DN01ovj/IaIE3PwVs/TL9PEOPv7T2vX/fAe7+H/j4c5hPiItLbQ9SyasmRcOCvvJN4OvPAXueB7Y9He+4a/8CFkjoq1TO/9snMA7tuEbcHvReoINNc++eHcCb48De59E1t+94gp+46rncGNq4OFBg6vfehAEzIl/5FnDkB/GdmpQL1w0SWmP2/lk11vryOoFNyJx3Pgu89eN0HBuHP3zkCc1ttmgCXLwui1ZVlCGYw98Brv82P3GZ174L/P031LY/C9FQs3qg9bU1Dm5MWP8UAuEE6v1D+QobxPErnptFQtWt0mNsb14daI2Daxtk3j+09WnPQUWLy7xJbf6RcciEqlu8rknzS2sEpnT7AITB4v759ewSqU6QLHJjJaLV5/4DieFZorjNSA3XpUfY4ofpFQdLDM/vH5YrLsNO5qRPGs1hekVgGu9N9Z6YbuEQKD1rZVjkrcIuwuYw3dwG74MQ+ITxiTMBN7s/DGmsFKlcgd3ihqAxX253TYIjjahQTVq6qxihIbCuyilLcvlRcrvbDo447GYp6IaLXYGVoPUzjhgSmlthcSW52NfUF3gXBGCqe324pCnFxbqhqcO3Q0iZMckCm4w/Hi0Bvt2FtXWqG2W0v5w5SyhFdsv4boiBV8F3pCRYe3egJ+D/h6AwPewoR0b3yPTw3Mzer0EEvN2BQ/m0CAfzPKpeYY+QpoY3J3Eoj96Mgtn5nKw+ZLdI6QmoOraXoIsP0a1TWoPg6TLv/AW4/R/v9zmZSdJuv/MRsPCZd+xrL8avH/PnXryR7NidQqIRtcHbSkpjiy543feoK54nvX3vbW/Gow+LHWdclgXiYxc+T35su8996yfhRQ1JfXmHVUbBRDmCx11v3wl+fSFi4vobHwT/Dh977ZPOPveNP0VPwJPQ5JB5hzJfTjgNrt5q/x7PYQ7j48/av7cQ8l7U5164gVDiNDuZowwROIwoJy096PzYXkCEwFEnOmzgPyrRGt/V+bGhnxvRFZIyWV6GwA/C33+3HNxOc6ITdaIPv9j5se0+15TZJkxf/zempyhWb0SBbHsG+NEL7d8fooRlfGTV6Tu+4g0rvv4SIknz2Be+CvzqJW/UKAxu2//4V4hAbZrQi0Vn0uySfx5Hz8B3Kf70XRQOLzIuIkT79+r2ClHZeV5QN2nJoXqliLnQ1wy8L7cdgu4xvuuQyrchgKj+rClwJBJ0sZKDNURsY37xH+gJrna06G9GKMw7vHU5BCDsyu+YizcgBl1nB/dhEUI4cQVGw8mipIuUzeuUHspwMMMnx6h1MVo4LuwCLVVJYL4LTUqixRyqwEj4whQVnqkPzNo6jSeiXGxiWyzNvWRadyzME1hjFoL4ecWswsfF67Lcy/iaenc2lOQ4mOFB9uNS18FogUOzxJvA/d7RymSdwQn9X2mryp4uy55Oy1Hm278LnvVRKFTbuH9WbeGHq7VoR5aLmXbTbaTw6w8Eiusx5z9YvcO/hg8hjKAJc1LgPOGCsHbXh5LmlZ3SVgTeUJW5/6AvspQSIH8fyeIytb7VpHlFYHdVFiUrm/bhk8rhuujM2p9GK1lcsu/cw9Ory/yvXSdLYJhm/OWUipyKyhGEEyrJOQGjW3aCXSOwG6aFjC75FL1Wlu9anqGxZEDfvDk8M2sEdsuWSo6LixSXmwPu37JrTamsaYVKc3hm1q34rh1ycb34JQ2LEJdF5RB84oqZ5VJVw7rNpIMXBP+ZnqFQPYqCyEtc7sNyCOa7H1hQnmpjQhgORGOeihvr1hcI3rNB4ViRAv/vAfD9t5EpQgsUHUPJ1amg19vvujKpP7Xb2ZkBDw0un1GBm3K0nTZLbfFBWMxAU8RtQ/jOZwW3xZZowtzLhE98V+2vDIsMVD080oYKfP+0mpVavrR4/d6wfQuZyFtXSoquEGHVLQvcMd9ajAgbKfASVUa0DdXy0DjVWrUKIvbyKzbhkkNUYtVM7LsLbagWAodmB2Nxfz22wDZUy0BTnzdOaPZJdH8whYWTHPthKQY698vvkQYJSLwEGq9BXO13N68UvztpL5Gk3W0m8R3+PGZccrCfroxFWHKBxU3S7jbT8SKGAxN6hA6ekTaXuuegpKrah91J2t1mOl6jY/msmlfKDkhkDZ/jTsVlulqE5d4ZdVlpK3JWUMZ8kM8xuiCVdWY3TegydaHOwZIaLC5FyQq6JLWFhK3I6ZGWuExq62Tdoy9EV8t+W+3qAjp3fA7TEpdJfSnwoUN6uFbHjJ3ukwzuCtEfLG6qN+mkvtIdlzT7qM9m+8mJmOd+btriMpksZeiK/Ai7bVkzBnSOSk9hrJuuUBiZ79YwMKmnqCt11BZEWqD2lgcOktaWk5LLdhy2XV7HXNVBOSvXNpPrfiuDk3qartxfPLFuzsm1zeS+oU7DzdPk5sLvf8qZ3FzbTGE7JvG28qqOc09A2J6jVHbanaFaAAVvieVVwOhbHO01oblfqxwcLEpYn8IF9mmUOqfooYjdyLugUMe2IkZgn0boLhvVRnPy5OAyDe2dlyKsjziBfdxkrIZRcnWZnu6DTOZ0HZc3DKKydFKJrMGLFbiZFbGBl8FiF9XN4oEUhVvSRW3GCIFb4TDOW9NTSByln11ZJWi8zDKvxMsLe/J6ntLCbxyMFLiVoSk9VH2IEVd03rKedzX3XD7EO3AG7gvlDc3ddR8qLLpZr6LX6iRoHxZLGzFvgkOj+ALBlx6CtCZy6AAAAABJRU5ErkJggg==",e.style.width="100%",e.style.height="100%",e.style.objectFit="cover",e.style.display="block",e.alt="Customer Service",e.onload=()=>{this.debug&&console.log("Icon image loaded successfully"),this.iconElement&&(e.style.opacity="1",e.style.visibility="visible")},e.onerror=A=>{console.error("Failed to load icon image",A)},e.style.opacity="1",e.style.visibility="visible";const t=document.createElement("div");Object.assign(t.style,{width:"100%",height:"100%",borderRadius:"50%",overflow:"hidden",position:"relative"}),t.appendChild(e),this.iconElement.appendChild(t);const n=this.getTargetElement();if(this.sideAttach&&n!==document.body){const A=window.getComputedStyle(n),e=A.overflowX,t=A.overflowY;"hidden"!==e&&(n.dataset.originalOverflowX||(n.dataset.originalOverflowX=e||"visible",n.dataset.originalOverflowY=t||"visible"),n.style.overflowX="hidden","visible"===t&&(n.style.overflowY="auto"),this.debug&&console.log("[IconManager] Set overflow-x: hidden on target container",{target:this.target,originalOverflowX:e,originalOverflowY:t}))}n?n.appendChild(this.iconElement):(document.body.appendChild(this.iconElement),this.debug&&console.warn("Target element not found, icon added to document.body")),this.setupDragEvents(),this.magnetic&&!this.iconPosition&&setTimeout(()=>{if(this.iconElement){const A=this.getTargetElement();if(A){const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=this.iconElement.offsetHeight||30,r=20,o=80,i=e.width-t-r,s=e.height-n-o;if(this.iconElement.style.left=`${i}px`,this.iconElement.style.top=`${s}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.sideAttach){this.isAttachedToSide=!0,this.attachedSide="right";const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto",this.iconElement.style.bottom=`${o}px`,this.iconElement.style.top="auto",this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease",this.debug&&console.log("[IconManager] Auto side attach on init",{isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide,hideDistance:A,right:`-${A}px`})}else this.magneticSnap(),this.debug&&console.log("[IconManager] Auto magnetic snap on init",{isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide})}}},200),this.sideAttach&&this.autoAttachDelay>0&&!this.isAttachedToSide&&setTimeout(()=>{this.startAutoAttachTimer()},300),this.debug&&console.log("CustomerSDK icon displayed")}forceCleanupDragEvents(){this.cleanupDragEvents()}hide(){if(this.cleanupDragEvents(),this.clearAutoAttachTimer(),this.iconElement){const A=window.getComputedStyle(this.iconElement),e=A.left,t=A.top;if("auto"!==e&&"auto"!==t&&""!==e&&""!==t){const A=parseFloat(e),n=parseFloat(t);isNaN(A)||isNaN(n)||(this.iconPosition={x:A,y:n},this.debug&&console.log("Icon position saved before hide:",this.iconPosition))}this.iconElement.remove(),this.iconElement=null,this.debug&&console.log("CustomerSDK icon hidden")}}setPosition(A){}setIconPosition(A){this.iconPosition=A,this.iconElement&&(void 0!==A.x&&(this.iconElement.style.left="number"==typeof A.x?`${A.x}px`:A.x,this.iconElement.style.right="auto"),void 0!==A.y&&(this.iconElement.style.top="number"==typeof A.y?`${A.y}px`:A.y,this.iconElement.style.bottom="auto"))}setStyle(A){}startAutoAttachTimer(){this.clearAutoAttachTimer(),this.isAttachedToSide||(this.autoAttachTimer=window.setTimeout(()=>{!this.iconElement||this.isDragging||this.dragStarted||this.autoAttachToSide(),this.autoAttachTimer=null},this.autoAttachDelay),this.debug&&console.log(`[IconManager] Auto attach timer started, will attach in ${this.autoAttachDelay}ms`))}clearAutoAttachTimer(){null!==this.autoAttachTimer&&(window.clearTimeout(this.autoAttachTimer),this.autoAttachTimer=null,this.debug&&console.log("[IconManager] Auto attach timer cleared"))}autoAttachToSide(){if(this.iconElement&&this.sideAttach)try{const A=this.getTargetElement();if(!A)return;const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=window.getComputedStyle(this.iconElement),r=parseFloat(n.left)||0,o=n.right,i=e.width;let s=!0;if("auto"!==o&&""!==o){const A=parseFloat(o);if(!isNaN(A)){s=i-t-A>=i/2}}else s=r>=i/2;if(s){this.isAttachedToSide=!0,this.attachedSide="right";const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto"}else{this.isAttachedToSide=!0,this.attachedSide="left";const A=t*this.sideHideRatio;this.iconElement.style.left=`-${A}px`,this.iconElement.style.right="auto"}const a=window.getComputedStyle(this.iconElement);"auto"!==a.top&&""!==a.top?(this.iconElement.style.top=a.top,this.iconElement.style.bottom="auto"):"auto"!==a.bottom&&""!==a.bottom&&(this.iconElement.style.bottom=a.bottom,this.iconElement.style.top="auto"),this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease",this.debug&&console.log("[IconManager] Auto attached to side",{attachedSide:this.attachedSide,hideDistance:t*this.sideHideRatio})}catch(A){this.debug&&console.error("[IconManager] Error in autoAttachToSide:",A)}}onClick(A){this.onClickCallback=A}onNotification(A){this.notificationCallback=A}showNotification(A){if(!this.iconElement)return void(this.debug&&console.warn("Icon not displayed, cannot show notification"));const{showBadge:e=!0,badgeCount:t=0,badgeText:n="",pulse:r=!1}=A;(e||t>0)&&this.createBadge(t,n,r),this.notificationCallback&&this.notificationCallback({badgeCount:t,badgeText:n,pulse:r}),this.debug&&console.log("Notification shown:",{badgeCount:t,badgeText:n})}clearNotification(){this.badgeElement&&(this.badgeElement.remove(),this.badgeElement=null),this.debug&&console.log("Notification cleared")}setupDragEvents(){this.iconElement&&(this.startDragHandler=this.startDrag.bind(this),this.onDragHandler=this.onDrag.bind(this),this.stopDragHandler=this.stopDrag.bind(this),this.iconElement.addEventListener("mousedown",this.startDragHandler),this.iconElement.addEventListener("touchstart",this.startDragHandler,{passive:!1}))}startDrag(A){if(!this.iconElement||!this.isClickEnabled)return;if(this.clearAutoAttachTimer(),this.isStoppingDrag)return void(this.debug&&console.warn("[IconManager] startDrag called while stopping, ignoring"));if(this.isDragging||this.dragStarted)return void(this.debug&&console.warn("[IconManager] startDrag called but already dragging, ignoring",{isDragging:this.isDragging,dragStarted:this.dragStarted}));null===this.dragTimeoutId&&null===this.activeDetectionRafId&&null===this.rafId||(this.debug&&console.warn("[IconManager] startDrag found leftover resources, cleaning up",{hasTimeout:null!==this.dragTimeoutId,hasActiveDetection:null!==this.activeDetectionRafId,hasRaf:null!==this.rafId}),this.cleanupDragEvents());const e=A.target;if(e&&("IFRAME"===e.tagName||e.closest("iframe")||e.closest(".customer-sdk-container")||e.closest(".customer-sdk-overlay")))return;A.preventDefault(),A.stopPropagation(),this.hasMoved=!1,this.dragStarted=!1,this.isDragging=!1,this.touchStartTime=Date.now();const t="touches"in A?A.touches[0].clientX:A.clientX,n="touches"in A?A.touches[0].clientY:A.clientY;this.lastTouchPosition.x=t,this.lastTouchPosition.y=n;try{const A=this.iconElement.getBoundingClientRect();if(!this.getTargetElement())return void(this.debug&&console.warn("Container not found"));this.dragOffset.x=t-A.left,this.dragOffset.y=n-A.top;const e=document.querySelectorAll("iframe");this.cachedIframes=Array.from(e).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=Date.now(),this.debug&&console.log(`[IconManager] Drag start - Found ${this.cachedIframes.length} iframe(s)`,{iframes:this.cachedIframes.map(({rect:A})=>({left:A.left,top:A.top,right:A.right,bottom:A.bottom,width:A.width,height:A.height}))}),this.onDragHandler&&(document.addEventListener("mousemove",this.onDragHandler),document.addEventListener("touchmove",this.onDragHandler,{passive:!1})),this.stopDragHandler&&(document.addEventListener("mouseup",this.stopDragHandler),document.addEventListener("touchend",this.stopDragHandler)),this.mouseLeaveHandler=A=>{!A.relatedTarget&&(A.clientY<=0||A.clientX<=0||A.clientX>=window.innerWidth||A.clientY>=window.innerHeight)&&(this.mouseLeaveTimeout&&clearTimeout(this.mouseLeaveTimeout),this.mouseLeaveTimeout=window.setTimeout(()=>{!this.isDragging&&!this.dragStarted||this.isStoppingDrag||(this.debug&&console.log("[IconManager] Mouse left window, stopping drag"),this.stopDrag()),this.mouseLeaveTimeout=null},50))},this.pointerLeaveHandler=A=>{!A.relatedTarget&&(A.clientY<=0||A.clientX<=0||A.clientX>=window.innerWidth||A.clientY>=window.innerHeight)&&(this.pointerLeaveTimeout&&clearTimeout(this.pointerLeaveTimeout),this.pointerLeaveTimeout=window.setTimeout(()=>{!this.isDragging&&!this.dragStarted||this.isStoppingDrag||(this.debug&&console.log("[IconManager] Pointer left window, stopping drag"),this.stopDrag()),this.pointerLeaveTimeout=null},50))},document.addEventListener("mouseleave",this.mouseLeaveHandler),document.addEventListener("pointerleave",this.pointerLeaveHandler),this.blurHandler=()=>{this.isStoppingDrag||(this.isDragging||this.dragStarted)&&(this.debug&&console.log("[IconManager] Window lost focus, stopping drag"),this.stopDrag())},window.addEventListener("blur",this.blurHandler),this.dragTimeoutId=window.setTimeout(()=>{this.isDragging&&(this.debug&&console.log("Drag timeout, stopping drag (likely mouse moved over iframe)"),this.stopDrag())},50),this.startActiveDetection(),this.debug&&console.log("[IconManager] Drag start",{startPosition:{x:t,y:n},iconRect:{left:A.left,top:A.top,width:A.width,height:A.height},dragOffset:this.dragOffset})}catch(A){this.debug&&console.error("Error in startDrag:",A)}}onDrag(A){if(!this.iconElement)return;A.preventDefault();const e="touches"in A?A.touches[0].clientX:A.clientX,t="touches"in A?A.touches[0].clientY:A.clientY;if(this.isDragging){const A=Date.now();if(0===this.cachedIframes.length||A-this.lastIframeUpdateTime>this.iframeUpdateInterval){const e=document.querySelectorAll("iframe"),t=this.cachedIframes.length;this.cachedIframes=Array.from(e).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=A,this.debug&&this.cachedIframes.length!==t&&console.log(`[IconManager] Iframe cache updated - Found ${this.cachedIframes.length} iframe(s)`,{iframes:this.cachedIframes.map(({rect:A})=>({left:A.left,top:A.top,right:A.right,bottom:A.bottom}))})}for(const{rect:A,element:n}of this.cachedIframes)if(e>=A.left&&e<=A.right&&t>=A.top&&t<=A.bottom)return this.debug&&console.log("[IconManager] Mouse over iframe detected, stopping drag immediately",{mousePosition:{x:e,y:t},iframeRect:{left:A.left,top:A.top,right:A.right,bottom:A.bottom},iframeSrc:n.src||"no src"}),void this.stopDrag()}const n=Date.now(),r=n-this.lastMousePosition.timestamp;this.lastMousePosition={x:e,y:t,timestamp:n},this.debug&&r>50&&this.lastMousePosition.timestamp>0&&console.warn(`[IconManager] Long gap between mousemove events: ${r}ms`,{lastPosition:{x:this.lastMousePosition.x,y:this.lastMousePosition.y},currentPosition:{x:e,y:t}}),null!==this.dragTimeoutId&&(window.clearTimeout(this.dragTimeoutId),this.dragTimeoutId=window.setTimeout(()=>{if(this.isDragging){if(this.debug){const A=Date.now()-this.lastMousePosition.timestamp;console.warn("[IconManager] Drag timeout triggered, stopping drag (likely mouse moved over iframe)",{timeSinceLastMove:A,lastMousePosition:this.lastMousePosition,iframeCount:this.cachedIframes.length})}this.stopDrag()}},50));const o=Math.abs(e-this.lastTouchPosition.x),i=Math.abs(t-this.lastTouchPosition.y);if(Math.sqrt(o*o+i*i)>this.clickThreshold&&(this.hasMoved=!0,!this.dragStarted)){this.dragStarted=!0,this.isDragging=!0,this.isAttachedToSide&&(this.isAttachedToSide=!1,this.attachedSide="",this.iconElement&&(this.iconElement.style.transform=""));const A=window.getComputedStyle(this.iconElement);if("auto"!==A.right||"auto"!==A.bottom){const A=this.iconElement.getBoundingClientRect(),n=this.getTargetElement();if(n){const r=n.getBoundingClientRect(),o=A.left-r.left,i=A.top-r.top;this.iconElement.style.left=`${o}px`,this.iconElement.style.top=`${i}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.dragOffset.x=e-A.left,this.dragOffset.y=t-A.top}}this.iconElement.style.transition="none",this.iconElement.style.cursor="grabbing",this.debug&&console.log("Drag started (moved > threshold)")}if(this.isDragging)try{const A=Date.now(),n=this.getTargetElement();if(!n)return;(!this.cachedContainer||this.cachedContainer!==n||A-this.lastContainerUpdateTime>this.containerUpdateInterval)&&(this.cachedContainer=n,this.cachedContainerRect=n.getBoundingClientRect(),this.cachedIconSize={width:this.iconElement.offsetWidth,height:this.iconElement.offsetHeight},this.lastContainerUpdateTime=A);const r=this.cachedContainerRect,o=this.cachedIconSize.width,i=this.cachedIconSize.height;let s=e-this.dragOffset.x-r.left,a=t-this.dragOffset.y-r.top;if(n===document.body)s=Math.max(0,Math.min(s,window.innerWidth-o)),a=Math.max(0,Math.min(a,window.innerHeight-i));else{const A=r.width,e=r.height;s=Math.max(0,Math.min(s,A-o)),a=Math.max(0,Math.min(a,e-i))}this.pendingPosition.x=s,this.pendingPosition.y=a,this.pendingPosition.needsUpdate=!0,null===this.rafId&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.pendingPosition.needsUpdate&&this.iconElement&&this.isDragging&&(this.iconElement.style.left=`${this.pendingPosition.x}px`,this.iconElement.style.top=`${this.pendingPosition.y}px`,this.iconElement.style.right="auto",this.iconElement.style.bottom="auto",this.pendingPosition.needsUpdate=!1)})),this.lastTouchPosition.x=e,this.lastTouchPosition.y=t}catch(A){this.debug&&console.error("Error in onDrag:",A)}}stopDrag(A){if(this.isStoppingDrag)return void(this.debug&&console.warn("[IconManager] stopDrag already in progress, ignoring duplicate call"));if(!(this.isDragging||this.dragStarted||this.dragTimeoutId||this.activeDetectionRafId))return void(this.debug&&console.warn("[IconManager] stopDrag called but not dragging, ignoring"));this.isStoppingDrag=!0;const e=this.isDragging?"drag_stopped":"not_dragging",t=this.iconElement?{left:this.iconElement.style.left,top:this.iconElement.style.top,computed:"auto"!==window.getComputedStyle(this.iconElement).left?{left:window.getComputedStyle(this.iconElement).left,top:window.getComputedStyle(this.iconElement).top}:null}:null;if(this.cleanupDragEvents(),!this.iconElement)return this.hasMoved=!1,this.isDragging=!1,this.dragStarted=!1,void(this.isStoppingDrag=!1);this.iconElement.style.transition="transform 0.2s ease",this.iconElement.style.cursor="pointer";const n=Date.now()-this.touchStartTime,r=!this.hasMoved&&n<1e3&&!this.dragStarted;this.debug&&console.log("[IconManager] Drag end",{stopReason:e,hasMoved:this.hasMoved,dragStarted:this.dragStarted,touchDuration:n,isValidClick:r,finalPosition:t,lastMousePosition:this.lastMousePosition});const o=r;if(this.dragStarted&&this.magnetic&&this.iconElement&&this.magneticSnap(),this.dragStarted&&this.isDragging&&this.iconElement){const A=window.getComputedStyle(this.iconElement),e=A.left,t=A.top;if("auto"!==e&&"auto"!==t){const A=parseFloat(e),n=parseFloat(t);isNaN(A)||isNaN(n)||(this.iconPosition={x:A,y:n},this.debug&&console.log("Icon position saved:",this.iconPosition))}}this.hasMoved=!1,this.isDragging=!1,this.dragStarted=!1,this.isStoppingDrag=!1,!this.isAttachedToSide&&this.sideAttach&&this.autoAttachDelay>0&&this.startAutoAttachTimer(),o&&setTimeout(()=>{!this.isClickEnabled||this.dragStarted||this.hasMoved||this.isDragging||this.handleClick()},100)}startActiveDetection(){if(null!==this.activeDetectionRafId)return void(this.debug&&console.log("[IconManager] Active detection already running"));this.debug&&console.log("[IconManager] Starting active detection mechanism");const A=()=>{if(!this.isDragging||this.isStoppingDrag)return this.debug&&console.log("[IconManager] Active detection stopped (drag ended or stopping)"),void(this.activeDetectionRafId=null);const e=Date.now(),t=e-this.lastMousePosition.timestamp;if(t>50){const A=this.lastMousePosition.x,n=this.lastMousePosition.y;if(this.debug&&t>100&&console.warn(`[IconManager] Active detection: No mousemove event for ${t}ms`,{lastMousePosition:{x:A,y:n},timestamp:this.lastMousePosition.timestamp,isDragging:this.isDragging,dragStarted:this.dragStarted}),0===this.cachedIframes.length||e-this.lastIframeUpdateTime>this.iframeUpdateInterval){const A=document.querySelectorAll("iframe");this.cachedIframes=Array.from(A).map(A=>({element:A,rect:A.getBoundingClientRect()})),this.lastIframeUpdateTime=e,this.debug&&console.log(`[IconManager] Active detection: Updated iframe cache (${this.cachedIframes.length} iframes)`)}for(const{rect:e,element:r}of this.cachedIframes)if(A>=e.left&&A<=e.right&&n>=e.top&&n<=e.bottom)return this.debug&&console.log("[IconManager] Active detection: Mouse over iframe detected, stopping drag immediately",{mousePosition:{x:A,y:n},iframeRect:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},iframeSrc:r.src||"no src",timeSinceLastMove:t}),void this.stopDrag()}this.activeDetectionRafId=requestAnimationFrame(A)};this.activeDetectionRafId=requestAnimationFrame(A)}stopActiveDetection(){null!==this.activeDetectionRafId&&(this.debug&&console.log("[IconManager] Stopping active detection mechanism"),cancelAnimationFrame(this.activeDetectionRafId),this.activeDetectionRafId=null)}cleanupDragEvents(){this.onDragHandler&&(document.removeEventListener("mousemove",this.onDragHandler),document.removeEventListener("touchmove",this.onDragHandler)),this.stopDragHandler&&(document.removeEventListener("mouseup",this.stopDragHandler),document.removeEventListener("touchend",this.stopDragHandler)),this.mouseLeaveHandler&&(document.removeEventListener("mouseleave",this.mouseLeaveHandler),this.mouseLeaveHandler=null),this.pointerLeaveHandler&&(document.removeEventListener("pointerleave",this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.blurHandler&&(window.removeEventListener("blur",this.blurHandler),this.blurHandler=null),null!==this.mouseLeaveTimeout&&(window.clearTimeout(this.mouseLeaveTimeout),this.mouseLeaveTimeout=null),null!==this.pointerLeaveTimeout&&(window.clearTimeout(this.pointerLeaveTimeout),this.pointerLeaveTimeout=null),null!==this.dragTimeoutId&&(window.clearTimeout(this.dragTimeoutId),this.dragTimeoutId=null),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.stopActiveDetection(),null!==this.activeDetectionRafId&&(this.debug&&console.warn("[IconManager] Active detection RAF ID still exists, force cleaning"),cancelAnimationFrame(this.activeDetectionRafId),this.activeDetectionRafId=null),this.cachedContainer=null,this.cachedContainerRect=null,this.cachedIframes=[],this.pendingPosition.needsUpdate=!1,this.debug&&console.log("[IconManager] Cleanup completed",{isDragging:this.isDragging,dragStarted:this.dragStarted,isStoppingDrag:this.isStoppingDrag,hasTimeout:null!==this.dragTimeoutId,hasActiveDetection:null!==this.activeDetectionRafId,hasRaf:null!==this.rafId})}handleClick(){this.isClickEnabled&&(this.clearAutoAttachTimer(),this.onClickCallback&&this.onClickCallback())}disableClick(){this.isClickEnabled=!1,this.iconElement&&this.startDragHandler&&(this.iconElement.removeEventListener("mousedown",this.startDragHandler),this.iconElement.removeEventListener("touchstart",this.startDragHandler)),this.iconElement&&(this.iconElement.style.pointerEvents="none",this.iconElement.style.cursor="default"),this.forceCleanupDragEvents()}enableClick(){this.isClickEnabled=!0,this.iconElement&&this.startDragHandler?(this.iconElement.addEventListener("mousedown",this.startDragHandler),this.iconElement.addEventListener("touchstart",this.startDragHandler,{passive:!1})):this.iconElement&&this.setupDragEvents(),this.iconElement&&(this.iconElement.style.pointerEvents="auto",this.iconElement.style.cursor="pointer")}magneticSnap(){if(this.iconElement)try{const A=this.getTargetElement();if(!A)return;const e=A.getBoundingClientRect(),t=this.iconElement.offsetWidth||30,n=this.iconElement.offsetHeight||30,r=window.getComputedStyle(this.iconElement),o=parseFloat(r.left)||0,i=parseFloat(r.top)||0;let s=o,a=i;if("x"===this.magneticDirection||"both"===this.magneticDirection){const A=e.width;if(o<A/2)if(s=this.margin,this.sideAttach&&o<t/2){this.isAttachedToSide=!0,this.attachedSide="left";s=-(t*this.sideHideRatio)}else this.isAttachedToSide=!1,this.attachedSide="";else if(s=A-t-this.margin,this.sideAttach){if(A-o-t<t/2||isNaN(o)||0===o||o>=A-t-this.margin-t/2){this.isAttachedToSide=!0,this.attachedSide="right";s=A-t*(1-this.sideHideRatio)}else this.isAttachedToSide=!1,this.attachedSide=""}else this.isAttachedToSide=!1,this.attachedSide=""}if("y"===this.magneticDirection||"both"===this.magneticDirection){const A=e.height;a=i<A/2?this.margin:A-n-this.margin}if(this.isAttachedToSide&&"right"===this.attachedSide){const A=t*this.sideHideRatio;this.iconElement.style.right=`-${A}px`,this.iconElement.style.left="auto"}else if(this.isAttachedToSide&&"left"===this.attachedSide){const A=t*this.sideHideRatio;this.iconElement.style.left=`-${A}px`,this.iconElement.style.right="auto"}else this.iconElement.style.left=`${s}px`,this.iconElement.style.right="auto";this.iconElement.style.top=`${a}px`,this.iconElement.style.bottom="auto",this.isAttachedToSide&&this.attachedSide?(this.iconElement.style.transform="translateX(0)",this.iconElement.style.transition="all 0.3s ease"):this.iconElement.style.transform="",this.isAttachedToSide&&"right"===this.attachedSide?this.iconPosition=null:this.iconPosition={x:s,y:a},this.debug&&console.log("[IconManager] Magnetic snap applied",{newPosition:{x:s,y:a},isAttachedToSide:this.isAttachedToSide,attachedSide:this.attachedSide})}catch(A){this.debug&&console.error("[IconManager] Error in magneticSnap:",A)}}getTargetElement(){if(!this.target)return document.body;if("string"==typeof this.target){const A=document.querySelector(this.target);return A||(this.debug&&console.warn(`Target element not found: ${this.target}, falling back to document.body`),document.body)}return this.target instanceof HTMLElement?document.body.contains(this.target)?this.target:(this.debug&&console.warn("Target element no longer in DOM, falling back to document.body"),document.body):document.body}createBadge(A,e="",t=!1){this.clearNotification(),this.badgeElement=document.createElement("div"),this.badgeElement.className="customer-sdk-icon-badge",this.badgeElement.textContent=A>0?A>99?"99+":A.toString():e||"",Object.assign(this.badgeElement.style,{position:"absolute",top:"-4px",left:"-4px",right:"auto",minWidth:"18px",height:"18px",borderRadius:"50%",backgroundColor:"#ff4444",color:"#ffffff",fontSize:"10px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000001",boxShadow:"0 -1px 4px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15)",...0===A&&""===e&&{width:"12px",height:"12px",minWidth:"12px",top:"-2px",left:"-2px"},...t&&{animation:"sdk-badge-pulse 1.5s infinite"}}),this.iconElement&&this.iconElement.appendChild(this.badgeElement)}}class t{constructor(A={}){this.iframeElement=null,this.containerElement=null,this.isOpen=!1,this.isCreated=!1,this.debug=!1,this.targetElement=null,this.messageHandler=null,this.config={src:"",mode:"auto",width:450,height:600,allowClose:!0,...A},this.debug=A.debug??!1}async init(){try{this.setupMessageListener(),this.cleanupOrphanedElements(),this.createIframe(),this.isCreated=!0,this.debug&&console.log("CustomerSDK iframe initialized (hidden, SSE connected)")}catch(A){throw console.error("Failed to initialize iframe:",A),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),A}}show(){if(!this.isOpen){if(!this.isCreated)throw new Error("Iframe not initialized. Call init() first.");try{this.containerElement&&(this.containerElement.parentNode||document.body.appendChild(this.containerElement),Object.assign(this.containerElement.style,{position:"fixed",visibility:"visible",opacity:"1",display:"block"}),this.preventBodyScroll(!0)),this.isOpen=!0,this.debug&&console.log("CustomerSDK iframe shown")}catch(A){console.error("Failed to show iframe:",A)}}}open(){this.show()}hide(){this.isOpen&&(this.containerElement&&Object.assign(this.containerElement.style,{visibility:"hidden",opacity:"0",display:"none"}),this.preventBodyScroll(!1),this.isOpen=!1,this.debug&&console.log("CustomerSDK iframe hidden (SSE still connected)"),this.config.onClose&&this.config.onClose())}close(){this.hide()}destroy(){this.hide(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.containerElement&&(this.containerElement.remove(),this.containerElement=null,this.iframeElement=null),this.isCreated=!1,this.debug&&console.log("CustomerSDK container destroyed")}isIframeOpen(){return this.isOpen}sendToIframe(A){this.iframeElement&&this.iframeElement.contentWindow&&this.iframeElement.contentWindow.postMessage(A,"*")}cleanupOrphanedElements(){document.querySelectorAll(".customer-sdk-container").forEach(A=>{A!==this.containerElement&&(A.remove(),this.debug&&console.log("清理旧的容器元素"))})}createIframe(){this.containerElement=document.createElement("div"),this.containerElement.className="customer-sdk-container",this.iframeElement=document.createElement("iframe"),this.iframeElement.className="customer-sdk-iframe",this.iframeElement.src=this.config.src||"",this.iframeElement.frameBorder="0",this.iframeElement.setAttribute("allow",["microphone","camera","geolocation","clipboard-read","clipboard-write","fullscreen","autoplay","encrypted-media"].join("; ")),this.iframeElement.setAttribute("sandbox",["allow-same-origin","allow-scripts","allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-storage-access-by-user-activation"].join(" ")),this.config.target&&(this.targetElement=this.getTargetElement(this.config.target));const A="popup"===this.getActualMode();this.iframeElement.scrolling="auto";const e=!!this.targetElement&&this.targetElement!==document.body?{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:"0",boxShadow:A?"none":"0 -4px 16px rgba(0, 0, 0, 0.25)",border:"none",position:"absolute",zIndex:"999999",top:"0",left:"0",bottom:"0",right:"0",transform:"none",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"}:A?{width:`${this.config.width||450}px`,height:"100%",maxWidth:"90vw",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:"0",boxShadow:"none",border:"none",position:"fixed",zIndex:"999999",top:"0",left:"50%",bottom:"0",right:"auto",transform:"translateX(-50%)",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"}:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",backgroundColor:"#ffffff",borderRadius:"0",boxShadow:"0 -4px 16px rgba(0, 0, 0, 0.25)",border:"none",position:"fixed",zIndex:"999999",top:"0",left:"0",bottom:"0",right:"0",transform:"none",overflow:"hidden",visibility:"hidden",opacity:"0",display:"none"};Object.assign(this.containerElement.style,e);if(Object.assign(this.iframeElement.style,{width:"100%",height:"100%",border:"none",borderRadius:"inherit"}),this.containerElement.appendChild(this.iframeElement),this.iframeElement.addEventListener("load",()=>{A||this.injectMobileStyles()}),this.targetElement&&this.targetElement!==document.body){"static"===window.getComputedStyle(this.targetElement).position&&(this.targetElement.style.position="relative",this.debug&&console.log("Set target element position to relative for iframe container")),this.targetElement.appendChild(this.containerElement),this.debug&&console.log("Iframe container added to target element")}else document.body.appendChild(this.containerElement),this.debug&&console.log("Iframe container added to document.body");this.debug&&console.log("CustomerSDK container created (hidden, ready for SSE)")}injectMobileStyles(){if(this.iframeElement)try{const A=this.iframeElement.contentDocument||this.iframeElement.contentWindow?.document;if(A){const e=A.createElement("style");e.textContent="\n /* 移动端iframe全屏样式优化 */\n * {\n -webkit-overflow-scrolling: touch !important;\n }\n \n body, html, #app, .container {\n overflow: auto !important;\n -webkit-overflow-scrolling: touch !important;\n }\n \n /* 隐藏所有滚动条 */\n ::-webkit-scrollbar {\n width: 0px !important;\n height: 0px !important;\n background: transparent !important;\n }\n \n /* Firefox */\n html {\n scrollbar-width: none !important;\n }\n \n /* IE/Edge */\n body {\n -ms-overflow-style: none !important;\n }\n \n /* 确保内容可以滚动 */\n body {\n overflow: auto !important;\n height: 100vh !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n ",A.head?.appendChild(e),this.debug&&console.log("CustomerSDK mobile styles injected successfully")}}catch(A){this.debug&&console.log("Cannot inject styles due to cross-origin restrictions:",A)}}preventBodyScroll(A){if(A){const A=window.scrollY;Object.assign(document.body.style,{position:"fixed",top:`-${A}px`,width:"100%",overflow:"hidden"}),document.body.setAttribute("data-scroll-position",A.toString())}else{const A=parseInt(document.body.getAttribute("data-scroll-position")||"0");Object.assign(document.body.style,{position:"",top:"",width:"",overflow:""}),document.body.removeAttribute("data-scroll-position"),window.scrollTo(0,A)}}isMobileDevice(){return window.innerWidth<=768||/Android|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent)}getActualMode(){return"auto"===this.config.mode?this.isMobileDevice()?"fullscreen":"popup":this.config.mode}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=A=>{this.config.src&&A.origin!==new URL(this.config.src).origin||this.handleIframeMessage(A.data)},window.addEventListener("message",this.messageHandler,!1)}handleIframeMessage(A){let e;if(this.debug&&console.log("Message from iframe:",A),"string"==typeof A)e=A;else{if(!A||!A.type)return void(this.debug&&console.log("Unknown message format:",A));e=A.type}switch(e){case"iframe_ready":this.debug&&console.log("Iframe is ready");break;case"close_iframe":case"close":this.close();break;case"resize_iframe":case"resize":"popup"===this.getActualMode()&&A.width&&A.height?this.resizeIframe(A.width,A.height):this.debug&&console.log("Resize request ignored (fullscreen mode)");break;case"new-message":this.debug&&console.log("Received new message notification"),this.config.onMessage&&this.config.onMessage(e,A);break;case"goto-login":this.debug&&console.log("Received goto-login message, forwarding to parent window"),this.forwardMessageToParent(A),this.config.onMessage&&this.config.onMessage(e,A);break;default:"string"==typeof e&&e.startsWith("gotoActivityDetailById:")?(this.debug&&console.log("Received gotoActivityDetailById message, forwarding to parent window:",e),this.forwardMessageToParent(A),this.config.onMessage&&this.config.onMessage(e,A)):this.debug&&console.log("Custom message:",A)}}forwardMessageToParent(A){try{window.parent&&window.parent!==window&&window.parent.postMessage(A,"*");const e=new MessageEvent("message",{data:A,origin:window.location.origin,source:window});window.dispatchEvent(e),this.debug&&console.log("Message forwarded via window.postMessage and dispatchEvent:",A)}catch(A){this.debug&&console.error("Failed to forward message:",A)}}resizeIframe(A,e){this.containerElement&&(this.containerElement.style.width=`${A}px`,this.containerElement.style.height=`${e}px`)}getTargetElement(A){if("string"==typeof A){const e=document.querySelector(A);return e||(this.debug&&console.warn(`Target element not found: ${A}, falling back to document.body`),document.body)}return A instanceof HTMLElement?document.body.contains(A)?A:(this.debug&&console.warn("Target element no longer in DOM, falling back to document.body"),document.body):document.body}}const n="p".charCodeAt(0),r="H".charCodeAt(0),o="Y".charCodeAt(0),i="s".charCodeAt(0);let s;function a(A){let e=-1;s||(s=function(){const A=new Int32Array(256);for(let e=0;e<256;e++){let t=e;for(let A=0;A<8;A++)t=1&t?3988292384^t>>>1:t>>>1;A[e]=t}return A}());for(let t=0;t<A.length;t++)e=s[255&(e^A[t])]^e>>>8;return-1^e}function c(A,e,t=!1){const s=new Uint8Array(13);e*=39.3701,s[0]=n,s[1]=r,s[2]=o,s[3]=i,s[4]=e>>>24,s[5]=e>>>16,s[6]=e>>>8,s[7]=255&e,s[8]=s[4],s[9]=s[5],s[10]=s[6],s[11]=s[7],s[12]=1;const c=a(s),l=new Uint8Array(4);if(l[0]=c>>>24,l[1]=c>>>16,l[2]=c>>>8,l[3]=255&c,t){const e=function(A){for(let e=A.length-1;e>=4;e--)if(9===A[e-4]&&A[e-3]===n&&A[e-2]===r&&A[e-1]===o&&A[e]===i)return e-3;return 0}(A);return A.set(s,e),A.set(l,e+13),A}{const e=new Uint8Array(4);e[0]=0,e[1]=0,e[2]=0,e[3]=9;const t=new Uint8Array(54);return t.set(A,0),t.set(e,33),t.set(s,37),t.set(l,50),t}}const l="[modern-screenshot]",u="undefined"!=typeof window,h=u&&"Worker"in window,g=u&&"atob"in window,d=u&&"btoa"in window,B=u?window.navigator?.userAgent:"",w=B.includes("Chrome"),f=B.includes("AppleWebKit")&&!w,m=B.includes("Firefox"),p=A=>1===A.nodeType,C=A=>"object"==typeof A.className,Q=A=>"image"===A.tagName,y=A=>p(A)&&void 0!==A.style&&!C(A),U=A=>8===A.nodeType,F=A=>"IMG"===A.tagName,b=A=>"VIDEO"===A.tagName,E=A=>"SLOT"===A.tagName;function v(A){const e=A?.createElement?.("canvas");return e&&(e.height=e.width=1),Boolean(e)&&"toDataURL"in e&&Boolean(e.toDataURL("image/webp").includes("image/webp"))}const H=A=>A.startsWith("data:");function I(A,e){if(A.match(/^[a-z]+:\/\//i))return A;if(u&&A.match(/^\/\//))return window.location.protocol+A;if(A.match(/^[a-z]+:/i))return A;if(!u)return A;const t=x().implementation.createHTMLDocument(),n=t.createElement("base"),r=t.createElement("a");return t.head.appendChild(n),t.body.appendChild(r),e&&(n.href=e),r.href=A,r.href}function x(A){return(A&&p(A)?A?.ownerDocument:A)??window.document}const S="http://www.w3.org/2000/svg";const L=A=>function(A,e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.onabort=()=>n(new Error(`Failed read blob to ${e}`)),r.readAsDataURL(A)})}(A,"dataUrl");function D(A,e){const t=x(e).createElement("img");return t.decoding="sync",t.loading="eager",t.src=A,t}function M(A,e){return new Promise(t=>{const{timeout:n,ownerDocument:r,onError:o,onWarn:i}=e??{},s="string"==typeof A?D(A,x(r)):A;let a=null,c=null;function l(){t(s),a&&clearTimeout(a),c?.()}if(n&&(a=setTimeout(l,n)),b(s)){const A=s.currentSrc||s.src;if(!A)return s.poster?M(s.poster,e).then(t):l();if(s.readyState>=2)return l();const n=l,r=e=>{i?.("Failed video load",A,e),o?.(e),l()};c=()=>{s.removeEventListener("loadeddata",n),s.removeEventListener("error",r)},s.addEventListener("loadeddata",n,{once:!0}),s.addEventListener("error",r,{once:!0})}else{const A=Q(s)?s.href.baseVal:s.currentSrc||s.src;if(!A)return l();const e=async()=>{if(F(s)&&"decode"in s)try{await s.decode()}catch(e){i?.("Failed to decode image, trying to render anyway",s.dataset.originalSrc||A,e)}l()},t=e=>{i?.("Failed image load",s.dataset.originalSrc||A,e),l()};if(F(s)&&s.complete)return e();c=()=>{s.removeEventListener("load",e),s.removeEventListener("error",t)},s.addEventListener("load",e,{once:!0}),s.addEventListener("error",t,{once:!0})}})}const K=function(){let A=0;return()=>(A+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${A}`)}();function T(A){return A?.split(",").map(A=>A.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let k=0;function R(A){const e=`${l}[#${k}]`;return k++,{time:t=>A&&console.time(`${e} ${t}`),timeEnd:t=>A&&console.timeEnd(`${e} ${t}`),warn:(...e)=>A&&((...A)=>console.warn(l,...A))(...e)}}async function P(A,e){return(t=A)&&"__CONTEXT__"in t?A:O(A,{...e,autoDestruct:!0});var t}async function O(A,e){const{scale:t=1,workerUrl:n,workerNumber:r=1}=e||{},o=Boolean(e?.debug),i=e?.features??!0,s=A.ownerDocument??(u?window.document:void 0),a=A.ownerDocument?.defaultView??(u?window:void 0),c=new Map,l={width:0,height:0,quality:1,type:"image/png",scale:t,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:(g=e?.fetch?.bypassingCache,{cache:g?"no-cache":"force-cache"}),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...e?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:r,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...e,__CONTEXT__:!0,log:R(o),node:A,ownerDocument:s,ownerWindow:a,dpi:1===t?null:96*t,svgStyleElement:N(s),svgDefsElement:s?.createElementNS(S,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:h&&n&&r?r:0})].map(()=>{try{const A=new Worker(n);return A.onmessage=async A=>{const{url:e,result:t}=A.data;t?c.get(e)?.resolve?.(t):c.get(e)?.reject?.(new Error(`Error receiving message from worker: ${e}`))},A.onmessageerror=A=>{const{url:e}=A.data;c.get(e)?.reject?.(new Error(`Error receiving message from worker: ${e}`))},A}catch(A){return l.log.warn("Failed to new Worker",A),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[v(s)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:c,drawImageCount:0,tasks:[],features:i,isEnable:A=>"restoreScrollPosition"===A?"boolean"!=typeof i&&(i[A]??!1):"boolean"==typeof i?i:i[A]??!0,shadowRoots:[]};var g;l.log.time("wait until load"),await async function(A,e){y(A)&&(F(A)||b(A)?await M(A,e):await Promise.all(["img","video"].flatMap(t=>Array.from(A.querySelectorAll(t)).map(A=>M(A,e)))))}(A,{timeout:l.timeout,onWarn:l.log.warn}),l.log.timeEnd("wait until load");const{width:d,height:B}=function(A,e){let{width:t,height:n}=e;if(p(A)&&(!t||!n)){const e=A.getBoundingClientRect();t=t||e.width||Number(A.getAttribute("width"))||0,n=n||e.height||Number(A.getAttribute("height"))||0}return{width:t,height:n}}(A,l);return l.width=d,l.height=B,l}function N(A){if(!A)return;const e=A.createElement("style"),t=e.ownerDocument.createTextNode("\n.______background-clip--text {\n background-clip: text;\n -webkit-background-clip: text;\n}\n");return e.appendChild(t),e}async function V(A,e){const{log:t,timeout:n,drawImageCount:r,drawImageInterval:o}=e;t.time("image to canvas");const i=await M(A,{timeout:n,onWarn:e.log.warn}),{canvas:s,context2d:a}=function(A,e){const{width:t,height:n,scale:r,backgroundColor:o,maximumCanvasSize:i}=e,s=A.createElement("canvas");s.width=Math.floor(t*r),s.height=Math.floor(n*r),s.style.width=`${t}px`,s.style.height=`${n}px`,i&&(s.width>i||s.height>i)&&(s.width>i&&s.height>i?s.width>s.height?(s.height*=i/s.width,s.width=i):(s.width*=i/s.height,s.height=i):s.width>i?(s.height*=i/s.width,s.width=i):(s.width*=i/s.height,s.height=i));const a=s.getContext("2d");a&&o&&(a.fillStyle=o,a.fillRect(0,0,s.width,s.height));return{canvas:s,context2d:a}}(A.ownerDocument,e),c=()=>{try{a?.drawImage(i,0,0,s.width,s.height)}catch(A){e.log.warn("Failed to drawImage",A)}};if(c(),e.isEnable("fixSvgXmlDecode"))for(let A=0;A<r;A++)await new Promise(e=>{setTimeout(()=>{a?.clearRect(0,0,s.width,s.height),c(),e()},A+o)});return e.drawImageCount=0,t.timeEnd("image to canvas"),s}function G(A,e){if(A.ownerDocument)try{const e=A.toDataURL();if("data:,"!==e)return D(e,A.ownerDocument)}catch(A){e.log.warn("Failed to clone canvas",A)}const t=A.cloneNode(!1),n=A.getContext("2d"),r=t.getContext("2d");try{return n&&r&&r.putImageData(n.getImageData(0,0,A.width,A.height),0,0),t}catch(A){e.log.warn("Failed to clone canvas",A)}return t}function W(A,e){return(A=>"CANVAS"===A.tagName)(A)?G(A,e):(A=>"IFRAME"===A.tagName)(A)?function(A,e){try{if(A?.contentDocument?.body)return eA(A.contentDocument.body,e)}catch(A){e.log.warn("Failed to clone iframe",A)}return A.cloneNode(!1)}(A,e):F(A)?function(A){const e=A.cloneNode(!1);return A.currentSrc&&A.currentSrc!==A.src&&(e.src=A.currentSrc,e.srcset=""),"lazy"===e.loading&&(e.loading="eager"),e}(A):b(A)?async function(A,e){if(A.ownerDocument&&!A.currentSrc&&A.poster)return D(A.poster,A.ownerDocument);const t=A.cloneNode(!1);t.crossOrigin="anonymous",A.currentSrc&&A.currentSrc!==A.src&&(t.src=A.currentSrc);const n=t.ownerDocument;if(n){let r=!0;if(await M(t,{onError:()=>r=!1,onWarn:e.log.warn}),!r)return A.poster?D(A.poster,A.ownerDocument):t;t.currentTime=A.currentTime,await new Promise(A=>{t.addEventListener("seeked",A,{once:!0})});const o=n.createElement("canvas");o.width=A.offsetWidth,o.height=A.offsetHeight;try{const A=o.getContext("2d");A&&A.drawImage(t,0,0,o.width,o.height)}catch(n){return e.log.warn("Failed to clone video",n),A.poster?D(A.poster,A.ownerDocument):t}return G(o,e)}return t}(A,e):A.cloneNode(!1)}const X=["width","height","-webkit-text-fill-color"],J=["stroke","fill"];function Y(A,e,t){const{defaultComputedStyles:n}=t,r=A.nodeName.toLowerCase(),o=C(A)&&"svg"!==r,i=o?J.map(e=>[e,A.getAttribute(e)]).filter(([,A])=>null!==A):[],s=[o&&"svg",r,i.map((A,e)=>`${A}=${e}`).join(","),e].filter(Boolean).join(":");if(n.has(s))return n.get(s);const a=function(A){let e=A.sandbox;if(!e){const{ownerDocument:t}=A;try{t&&(e=t.createElement("iframe"),e.id=`__SANDBOX__${K()}`,e.width="0",e.height="0",e.style.visibility="hidden",e.style.position="fixed",t.body.appendChild(e),e.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',A.sandbox=e)}catch(e){A.log.warn("Failed to getSandBox",e)}}return e}(t),c=a?.contentWindow;if(!c)return new Map;const l=c?.document;let u,h;o?(u=l.createElementNS(S,"svg"),h=u.ownerDocument.createElementNS(u.namespaceURI,r),i.forEach(([A,e])=>{h.setAttributeNS(null,A,e)}),u.appendChild(h)):u=h=l.createElement(r),h.textContent=" ",l.body.appendChild(u);const g=c.getComputedStyle(h,e),d=new Map;for(let A=g.length,e=0;e<A;e++){const A=g.item(e);X.includes(A)||d.set(A,g.getPropertyValue(A))}return l.body.removeChild(u),n.set(s,d),d}function $(A,e,t){const n=new Map,r=[],o=new Map;if(t)for(const A of t)i(A);else for(let e=A.length,t=0;t<e;t++){i(A.item(t))}for(let A=r.length,e=0;e<A;e++)o.get(r[e])?.forEach((A,e)=>n.set(e,A));function i(t){const i=A.getPropertyValue(t),s=A.getPropertyPriority(t),a=t.lastIndexOf("-"),c=a>-1?t.substring(0,a):void 0;if(c){let A=o.get(c);A||(A=new Map,o.set(c,A)),A.set(t,[i,s])}(e.get(t)!==i||s)&&(c?r.push(c):n.set(t,[i,s]))}return n}const Z=[":before",":after"],j=[":-webkit-scrollbar",":-webkit-scrollbar-button",":-webkit-scrollbar-thumb",":-webkit-scrollbar-track",":-webkit-scrollbar-track-piece",":-webkit-scrollbar-corner",":-webkit-resizer"];const _=new Set(["symbol"]);async function z(A,e,t,n,r){if(p(t)&&((A=>"STYLE"===A.tagName)(t)||(A=>"SCRIPT"===A.tagName)(t)))return;if(n.filter&&!n.filter(t))return;_.has(e.nodeName)||_.has(t.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;const o=await eA(t,n,!1,r);n.isEnable("restoreScrollPosition")&&function(A,e){if(!y(A)||!y(e))return;const{scrollTop:t,scrollLeft:n}=A;if(!t&&!n)return;const{transform:r}=e.style,o=new DOMMatrix(r),{a:i,b:s,c:a,d:c}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-n,-t),o.a=i,o.b=s,o.c=a,o.d=c,e.style.transform=o.toString()}(A,o),e.appendChild(o)}async function q(A,e,t,n){let r=A.firstChild;p(A)&&A.shadowRoot&&(r=A.shadowRoot?.firstChild,t.shadowRoots.push(A.shadowRoot));for(let o=r;o;o=o.nextSibling)if(!U(o))if(p(o)&&E(o)&&"function"==typeof o.assignedNodes){const r=o.assignedNodes();for(let o=0;o<r.length;o++)await z(A,e,r[o],t,n)}else await z(A,e,o,t,n)}const AA=/^[\w-:]+$/;async function eA(A,e,t=!1,n){const{ownerDocument:r,ownerWindow:o,fontFamilies:i,onCloneEachNode:s}=e;if(r&&(A=>3===A.nodeType)(A))return n&&/\S/.test(A.data)&&n(A.data),r.createTextNode(A.data);if(r&&o&&p(A)&&(y(A)||C(A))){const n=await W(A,e);if(e.isEnable("removeAbnormalAttributes")){const A=n.getAttributeNames();for(let e=A.length,t=0;t<e;t++){const e=A[t];AA.test(e)||n.removeAttribute(e)}}const r=e.currentNodeStyle=function(A,e,t,n){const{ownerWindow:r,includeStyleProperties:o,currentParentNodeStyle:i}=n,s=e.style,a=r.getComputedStyle(A),c=Y(A,null,n);i?.forEach((A,e)=>{c.delete(e)});const l=$(a,c,o);l.delete("transition-property"),l.delete("all"),l.delete("d"),l.delete("content"),t&&(l.delete("margin-top"),l.delete("margin-right"),l.delete("margin-bottom"),l.delete("margin-left"),l.delete("margin-block-start"),l.delete("margin-block-end"),l.delete("margin-inline-start"),l.delete("margin-inline-end"),l.set("box-sizing",["border-box",""])),"text"===l.get("background-clip")?.[0]&&e.classList.add("______background-clip--text"),w&&(l.has("font-kerning")||l.set("font-kerning",["normal",""]),"hidden"!==l.get("overflow-x")?.[0]&&"hidden"!==l.get("overflow-y")?.[0]||"ellipsis"!==l.get("text-overflow")?.[0]||A.scrollWidth!==A.clientWidth||l.set("text-overflow",["clip",""]));for(let A=s.length,e=0;e<A;e++)s.removeProperty(s.item(e));return l.forEach(([A,e],t)=>{s.setProperty(t,A,e)}),l}(A,n,t,e);t&&function(A,e){const{backgroundColor:t,width:n,height:r,style:o}=e,i=A.style;if(t&&i.setProperty("background-color",t,"important"),n&&i.setProperty("width",`${n}px`,"important"),r&&i.setProperty("height",`${r}px`,"important"),o)for(const A in o)i[A]=o[A]}(n,e);let o=!1;if(e.isEnable("copyScrollbar")){const e=[r.get("overflow-x")?.[0],r.get("overflow-y")?.[0]];o=e.includes("scroll")||(e.includes("auto")||e.includes("overlay"))&&(A.scrollHeight>A.clientHeight||A.scrollWidth>A.clientWidth)}const a=r.get("text-transform")?.[0],c=T(r.get("font-family")?.[0]),l=c?A=>{"uppercase"===a?A=A.toUpperCase():"lowercase"===a?A=A.toLowerCase():"capitalize"===a&&(A=A[0].toUpperCase()+A.substring(1)),c.forEach(e=>{let t=i.get(e);t||i.set(e,t=new Set),A.split("").forEach(A=>t.add(A))})}:void 0;return function(A,e,t,n,r){const{ownerWindow:o,svgStyleElement:i,svgStyles:s,currentNodeStyle:a}=n;function c(t){const i=o.getComputedStyle(A,t);let c=i.getPropertyValue("content");if(!c||"none"===c)return;r?.(c),c=c.replace(/(')|(")|(counter\(.+\))/g,"");const l=[K()],u=Y(A,t,n);a?.forEach((A,e)=>{u.delete(e)});const h=$(i,u,n.includeStyleProperties);h.delete("content"),h.delete("-webkit-locale"),"text"===h.get("background-clip")?.[0]&&e.classList.add("______background-clip--text");const g=[`content: '${c}';`];if(h.forEach(([A,e],t)=>{g.push(`${t}: ${A}${e?" !important":""};`)}),1===g.length)return;try{e.className=[e.className,...l].join(" ")}catch(A){return void n.log.warn("Failed to copyPseudoClass",A)}const d=g.join("\n ");let B=s.get(d);B||(B=[],s.set(d,B)),B.push(`.${l[0]}:${t}`)}i&&o&&(Z.forEach(c),t&&j.forEach(c))}(A,n,o,e,l),function(A,e){((A=>"TEXTAREA"===A.tagName)(A)||(A=>"INPUT"===A.tagName)(A)||(A=>"SELECT"===A.tagName)(A))&&e.setAttribute("value",A.value)}(A,n),b(A)||await q(A,n,e,l),await(s?.(n)),n}const a=A.cloneNode(!1);return await q(A,a,e),await(s?.(a)),a}function tA(A){if(A.ownerDocument=void 0,A.ownerWindow=void 0,A.svgStyleElement=void 0,A.svgDefsElement=void 0,A.svgStyles.clear(),A.defaultComputedStyles.clear(),A.sandbox){try{A.sandbox.remove()}catch(e){A.log.warn("Failed to destroyContext",e)}A.sandbox=void 0}A.workers=[],A.fontFamilies.clear(),A.fontCssTexts.clear(),A.requests.clear(),A.tasks=[],A.shadowRoots=[]}function nA(A,e){const{url:t,requestType:n="text",responseType:r="text",imageDom:o}=e;let i=t;const{timeout:s,acceptOfImage:a,requests:c,fetchFn:l,fetch:{requestInit:u,bypassingCache:h,placeholderImage:g},font:d,workers:B,fontFamilies:w}=A;"image"===n&&(f||m)&&A.drawImageCount++;let p=c.get(t);if(!p){h&&h instanceof RegExp&&h.test(i)&&(i+=(/\?/.test(i)?"&":"?")+(new Date).getTime());const e=n.startsWith("font")&&d&&d.minify,m=new Set;if(e){n.split(";")[1].split(",").forEach(A=>{w.has(A)&&w.get(A).forEach(A=>m.add(A))})}const C=e&&m.size,Q={url:i,timeout:s,responseType:C?"arrayBuffer":r,headers:"image"===n?{accept:a}:void 0,...u};p={type:n,resolve:void 0,reject:void 0,response:null},p.response=(async()=>{if(l&&"image"===n){const A=await l(t);if(A)return A}return!f&&t.startsWith("http")&&B.length?new Promise((A,e)=>{B[c.size&B.length-1].postMessage({rawUrl:t,...Q}),p.resolve=A,p.reject=e}):function(A){const{url:e,timeout:t,responseType:n,...r}=A,o=new AbortController,i=t?setTimeout(()=>o.abort(),t):void 0;return fetch(e,{signal:o.signal,...r}).then(A=>{if(!A.ok)throw new Error("Failed fetch, not 2xx response",{cause:A});switch(n){case"arrayBuffer":return A.arrayBuffer();case"dataUrl":return A.blob().then(L);default:return A.text()}}).finally(()=>clearTimeout(i))}(Q)})().catch(e=>{if(c.delete(t),"image"===n&&g)return A.log.warn("Failed to fetch image base64, trying to use placeholder image",i),"string"==typeof g?g:g(o);throw e}),c.set(t,p)}return p.response}async function rA(A,e,t,n){if(!oA(A))return A;for(const[r,o]of function(A,e){const t=[];return A.replace(iA,(A,n,r)=>(t.push([r,I(r,e)]),A)),t.filter(([A])=>!H(A))}(A,e))try{const e=await nA(t,{url:o,requestType:n?"image":"text",responseType:"dataUrl"});A=A.replace(sA(r),`$1${e}$3`)}catch(A){t.log.warn("Failed to fetch css data url",r,A)}return A}function oA(A){return/url\((['"]?)([^'"]+?)\1\)/.test(A)}const iA=/url\((['"]?)([^'"]+?)\1\)/g;function sA(A){const e=A.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}const aA=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function cA(A,e){const{tasks:t}=e;p(A)&&((F(A)||Q(A))&&t.push(...function(A,e){if(F(A)){const t=A.currentSrc||A.src;if(!H(t))return[nA(e,{url:t,imageDom:A,requestType:"image",responseType:"dataUrl"}).then(e=>{e&&(A.srcset="",A.dataset.originalSrc=t,A.src=e||"")})];(f||m)&&e.drawImageCount++}else if(C(A)&&!H(A.href.baseVal)){const t=A.href.baseVal;return[nA(e,{url:t,imageDom:A,requestType:"image",responseType:"dataUrl"}).then(e=>{e&&(A.dataset.originalSrc=t,A.href.baseVal=e||"")})]}return[]}(A,e)),"use"===A.tagName&&t.push(...function(A,e){const{ownerDocument:t,svgDefsElement:n}=e,r=A.getAttribute("href")??A.getAttribute("xlink:href");if(!r)return[];const[o,i]=r.split("#");if(i){const r=`#${i}`,s=e.shadowRoots.reduce((A,e)=>A??e.querySelector(`svg ${r}`),t?.querySelector(`svg ${r}`));if(o&&A.setAttribute("href",r),n?.querySelector(r))return[];if(s)return n?.appendChild(s.cloneNode(!0)),[];if(o)return[nA(e,{url:o,responseType:"text"}).then(A=>{n?.insertAdjacentHTML("beforeend",A)})]}return[]}(A,e))),y(A)&&t.push(...function(A,e){return aA.map(t=>{const n=A.getPropertyValue(t);return n&&"none"!==n?((f||m)&&e.drawImageCount++,rA(n,null,e,!0).then(e=>{e&&n!==e&&A.setProperty(t,e,A.getPropertyPriority(t))})):null}).filter(Boolean)}(A.style,e)),A.childNodes.forEach(A=>{cA(A,e)})}async function lA(A,e){const{ownerDocument:t,svgStyleElement:n,fontFamilies:r,fontCssTexts:o,tasks:i,font:s}=e;if(t&&n&&r.size)if(s&&s.cssText){const A=BA(s.cssText,e);n.appendChild(t.createTextNode(`${A}\n`))}else{const A=Array.from(t.styleSheets).filter(A=>{try{return"cssRules"in A&&Boolean(A.cssRules.length)}catch(t){return e.log.warn(`Error while reading CSS rules from ${A.href}`,t),!1}});await Promise.all(A.flatMap(A=>Array.from(A.cssRules).map(async(t,n)=>{if("CSSImportRule"===t.constructor.name){let r=n+1;const o=t.href;let i="";try{i=await nA(e,{url:o,requestType:"text",responseType:"text"})}catch(A){e.log.warn(`Error fetch remote css import from ${o}`,A)}const s=i.replace(iA,(A,e,t)=>A.replace(t,I(t,o)));for(const t of function(A){if(null==A)return[];const e=[];let t=A.replace(uA,"");for(;;){const A=hA.exec(t);if(!A)break;e.push(A[0])}t=t.replace(hA,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,r=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let A=n.exec(t);if(A)r.lastIndex=n.lastIndex;else{if(A=r.exec(t),!A)break;n.lastIndex=r.lastIndex}e.push(A[0])}return e}(s))try{A.insertRule(t,t.startsWith("@import")?r+=1:A.cssRules.length)}catch(A){e.log.warn("Error inserting rule from remote css import",{rule:t,error:A})}}})));A.flatMap(A=>Array.from(A.cssRules)).filter(A=>"CSSFontFaceRule"===A.constructor.name&&oA(A.style.getPropertyValue("src"))&&T(A.style.getPropertyValue("font-family"))?.some(A=>r.has(A))).forEach(A=>{const r=A,s=o.get(r.cssText);s?n.appendChild(t.createTextNode(`${s}\n`)):i.push(rA(r.cssText,r.parentStyleSheet?r.parentStyleSheet.href:null,e).then(A=>{A=BA(A,e),o.set(r.cssText,A),n.appendChild(t.createTextNode(`${A}\n`))}))})}}const uA=/(\/\*[\s\S]*?\*\/)/g,hA=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;const gA=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,dA=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function BA(A,e){const{font:t}=e,n=t?t?.preferredFormat:void 0;return n?A.replace(dA,A=>{for(;;){const[e,,t]=gA.exec(A)||[];if(!t)return"";if(t===n)return`src: ${e};`}}):A}async function wA(A,e){const t=await P(A,e);if(p(t.node)&&C(t.node))return t.node;const{ownerDocument:n,log:r,tasks:o,svgStyleElement:i,svgDefsElement:s,svgStyles:a,font:c,progress:l,autoDestruct:u,onCloneNode:h,onEmbedNode:g,onCreateForeignObjectSvg:d}=t;r.time("clone node");const B=await eA(t.node,t,!0);if(i&&n){let A="";a.forEach((e,t)=>{A+=`${e.join(",\n")} {\n ${t}\n}\n`}),i.appendChild(n.createTextNode(A))}r.timeEnd("clone node"),await(h?.(B)),!1!==c&&p(B)&&(r.time("embed web font"),await lA(0,t),r.timeEnd("embed web font")),r.time("embed node"),cA(B,t);const w=o.length;let f=0;l?.(f,w),await Promise.all([...Array.from({length:4})].map(async()=>{for(;;){const A=o.pop();if(!A)break;try{await A}catch(A){t.log.warn("Failed to run task",A)}l?.(++f,w)}})),r.timeEnd("embed node"),await(g?.(B));const m=function(A,e){const{width:t,height:n}=e,r=function(A,e,t){const n=x(t).createElementNS(S,"svg");return n.setAttributeNS(null,"width",A.toString()),n.setAttributeNS(null,"height",e.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${A} ${e}`),n}(t,n,A.ownerDocument),o=r.ownerDocument.createElementNS(r.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(A),r.appendChild(o),r}(B,t);return s&&m.insertBefore(s,m.children[0]),i&&m.insertBefore(i,m.children[0]),u&&tA(t),await(d?.(m)),m}async function fA(A,e){const t=await P(A,e),n=await wA(t),r=function(A,e){let t=(new XMLSerializer).serializeToString(A);return e&&(t=t.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}(n,t.isEnable("removeControlCharacter"));t.autoDestruct||(t.svgStyleElement=N(t.ownerDocument),t.svgDefsElement=t.ownerDocument?.createElementNS(S,"defs"),t.svgStyles.clear());const o=D(r,n.ownerDocument);return await V(o,t)}async function mA(A,e){const t=await P(A,e),{log:n,quality:r,type:o,dpi:i}=t,s=await fA(t);n.time("canvas to data url");let a=s.toDataURL(o,r);if(["image/png","image/jpeg"].includes(o)&&i&&g&&d){const[A,e]=a.split(",");let t=0,n=!1;if("image/png"===o){const A=function(A){let e=A.indexOf("AAlwSFlz");return-1===e&&(e=A.indexOf("AAAJcEhZ")),-1===e&&(e=A.indexOf("AAAACXBI")),e}(e);A>=0?(t=4*Math.ceil((A+28)/3),n=!0):t=44}else"image/jpeg"===o&&(t=24);const r=e.substring(0,t),s=e.substring(t),l=window.atob(r),u=new Uint8Array(l.length);for(let A=0;A<u.length;A++)u[A]=l.charCodeAt(A);const h="image/png"===o?c(u,i,n):function(A,e){return A[13]=1,A[14]=e>>8,A[15]=255&e,A[16]=e>>8,A[17]=255&e,A}(u,i);a=[A,",",window.btoa(String.fromCharCode(...h)),s].join("")}return n.timeEnd("canvas to data url"),a}async function pA(A,e){return mA(await P(A,{...e,type:"image/jpeg"}))}async function CA(A,e){return mA(await P(A,{...e,type:"image/png"}))}async function QA(A,e){return mA(await P(A,{...e,type:"image/webp"}))}var yA={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function UA(A){const e=A.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;const t=e[2].trim();return t.startsWith("#")?null:t}function FA(A){if(/%[0-9A-Fa-f]{2}/.test(A))return A;try{return encodeURI(A)}catch{return A}}var bA=function(A="[snapDOM]",{ttlMs:e=3e5,maxEntries:t=12}={}){const n=new Map;let r=0;function o(o,i,s){if(r>=t)return;const a=Date.now();(n.get(i)||0)>a||(n.set(i,a+e),r++,"warn"===o&&console&&console.warn?console.warn(`${A} ${s}`):console&&console.error&&console.error(`${A} ${s}`))}return{warnOnce(A,e){o("warn",A,e)},errorOnce(A,e){o("error",A,e)},reset(){n.clear(),r=0}}}("[snapDOM]",{ttlMs:18e4,maxEntries:10}),EA=new Map,vA=new Map;function HA(A,e){if(!e)return!1;if(function(A){return/^data:|^blob:|^about:blank$/i.test(A)}(A))return!1;if(function(A,e){try{const t="undefined"!=typeof location&&location.href?location.href:"http://localhost/",n=e.includes("{url}")?e.split("{url}")[0]:e,r=new URL(n||".",t),o=new URL(A,t);if(o.origin===r.origin)return!0;const i=o.searchParams;if(i&&(i.has("url")||i.has("target")))return!0}catch{}return!1}(A,e))return!1;try{const e="undefined"!=typeof location&&location.href?location.href:"http://localhost/",t=new URL(A,e);return"undefined"==typeof location||t.origin!==location.origin}catch{return!!e}}function IA(A){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(String(n.result||"")),n.onerror=()=>t(new Error("read_failed")),n.readAsDataURL(A)})}async function xA(A,e={}){const t=e.as??"blob",n=e.timeout??3e3,r=e.useProxy||"",o=e.errorTTL??8e3,i=e.headers||{},s=!!e.silent;if(/^data:/i.test(A))try{if("text"===t)return{ok:!0,data:String(A),status:200,url:A,fromCache:!1};if("dataURL"===t)return{ok:!0,data:String(A),status:200,url:A,fromCache:!1,mime:String(A).slice(5).split(";")[0]||""};const[,e="",n=""]=String(A).match(/^data:([^,]*),(.*)$/)||[],r=/;base64/i.test(e)?atob(n):decodeURIComponent(n),o=new Uint8Array([...r].map(A=>A.charCodeAt(0))),i=new Blob([o],{type:(e||"").split(";")[0]||""});return{ok:!0,data:i,status:200,url:A,fromCache:!1,mime:i.type||""}}catch{return{ok:!1,data:null,status:0,url:A,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(A))try{const e=await fetch(A);if(!e.ok)return{ok:!1,data:null,status:e.status,url:A,fromCache:!1,reason:"http_error"};const n=await e.blob(),r=n.type||e.headers.get("content-type")||"";if("dataURL"===t){return{ok:!0,data:await IA(n),status:e.status,url:A,fromCache:!1,mime:r}}if("text"===t){return{ok:!0,data:await n.text(),status:e.status,url:A,fromCache:!1,mime:r}}return{ok:!0,data:n,status:e.status,url:A,fromCache:!1,mime:r}}catch{return{ok:!1,data:null,status:0,url:A,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(A))return"dataURL"===t?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:A,fromCache:!1,mime:"image/png"}:{ok:!0,data:"text"===t?"":new Blob([]),status:200,url:A,fromCache:!1};const a=function(A,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,A].join("|")}(A,{as:t,timeout:n,useProxy:r,errorTTL:o}),c=vA.get(a);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&vA.delete(a);const l=EA.get(a);if(l)return l;const u=HA(A,r)?function(A,e){if(!e)return A;if(e.includes("{url}"))return e.replace("{urlRaw}",FA(A)).replace("{url}",encodeURIComponent(A));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(A)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(A)}`;if(e.endsWith("/"))return`${e}${FA(A)}`;const t=e.includes("?")?"&":"?";return`${e}${t}url=${encodeURIComponent(A)}`}(A,r):A;let h=e.credentials;if(!h)try{const e="undefined"!=typeof location&&location.href?location.href:"http://localhost/",t=new URL(A,e),n="undefined"!=typeof location&&t.origin===location.origin;h=n?"include":"omit"}catch{h="omit"}const g=new AbortController,d=setTimeout(()=>g.abort("timeout"),n),B=(async()=>{try{const n=await fetch(u,{signal:g.signal,credentials:h,headers:i});if(!n.ok){const r={ok:!1,data:null,status:n.status,url:u,fromCache:!1,reason:"http_error"};if(o>0&&vA.set(a,{until:Date.now()+o,result:r}),!s){const e=`${n.status} ${n.statusText||""}`.trim();bA.warnOnce(`http:${n.status}:${t}:${new URL(A,location?.href??"http://localhost/").origin}`,`HTTP error ${e} while fetching ${t} ${A}`)}return e.onError&&e.onError(r),r}if("text"===t){return{ok:!0,data:await n.text(),status:n.status,url:u,fromCache:!1}}const r=await n.blob(),c=r.type||n.headers.get("content-type")||"";if("dataURL"===t){return{ok:!0,data:await IA(r),status:n.status,url:u,fromCache:!1,mime:c}}return{ok:!0,data:r,status:n.status,url:u,fromCache:!1,mime:c}}catch(r){const i=r&&"object"==typeof r&&"name"in r&&"AbortError"===r.name?String(r.message||"").includes("timeout")?"timeout":"abort":"network",c={ok:!1,data:null,status:0,url:u,fromCache:!1,reason:i};if(!/^blob:/i.test(A)&&o>0&&vA.set(a,{until:Date.now()+o,result:c}),!s){const e=`${i}:${t}:${new URL(A,location?.href??"http://localhost/").origin}`,r="timeout"===i?`Timeout after ${n}ms. Consider increasing timeout or using a proxy for ${A}`:"abort"===i?`Request aborted while fetching ${t} ${A}`:`Network/CORS issue while fetching ${t} ${A}. A proxy may be required`;bA.errorOnce(e,r)}return e.onError&&e.onError(c),c}finally{clearTimeout(d),EA.delete(a)}})();return EA.set(a,B),B}function SA(A,e){if(!e||!A.width||!A.height)return A;const t=document.createElement("canvas");t.width=A.width,t.height=A.height;const n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,t.width,t.height),n.drawImage(A,0,0),t}async function LA(A,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(A)||"none"===A.trim())return A;const t=UA(A);if(!t)return A;const n=FA(t);if(yA.background.has(n)){const A=yA.background.get(n);return A?`url("${A}")`:"none"}try{const A=await xA(n,{as:"dataURL",useProxy:e.useProxy});return A.ok?(yA.background.set(n,A.data),`url("${A.data}")`):(yA.background.set(n,null),"none")}catch{return yA.background.set(n,null),"none"}}var DA=new Set(["meta","script","noscript","title","link","template"]),MA=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]);var KA=/(?:^|-)(animation|transition)(?:-|$)/i,TA=/^(--|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,kA=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope"]);function RA(A){const e=String(A).toLowerCase();return!!kA.has(e)||(!!TA.test(e)||!!KA.test(e))}function PA(A,e){if(e=String(e||"").toLowerCase(),MA.has(e))return"";const t=[],n=function(A){if(A=String(A).toLowerCase(),MA.has(A)){const e={};return yA.defaultStyle.set(A,e),e}if(yA.defaultStyle.has(A))return yA.defaultStyle.get(A);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));const t=document.createElement(A);t.style.all="initial",e.appendChild(t);const n=getComputedStyle(t),r={};for(let A of n){if(RA(A))continue;const e=n.getPropertyValue(A);r[A]=e}return e.removeChild(t),yA.defaultStyle.set(A,r),r}(e);for(let[e,r]of Object.entries(A)){if(RA(e))continue;const A=n[e];r&&r!==A&&t.push(`${e}:${r}`)}return t.sort(),t.join(";")}function OA(A,e=null){if(!(A instanceof Element))return window.getComputedStyle(A,e);let t=yA.computedStyle.get(A);if(t||(t=new Map,yA.computedStyle.set(A,t)),!t.has(e)){const n=window.getComputedStyle(A,e);t.set(e,n)}return t.get(e)}function NA(A){const e={};for(let t of A)e[t]=A.getPropertyValue(t);return e}function VA(A){const e=[];let t=0,n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&t++,")"===o&&t--,","===o&&0===t&&(e.push(A.slice(n,r).trim()),n=r+1)}return e.push(A.slice(n).trim()),e}function GA(A,{fast:e=!1}={}){if(e)return A();"requestIdleCallback"in window?requestIdleCallback(A,{timeout:50}):setTimeout(A,1)}function WA(){const A="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent:"",e=/^((?!chrome|android).)*safari/i.test(A),t=/AppleWebKit/i.test(A)&&/Mobile/i.test(A)&&!/Safari/i.test(A),n=/(MicroMessenger|wxwork|WeCom|WindowsWechat|MacWechat)/i.test(A);return e||t||n}var XA=new WeakMap,JA=new Map,YA=0;function $A(){YA++}var ZA=!1;var jA=new WeakMap;function _A(A,e=null,t={}){const n=XA.get(A);if(n&&n.epoch===YA)return n.snapshot;const r=e||getComputedStyle(A),o=function(A,e={}){const t={},n=A.getPropertyValue("visibility");for(let e=0;e<A.length;e++){const n=A[e];let r=A.getPropertyValue(n);"background-image"!==n&&"content"!==n||!r.includes("url(")||r.includes("data:")||(r="none"),t[n]=r}if(e.embedFonts){const e=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(const n of e)if(!t[n])try{const e=A.getPropertyValue(n);e&&(t[n]=e)}catch{}}return"hidden"===n&&(t.opacity="0"),t}(r,t);return function(A,e,t){if(A instanceof HTMLElement&&A.style&&A.style.height)return;const n=e.display||"";if(n.includes("flex")||n.includes("grid"))return;if(function(A){return A instanceof HTMLImageElement||A instanceof HTMLCanvasElement||A instanceof HTMLVideoElement||A instanceof HTMLIFrameElement||A instanceof SVGElement||A instanceof HTMLObjectElement||A instanceof HTMLEmbedElement}(A))return;const r=e.position;if("absolute"===r||"fixed"===r||"sticky"===r)return;if("none"!==e.transform)return;if(function(A){if(A.backgroundImage&&"none"!==A.backgroundImage)return!0;if(A.backgroundColor&&"rgba(0, 0, 0, 0)"!==A.backgroundColor&&"transparent"!==A.backgroundColor)return!0;if((parseFloat(A.borderTopWidth)||0)>0)return!0;if((parseFloat(A.borderBottomWidth)||0)>0)return!0;if((parseFloat(A.paddingTop)||0)>0)return!0;if((parseFloat(A.paddingBottom)||0)>0)return!0;const e=A.overflowBlock||A.overflowY||"visible";return"visible"!==e}(e))return;if(function(A){const e=A.parentElement;if(!e)return!1;const t=getComputedStyle(e).display||"";return t.includes("flex")||t.includes("grid")}(A))return;if(!function(A,e){if(A.textContent&&/\S/.test(A.textContent))return!0;const t=A.firstElementChild,n=A.lastElementChild;if(t&&"BR"===t.tagName||n&&"BR"===n.tagName)return!0;const r=A.scrollHeight;if(0===r)return!1;const o=parseFloat(e.paddingTop)||0,i=parseFloat(e.paddingBottom)||0;return r>o+i}(A,e))return;delete t.height,delete t["block-size"]}(A,r,o),XA.set(A,{epoch:YA,snapshot:o}),o}async function zA(A,e,t,n){if("STYLE"===A.tagName)return;const r=function(A,e){return A&&A.session&&A.persist?A:A&&(A.styleMap||A.styleCache||A.nodeMap)?{session:A,persist:{snapshotKeyCache:JA,defaultStyle:yA.defaultStyle,baseStyle:yA.baseStyle,image:yA.image,resource:yA.resource,background:yA.background,font:yA.font},options:e||{}}:{session:yA.session,persist:{snapshotKeyCache:JA,defaultStyle:yA.defaultStyle,baseStyle:yA.baseStyle,image:yA.image,resource:yA.resource,background:yA.background,font:yA.font},options:A||e||{}}}(t,n),o=r.options&&r.options.cache||"auto";if("disabled"!==o&&function(A=document.documentElement){if(!ZA){ZA=!0;try{new MutationObserver(()=>$A()).observe(A,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>$A()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{const A=document.fonts;A&&(A.addEventListener?.("loadingdone",$A),A.ready?.then(()=>$A()).catch(()=>{}))}catch{}}}(document.documentElement),"disabled"!==o||r.session.__bumpedForDisabled||($A(),JA.clear(),r.session.__bumpedForDisabled=!0),MA.has(A.tagName?.toLowerCase())){const t=A.getAttribute?.("style");t&&e.setAttribute("style",t)}const{session:i,persist:s}=r;i.styleCache.has(A)||i.styleCache.set(A,getComputedStyle(A));const a=_A(A,i.styleCache.get(A),r.options),c=function(A){let e=jA.get(A);return e||(e=Object.entries(A).sort((A,e)=>A[0]<e[0]?-1:A[0]>e[0]?1:0).map(([A,e])=>`${A}:${e}`).join(";"),jA.set(A,e),e)}(a);let l=s.snapshotKeyCache.get(c);if(!l){l=PA(a,A.tagName?.toLowerCase()||"div"),s.snapshotKeyCache.set(c,l)}i.styleMap.set(e,l)}function qA(A,e,t){return Promise.all(A.map(A=>new Promise(n=>{!function r(){GA(t=>{!t||"function"!=typeof t.timeRemaining||t.timeRemaining()>0?e(A,n):r()},{fast:t})}()})))}function Ae(A,e){return A?A=(A=(A=(A=(A=A.replace(/:host\(([^)]+)\)/g,(A,t)=>`:where(${e}:is(${t.trim()}))`)).replace(/:host\b/g,`:where(${e})`)).replace(/:host-context\(([^)]+)\)/g,(A,t)=>`:where(:where(${t.trim()}) ${e})`)).replace(/::slotted\(([^)]+)\)/g,(A,t)=>`:where(${e} ${t.trim()})`)).replace(/(^|})(\s*)([^@}{]+){/g,(A,t,n,r)=>{const o=function(A,e,t=!0){return A.split(",").map(A=>A.trim()).filter(Boolean).map(A=>{if(A.startsWith(":where("))return A;if(A.startsWith("@"))return A;const n=t?(r=(r=A).trim())?/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(r)?r:`${r}:not([data-sd-slotted])`:r:A;var r;return`:where(${e} ${n})`}).join(", ")}(r,e,!0);return`${t}${n}${o}{`}):""}function ee(A,e){try{let t=getComputedStyle(A).getPropertyValue(e).trim();if(t)return t}catch{}try{let A=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(A)return A}catch{}return""}async function te(A,e,t){const n=await async function(A,e=3){const t=()=>{try{return A.contentDocument||A.contentWindow?.document||null}catch{return null}};let n=t(),r=0;for(;r<e&&(!n||!n.body&&!n.documentElement);)await new Promise(A=>setTimeout(A,0)),n=t(),r++;return n&&(n.body||n.documentElement)?n:null}(A,3);if(!n)throw new Error("iframe document not accessible/ready");const{contentWidth:r,contentHeight:o,rect:i}=function(A){const e=A.getBoundingClientRect();let t=0,n=0,r=0,o=0;try{const e=getComputedStyle(A);t=parseFloat(e.borderLeftWidth)||0,n=parseFloat(e.borderRightWidth)||0,r=parseFloat(e.borderTopWidth)||0,o=parseFloat(e.borderBottomWidth)||0}catch{}return{contentWidth:Math.max(0,Math.round(e.width-(t+n))),contentHeight:Math.max(0,Math.round(e.height-(r+o))),rect:e}}(A),s=t?.snap;if(!s||"function"!=typeof s.toPng)throw new Error("snapdom.toPng not available in iframe or window");const a={...t,scale:1},c=function(A,e,t){const n=A.createElement("style");return n.setAttribute("data-sd-iframe-pin",""),n.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${t}px !important;min-width: ${e}px !important;min-height: ${t}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(A.head||A.documentElement).appendChild(n),()=>{try{n.remove()}catch{}}}(n,r,o);let l;try{l=await s.toPng(n.documentElement,a)}finally{c()}l.style.display="block",l.style.width=`${r}px`,l.style.height=`${o}px`;const u=document.createElement("div");return e.nodeMap.set(u,A),zA(A,u,e,t),u.style.overflow="hidden",u.style.display="block",u.style.width||(u.style.width=`${Math.round(i.width)}px`),u.style.height||(u.style.height=`${Math.round(i.height)}px`),u.appendChild(l),u}async function ne(A,e,t){if(!A)throw new Error("Invalid node");const n=new Set;let r,o=null,i=null;if(A.nodeType===Node.ELEMENT_NODE){const e=(A.localName||A.tagName||"").toLowerCase();if("snapdom-sandbox"===A.id||A.hasAttribute("data-snapdom-sandbox"))return null;if(DA.has(e))return null}if(A.nodeType===Node.TEXT_NODE)return A.cloneNode(!0);if(A.nodeType!==Node.ELEMENT_NODE)return A.cloneNode(!0);if("exclude"===A.getAttribute("data-capture")){if("hide"===t.excludeMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.excludeMode)return null}if(t.exclude&&Array.isArray(t.exclude))for(const e of t.exclude)try{if(A.matches?.(e)){if("hide"===t.excludeMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.excludeMode)return null}}catch(A){console.warn(`Invalid selector in exclude option: ${e}`,A)}if("function"==typeof t.filter)try{if(!t.filter(A)){if("hide"===t.filterMode){const e=document.createElement("div"),t=A.getBoundingClientRect();return e.style.cssText=`display:inline-block;width:${t.width}px;height:${t.height}px;visibility:hidden;`,e}if("remove"===t.filterMode)return null}}catch(A){console.warn("Error in filter function:",A)}if("IFRAME"===A.tagName){let n=!1;try{n=!(!A.contentDocument&&!A.contentWindow?.document)}catch{n=!1}if(n)try{return await te(A,e,t)}catch(A){console.warn("[SnapDOM] iframe rasterization failed, fallback:",A)}if(t.placeholders){const n=document.createElement("div");return n.style.cssText=`width:${A.offsetWidth}px;height:${A.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,zA(A,n,e,t),n}{const n=A.getBoundingClientRect(),r=document.createElement("div");return r.style.cssText=`display:inline-block;width:${n.width}px;height:${n.height}px;visibility:hidden;`,zA(A,r,e,t),r}}if("placeholder"===A.getAttribute("data-capture")){const n=A.cloneNode(!1);e.nodeMap.set(n,A),zA(A,n,e,t);const r=document.createElement("div");return r.textContent=A.getAttribute("data-placeholder-text")||"",r.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",n.appendChild(r),n}if("CANVAS"===A.tagName){const n=A.toDataURL(),r=document.createElement("img");return r.src=n,r.width=A.width,r.height=A.height,e.nodeMap.set(r,A),zA(A,r,e,t),r}try{if(r=A.cloneNode(!1),function(A,e){if(!(A instanceof Element&&e instanceof Element))return;const t=A.getAttribute?.("style");let n,r=!(!t||!t.includes("var("));if(!r&&A.attributes?.length){const e=A.attributes;for(let A=0;A<e.length;A++){const t=e[A];if(t&&"string"==typeof t.value&&t.value.includes("var(")){r=!0;break}}}if(!r)return;try{n=getComputedStyle(A)}catch{return}const o=A.style;if(o&&o.length)for(let A=0;A<o.length;A++){const t=o[A],r=o.getPropertyValue(t);if(!r||!r.includes("var("))continue;const i=n.getPropertyValue(t);if(i)try{e.style.setProperty(t,i.trim(),o.getPropertyPriority(t))}catch{}}if(A.attributes?.length){const t=A.attributes;for(let A=0;A<t.length;A++){const r=t[A];if(!r||"string"!=typeof r.value||!r.value.includes("var("))continue;const o=r.name;let i="";try{i=n.getPropertyValue(o)}catch{}if(i)try{e.style.setProperty(o,i.trim())}catch{}}}}(A,r),e.nodeMap.set(r,A),"IMG"===A.tagName){!function(A,e){try{const t=A.currentSrc||A.src||"";if(!t)return;e.setAttribute("src",t),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}(A,r);try{const e=A.getBoundingClientRect();let t=Math.round(e.width||0),n=Math.round(e.height||0);if(!t||!n){const e=window.getComputedStyle(A),r=parseFloat(e.width)||0,o=parseFloat(e.height)||0,i=parseInt(A.getAttribute("width")||"",10)||0,s=parseInt(A.getAttribute("height")||"",10)||0,a=A.width||A.naturalWidth||0,c=A.height||A.naturalHeight||0;t=Math.round(t||r||i||a||0),n=Math.round(n||o||s||c||0)}t&&(r.dataset.snapdomWidth=String(t)),n&&(r.dataset.snapdomHeight=String(n))}catch{}}}catch(e){throw console.error("[Snapdom] Failed to clone node:",A,e),e}if(A instanceof HTMLTextAreaElement){const e=A.getBoundingClientRect();r.style.width=`${e.width}px`,r.style.height=`${e.height}px`}if(A instanceof HTMLInputElement&&(r.value=A.value,r.setAttribute("value",A.value),void 0!==A.checked&&(r.checked=A.checked,A.checked&&r.setAttribute("checked",""),A.indeterminate&&(r.indeterminate=A.indeterminate))),A instanceof HTMLSelectElement&&(o=A.value),A instanceof HTMLTextAreaElement&&(i=A.value),zA(A,r,e,t),A.shadowRoot){let o=function(A,n){if(A.nodeType===Node.ELEMENT_NODE&&"STYLE"===A.tagName)return n(null);ne(A,e,t).then(A=>{n(A||null)}).catch(()=>{n(null)})};try{const e=A.shadowRoot.querySelectorAll("slot");for(const A of e){let e=[];try{e=A.assignedNodes?.({flatten:!0})||A.assignedNodes?.()||[]}catch{e=A.assignedNodes?.()||[]}for(const A of e)n.add(A)}}catch{}const i=function(A){return A.shadowScopeSeq=(A.shadowScopeSeq||0)+1,`s${A.shadowScopeSeq}`}(e),s=`[data-sd="${i}"]`;try{r.setAttribute("data-sd",i)}catch{}const a=function(A){let e="";try{A.querySelectorAll("style").forEach(A=>{e+=(A.textContent||"")+"\n"});const t=A.adoptedStyleSheets||[];for(const A of t)try{if(A&&A.cssRules)for(const t of A.cssRules)e+=t.cssText+"\n"}catch{}}catch{}return e}(A.shadowRoot),c=Ae(a,s),l=function(A,e,t){const n=[];for(const t of e){const e=ee(A,t);e&&n.push(`${t}: ${e};`)}return n.length?`${t}{${n.join("")}}\n`:""}(A,function(A){const e=new Set;if(!A)return e;const t=/var\(\s*(--[A-Za-z0-9_-]+)\b/g;let n;for(;n=t.exec(A);)e.add(n[1]);return e}(a),s);!function(A,e,t){if(!e)return;const n=document.createElement("style");n.setAttribute("data-sd",t),n.textContent=e,A.insertBefore(n,A.firstChild||null)}(r,l+c,i);const u=document.createDocumentFragment(),h=await qA(Array.from(A.shadowRoot.childNodes),o,t.fast);u.append(...h.filter(A=>!!A)),r.appendChild(u)}if("SLOT"===A.tagName){let n=function(A,n){ne(A,e,t).then(A=>{var e;A&&(e=A)&&(e.nodeType===Node.ELEMENT_NODE&&e.setAttribute("data-sd-slotted",""),e.querySelectorAll&&e.querySelectorAll("*").forEach(A=>A.setAttribute("data-sd-slotted",""))),n(A||null)}).catch(()=>{n(null)})};const r=A.assignedNodes?.({flatten:!0})||[],o=r.length>0?r:Array.from(A.childNodes),i=document.createDocumentFragment(),s=await qA(Array.from(o),n,t.fast);return i.append(...s.filter(A=>!!A)),i}const s=await qA(Array.from(A.childNodes),function(A,r){if(n.has(A))return r(null);ne(A,e,t).then(A=>{r(A||null)}).catch(()=>{r(null)})},t.fast);if(r.append(...s.filter(A=>!!A)),null!==o&&r instanceof HTMLSelectElement){r.value=o;for(const A of r.options)A.value===o?A.setAttribute("selected",""):A.removeAttribute("selected")}return null!==i&&r instanceof HTMLTextAreaElement&&(r.textContent=i),r}var re=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],oe=[];function ie(A){const e="string"==typeof A?A:"",t=[...re,...oe];for(const A of t)if(A instanceof RegExp&&A.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}async function se(A,e,t,n=32,r="#000"){e=e.replace(/^['"]+|['"]+$/g,"");const o=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}const i=document.createElement("span");i.textContent=A,i.style.position="absolute",i.style.visibility="hidden",i.style.fontFamily=`"${e}"`,i.style.fontWeight=t||"normal",i.style.fontSize=`${n}px`,i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.padding="0",i.style.margin="0",document.body.appendChild(i);const s=i.getBoundingClientRect(),a=Math.ceil(s.width),c=Math.ceil(s.height);document.body.removeChild(i);const l=document.createElement("canvas");l.width=Math.max(1,a*o),l.height=Math.max(1,c*o);const u=l.getContext("2d");return u.scale(o,o),u.font=t?`${t} ${n}px "${e}"`:`${n}px "${e}"`,u.textAlign="left",u.textBaseline="top",u.fillStyle=r,u.fillText(A,0,0),{dataUrl:l.toDataURL(),width:a,height:c}}var ae=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function ce(A){if(!A)return"";for(let e of A.split(",")){let A=e.trim().replace(/^['"]+|['"]+$/g,"");if(A&&!ae.has(A.toLowerCase()))return A}return""}function le(A){const e=String(A??"400").trim().toLowerCase();if("normal"===e)return 400;if("bold"===e)return 700;const t=parseInt(e,10);return Number.isFinite(t)?Math.min(900,Math.max(100,t)):400}function ue(A){const e=String(A??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function he(A,e){if(!A)return!1;try{const t=new URL(A,location.href);if(t.origin===location.origin)return!0;const n=t.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(A=>n.endsWith(A)))return!0;const r=(t.pathname+t.search).toLowerCase();if(/\bfont(s)?\b/.test(r)||/\.woff2?(\b|$)/.test(r))return!0;for(const A of e){const e=A.toLowerCase().replace(/\s+/g,"+"),t=A.toLowerCase().replace(/\s+/g,"-");if(r.includes(e)||r.includes(t))return!0}return!1}catch{return!1}}function ge(A,e){return A?A.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(A,t,n)=>{const r=(n||"").trim();if(!r||/^data:|^blob:|^https?:|^file:|^about:/i.test(r))return A;let o=r;try{o=new URL(r,e||location.href).href}catch{}return`url("${o}")`}):A}var de=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g;async function Be(A,e,t){if(!A)return A;const n=new Set;function r(A,e){try{return new URL(A,e||location.href).href}catch{return A}}let o=ge(A,e||location.href);return o=await async function A(e,o,i=0){if(i>4)return console.warn(`[snapDOM] @import depth exceeded (4) at ${o}`),e;let s,a="",c=0;for(;s=de.exec(e);){a+=e.slice(c,s.index),c=de.lastIndex;const l=r((s[2]||s[4]||"").trim(),o);if(n.has(l)){console.warn(`[snapDOM] Skipping circular @import: ${l}`);continue}n.add(l);let u="";try{const A=await xA(l,{as:"text",useProxy:t,silent:!0});A.ok&&"string"==typeof A.data&&(u=A.data)}catch{}u?(u=ge(u,l),u=await A(u,l,i+1),a+=`\n/* inlined: ${l} */\n${u}\n`):a+=s[0]}return a+=e.slice(c),a}(o,e||location.href,0),o}var we=/url\((["']?)([^"')]+)\1\)/g,fe=/@font-face[^{}]*\{[^}]*\}/g;function me(A){if(!A)return[];const e=[],t=A.split(",").map(A=>A.trim()).filter(Boolean);for(const A of t){const t=A.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!t)continue;const n=t[1],r=t[2],o=A=>{if(!A.includes("?"))return parseInt(A,16);return[parseInt(A.replace(/\?/g,"0"),16),parseInt(A.replace(/\?/g,"F"),16)]};if(r){const A=o(n),t=o(r),i=Array.isArray(A)?A[0]:A,s=Array.isArray(t)?t[1]:t;e.push([Math.min(i,s),Math.max(i,s)])}else{const A=o(n);Array.isArray(A)?e.push([A[0],A[1]]):e.push([A,A])}}return e}function pe(A,e){if(!e.length)return!0;if(!A||0===A.size)return!0;for(const t of A)for(const[A,n]of e)if(t>=A&&t<=n)return!0;return!1}function Ce(A,e){const t=[];if(!A)return t;for(const n of A.matchAll(we)){let A=(n[2]||"").trim();if(A&&!A.startsWith("data:")){if(!/^https?:/i.test(A))try{A=new URL(A,e||location.href).href}catch{}t.push(A)}}return t}async function Qe(A,e,t=""){let n=A;for(const r of A.matchAll(we)){const A=UA(r[0]);if(!A)continue;let o=A;if(!o.startsWith("http")&&!o.startsWith("data:"))try{o=new URL(o,e||location.href).href}catch{}if(!ie(o))if(yA.resource?.has(o))yA.font?.add(o),n=n.replace(r[0],`url(${yA.resource.get(o)})`);else if(!yA.font?.has(o))try{const A=await xA(o,{as:"dataURL",useProxy:t,silent:!0});if(A.ok&&"string"==typeof A.data){const e=A.data;yA.resource?.set(o,e),yA.font?.add(o),n=n.replace(r[0],`url(${e})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",o)}}return n}function ye(A={}){const e=new Set((A.families||[]).map(A=>String(A).toLowerCase())),t=new Set((A.domains||[]).map(A=>String(A).toLowerCase())),n=new Set((A.subsets||[]).map(A=>String(A).toLowerCase()));return(A,r)=>{if(e.size&&e.has(A.family.toLowerCase()))return!0;if(t.size)for(const e of A.srcUrls)try{if(t.has(new URL(e).host.toLowerCase()))return!0}catch{}if(n.size){const A=function(A){if(!A.length)return null;const e=(e,t)=>A.some(([A,n])=>!(n<e||A>t)),t=e(0,255)||e(305,305),n=e(256,591)||e(7680,7935),r=e(880,1023),o=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":o?"cyrillic":r?"greek":n?"latin-ext":t?"latin":null}(r);if(A&&n.has(A))return!0}return!1}}async function Ue(A,e,t,n){let r;try{r=A.cssRules||[]}catch{return}const o=(A,e)=>{try{return new URL(A,e||location.href).href}catch{return A}};for(const A of r){if(A.type===CSSRule.IMPORT_RULE&&A.styleSheet){const r=A.href?o(A.href,e):e;if(n.depth>=4){console.warn(`[snapDOM] CSSOM import depth exceeded (4) at ${r}`);continue}if(r&&n.visitedSheets.has(r)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${r}`);continue}r&&n.visitedSheets.add(r);const i={...n,depth:(n.depth||0)+1};await Ue(A.styleSheet,r,t,i);continue}if(A.type===CSSRule.FONT_FACE_RULE){const r=ce((A.style.getPropertyValue("font-family")||"").trim());if(!r||ie(r))continue;const o=(A.style.getPropertyValue("font-weight")||"400").trim(),i=(A.style.getPropertyValue("font-style")||"normal").trim(),s=(A.style.getPropertyValue("font-stretch")||"100%").trim(),a=(A.style.getPropertyValue("src")||"").trim(),c=(A.style.getPropertyValue("unicode-range")||"").trim();if(!n.faceMatchesRequired(r,i,o,s))continue;const l=me(c);if(!pe(n.usedCodepoints,l))continue;const u={family:r,weightSpec:o,styleSpec:i,stretchSpec:s,unicodeRange:c,srcRaw:a,srcUrls:Ce(a,e||location.href),href:e||location.href};if(n.simpleExcluder&&n.simpleExcluder(u,l))continue;if(/url\(/i.test(a)){const A=await Qe(a,e||location.href,n.useProxy);await t(`@font-face{font-family:${r};src:${A};font-style:${i};font-weight:${o};font-stretch:${s};${c?`unicode-range:${c};`:""}}`)}else await t(`@font-face{font-family:${r};src:${a};font-style:${i};font-weight:${o};font-stretch:${s};${c?`unicode-range:${c};`:""}}`)}}}async function Fe({required:A,usedCodepoints:e,exclude:t,localFonts:n=[],useProxy:r=""}={}){A instanceof Set||(A=new Set),e instanceof Set||(e=new Set);const o=new Map;for(const e of A){const[A,t,n,r]=String(e).split("__");if(!A)continue;const i=o.get(A)||[];i.push({w:parseInt(t,10),s:n,st:parseInt(r,10)}),o.set(A,i)}function i(A,e,t,n){if(!o.has(A))return!1;const r=o.get(A),i=function(A){const e=String(A||"400").trim(),t=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(t){const A=le(t[1]),e=le(t[2]);return{min:Math.min(A,e),max:Math.max(A,e)}}const n=le(e);return{min:n,max:n}}(t),s=function(A){const e=String(A||"normal").trim().toLowerCase();return"italic"===e?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}(e),a=function(A){const e=String(A||"100%").trim(),t=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(t){const A=parseFloat(t[1]),e=parseFloat(t[2]);return{min:Math.min(A,e),max:Math.max(A,e)}}const n=e.match(/(\d+(?:\.\d+)?)\s*%/),r=n?parseFloat(n[1]):100;return{min:r,max:r}}(n),c=i.min!==i.max,l=i.min,u=A=>"normal"===s.kind&&"normal"===A||"normal"!==s.kind&&("italic"===A||"oblique"===A);let h=!1;for(const A of r){const e=c?A.w>=i.min&&A.w<=i.max:A.w===l,t=u(ue(A.s)),n=A.st>=a.min&&A.st<=a.max;if(e&&t&&n){h=!0;break}}if(h)return!0;if(!c)for(const A of r){const e=u(ue(A.s)),t=A.st>=a.min&&A.st<=a.max;if(Math.abs(l-A.w)<=300&&e&&t)return!0}return!1}const s=ye(t),a=function(A,e,t,n){return`fonts-embed-css::req=${Array.from(A||[]).sort().join("|")}::ex=${e?JSON.stringify({families:(e.families||[]).map(A=>String(A).toLowerCase()).sort(),domains:(e.domains||[]).map(A=>String(A).toLowerCase()).sort(),subsets:(e.subsets||[]).map(A=>String(A).toLowerCase()).sort()}):""}::lf=${(t||[]).map(A=>`${(A.family||"").toLowerCase()}::${A.weight||"normal"}::${A.style||"normal"}::${A.src||""}`).sort().join("|")}::px=${n||""}`}(A,t,n,r);if(yA.resource?.has(a))return yA.resource.get(a);const c=function(A){const e=new Set;for(const t of A||[]){const A=String(t).split("__")[0]?.trim();A&&e.add(A)}return e}(A),l=[],u=de;for(const A of document.querySelectorAll("style")){const e=A.textContent||"";for(const A of e.matchAll(u)){const e=(A[2]||A[4]||"").trim();if(!e||ie(e))continue;!!document.querySelector(`link[rel="stylesheet"][href="${e}"]`)||l.push(e)}}l.length&&await Promise.all(l.map(A=>new Promise(e=>{if(document.querySelector(`link[rel="stylesheet"][href="${A}"]`))return e(null);const t=document.createElement("link");t.rel="stylesheet",t.href=A,t.setAttribute("data-snapdom","injected-import"),t.onload=()=>e(t),t.onerror=()=>e(null),document.head.appendChild(t)})));let h="";const g=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(A=>!!A.href);for(const A of g)try{if(ie(A.href))continue;let n="",o=!1;try{o=new URL(A.href,location.href).origin===location.origin}catch{}if(!o&&!he(A.href,c))continue;if(o){const e=Array.from(document.styleSheets).find(e=>e.href===A.href);if(e)try{const A=e.cssRules||[];n=Array.from(A).map(A=>A.cssText).join("")}catch{}}if(!n){if(n=(await xA(A.href,{as:"text",useProxy:r})).data,ie(A.href))continue}n=await Be(n,A.href,r);let a="";for(const o of n.match(fe)||[]){const n=ce((o.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim());if(!n||ie(n))continue;const c=(o.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),l=(o.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),u=(o.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),h=(o.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),g=(o.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),d=Ce(g,A.href);if(!i(n,l,c,u))continue;const B=me(h);if(!pe(e,B))continue;const w={family:n,weightSpec:c,styleSpec:l,stretchSpec:u,unicodeRange:h,srcRaw:g,srcUrls:d,href:A.href};if(t&&s(w,B))continue;a+=/url\(/i.test(g)?await Qe(o,A.href,r):o}a.trim()&&(h+=a)}catch{console.warn("[snapDOM] Failed to process stylesheet:",A.href)}const d={requiredIndex:o,usedCodepoints:e,faceMatchesRequired:i,simpleExcluder:t?ye(t):null,useProxy:r,visitedSheets:new Set,depth:0};for(const A of document.styleSheets)if(!A.href||!g.some(e=>e.href===A.href))try{const e=A.href||location.href;e&&d.visitedSheets.add(e),await Ue(A,e,async A=>{h+=A},d)}catch{}try{for(const A of document.fonts||[]){if(!A||!A.family||"loaded"!==A.status||!A._snapdomSrc)continue;const e=String(A.family).replace(/^['"]+|['"]+$/g,"");if(ie(e))continue;if(!o.has(e))continue;if(t?.families&&t.families.some(A=>String(A).toLowerCase()===e.toLowerCase()))continue;let n=A._snapdomSrc;if(!String(n).startsWith("data:"))if(yA.resource?.has(A._snapdomSrc))n=yA.resource.get(A._snapdomSrc),yA.font?.add(A._snapdomSrc);else if(!yA.font?.has(A._snapdomSrc))try{const e=await xA(A._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(!e.ok||"string"!=typeof e.data)continue;n=e.data,yA.resource?.set(A._snapdomSrc,n),yA.font?.add(A._snapdomSrc)}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",A._snapdomSrc);continue}h+=`@font-face{font-family:'${e}';src:url(${n});font-style:${A.style||"normal"};font-weight:${A.weight||"normal"};}`}}catch{}for(const A of n){if(!A||"object"!=typeof A)continue;const e=String(A.family||"").replace(/^['"]+|['"]+$/g,"");if(!e||ie(e))continue;if(!o.has(e))continue;if(t?.families&&t.families.some(A=>String(A).toLowerCase()===e.toLowerCase()))continue;const n=null!=A.weight?String(A.weight):"normal",i=null!=A.style?String(A.style):"normal",s=null!=A.stretchPct?`${A.stretchPct}%`:"100%",a=String(A.src||"");let c=a;if(!c.startsWith("data:"))if(yA.resource?.has(a))c=yA.resource.get(a),yA.font?.add(a);else if(!yA.font?.has(a))try{const A=await xA(a,{as:"dataURL",useProxy:r,silent:!0});if(!A.ok||"string"!=typeof A.data)continue;c=A.data,yA.resource?.set(a,c),yA.font?.add(a)}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",a);continue}h+=`@font-face{font-family:'${e}';src:url(${c});font-style:${i};font-weight:${n};font-stretch:${s};}`}return h&&(h=function(A){if(!A)return A;const e=/@font-face[^{}]*\{[^}]*\}/gi,t=new Set,n=[];for(const r of A.match(e)||[]){const A=ce(r.match(/font-family:\s*([^;]+);/i)?.[1]||""),e=(r.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),o=(r.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),i=(r.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),s=(r.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),a=(r.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),c=Ce(a,location.href),l=c.length?c.map(A=>String(A).toLowerCase()).sort().join("|"):a.toLowerCase(),u=[String(A||"").toLowerCase(),e,o,i,s.toLowerCase(),l].join("|");t.has(u)||(t.add(u),n.push(r))}if(0===n.length)return A;let r=0;return A.replace(e,()=>n[r++]||"")}(h),yA.resource?.set(a,h)),h}function be(A){const e=new Set;if(!A)return e;const t=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT,null),n=A=>{const t=ce(A.fontFamily);if(!t)return;var n,r,o;e.add((n=A.fontWeight,r=A.fontStyle,o=A.fontStretch,`${t}__${le(n)}__${ue(r)}__${function(A){const e=String(A??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}(o)}`))};n(getComputedStyle(A));const r=getComputedStyle(A,"::before");r&&r.content&&"none"!==r.content&&n(r);const o=getComputedStyle(A,"::after");for(o&&o.content&&"none"!==o.content&&n(o);t.nextNode();){const A=t.currentNode;n(getComputedStyle(A));const e=getComputedStyle(A,"::before");e&&e.content&&"none"!==e.content&&n(e);const r=getComputedStyle(A,"::after");r&&r.content&&"none"!==r.content&&n(r)}return e}function Ee(A,e=!1){let t="",n=Math.max(1,A);for(;n>0;)n--,t=String.fromCharCode(97+n%26)+t,n=Math.floor(n/26);return e?t.toUpperCase():t}function ve(A,e=!0){const t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n=Math.max(1,Math.min(3999,A)),r="";for(const[A,e]of t)for(;n>=A;)r+=e,n-=A;return e?r:r.toLowerCase()}function He(A,e){switch((e||"decimal").toLowerCase()){case"decimal":default:return String(Math.max(0,A));case"decimal-leading-zero":return(A<10?"0":"")+String(Math.max(0,A));case"lower-alpha":return Ee(A,!1);case"upper-alpha":return Ee(A,!0);case"lower-roman":return ve(A,!1);case"upper-roman":return ve(A,!0)}}function Ie(A){const e=new WeakMap,t=A instanceof Document?A.documentElement:A,n=A=>{let e=0,t=A?.parentElement;if(!t)return 0;for(const n of t.children){if(n===A)break;"LI"===n.tagName&&e++}return e},r=(A,e,t)=>{const r=(A=>{const e=new Map;for(const[t,n]of A)e.set(t,n.slice());return e})(A);let o,i;try{o=t.style?.counterReset||getComputedStyle(t).counterReset}catch{}if(o&&"none"!==o)for(const A of o.split(",")){const t=A.trim().split(/\s+/),n=t[0],o=Number.isFinite(Number(t[1]))?Number(t[1]):0;if(!n)continue;const i=e.get(n);if(i&&i.length){const A=i.slice();A.push(o),r.set(n,A)}else r.set(n,[o])}try{i=t.style?.counterIncrement||getComputedStyle(t).counterIncrement}catch{}if(i&&"none"!==i)for(const A of i.split(",")){const e=A.trim().split(/\s+/),t=e[0],n=Number.isFinite(Number(e[1]))?Number(e[1]):1;if(!t)continue;const o=r.get(t)||[];0===o.length&&o.push(0),o[o.length-1]+=n,r.set(t,o)}try{if("list-item"===getComputedStyle(t).display&&(A=>A&&"LI"===A.tagName)(t)){const A=t.parentElement;let e=1;if(A&&"OL"===A.tagName){const r=A.getAttribute("start"),o=Number.isFinite(Number(r))?Number(r):1,i=n(t),s=t.getAttribute("value");e=Number.isFinite(Number(s))?Number(s):o+i}else e=1+n(t);const o=r.get("list-item")||[];0===o.length&&o.push(0),o[o.length-1]=e,r.set("list-item",o)}}catch{}return r},o=(A,t,n)=>{const i=r(n,t,A);e.set(A,i);let s=i;for(const e of A.children){s=o(e,i,s)}return i},i=new Map;return o(t,i,i),{get(A,t){const n=e.get(A)?.get(t);return n&&n.length?n[n.length-1]:0},getStack(A,t){const n=e.get(A)?.get(t);return n?n.slice():[]}}}var xe=null,Se=new WeakMap;function Le(A,e){const t=A.parentElement,n=t?Se.get(t):null;return n?{get(A,t){const r=e.get(A,t),o=n.get(t);return"number"==typeof o?Math.max(r,o):r},getStack(A,t){const r=e.getStack(A,t);if(!r.length)return r;const o=n.get(t);if("number"==typeof o){const A=r.slice();return A[A.length-1]=Math.max(A[A.length-1],o),A}return r}}:e}function De(A,e,t){const n=new Map;function r(A){const e=[];if(!A||"none"===A)return e;for(const t of String(A).split(",")){const A=t.trim().split(/\s+/),n=A[0],r=Number.isFinite(Number(A[1]))?Number(A[1]):void 0;n&&e.push({name:n,num:r})}return e}const o=r(e?.counterReset),i=r(e?.counterIncrement);function s(e){if(n.has(e))return n.get(e).slice();let r=t.getStack(A,e);r=r.length?r.slice():[];const s=o.find(A=>A.name===e);if(s){const A=Number.isFinite(s.num)?s.num:0;r=r.length?[...r,A]:[A]}const a=i.find(A=>A.name===e);if(a){const A=Number.isFinite(a.num)?a.num:1;0===r.length&&(r=[0]),r[r.length-1]+=A}return n.set(e,r.slice()),r}return{get(A,e){const t=s(e);return t.length?t[t.length-1]:0},getStack:(A,e)=>s(e),__incs:i}}function Me(A,e,t){let n;try{n=getComputedStyle(A,e)}catch{}const r=n?.content;if(!r||"none"===r||"normal"===r)return{text:"",incs:[]};const o=De(A,n,Le(A,t));let i=/\bcounter\s*\(|\bcounters\s*\(/.test(r||"")?function(A,e,t){if(!A||"none"===A)return A;try{const n=/\b(counter|counters)\s*\(([^)]+)\)/g;return(A.replace(n,(A,n,r)=>{const o=String(r).split(",").map(A=>A.trim());if("counter"===n){const A=o[0]?.replace(/^["']|["']$/g,""),n=(o[1]||"decimal").toLowerCase();return He(t.get(e,A),n)}{const A=o[0]?.replace(/^["']|["']$/g,""),n=o[1]?.replace(/^["']|["']$/g,"")??"",r=(o[2]||"decimal").toLowerCase(),i=t.getStack(e,A);return i.length?i.map(A=>He(A,r)).join(n):""}})||"").replace(/"([^"]*)"/g,"$1")}catch{return"- "}}(r,A,o):r;const s=function(A){if(!A)return"";const e=[],t=/"([^"]*)"/g;let n;for(;n=t.exec(A);)e.push(n[1]);return e.length?e.join(""):(A||"").replace(/"([^"]*)"/g,"$1")}(i);return{text:s,incs:o.__incs||[]}}async function Ke(A,e,t,n){if(!(A instanceof Element&&e instanceof Element))return;if(!xe)try{xe=Ie(A.ownerDocument||document)}catch{}for(const r of["::before","::after","::first-letter"])try{const o=OA(A,r);if(!o||"function"!=typeof o[Symbol.iterator])continue;if(!("none"!==o.content||"none"!==o.backgroundImage||"transparent"!==o.backgroundColor||"none"!==o.borderStyle&&0!==parseFloat(o.borderWidth)||o.transform&&"none"!==o.transform||"inline"!==o.display))continue;if("::first-letter"===r){const n=getComputedStyle(A);if(!(o.color!==n.color||o.fontSize!==n.fontSize||o.fontWeight!==n.fontWeight))continue;const r=Array.from(e.childNodes).find(A=>A.nodeType===Node.TEXT_NODE&&A.textContent?.trim().length>0);if(!r)continue;const i=r.textContent,s=i.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u),a=s?.[0],c=i.slice(a?.length||0);if(!a||/[\uD800-\uDFFF]/.test(a))continue;const l=document.createElement("span");l.textContent=a,l.dataset.snapdomPseudo="::first-letter";const u=PA(NA(o),"span");t.styleMap.set(l,u);const h=document.createTextNode(c);e.replaceChild(h,r),e.insertBefore(l,h);continue}const i=o.content,{text:s,incs:a}=Me(A,r,xe),c=o.backgroundImage,l=o.backgroundColor,u=o.fontFamily,h=parseInt(o.fontSize)||32,g=parseInt(o.fontWeight)||!1,d=o.color||"#000",B=o.borderStyle,w=parseFloat(o.borderWidth),f=o.transform,m=ie(u),p="none"!==i&&""!==s,C=c&&"none"!==c,Q=l&&"transparent"!==l&&"rgba(0, 0, 0, 0)"!==l,y=B&&"none"!==B&&w>0,U=f&&"none"!==f;if(!(p||C||Q||y||U)){if(a&&a.length&&A.parentElement){const e=Se.get(A.parentElement)||new Map;for(const{name:t}of a){if(!t)continue;const n=Le(A,xe),o=De(A,getComputedStyle(A,r),n).get(A,t);e.set(t,o)}Se.set(A.parentElement,e)}continue}const F=document.createElement("span");F.dataset.snapdomPseudo=r,F.style.verticalAlign="middle",F.style.pointerEvents="none";const b=PA(NA(o),"span");if(t.styleMap.set(F,b),m&&s&&1===s.length){const{dataUrl:A,width:t,height:n}=await se(s,u,g,h,d),r=document.createElement("img");r.src=A,r.style=`height:${h}px;width:${t/n*h}px;object-fit:contain;`,F.appendChild(r),e.dataset.snapdomHasIcon="true"}else if(s&&s.startsWith("url(")){const e=UA(s);if(e?.trim())try{const A=document.createElement("img"),t=await xA(FA(e),{as:"dataURL",useProxy:n.useProxy});A.src=t.data,A.style=`width:${h}px;height:auto;object-fit:contain;`,F.appendChild(A)}catch(e){console.error(`[snapdom] Error in pseudo ${r} for`,A,e)}}else!m&&p&&(F.textContent=s);if(F.style.background="none","mask"in F.style&&(F.style.mask="none"),C)try{const A=VA(c),e=await Promise.all(A.map(LA));F.style.backgroundImage=e.join(", ")}catch(A){console.warn(`[snapdom] Failed to inline background-image for ${r}`,A)}Q&&(F.style.backgroundColor=l);const E=F.childNodes.length>0||""!==F.textContent?.trim()||C||Q||y||U;if(a&&a.length&&A.parentElement){const e=Se.get(A.parentElement)||new Map,t=Le(A,xe),n=De(A,getComputedStyle(A,r),t);for(const{name:t}of a){if(!t)continue;const r=n.get(A,t);e.set(t,r)}Se.set(A.parentElement,e)}if(!E)continue;"::before"===r?e.insertBefore(F,e.firstChild):e.appendChild(F)}catch(e){console.warn(`[snapdom] Failed to capture ${r} for`,A,e)}const r=Array.from(A.children),o=Array.from(e.children).filter(A=>!A.dataset.snapdomPseudo);for(let A=0;A<Math.min(r.length,o.length);A++)await Ke(r[A],o[A],t,n)}function Te(A){if(!A||"auto"===A)return null;const e=Number.parseFloat(A);return Number.isFinite(e)?e:null}function ke(A,e){const t=[];for(let n=A;n&&n!==e;){const A=n.parentElement;if(!A)break;t.push(Array.prototype.indexOf.call(A.children,n)),n=A}return t.reverse()}function Re(A,e,t){let n=A;for(let A=0;A<e.length;A++){if(n=Pe(n,t)[e[A]],!n)return null}return n instanceof HTMLElement?n:null}function Pe(A,e){const t=[],n=A.children;for(let A=0;A<n.length;A++){const r=n[A];r.hasAttribute(e)||t.push(r)}return t}async function Oe(A,e={}){const t={styleMap:yA.session.styleMap,styleCache:yA.session.styleCache,nodeMap:yA.session.nodeMap};let n,r="",o="";!function(A){const e=getComputedStyle(A),t=e.outlineStyle,n=e.outlineWidth,r=e.borderStyle,o=e.borderWidth,i="none"!==t&&parseFloat(n)>0,s="none"===r||0===parseFloat(o);i&&s&&(A.style.border=`${n} solid transparent`)}(A);try{!function(A){if(!A)return;const e=new Set;if(A.querySelectorAll("use").forEach(A=>{const t=A.getAttribute("xlink:href")||A.getAttribute("href");t&&t.startsWith("#")&&e.add(t.slice(1))}),!e.size)return;const t=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),n=t.filter(A=>"symbol"===A.tagName.toLowerCase()),r=t.filter(A=>"defs"===A.tagName.toLowerCase());let o=A.querySelector("svg.inline-defs-container");o||(o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("aria-hidden","true"),o.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),o.classList.add("inline-defs-container"),A.insertBefore(o,A.firstChild));const i=new Set;A.querySelectorAll("symbol[id], defs > *[id]").forEach(A=>{i.add(A.id)}),e.forEach(A=>{if(i.has(A))return;const e=n.find(e=>e.id===A);if(e)return o.appendChild(e.cloneNode(!0)),void i.add(A);for(const e of r){const t=e.querySelector(`#${CSS.escape(A)}`);if(t){let e=o.querySelector("defs");e||(e=document.createElementNS("http://www.w3.org/2000/svg","defs"),o.appendChild(e)),e.appendChild(t.cloneNode(!0)),i.add(A);break}}})}(A)}catch(A){console.warn("inlineExternal defs or symbol failed:",A)}try{n=await ne(A,t,e)}catch(A){throw console.warn("deepClone failed:",A),A}try{await Ke(A,n,t,e)}catch(A){console.warn("inlinePseudoElements failed:",A)}await async function(A){if(!A)return;const e=A.querySelectorAll?A.querySelectorAll("img"):[];for(const A of e)try{const e=A.getAttribute("src")||A.currentSrc||"";if(Xe(e)){const t=await Ve(e);A.setAttribute("src",t)}const t=A.getAttribute("srcset");if(t&&t.includes("blob:")){const e=Je(t);let n=!1;for(const A of e)if(Xe(A.url))try{A.url=await Ve(A.url),n=!0}catch{}n&&A.setAttribute("srcset",Ye(e))}}catch{}const t=A.querySelectorAll?A.querySelectorAll("image"):[];for(const A of t)try{const e="http://www.w3.org/1999/xlink",t=A.getAttribute("href")||A.getAttributeNS?.(e,"href");if(Xe(t)){const n=await Ve(t);A.setAttribute("href",n),A.removeAttributeNS?.(e,"href")}}catch{}const n=A.querySelectorAll?A.querySelectorAll("[style*='blob:']"):[];for(const A of n)try{const e=A.getAttribute("style");if(e&&e.includes("blob:")){const t=await We(e);A.setAttribute("style",t)}}catch{}const r=A.querySelectorAll?A.querySelectorAll("style"):[];for(const A of r)try{const e=A.textContent||"";e.includes("blob:")&&(A.textContent=await We(e))}catch{}const o=["poster"];for(const e of o){const t=A.querySelectorAll?A.querySelectorAll(`[${e}^='blob:']`):[];for(const A of t)try{const t=A.getAttribute(e);Xe(t)&&A.setAttribute(e,await Ve(t))}catch{}}}(n);try{const A=n.querySelectorAll("style[data-sd]");for(const e of A)o+=e.textContent||"",e.remove()}catch{}const i=function(A){const e=Array.from(new Set(A.values())).filter(Boolean).sort(),t=new Map;let n=1;for(const A of e)t.set(A,"c"+n++);return t}(t.styleMap);r=Array.from(i.entries()).map(([A,e])=>`.${e}{${A}}`).join(""),r=o+r;for(const[A,e]of t.styleMap.entries()){if("STYLE"===A.tagName)continue;if(A.getRootNode&&A.getRootNode()instanceof ShadowRoot){A.setAttribute("style",e.replace(/;/g,"; "));continue}const t=i.get(e);t&&A.classList.add(t);const n=A.style?.backgroundImage,r=A.dataset?.snapdomHasIcon;n&&"none"!==n&&(A.style.backgroundImage=n),r&&(A.style.verticalAlign="middle",A.style.display="inline")}for(const[A,e]of t.nodeMap.entries()){const t=e.scrollLeft,n=e.scrollTop;if((t||n)&&A instanceof HTMLElement){A.style.overflow="hidden",A.style.scrollbarWidth="none",A.style.msOverflowStyle="none";const e=document.createElement("div");for(e.style.transform=`translate(${-t}px, ${-n}px)`,e.style.willChange="transform",e.style.display="inline-block",e.style.width="100%";A.firstChild;)e.appendChild(A.firstChild);A.appendChild(e)}}if(function(A,e){if(!A||!e)return;const t=A.scrollTop||0;if(!t)return;"static"===getComputedStyle(e).position&&(e.style.position="relative");const n=A.getBoundingClientRect(),r=A.clientHeight,o="data-snap-ph",i=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT);for(;i.nextNode();){const s=i.currentNode,a=getComputedStyle(s),c=a.position;if("sticky"!==c&&"-webkit-sticky"!==c)continue;const l=Te(a.top),u=Te(a.bottom);if(null==l&&null==u)continue;const h=Re(e,ke(s,A),o);if(!h)continue;const g=s.getBoundingClientRect(),d=g.width,B=g.height,w=g.left-n.left;if(!(d>0&&B>0))continue;if(!Number.isFinite(w))continue;const f=null!=l?l+t:t+(r-B-u);if(!Number.isFinite(f))continue;const m=Number.parseInt(a.zIndex,10),p=Number.isFinite(m),C=p?Math.max(m,1)+1:2,Q=p?m-1:0,y=h.cloneNode(!1);y.setAttribute(o,"1"),y.style.position="sticky",y.style.left=`${w}px`,y.style.top=`${f}px`,y.style.width=`${d}px`,y.style.height=`${B}px`,y.style.visibility="hidden",y.style.zIndex=String(Q),y.style.overflow="hidden",y.style.background="transparent",y.style.boxShadow="none",y.style.filter="none",h.parentElement?.insertBefore(y,h),h.style.position="absolute",h.style.left=`${w}px`,h.style.top=`${f}px`,h.style.bottom="auto",h.style.zIndex=String(C),h.style.pointerEvents="none"}}(A,n instanceof HTMLElement&&n.firstElementChild instanceof HTMLElement?n.firstElementChild:n),A===t.nodeMap.get(n)){const e=t.styleCache.get(A)||window.getComputedStyle(A);t.styleCache.set(A,e);const r=function(A){if(!A||"none"===A)return"";let e=A.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(A,e)=>{const t=e.split(",").map(A=>A.trim());return 6!==t.length?`matrix(${e})`:(t[4]="0",t[5]="0",`matrix(${t.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(A,e)=>{const t=e.split(",").map(A=>A.trim());return 16!==t.length?`matrix3d(${e})`:(t[12]="0",t[13]="0",`matrix3d(${t.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}(e.transform);n.style.margin="0",n.style.top="auto",n.style.left="auto",n.style.right="auto",n.style.bottom="auto",n.style.animation="none",n.style.transition="none",n.style.willChange="auto",n.style.float="none",n.style.clear="none",n.style.transform=r||""}for(const[A,e]of t.nodeMap.entries())"PRE"===e.tagName&&(A.style.marginTop="0",A.style.marginBlockStart="0");return{clone:n,classCSS:r,styleCache:t.styleCache}}var Ne=new Map;async function Ve(A){if(yA.resource?.has(A))return yA.resource.get(A);if(Ne.has(A))return Ne.get(A);const e=(async()=>{const e=await xA(A,{as:"dataURL",silent:!0});if(!e.ok||"string"!=typeof e.data)throw new Error(`[snapDOM] Failed to read blob URL: ${A}`);return yA.resource?.set(A,e.data),e.data})();Ne.set(A,e);try{const t=await e;return Ne.set(A,t),t}catch(e){throw Ne.delete(A),e}}var Ge=/\bblob:[^)"'\s]+/g;async function We(A){if(!A||-1===A.indexOf("blob:"))return A;const e=Array.from(new Set(A.match(Ge)||[]));if(0===e.length)return A;let t=A;for(const A of e)try{const e=await Ve(A);t=t.split(A).join(e)}catch{}return t}function Xe(A){return"string"==typeof A&&A.startsWith("blob:")}function Je(A){return(A||"").split(",").map(A=>A.trim()).filter(Boolean).map(A=>{const e=A.match(/^(\S+)(\s+.+)?$/);return e?{url:e[1],desc:e[2]||""}:null}).filter(Boolean)}function Ye(A){return A.map(A=>A.desc?`${A.url} ${A.desc.trim()}`:A.url).join(", ")}function $e(A){if(!A)return()=>{};const e=function(A){const e=getComputedStyle(A);let t=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");t=(t||"").trim();const n=parseInt(t,10);return Number.isFinite(n)&&n>0?n:0}(A);if(e<=0)return()=>{};if(!function(A){return!(A.childElementCount>0)&&Array.from(A.childNodes).some(A=>A.nodeType===Node.TEXT_NODE)}(A))return()=>{};const t=getComputedStyle(A),n=Math.round(function(A){const e=(A.lineHeight||"").trim(),t=parseFloat(A.fontSize)||16;return e&&"normal"!==e?e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*t):e.endsWith("%")?Math.round(parseFloat(e)/100*t):Math.round(1.2*t):Math.round(1.2*t)}(t)*e+function(A){return(parseFloat(A.paddingTop)||0)+(parseFloat(A.paddingBottom)||0)}(t)),r=A.textContent??"",o=r;if(A.scrollHeight<=n+.5)return()=>{};let i=0,s=r.length,a=-1;for(;i<=s;){const e=i+s>>1;A.textContent=r.slice(0,e)+"…",A.scrollHeight<=n+.5?(a=e,i=e+1):s=e-1}return A.textContent=(a>=0?r.slice(0,a):"")+"…",()=>{A.textContent=o}}async function Ze(A,e){if(!A)throw new Error("Element cannot be null or undefined");!function(A="soft"){switch(A){case"auto":return yA.session.styleMap=new Map,void(yA.session.nodeMap=new Map);case"soft":default:return yA.session.styleMap=new Map,yA.session.nodeMap=new Map,void(yA.session.styleCache=new WeakMap);case"full":return;case"disabled":yA.session.styleMap=new Map,yA.session.nodeMap=new Map,yA.session.styleCache=new WeakMap,yA.computedStyle=new WeakMap,yA.baseStyle=new Map,yA.defaultStyle=new Map,yA.image=new Map,yA.background=new Map,yA.resource=new Map,yA.font=new Set}}(e.cache);const t=e.fast,n=!!e.straighten,r=!!e.noShadows;let o,i,s,a,c,l="",u="",h=null;const g=$e(A);try{({clone:o,classCSS:i,styleCache:s}=await Oe(A,e)),n&&o&&(h=function(A,e){if(!A||!e||!e.style)return null;const t=getComputedStyle(A);try{e.style.transformOrigin="0 0"}catch{}try{"translate"in e.style&&(e.style.translate="none"),"rotate"in e.style&&(e.style.rotate="none")}catch{}const n=t.transform||"none";if("none"===n)try{const t=_e(A);if(1===t.a&&0===t.b&&0===t.c&&1===t.d)return e.style.transform="none",{a:1,b:0,c:0,d:1}}catch{}const r=n.match(/^matrix\(\s*([^)]+)\)$/i);if(r){const A=r[1].split(",").map(A=>parseFloat(A.trim()));if(6===A.length&&A.every(Number.isFinite)){const[t,n,r,o]=A,i=Math.sqrt(t*t+n*n)||0;let s=0,a=0,c=0,l=0,u=0,h=0;i>0&&(s=t/i,a=n/i,c=s*r+a*o,l=r-s*c,u=o-a*c,h=Math.sqrt(l*l+u*u)||0,h>0?c/=h:c=0);const g=i,d=0,B=c*h,w=h;try{e.style.transform=`matrix(${g}, ${d}, ${B}, ${w}, 0, 0)`}catch{}return{a:g,b:d,c:B,d:w}}}try{const A=String(n).trim();return e.style.transform=A+" translate(0px, 0px) rotate(0deg)",null}catch{return null}}(A,o)),r&&o&&function(A,e){if(!A||!e||!e.style)return;const t=getComputedStyle(A);try{e.style.boxShadow="none"}catch{}try{e.style.textShadow="none"}catch{}try{e.style.outline="none"}catch{}const n=(t.filter||"").replace(/\bblur\([^()]*\)\s*/gi,"").replace(/\bdrop-shadow\([^()]*\)\s*/gi,"").trim().replace(/\s+/g," ");try{e.style.filter=n.length?n:"none"}catch{}}(A,o)}finally{g()}await new Promise(A=>{GA(async()=>{await async function(A,e={}){const t=Array.from(A.querySelectorAll("img")),n=async A=>{if(!A.getAttribute("src")){const e=A.currentSrc||A.src||"";e&&A.setAttribute("src",e)}A.removeAttribute("srcset"),A.removeAttribute("sizes");const t=A.src||"";if(!t)return;const n=await xA(t,{as:"dataURL",useProxy:e.useProxy});if(n.ok&&"string"==typeof n.data&&n.data.startsWith("data:"))return A.src=n.data,A.width||(A.width=A.naturalWidth||100),void(A.height||(A.height=A.naturalHeight||100));const{fallbackURL:r}=e||{};if(r)try{const n=parseInt(A.dataset?.snapdomWidth||"",10)||0,o=parseInt(A.dataset?.snapdomHeight||"",10)||0,i=parseInt(A.getAttribute("width")||"",10)||0,s=parseInt(A.getAttribute("height")||"",10)||0,a=parseFloat(A.style?.width||"")||0,c=parseFloat(A.style?.height||"")||0,l=n||a||i||A.width||void 0,u=o||c||s||A.height||void 0,h="function"==typeof r?await r({width:l,height:u,src:t,element:A}):r;if(h){const t=await xA(h,{as:"dataURL",useProxy:e.useProxy});return A.src=t.data,!A.width&&l&&(A.width=l),!A.height&&u&&(A.height=u),A.width||(A.width=A.naturalWidth||100),void(A.height||(A.height=A.naturalHeight||100))}}catch{}const o=A.width||A.naturalWidth||100,i=A.height||A.naturalHeight||100;if(!1!==e.placeholders){const e=document.createElement("div");e.style.cssText=[`width:${o}px`,`height:${i}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${i}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),e.textContent="img",A.replaceWith(e)}else{const e=document.createElement("div");e.style.cssText=`display:inline-block;width:${o}px;height:${i}px;visibility:hidden;`,A.replaceWith(e)}};for(let A=0;A<t.length;A+=4){const e=t.slice(A,A+4).map(n);await Promise.allSettled(e)}}(o,e),A()},{fast:t})}),await new Promise(n=>{GA(async()=>{await async function(A,e,t,n={}){const r=[[A,e]],o=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],i=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],s=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;r.length;){const[A,e]=r.shift(),a=t.get(A)||OA(A);t.has(A)||t.set(A,a);const c=(()=>{const A=a.getPropertyValue("border-image"),e=a.getPropertyValue("border-image-source");return A&&"none"!==A||e&&"none"!==e})();for(const A of o){const t=a.getPropertyValue(A);if(!t||"none"===t)continue;const r=VA(t),o=await Promise.all(r.map(A=>LA(A,n)));o.some(A=>A&&"none"!==A&&!/^url\(undefined/.test(A))&&e.style.setProperty(A,o.join(", "))}for(const A of i){const t=a.getPropertyValue(A);t&&"initial"!==t&&e.style.setProperty(A,t)}if(c)for(const A of s){const t=a.getPropertyValue(A);t&&"initial"!==t&&e.style.setProperty(A,t)}const l=Array.from(A.children),u=Array.from(e.children);for(let A=0;A<Math.min(l.length,u.length);A++)r.push([l[A],u[A]])}}(A,o,s,e),n()},{fast:t})}),e.embedFonts&&await new Promise(n=>{GA(async()=>{const t=be(A),r=function(A){const e=new Set,t=A=>{if(A)for(const t of A)e.add(t.codePointAt(0))},n=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;n.nextNode();){const A=n.currentNode;if(A.nodeType===Node.TEXT_NODE)t(A.nodeValue||"");else if(A.nodeType===Node.ELEMENT_NODE){const n=A;for(const A of["::before","::after"]){const r=getComputedStyle(n,A),o=r?.getPropertyValue("content");if(o&&"none"!==o)if(/^"/.test(o)||/^'/.test(o))t(o.slice(1,-1));else{const A=o.match(/\\[0-9A-Fa-f]{1,6}/g);if(A)for(const t of A)try{e.add(parseInt(t.slice(1),16))}catch{}}}}}return e}(A);if(WA()){const A=new Set(Array.from(t).map(A=>String(A).split("__")[0]).filter(Boolean));await async function(A,e=2){try{await document.fonts.ready}catch{}const t=Array.from(A||[]).filter(Boolean);if(0===t.length)return;const n=()=>{const A=document.createElement("div");A.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(const e of t){const t=document.createElement("span");t.textContent="AaBbGg1234ÁÉÍÓÚçñ—∞",t.style.fontFamily=`"${e}"`,t.style.fontWeight="700",t.style.fontStyle="italic",t.style.fontSize="32px",t.style.lineHeight="1",t.style.whiteSpace="nowrap",t.style.margin="0",t.style.padding="0",A.appendChild(t)}document.body.appendChild(A),A.offsetWidth,document.body.removeChild(A)};for(let A=0;A<Math.max(1,e);A++)n(),await new Promise(A=>requestAnimationFrame(()=>requestAnimationFrame(A)))}(A,1)}l=await Fe({required:t,usedCodepoints:r,exclude:e.excludeFonts,useProxy:e.useProxy}),n()},{fast:t})});const d=function(A){const e=new Set;return A.nodeType!==Node.ELEMENT_NODE&&A.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(A.tagName&&e.add(A.tagName.toLowerCase()),"function"==typeof A.querySelectorAll&&A.querySelectorAll("*").forEach(A=>e.add(A.tagName.toLowerCase())),Array.from(e))}(o).sort(),B=d.join(",");yA.baseStyle.has(B)?u=yA.baseStyle.get(B):await new Promise(A=>{GA(()=>{u=function(A){const e=new Map;for(let t of A){const A=yA.defaultStyle.get(t);if(!A)continue;const n=Object.entries(A).map(([A,e])=>`${A}:${e};`).sort().join("");n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let t="";for(let[A,n]of e.entries())t+=`${n.join(",")} { ${A} }\n`;return t}(d),yA.baseStyle.set(B,u),A()},{fast:t})}),await new Promise(s=>{GA(()=>{const t=getComputedStyle(A);const g=A.getBoundingClientRect(),d=Math.max(1,Math.ceil(A.offsetWidth||parseFloat(t.width)||g.width||1)),B=Math.max(1,Math.ceil(A.offsetHeight||parseFloat(t.height)||g.height||1)),w=(A,e=NaN)=>{const t="string"==typeof A?parseFloat(A):A;return Number.isFinite(t)?t:e},f=w(e.width),m=w(e.height);let p=d,C=B;const Q=Number.isFinite(f),y=Number.isFinite(m),U=B>0?d/B:1;Q&&y?(p=Math.max(1,Math.ceil(f)),C=Math.max(1,Math.ceil(m))):Q?(p=Math.max(1,Math.ceil(f)),C=Math.max(1,Math.ceil(p/(U||1)))):y?(C=Math.max(1,Math.ceil(m)),p=Math.max(1,Math.ceil(C*(U||1)))):(p=d,C=B);let F=0,b=0,E=d,v=B;if(n&&h&&Number.isFinite(h.a)){const A=je(d,B,{a:h.a,b:h.b||0,c:h.c||0,d:h.d||1,e:0,f:0},0,0);F=A.minX,b=A.minY,E=A.maxX,v=A.maxY}else{if(!n&&function(A){const e=getComputedStyle(A),t=e.transform||"none";if("none"!==t&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(t))return!0;const n=e.rotate&&"none"!==e.rotate&&"0deg"!==e.rotate,r=e.scale&&"none"!==e.scale&&"1"!==e.scale,o=e.translate&&"none"!==e.translate&&"0px 0px"!==e.translate;return Boolean(n||r||o)}(A)){const e=t.transform&&"none"!==t.transform?t.transform:"",n=function(A){const e={rotate:"0deg",scale:null,translate:null},t="function"==typeof A.computedStyleMap?A.computedStyleMap():null;if(t){const n=A=>{try{return"function"!=typeof t.has||t.has(A)?"function"!=typeof t.get?null:t.get(A):null}catch{return null}},r=n("rotate");if(r)if(r.angle){const A=r.angle;e.rotate="rad"===A.unit?180*A.value/Math.PI+"deg":A.value+A.unit}else r.unit?e.rotate="rad"===r.unit?180*r.value/Math.PI+"deg":r.value+r.unit:e.rotate=String(r);else{const t=getComputedStyle(A);e.rotate=t.rotate&&"none"!==t.rotate?t.rotate:"0deg"}const o=n("scale");if(o){const A="x"in o&&null!=o.x?.value?o.x.value:Array.isArray(o)?o[0]?.value:Number(o)||1,t="y"in o&&null!=o.y?.value?o.y.value:Array.isArray(o)?o[1]?.value:A;e.scale=`${A} ${t}`}else{const t=getComputedStyle(A);e.scale=t.scale&&"none"!==t.scale?t.scale:null}const i=n("translate");if(i){const A="x"in i&&"value"in i.x?i.x.value:Array.isArray(i)?i[0]?.value:0,t="y"in i&&"value"in i.y?i.y.value:Array.isArray(i)?i[1]?.value:0,n="x"in i&&i.x?.unit?i.x.unit:"px",r="y"in i&&i.y?.unit?i.y.unit:"px";e.translate=`${A}${n} ${t}${r}`}else{const t=getComputedStyle(A);e.translate=t.translate&&"none"!==t.translate?t.translate:null}return e}const n=getComputedStyle(A);return e.rotate=n.rotate&&"none"!==n.rotate?n.rotate:"0deg",e.scale=n.scale&&"none"!==n.scale?n.scale:null,e.translate=n.translate&&"none"!==n.translate?n.translate:null,e}(A),r=function(A){const e=function(){if(ze)return ze;const A=document.createElement("div");return A.id="snapdom-measure-slot",A.setAttribute("aria-hidden","true"),Object.assign(A.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(A),ze=A,A}(),t=document.createElement("div");t.style.transformOrigin="0 0",A.baseTransform&&(t.style.transform=A.baseTransform);A.rotate&&(t.style.rotate=A.rotate);A.scale&&(t.style.scale=A.scale);A.translate&&(t.style.translate=A.translate);e.appendChild(t);const n=_e(t);return e.removeChild(t),n}({baseTransform:e,rotate:n.rotate||"0deg",scale:n.scale,translate:n.translate}),{ox:o,oy:i}=function(A,e,t){const n=(A.transformOrigin||"0 0").trim().split(/\s+/),[r,o]=[n[0]||"0",n[1]||"0"],i=(A,e)=>{const t=A.toLowerCase();return"left"===t||"top"===t?0:"center"===t?e/2:"right"===t||"bottom"===t?e:t.endsWith("px")?parseFloat(t)||0:t.endsWith("%")?(parseFloat(t)||0)*e/100:/^-?\d+(\.\d+)?$/.test(t)&&parseFloat(t)||0};return{ox:i(r,e),oy:i(o,t)}}(t,d,B),s=je(d,B,r.is2D?r:new DOMMatrix(r.toString()),o,i);F=s.minX,b=s.minY,E=s.maxX,v=s.maxY}}const H=function(A){const e=A.boxShadow||"";if(!e||"none"===e)return{top:0,right:0,bottom:0,left:0};const t=e.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(A=>A.trim());let n=0,r=0,o=0,i=0;for(const A of t){const e=A.match(/-?\d+(\.\d+)?px/g)?.map(A=>parseFloat(A))||[];if(e.length<2)continue;const[t,s,a=0,c=0]=e,l=Math.abs(t)+a+c,u=Math.abs(s)+a+c;r=Math.max(r,l+Math.max(t,0)),i=Math.max(i,l+Math.max(-t,0)),o=Math.max(o,u+Math.max(s,0)),n=Math.max(n,u+Math.max(-s,0))}return{top:Math.ceil(n),right:Math.ceil(r),bottom:Math.ceil(o),left:Math.ceil(i)}}(t),I=function(A){const e=(A.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),t=e?Math.ceil(parseFloat(e[1])||0):0;return{top:t,right:t,bottom:t,left:t}}(t),x=function(A){if("none"===(A.outlineStyle||"none"))return{top:0,right:0,bottom:0,left:0};const e=Math.ceil(parseFloat(A.outlineWidth||"0")||0);return{top:e,right:e,bottom:e,left:e}}(t),S=function(A){const e=`${A.filter||""} ${A.webkitFilter||""}`.trim();if(!e||"none"===e)return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};const t=e.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[];let n=0,r=0,o=0,i=0,s=!1;for(const A of t){s=!0;const e=A.match(/-?\d+(?:\.\d+)?px/gi)?.map(A=>parseFloat(A))||[],[t=0,a=0,c=0]=e,l=Math.abs(t)+c,u=Math.abs(a)+c;r=Math.max(r,l+Math.max(t,0)),i=Math.max(i,l+Math.max(-t,0)),o=Math.max(o,u+Math.max(a,0)),n=Math.max(n,u+Math.max(-a,0))}return{bleed:{top:Math.ceil(n),right:Math.ceil(r),bottom:Math.ceil(o),left:Math.ceil(i)},has:s}}(t),L=r?{top:0,right:0,bottom:0,left:0}:{top:H.top+I.top+x.top+S.bleed.top,right:H.right+I.right+x.right+S.bleed.right,bottom:H.bottom+I.bottom+x.bottom+S.bleed.bottom,left:H.left+I.left+x.left+S.bleed.left};F-=L.left,b-=L.top,E+=L.right,v+=L.bottom;const D=Math.max(1,Math.ceil(E-F)),M=Math.max(1,Math.ceil(v-b)),K=Math.max(1,Math.round(D*(Q||y?p/d:1))),T=Math.max(1,Math.round(M*(y||Q?C/B:1))),k="http://www.w3.org/2000/svg",R=(WA()?1:0)+(n?1:0),P=document.createElementNS(k,"foreignObject"),O=Math.floor(F),N=Math.floor(b);P.setAttribute("x",String(-(O-R))),P.setAttribute("y",String(-(N-R))),P.setAttribute("width",String(Math.ceil(d+2*R))),P.setAttribute("height",String(Math.ceil(B+2*R))),P.style.overflow="visible";const V=document.createElement("style");V.textContent=u+l+"svg{overflow:visible;} foreignObject{overflow:visible;}"+i,P.appendChild(V);const G=document.createElement("div");G.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),G.style.width=`${d}px`,G.style.height=`${B}px`,G.style.overflow="visible",o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),G.appendChild(o),P.appendChild(G);const W=(new XMLSerializer).serializeToString(P),X=D+2*R,J=M+2*R,Y=Q||y;e.meta={w0:d,h0:B,vbW:X,vbH:J,targetW:p,targetH:C};const $=WA()&&Y?X:K+2*R,Z=WA()&&Y?J:T+2*R;c=`<svg xmlns="${k}" width="${$}" height="${Z}" viewBox="0 0 ${X} ${J}">`+W+"</svg>",a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(c)}`,s()},{fast:t})});const w=document.getElementById("snapdom-sandbox");return w&&"absolute"===w.style.position&&w.remove(),a}function je(A,e,t,n,r){const o=t.a,i=t.b,s=t.c,a=t.d,c=t.e||0,l=t.f||0;function u(A,e){let t=A-n,u=e-r,h=o*t+s*u,g=i*t+a*u;return h+=n+c,g+=r+l,[h,g]}const h=[u(0,0),u(A,0),u(0,e),u(A,e)];let g=1/0,d=1/0,B=-1/0,w=-1/0;for(const[A,e]of h)A<g&&(g=A),e<d&&(d=e),A>B&&(B=A),e>w&&(w=e);return{minX:g,minY:d,maxX:B,maxY:w,width:B-g,height:w-d}}function _e(A){const e=getComputedStyle(A).transform;if(!e||"none"===e)return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}var ze=null;function qe(A){const e=function(A){let e=[],t="",n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&n++,")"===o&&(n=Math.max(0,n-1)),";"===o&&0===n?(e.push(t),t=""):t+=o}return t.trim()&&e.push(t),e.map(A=>A.trim()).filter(Boolean)}(A);let t=null,n=null,r=null;const o=[];for(const A of e){const e=A.indexOf(":");if(e<0)continue;const i=A.slice(0,e).trim().toLowerCase(),s=A.slice(e+1).trim();"box-shadow"===i?r=s:"filter"===i?t=s:"-webkit-filter"===i?n=s:o.push([i,s])}if(r){const A=function(A){const e=[];let t="",n=0;for(let r=0;r<A.length;r++){const o=A[r];"("===o&&n++,")"===o&&(n=Math.max(0,n-1)),","===o&&0===n?(e.push(t.trim()),t=""):t+=o}t.trim()&&e.push(t.trim());const r=[];for(const A of e){if(/\binset\b/i.test(A))continue;const e=A.match(/-?\d+(?:\.\d+)?px/gi)||[],[t="0px",n="0px",o="0px"]=e;let i=A.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/gi,"").trim().replace(/\s{2,}/g," ");const s=!!i&&","!==i;r.push(`drop-shadow(${t} ${n} ${o}${s?` ${i}`:""})`)}return r.join(" ")}(r);A&&(t=t?`${t} ${A}`:A,n=n?`${n} ${A}`:A)}const i=[...o];return t&&i.push(["filter",t]),n&&i.push(["-webkit-filter",n]),i.map(([A,e])=>`${A}:${e}`).join(";")}function At(A){return A=(A=A.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(A,e)=>A.replace(e,function(A){return A.replace(/([^{}]+)\{([^}]*)\}/g,(A,e,t)=>`${e}{${qe(t)}}`)}(e)))).replace(/style=(['"])([\s\S]*?)\1/gi,(A,e,t)=>`style=${e}${qe(t)}${e}`)}function et(A){if(!WA()||("string"!=typeof(e=A)||!/^data:image\/svg\+xml/i.test(e)))return A;var e;try{const e=function(A){const e=A.indexOf(",");return e>=0?decodeURIComponent(A.slice(e+1)):""}(A),t=At(e);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}catch{return A}}async function tt(A,e){let{width:t,height:n,scale:r=1,dpr:o=1,meta:i={}}=e;A=et(A);const s=new Image;s.loading="eager",s.decoding="sync",s.crossOrigin="anonymous",s.src=A,await s.decode();const a=s.naturalWidth,c=s.naturalHeight,l=Number.isFinite(i.w0)?i.w0:a,u=Number.isFinite(i.h0)?i.h0:c;let h,g;const d=Number.isFinite(t),B=Number.isFinite(n);if(d&&B)h=Math.max(1,t),g=Math.max(1,n);else if(d){const A=t/Math.max(1,l);h=t,g=Math.round(u*A)}else if(B){const A=n/Math.max(1,u);g=n,h=Math.round(l*A)}else h=a,g=c;h=Math.round(h*r),g=Math.round(g*r);const w=document.createElement("canvas");w.width=Math.ceil(h*o),w.height=Math.ceil(g*o),w.style.width=`${h}px`,w.style.height=`${g}px`;const f=w.getContext("2d");return 1!==o&&f.scale(o,o),f.drawImage(s,0,0,h,g),w}async function nt(A,e){const t=await tt(A,e),n=e.backgroundColor?SA(t,e.backgroundColor):t,r=new Image;return r.src=n.toDataURL(`image/${e.format}`,e.quality),await r.decode(),r.style.width=n.width/e.dpr+"px",r.style.height=n.height/e.dpr+"px",r}async function rt(A,e){const{scale:t=1,width:n,height:r,meta:o={}}=e,i=Number.isFinite(n),s=Number.isFinite(r),a=Number.isFinite(t)&&1!==t||i||s;if(WA()&&a){return await nt(A,{...e,format:"png",quality:1,meta:o})}const c=new Image;if(c.decoding="sync",c.loading="eager",c.src=A,await c.decode(),i&&s)c.style.width=`${n}px`,c.style.height=`${r}px`;else if(i){const A=Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.h0)?o.h0:c.naturalHeight,t=n/Math.max(1,A);c.style.width=`${n}px`,c.style.height=`${Math.round(e*t)}px`}else if(s){const A=Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.h0)?o.h0:c.naturalHeight,t=r/Math.max(1,e);c.style.height=`${r}px`,c.style.width=`${Math.round(A*t)}px`}else{const e=Math.round(c.naturalWidth*t),n=Math.round(c.naturalHeight*t);if(c.style.width=`${e}px`,c.style.height=`${n}px`,"string"==typeof A&&A.startsWith("data:image/svg+xml"))try{const t=decodeURIComponent(A.split(",")[1]).replace(/width="[^"]*"/,`width="${e}"`).replace(/height="[^"]*"/,`height="${n}"`);A=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,c.src=A}catch{}}return c}async function ot(A,e){const t=e.type;if("svg"===t){const e=decodeURIComponent(A.split(",")[1]);return new Blob([e],{type:"image/svg+xml"})}const n=await tt(A,e),r=e.backgroundColor?SA(n,e.backgroundColor):n;return new Promise(A=>r.toBlob(e=>A(e),`image/${t}`,e.quality))}var it=Symbol("snapdom.internal"),st=!1;async function at(A,e){if(!A)throw new Error("Element cannot be null or undefined");const t=function(A={}){const e=A.format??"png",t=function(A){if("string"==typeof A){const e=A.toLowerCase().trim();if("disabled"===e||"full"===e||"auto"===e||"soft"===e)return e}return"soft"}(A.cache);return{debug:A.debug??!1,fast:A.fast??!0,scale:A.scale??1,exclude:A.exclude??[],excludeMode:A.excludeMode??"hide",filter:A.filter??null,filterMode:A.filterMode??"hide",placeholders:!1!==A.placeholders,embedFonts:A.embedFonts??!1,iconFonts:Array.isArray(A.iconFonts)?A.iconFonts:A.iconFonts?[A.iconFonts]:[],localFonts:Array.isArray(A.localFonts)?A.localFonts:[],excludeFonts:A.excludeFonts??void 0,fallbackURL:A.fallbackURL??void 0,cache:t,useProxy:"string"==typeof A.useProxy?A.useProxy:"",width:A.width??null,height:A.height??null,format:e,type:A.type??"svg",quality:A.quality??.92,dpr:A.dpr??(window.devicePixelRatio||1),backgroundColor:A.backgroundColor??(["jpg","jpeg","webp"].includes(e)?"#ffffff":null),filename:A.filename??"snapDOM",straighten:A.straighten??!1,noShadows:A.noShadows??!1}}(e);if(WA()&&(!0===t.embedFonts||function(A){const e=document.createTreeWalker(A,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){const A=e.currentNode,t=getComputedStyle(A),n=t.backgroundImage&&"none"!==t.backgroundImage,r=t.maskImage&&"none"!==t.maskImage||t.webkitMaskImage&&"none"!==t.webkitMaskImage;if(n||r)return!0}return!1}(A)))for(let t=0;t<3;t++)try{await ct(A,e),console.log("Iteración número:",t),st=!1}catch{}return t.iconFonts&&t.iconFonts.length>0&&function(A){const e=Array.isArray(A)?A:[A];for(const A of e)A instanceof RegExp?oe.push(A):"string"==typeof A?oe.push(new RegExp(A,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",A)}(t.iconFonts),t.snap||(t.snap={toPng:(A,e)=>at.toPng(A,e),toSvg:(A,e)=>at.toSvg(A,e)}),at.capture(A,t,it)}async function ct(A,e){if(st)return;const t={...e,fast:!0,embedFonts:!0,scale:.2};let n;try{n=await Ze(A,t)}catch{return}await new Promise(A=>{const e=new Image;e.decoding="sync",e.loading="eager",e.style.position="fixed",e.style.left=0,e.style.top=0,e.style.width="10px",e.style.height="10px",e.style.opacity="0.01",e.style.transform="translateZ(10px)",e.style.willChange="transform,opacity;",e.src=n;document.body.appendChild(e),(async()=>{await new Promise(A=>setTimeout(A,100)),e&&e.parentNode&&e.parentNode.removeChild(e),st=!0,A()})()})}at.capture=async(A,e,t)=>{if(t!==it)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");const n=await Ze(A,e),r=A=>({...e,...A||{}}),o=A=>e=>{const t=r({...e||{},format:A}),o="jpeg"===A||"jpg"===A,i=null==t.backgroundColor||"transparent"===t.backgroundColor;return o&&i&&(t.backgroundColor="#ffffff"),nt(n,t)};return{url:n,toRaw:()=>n,toImg:A=>rt(n,r(A)),toSvg:A=>rt(n,r(A)),toCanvas:A=>tt(n,r(A)),toBlob:A=>ot(n,r(A)),toPng:o("png"),toJpg:o("jpeg"),toWebp:o("webp"),download:A=>async function(A,e){if(e.dpr=1,"svg"===e.format){const t=await ot(A,{...e,type:"svg"}),n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e.filename,r.click(),void URL.revokeObjectURL(n)}const t=await tt(A,e),n=e.backgroundColor?SA(t,e.backgroundColor):t,r=document.createElement("a");r.href=n.toDataURL(`image/${e.format}`,e.quality),r.download=e.filename,r.click()}(n,r(A))}},at.toRaw=(A,e)=>at(A,e).then(A=>A.toRaw()),at.toImg=(A,e)=>at(A,e).then(A=>A.toImg()),at.toSvg=(A,e)=>at(A,e).then(A=>A.toSvg()),at.toCanvas=(A,e)=>at(A,e).then(A=>A.toCanvas()),at.toBlob=(A,e)=>at(A,e).then(A=>A.toBlob()),at.toPng=(A,e)=>at(A,{...e,format:"png"}).then(A=>A.toPng()),at.toJpg=(A,e)=>at(A,{...e,format:"jpeg"}).then(A=>A.toJpg()),at.toWebp=(A,e)=>at(A,{...e,format:"webp"}).then(A=>A.toWebp()),at.download=(A,e)=>at(A,e).then(A=>A.download());"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function lt(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var ut={exports:{}};
|
|
2
2
|
/*!
|
|
3
3
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
4
4
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
package/package.json
CHANGED