@unicom-cloud/utils 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/date/index.js +22 -0
  2. package/date.js +9 -0
  3. package/index.js +56 -54
  4. package/lunar/index.js +36 -0
  5. package/lunar/lib/Holiday.js +42 -0
  6. package/lunar/lib/HolidayUtil.js +128 -0
  7. package/lunar/lib/I18n.js +1005 -0
  8. package/lunar/lib/JieQi.js +40 -0
  9. package/lunar/lib/Lunar.js +1035 -0
  10. package/lunar/lib/LunarMonth.js +150 -0
  11. package/lunar/lib/LunarTime.js +138 -0
  12. package/lunar/lib/LunarUtil.js +1752 -0
  13. package/lunar/lib/LunarYear.js +616 -0
  14. package/lunar/lib/ShouXingUtil.js +6915 -0
  15. package/lunar/lib/Solar.js +311 -0
  16. package/lunar/lib/SolarHalfYear.js +45 -0
  17. package/lunar/lib/SolarMonth.js +55 -0
  18. package/lunar/lib/SolarSeason.js +42 -0
  19. package/lunar/lib/SolarUtil.js +256 -0
  20. package/lunar/lib/SolarWeek.js +153 -0
  21. package/lunar/lib/SolarYear.js +35 -0
  22. package/lunar/lib/index.js +35 -0
  23. package/lunar.js +36 -0
  24. package/package.json +1 -1
  25. package/snapdom/src/api/preCache.js +26 -36
  26. package/snapdom/src/api/snapdom.js +78 -61
  27. package/snapdom/src/core/capture.js +54 -54
  28. package/snapdom/src/core/prepare.js +46 -37
  29. package/snapdom/src/modules/fonts.js +90 -92
  30. package/snapdom/src/modules/iconFonts.js +28 -0
  31. package/snapdom/src/modules/images.js +6 -6
  32. package/snapdom/src/modules/pseudo.js +51 -49
  33. package/snapdom/src/modules/styles.js +27 -7
  34. package/snapdom/src/modules/svgDefs.js +26 -0
  35. package/snapdom/src/utils/helpers.js +150 -103
  36. package/tinycolor/index.js +46 -0
  37. package/tinycolor/src/conversion.js +143 -0
  38. package/tinycolor/src/css-color-names.js +153 -0
  39. package/tinycolor/src/format-input.js +77 -0
  40. package/tinycolor/src/from-ratio.js +21 -0
  41. package/tinycolor/src/index.js +404 -0
  42. package/tinycolor/src/random.js +221 -0
  43. package/tinycolor/src/readability.js +37 -0
  44. package/tinycolor/src/to-ms-filter.js +15 -0
  45. package/tinycolor/src/util.js +32 -0
  46. package/tinycolor.js +46 -0
  47. package/tree/index.js +10 -8
  48. package/tree.js +9 -7
  49. package/types/date/index.d.ts +4 -0
  50. package/types/index.d.ts +4 -3
  51. package/types/lunar/index.d.ts +3 -0
  52. package/types/lunar/lib/Holiday.d.ts +17 -0
  53. package/types/lunar/lib/HolidayUtil.d.ts +23 -0
  54. package/types/lunar/lib/I18n.d.ts +23 -0
  55. package/types/lunar/lib/JieQi.d.ts +15 -0
  56. package/types/lunar/lib/Lunar.d.ts +245 -0
  57. package/types/lunar/lib/LunarMonth.d.ts +35 -0
  58. package/types/lunar/lib/LunarTime.d.ts +40 -0
  59. package/types/lunar/lib/LunarUtil.d.ts +128 -0
  60. package/types/lunar/lib/LunarYear.d.ts +61 -0
  61. package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
  62. package/types/lunar/lib/Solar.d.ts +51 -0
  63. package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
  64. package/types/lunar/lib/SolarMonth.d.ts +16 -0
  65. package/types/lunar/lib/SolarSeason.d.ts +15 -0
  66. package/types/lunar/lib/SolarUtil.d.ts +20 -0
  67. package/types/lunar/lib/SolarWeek.d.ts +23 -0
  68. package/types/lunar/lib/SolarYear.d.ts +12 -0
  69. package/types/lunar/lib/index.d.ts +17 -0
  70. package/types/snapdom/src/core/prepare.d.ts +1 -1
  71. package/types/snapdom/src/modules/fonts.d.ts +1 -3
  72. package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
  73. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  74. package/types/snapdom/src/modules/styles.d.ts +1 -10
  75. package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
  76. package/types/snapdom/src/utils/helpers.d.ts +1 -1
  77. package/types/tinycolor/index.d.ts +2 -0
  78. package/types/tinycolor/src/conversion.d.ts +79 -0
  79. package/types/tinycolor/src/css-color-names.d.ts +4 -0
  80. package/types/tinycolor/src/format-input.d.ts +38 -0
  81. package/types/tinycolor/src/from-ratio.d.ts +14 -0
  82. package/types/tinycolor/src/index.d.ts +214 -0
  83. package/types/tinycolor/src/interfaces.d.ts +57 -0
  84. package/types/tinycolor/src/public_api.d.ts +10 -0
  85. package/types/tinycolor/src/random.d.ts +24 -0
  86. package/types/tinycolor/src/readability.d.ts +46 -0
  87. package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
  88. package/types/tinycolor/src/umd_api.d.ts +22 -0
  89. package/types/tinycolor/src/util.d.ts +36 -0
  90. package/types/tree/index.d.ts +1 -0
  91. package/types/ui-color/compareColorByRange.d.ts +2 -0
  92. package/types/ui-color/index.d.ts +183 -0
  93. package/ui-color/compareColorByRange.js +9 -0
  94. package/ui-color/index.js +155 -0
  95. package/uiColor.js +28 -0
  96. package/convertTime.js +0 -4
  97. package/dayjs/index.js +0 -15
  98. package/dayjs.js +0 -5
  99. package/lunar-converter/index.js +0 -641
  100. package/lunarConverter.js +0 -4
  101. package/searchTree.js +0 -4
  102. package/types/dayjs/index.d.ts +0 -1
  103. package/types/lunar-converter/index.d.ts +0 -113
  104. /package/{convert-time/index.js → date/convertTime.js} +0 -0
  105. /package/{search-tree/index.js → tree/searchTree.js} +0 -0
  106. /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
  107. /package/types/{search-tree/index.d.ts → tree/searchTree.d.ts} +0 -0
@@ -1,92 +1,109 @@
1
1
  import { captureDOM as v } from "../core/capture.js";
2
- import { isSafari as R } from "../utils/helpers.js";
3
- async function x(e, { dpr: t = 1, scale: c = 1 }) {
4
- const a = new Image();
5
- return a.src = e, await a.decode(), R ? (a.width = a.width * c, a.height = a.height * c) : (a.width = a.width / c, a.height = a.height / c), a;
2
+ import { extendIconFonts as R } from "../modules/iconFonts.js";
3
+ import { isSafari as j } from "../utils/helpers.js";
4
+ async function x(a, { dpr: t = 1, scale: o = 1 }) {
5
+ const e = new Image();
6
+ return e.src = a, await e.decode(), j ? (e.width = e.width * o, e.height = e.height * o) : (e.width = e.width / o, e.height = e.height / o), e;
6
7
  }
7
- async function p(e, { dpr: t = 1, scale: c = 1 } = {}) {
8
- const a = new Image();
9
- a.src = e, await a.decode();
10
- const n = document.createElement("canvas"), o = a.width * c, g = a.height * c;
11
- n.width = Math.ceil(o * t), n.height = Math.ceil(g * t);
8
+ async function u(a, { dpr: t = 1, scale: o = 1 } = {}) {
9
+ const e = new Image();
10
+ e.src = a, await e.decode();
11
+ const n = document.createElement("canvas"), c = e.width * o, i = e.height * o;
12
+ n.width = Math.ceil(c * t), n.height = Math.ceil(i * t);
12
13
  const s = n.getContext("2d");
13
- return s.scale(t, t), s.drawImage(a, 0, 0, o, g), n.style.width = `${o}px`, n.style.height = `${g}px`, n;
14
+ return s.scale(t, t), s.drawImage(e, 0, 0, c, i), n.style.width = `${c}px`, n.style.height = `${i}px`, n;
14
15
  }
15
- async function u(e) {
16
- const t = decodeURIComponent(e.split(",")[1]);
17
- return new Blob([t], { type: "image/svg+xml" });
16
+ async function l(a, { type: t = "svg", scale: o = 1, backgroundColor: e = "#fff", quality: n } = {}) {
17
+ const c = {
18
+ jpg: "image/jpeg",
19
+ jpeg: "image/jpeg",
20
+ png: "image/png",
21
+ webp: "image/webp"
22
+ }[t] || "image/png";
23
+ if (t === "svg") {
24
+ const s = decodeURIComponent(a.split(",")[1]);
25
+ return new Blob([s], { type: "image/svg+xml" });
26
+ }
27
+ const i = await m(
28
+ a,
29
+ { dpr: 1, scale: o },
30
+ e
31
+ );
32
+ return new Promise((s) => {
33
+ i.toBlob((r) => s(r), `${c}`, n);
34
+ });
18
35
  }
19
- async function l(e, { dpr: t = 1, scale: c = 1 }, a) {
20
- const n = await p(e, { dpr: t, scale: c });
21
- if (!a) return n;
22
- const o = document.createElement("canvas");
23
- o.width = n.width, o.height = n.height;
24
- const g = o.getContext("2d");
25
- return g.fillStyle = a, g.fillRect(0, 0, o.width, o.height), g.drawImage(n, 0, 0), o;
36
+ async function m(a, { dpr: t = 1, scale: o = 1 }, e) {
37
+ const n = await u(a, { dpr: t, scale: o });
38
+ if (!e) return n;
39
+ const c = document.createElement("canvas");
40
+ c.width = n.width, c.height = n.height;
41
+ const i = c.getContext("2d");
42
+ return i.fillStyle = e, i.fillRect(0, 0, c.width, c.height), i.drawImage(n, 0, 0), c;
26
43
  }
27
- async function d(e, { dpr: t = 1, scale: c = 1, backgroundColor: a = "#fff", quality: n }, o = "png") {
28
- const g = await l(e, { dpr: t, scale: c }, a), s = new Image();
29
- return s.src = g.toDataURL(`image/${o}`, n), await s.decode(), s.style.width = `${g.width / t}px`, s.style.height = `${g.height / t}px`, s;
44
+ async function p(a, { dpr: t = 1, scale: o = 1, backgroundColor: e = "#fff", quality: n }, c = "png") {
45
+ const i = await m(a, { dpr: t, scale: o }, e), s = new Image();
46
+ return s.src = i.toDataURL(`image/${c}`, n), await s.decode(), s.style.width = `${i.width / t}px`, s.style.height = `${i.height / t}px`, s;
30
47
  }
31
- async function I(e, {
48
+ async function I(a, {
32
49
  dpr: t = 1,
33
- scale: c = 1,
34
- backgroundColor: a = "#fff",
50
+ scale: o = 1,
51
+ backgroundColor: e = "#fff",
35
52
  format: n = "png",
36
- filename: o = "capture"
53
+ filename: c = "capture"
37
54
  } = {}) {
38
55
  if (n === "svg") {
39
- const b = await u(e), h = URL.createObjectURL(b), w = document.createElement("a");
40
- w.href = h, w.download = `${o}.svg`, w.click(), URL.revokeObjectURL(h);
56
+ const y = await l(a), h = URL.createObjectURL(y), d = document.createElement("a");
57
+ d.href = h, d.download = `${c}.svg`, d.click(), URL.revokeObjectURL(h);
41
58
  return;
42
59
  }
43
- const g = ["jpg", "jpeg", "webp"].includes(n) ? "#fff" : void 0, m = await l(e, { dpr: t, scale: c }, a ?? g), f = {
60
+ const i = ["jpg", "jpeg", "webp"].includes(n) ? "#fff" : void 0, r = await m(a, { dpr: t, scale: o }, e ?? i), f = {
44
61
  jpg: "image/jpeg",
45
62
  jpeg: "image/jpeg",
46
63
  png: "image/png",
47
64
  webp: "image/webp"
48
- }[n] || "image/png", y = m.toDataURL(f), r = document.createElement("a");
49
- r.href = y, r.download = `${o}.${n}`, r.click();
65
+ }[n] || "image/png", b = r.toDataURL(f), w = document.createElement("a");
66
+ w.href = b, w.download = `${c}.${n}`, w.click();
50
67
  }
51
- async function i(e, t = {}) {
52
- if (t = { scale: 1, ...t }, !e) throw new Error("Element cannot be null or undefined");
53
- return await i.capture(e, t);
68
+ async function g(a, t = {}) {
69
+ if (t = { scale: 1, ...t }, !a) throw new Error("Element cannot be null or undefined");
70
+ return t.iconFonts && R(t.iconFonts), await g.capture(a, t);
54
71
  }
55
- i.capture = async (e, t = {}) => {
56
- const c = await v(e, t), a = window.devicePixelRatio || 1, n = t.scale || 1;
72
+ g.capture = async (a, t = {}) => {
73
+ const o = await v(a, t), e = window.devicePixelRatio || 1, n = t.scale || 1;
57
74
  return {
58
- url: c,
75
+ url: o,
59
76
  options: t,
60
- toRaw: () => c,
61
- toImg: () => x(c, { dpr: a, scale: n }),
62
- toCanvas: () => p(c, { dpr: a, scale: n }),
63
- toBlob: () => u(c),
64
- toPng: (o) => d(c, { dpr: a, scale: n, ...o }, "png"),
65
- toJpg: (o) => d(c, { dpr: a, scale: n, ...o }, "jpeg"),
66
- toWebp: (o) => d(c, { dpr: a, scale: n, ...o }, "webp"),
77
+ toRaw: () => o,
78
+ toImg: () => x(o, { dpr: e, scale: n }),
79
+ toCanvas: () => u(o, { dpr: e, scale: n }),
80
+ toBlob: (c) => l(o, { scale: n, ...c }),
81
+ toPng: (c) => p(o, { dpr: e, scale: n, ...c }, "png"),
82
+ toJpg: (c) => p(o, { dpr: e, scale: n, ...c }, "jpeg"),
83
+ toWebp: (c) => p(o, { dpr: e, scale: n, ...c }, "webp"),
67
84
  download: ({
68
- format: o = "png",
69
- filename: g = "capture",
85
+ format: c = "png",
86
+ filename: i = "capture",
70
87
  backgroundColor: s
71
- } = {}) => I(c, { dpr: a, scale: n, backgroundColor: s, format: o, filename: g })
88
+ } = {}) => I(o, { dpr: e, scale: n, backgroundColor: s, format: c, filename: i })
72
89
  };
73
90
  };
74
- i.toRaw = async (e, t) => (await i.capture(e, t)).toRaw();
75
- i.toImg = async (e, t) => (await i.capture(e, t)).toImg();
76
- i.toCanvas = async (e, t) => (await i.capture(e, t)).toCanvas();
77
- i.toBlob = async (e, t) => (await i.capture(e, t)).toBlob();
78
- i.toPng = async (e, t) => (await i.capture(e, t)).toPng(t);
79
- i.toJpg = async (e, t) => (await i.capture(e, t)).toJpg(t);
80
- i.toWebp = async (e, t) => (await i.capture(e, t)).toWebp(t);
81
- i.download = async (e, t = {}) => {
91
+ g.toRaw = async (a, t) => (await g.capture(a, t)).toRaw();
92
+ g.toImg = async (a, t) => (await g.capture(a, t)).toImg();
93
+ g.toCanvas = async (a, t) => (await g.capture(a, t)).toCanvas();
94
+ g.toBlob = async (a, t) => (await g.capture(a, t)).toBlob(t);
95
+ g.toPng = async (a, t) => (await g.capture(a, t)).toPng(t);
96
+ g.toJpg = async (a, t) => (await g.capture(a, t)).toJpg(t);
97
+ g.toWebp = async (a, t) => (await g.capture(a, t)).toWebp(t);
98
+ g.download = async (a, t = {}) => {
82
99
  const {
83
- format: c = "png",
84
- filename: a = "capture",
100
+ format: o = "png",
101
+ filename: e = "capture",
85
102
  backgroundColor: n,
86
- ...o
103
+ ...c
87
104
  } = t;
88
- return await (await i.capture(e, o)).download({ format: c, filename: a, backgroundColor: n });
105
+ return await (await g.capture(a, c)).download({ format: o, filename: e, backgroundColor: n });
89
106
  };
90
107
  export {
91
- i as snapdom
108
+ g as snapdom
92
109
  };
@@ -1,84 +1,84 @@
1
1
  import { baseCSSCache as S } from "./cache.js";
2
- import { inlineBackgroundImages as P } from "../modules/background.js";
3
- import { embedCustomFonts as z } from "../modules/fonts.js";
4
- import { inlineImages as H } from "../modules/images.js";
5
- import { collectUsedTagNames as A, generateDedupedBaseCSS as D } from "../utils/cssTools.js";
6
- import { idle as l, isSafari as R } from "../utils/helpers.js";
7
- import { prepareClone as U } from "./prepare.js";
8
- async function Q(r, n = {}) {
9
- if (!r) throw new Error("Element cannot be null or undefined");
10
- if (!(r instanceof Element))
11
- throw new Error("captureDOM: Only Element nodes are supported");
2
+ import { inlineBackgroundImages as M } from "../modules/background.js";
3
+ import { embedCustomFonts as A } from "../modules/fonts.js";
4
+ import { inlineImages as O } from "../modules/images.js";
5
+ import { collectUsedTagNames as R, generateDedupedBaseCSS as U } from "../utils/cssTools.js";
6
+ import { idle as c, isSafari as j } from "../utils/helpers.js";
7
+ import { prepareClone as D } from "./prepare.js";
8
+ async function V(l, a = {}) {
9
+ if (!l) throw new Error("Element cannot be null or undefined");
12
10
  const {
13
- compress: b = !0,
14
- embedFonts: h = !1,
15
- fast: o = !0,
16
- scale: f = 1
17
- } = n;
18
- let t, y, v, C = "", m = "", $, x;
19
- if ({ clone: t, classCSS: y, styleCache: v } = await U(
20
- r,
11
+ compress: p = !0,
12
+ embedFonts: b = !1,
13
+ fast: r = !0,
14
+ scale: h = 1,
15
+ useProxy: T = ""
16
+ } = a;
17
+ let t, y, v, C = "", m = "", x, $;
18
+ if ({ clone: t, classCSS: y, styleCache: v } = await D(
19
+ l,
20
+ p,
21
21
  b,
22
- h
22
+ T
23
23
  ), await new Promise((s) => {
24
- l(
24
+ c(
25
25
  async () => {
26
- await H(t, n), s();
26
+ await O(t, a), s();
27
27
  },
28
- { fast: o }
28
+ { fast: r }
29
29
  );
30
30
  }), await new Promise((s) => {
31
- l(
31
+ c(
32
32
  async () => {
33
- await P(r, t, v, n), s();
33
+ await M(l, t, v, a), s();
34
34
  },
35
- { fast: o }
35
+ { fast: r }
36
36
  );
37
- }), h && await new Promise((s) => {
38
- l(
37
+ }), b && await new Promise((s) => {
38
+ c(
39
39
  async () => {
40
- C = await z({ ignoreIconFonts: !h }), s();
40
+ C = await A(), s();
41
41
  },
42
- { fast: o }
42
+ { fast: r }
43
43
  );
44
- }), b) {
45
- const s = A(t).sort(), i = s.join(",");
44
+ }), p) {
45
+ const s = R(t).sort(), i = s.join(",");
46
46
  S.has(i) ? m = S.get(i) : await new Promise((e) => {
47
- l(
47
+ c(
48
48
  () => {
49
- m = D(s), S.set(i, m), e();
49
+ m = U(s), S.set(i, m), e();
50
50
  },
51
- { fast: o }
51
+ { fast: r }
52
52
  );
53
53
  });
54
54
  }
55
55
  await new Promise((s) => {
56
- l(
56
+ c(
57
57
  () => {
58
- const i = r.getBoundingClientRect();
59
- let e = i.width, a = i.height;
60
- const d = Number.isFinite(n.width), u = Number.isFinite(n.height), p = typeof f == "number" && f !== 1;
61
- if (!p) {
58
+ const i = l.getBoundingClientRect();
59
+ let e = i.width, n = i.height;
60
+ const w = Number.isFinite(a.width), d = Number.isFinite(a.height), u = typeof h == "number" && h !== 1;
61
+ if (!u) {
62
62
  const g = i.width / i.height;
63
- d && u ? (e = n.width, a = n.height) : d ? (e = n.width, a = e / g) : u && (a = n.height, e = a * g);
63
+ w && d ? (e = a.width, n = a.height) : w ? (e = a.width, n = e / g) : d && (n = a.height, e = n * g);
64
64
  }
65
- if (e = Math.ceil(e), a = Math.ceil(a), t.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"), t.style.transformOrigin = "top left", !p && (d || u)) {
66
- const g = i.width, B = i.height, I = e / g, M = a / B, N = t.style.transform || "", O = `scale(${I}, ${M})`;
67
- t.style.transform = `${O} ${N}`.trim();
68
- } else p && R() && (t.style.scale = `${f}`);
69
- const E = "http://www.w3.org/2000/svg", c = document.createElementNS(E, "foreignObject");
70
- c.setAttribute("width", "100%"), c.setAttribute("height", "100%");
71
- const F = document.createElement("style");
72
- F.textContent = m + C + "svg{overflow:visible;}" + y, c.appendChild(F), c.appendChild(t);
73
- const T = new XMLSerializer().serializeToString(c);
74
- x = `<svg xmlns="${E}" width="${e}" height="${a}" viewBox="0 0 ${e} ${a}">` + T + "</svg>", $ = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(x)}`, s();
65
+ if (e = Math.ceil(e), n = Math.ceil(n), t.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"), t.style.transformOrigin = "top left", !u && (w || d)) {
66
+ const g = i.width, E = i.height, N = e / g, z = n / E, H = t.style.transform || "", I = `scale(${N}, ${z})`;
67
+ t.style.transform = `${I} ${H}`.trim();
68
+ } else u && j() && (t.style.scale = `${h}`);
69
+ const F = "http://www.w3.org/2000/svg", o = document.createElementNS(F, "foreignObject");
70
+ o.setAttribute("width", "100%"), o.setAttribute("height", "100%");
71
+ const P = document.createElement("style");
72
+ P.textContent = m + C + "svg{overflow:visible;}" + y, o.appendChild(P), o.appendChild(t);
73
+ const B = new XMLSerializer().serializeToString(o);
74
+ $ = `<svg xmlns="${F}" width="${e}" height="${n}" viewBox="0 0 ${e} ${n}">` + B + "</svg>", x = `data:image/svg+xml;charset=utf-8,${encodeURIComponent($)}`, s();
75
75
  },
76
- { fast: o }
76
+ { fast: r }
77
77
  );
78
78
  });
79
- const w = document.getElementById("snapdom-sandbox");
80
- return w && w.style.position === "absolute" && w.remove(), $;
79
+ const f = document.getElementById("snapdom-sandbox");
80
+ return f && f.style.position === "absolute" && f.remove(), x;
81
81
  }
82
82
  export {
83
- Q as captureDOM
83
+ V as captureDOM
84
84
  };
@@ -1,59 +1,68 @@
1
- import { inlinePseudoElements as m } from "../modules/pseudo.js";
2
- import { generateCSSClasses as g } from "../utils/cssTools.js";
3
- import { stripTranslate as u } from "../utils/helpers.js";
4
- import { deepClone as h } from "./clone.js";
5
- async function k(s, f = !1, p = !1) {
6
- const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new Map();
7
- let t;
1
+ import { inlinePseudoElements as g } from "../modules/pseudo.js";
2
+ import { inlineExternalDef as u } from "../modules/svgDefs.js";
3
+ import { generateCSSClasses as h } from "../utils/cssTools.js";
4
+ import { stripTranslate as w } from "../utils/helpers.js";
5
+ import { deepClone as C } from "./clone.js";
6
+ async function T(n, y = !1, m = !1, p = "") {
7
+ const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new Map();
8
+ let o;
8
9
  try {
9
- t = h(s, a, r, y, f);
10
+ o = C(n, a, r, c, y);
10
11
  } catch (e) {
11
12
  throw console.warn("deepClone failed:", e), e;
12
13
  }
13
14
  try {
14
- await m(
15
- s,
16
- t,
15
+ await g(
16
+ n,
17
+ o,
17
18
  a,
18
19
  r,
19
- f,
20
+ y,
21
+ m,
20
22
  p
21
23
  );
22
24
  } catch (e) {
23
25
  console.warn("inlinePseudoElements failed:", e);
24
26
  }
27
+ try {
28
+ u(o);
29
+ } catch (e) {
30
+ console.warn("inlineExternalDef failed:", e);
31
+ }
25
32
  let d = "";
26
- if (f) {
27
- const e = g(a);
28
- d = Array.from(e.entries()).map(([o, n]) => `.${n}{${o}}`).join("");
29
- for (const [o, n] of a.entries()) {
30
- if (o.tagName === "STYLE") continue;
31
- const i = e.get(n);
32
- i && o.classList.add(i);
33
- const c = o.style?.backgroundImage;
34
- o.removeAttribute("style"), c && c !== "none" && (o.style.backgroundImage = c);
33
+ if (y) {
34
+ const e = h(a);
35
+ d = Array.from(e.entries()).map(([t, l]) => `.${l}{${t}}`).join("");
36
+ for (const [t, l] of a.entries()) {
37
+ if (t.tagName === "STYLE") continue;
38
+ const i = e.get(l);
39
+ i && t.classList.add(i);
40
+ const f = t.style?.backgroundImage;
41
+ t.removeAttribute("style"), f && f !== "none" && (t.style.backgroundImage = f);
35
42
  }
36
43
  } else
37
- for (const [e, o] of a.entries())
38
- e.tagName !== "STYLE" && e.setAttribute("style", o.replace(/;/g, "; "));
39
- for (const [e, o] of y.entries()) {
40
- const n = o.scrollLeft, i = o.scrollTop;
41
- if ((n || i) && e instanceof HTMLElement) {
44
+ for (const [e, t] of a.entries())
45
+ e.tagName !== "STYLE" && e.setAttribute("style", t.replace(/;/g, "; "));
46
+ for (const [e, t] of c.entries()) {
47
+ const l = t.scrollLeft, i = t.scrollTop;
48
+ if ((l || i) && e instanceof HTMLElement) {
42
49
  e.style.overflow = "hidden", e.style.scrollbarWidth = "none", e.style.msOverflowStyle = "none";
43
- const l = document.createElement("div");
44
- for (l.style.transform = `translate(${-n}px, ${-i}px)`, l.style.willChange = "transform", l.style.display = "inline-block", l.style.width = "100%"; e.firstChild; )
45
- l.appendChild(e.firstChild);
46
- e.appendChild(l);
50
+ const s = document.createElement("div");
51
+ for (s.style.transform = `translate(${-l}px, ${-i}px)`, s.style.willChange = "transform", s.style.display = "inline-block", s.style.width = "100%"; e.firstChild; )
52
+ s.appendChild(e.firstChild);
53
+ e.appendChild(s);
47
54
  }
48
55
  }
49
- if (s === y.get(t)) {
50
- const e = r.get(s) || window.getComputedStyle(s);
51
- r.set(s, e);
52
- const o = u(e.transform);
53
- t.style.margin = "0", t.style.position = "static", t.style.top = "auto", t.style.left = "auto", t.style.right = "auto", t.style.bottom = "auto", t.style.zIndex = "auto", t.style.float = "none", t.style.clear = "none", t.style.transform = o || "";
56
+ if (n === c.get(o)) {
57
+ const e = r.get(n) || window.getComputedStyle(n);
58
+ r.set(n, e);
59
+ const t = w(e.transform);
60
+ o.style.margin = "0", o.style.position = "static", o.style.top = "auto", o.style.left = "auto", o.style.right = "auto", o.style.bottom = "auto", o.style.zIndex = "auto", o.style.float = "none", o.style.clear = "none", o.style.transform = t || "";
54
61
  }
55
- return { clone: t, classCSS: d, styleCache: r };
62
+ for (const [e, t] of c.entries())
63
+ t.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
64
+ return { clone: o, classCSS: d, styleCache: r };
56
65
  }
57
66
  export {
58
- k as prepareClone
67
+ T as prepareClone
59
68
  };